/* * Sun Public License * * The contents of this file are subject to the Sun Public License Version * 1.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is available at http://www.sun.com/ * * The Original Code is the SLAMD Distributed Load Generation Engine. * The Initial Developer of the Original Code is Neil A. Wilson. * Portions created by Neil A. Wilson are Copyright (C) 2004-2010. * Some preexisting portions Copyright (C) 2002-2006 Sun Microsystems, Inc. * All Rights Reserved. * * Contributor(s): Neil A. Wilson */ package com.slamd.jobs; import java.util.Date; import com.slamd.job.JobClass; import com.slamd.job.UnableToRunException; import com.slamd.parameter.InvalidValueException; import com.slamd.parameter.ParameterList; import com.slamd.stat.StatTracker; /** * This class defines a SLAMD job that does nothing. It simply provides the * capability to insert a delay between jobs. * * * @author Neil A. Wilson */ public class NullJobClass extends JobClass { /** * The default constructor used to create a new instance of the job class. * The only thing it should do is to invoke the superclass constructor. All * other initialization should be performed in the <CODE>initialize</CODE> * method. */ public NullJobClass() { super(); } /** * {@inheritDoc} */ @Override() public String getJobName() { return "Null"; } /** * {@inheritDoc} */ @Override() public String getShortDescription() { return "Insert a delay between other jobs"; } /** * {@inheritDoc} */ @Override() public String[] getLongDescription() { return new String[] { "This job can be used to insert a delay between other jobs. It does " + "not perform any processing, and it does not collect any statistics." }; } /** * {@inheritDoc} */ @Override() public String getJobCategoryName() { return "Utility"; } /** * {@inheritDoc} */ @Override() public ParameterList getParameterStubs() { return new ParameterList(); } /** * {@inheritDoc} */ @Override() public StatTracker[] getStatTrackerStubs(String clientID, String threadID, int collectionInterval) { return new StatTracker[0]; } /** * {@inheritDoc} */ @Override() public StatTracker[] getStatTrackers() { return new StatTracker[0]; } /** * {@inheritDoc} */ @Override() public void validateJobInfo(int numClients, int threadsPerClient, int threadStartupDelay, Date startTime, Date stopTime, int duration, int collectionInterval, ParameterList parameters) throws InvalidValueException { // Either a duration or a stop time must have been specified. if ((duration <= 0) && (stopTime == null)) { throw new InvalidValueException("Null jobs will never stop on their " + "own and must be scheduled with a duration or stop time."); } } /** * {@inheritDoc} */ @Override() public void initializeThread(String clientID, String threadID, int collectionInterval, ParameterList parameters) throws UnableToRunException { // No implementation necessary } /** * {@inheritDoc} */ @Override() public void runJob() { // Loop until it is determined that the job should stop. while (! shouldStop()) { try { Thread.sleep(100); } catch (InterruptedException ie) {} } } }