cdx.scorebot.net.tests
Class TestSchedule

java.lang.Object
  extended by cdx.scorebot.net.tests.TestSchedule
All Implemented Interfaces:
java.io.Serializable

public class TestSchedule
extends java.lang.Object
implements java.io.Serializable

Defines when a test is to be run (how often and during what time periods). The test interval describes the number of seconds between runs. The number of repetitions is how many times to run the test each time it is scheduled (such runs will be spread out by a the specified number of seconds between repetitions).

Note: If multiple tests are being run together (multiple repetitions) then the interval specifies the amount of time between the LAST test in the current repetition and the FIRST test in the next repetition.

Author:
David Underhill
See Also:
Serialized Form

Field Summary
static int DEFAULT_INTERVAL
          default min/max interval
static java.util.Random RAND
          generates random numbers
 
Constructor Summary
TestSchedule()
          default constructor
 
Method Summary
 void addTimeRangeToRun(TimestampRange tr)
          Adds a range of time during which tests will be run.
 boolean equals(java.lang.Object o)
           
 int getMaxInterval()
          gets max number of seconds between runs of the test
 int getMinInterval()
          gets min number of seconds between runs of the test
 Timestamp getMostRecentRunTime()
          gets when the test was last scheduled to run
 Timestamp getNextRunTime()
          gets when the test is next scheduled to run
 int getRepetitions()
          gets number of times to run the test each interval
 int getSecsBetweenRepetitions()
          gets the number of seconds between repetitions
 java.util.Vector<TimestampRange> getTimeRangesToRun()
          gets when to run the test (time block(s))
 TimestampRange getTimeRangeToRun(int index)
          Gets the specified range of time to run
 void initializeTimes()
          initializes the mostRecentRunTime to now and the nextRunTime to some time one interval from now
 boolean neverAutoSchedule()
          Gets whether or not the test this applies to should ever be automatically scheduled or not.
 void removeTimeRangeToRun(int index)
          Removes the range of time from this TestSchedule
 Timestamp scheduleNextRunTime()
          The next run time will be set as follows.
 void setInterval(int minInterval, int maxInterval)
          sets the interval in the number of seconds between runs of the test
 void setMaxInterval(int maxInterval)
          sets the maximum interval in the number of seconds between runs of the test
 void setMinInterval(int minInterval)
          sets the minimum interval in the number of seconds between runs of the test
 void setNeverAutoSchedule(boolean neverAutoSchedule)
          Sets whether or not the test this applies to should ever be automatically scheduled or not.
 void setRepetitions(int repetitions)
          sets number of times to run the test each interval
 void setSecsBetweenRepetitions(int secsBetweenRepetitions)
          sets the number of seconds between repetitions
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RAND

public static final java.util.Random RAND
generates random numbers


DEFAULT_INTERVAL

public static final int DEFAULT_INTERVAL
default min/max interval

See Also:
Constant Field Values
Constructor Detail

TestSchedule

public TestSchedule()
default constructor

Method Detail

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

initializeTimes

public void initializeTimes()
initializes the mostRecentRunTime to now and the nextRunTime to some time one interval from now


scheduleNextRunTime

public Timestamp scheduleNextRunTime()
The next run time will be set as follows. First, an interval will be chosen randomly between the minimum and maximum intervals. Second, the amount of time between the first and last test in this set will be computed (only affects tests with multiple repetitions). This is added to the interval so that the delay between runs is the time between the last test of the current set and the first test of the next set. Finally, this is added to the previously scheduled time to get the next scheduled time.

Returns:
next time to schedule this test run at

setMinInterval

public void setMinInterval(int minInterval)
sets the minimum interval in the number of seconds between runs of the test

Parameters:
minInterval - smallest interval between test runs allowed (in the range [1, maxInterval]

setMaxInterval

public void setMaxInterval(int maxInterval)
sets the maximum interval in the number of seconds between runs of the test

Parameters:
maxInterval - biggest interval between test runs allowed (in the range [minInterval, MAX_INTEGER)

setInterval

public void setInterval(int minInterval,
                        int maxInterval)
sets the interval in the number of seconds between runs of the test

Parameters:
minInterval - smallest interval between test runs allowed (in the range [1, maxInterval]
maxInterval - biggest interval between test runs allowed (in the range [minInterval, MAX_INTEGER)

addTimeRangeToRun

public void addTimeRangeToRun(TimestampRange tr)
Adds a range of time during which tests will be run.

Parameters:
tr - the TimestampRange to add to this TestSchedule

removeTimeRangeToRun

public void removeTimeRangeToRun(int index)
                          throws java.lang.ArrayIndexOutOfBoundsException
Removes the range of time from this TestSchedule

Parameters:
index - remove the TimestampRange at the specified index.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index was invalid.

getTimeRangeToRun

public TimestampRange getTimeRangeToRun(int index)
                                 throws java.lang.ArrayIndexOutOfBoundsException
Gets the specified range of time to run

Returns:
the TimestampRange at the specified index in the TimestampRange vector
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index was invalid.

getTimeRangesToRun

public java.util.Vector<TimestampRange> getTimeRangesToRun()
gets when to run the test (time block(s))


getRepetitions

public int getRepetitions()
gets number of times to run the test each interval


setRepetitions

public void setRepetitions(int repetitions)
sets number of times to run the test each interval


getSecsBetweenRepetitions

public int getSecsBetweenRepetitions()
gets the number of seconds between repetitions


setSecsBetweenRepetitions

public void setSecsBetweenRepetitions(int secsBetweenRepetitions)
sets the number of seconds between repetitions


getMinInterval

public int getMinInterval()
gets min number of seconds between runs of the test


getMaxInterval

public int getMaxInterval()
gets max number of seconds between runs of the test


getMostRecentRunTime

public Timestamp getMostRecentRunTime()
gets when the test was last scheduled to run


getNextRunTime

public Timestamp getNextRunTime()
gets when the test is next scheduled to run


neverAutoSchedule

public boolean neverAutoSchedule()
Gets whether or not the test this applies to should ever be automatically scheduled or not. If this is true, then the test this applies to will only be run if the user manually executes it. Users may also manually execute tests which are automatically scheduled.


setNeverAutoSchedule

public void setNeverAutoSchedule(boolean neverAutoSchedule)
Sets whether or not the test this applies to should ever be automatically scheduled or not. If this is true, then the test this applies to will only be run if the user manually executes it. Users may also manually execute tests which are automatically scheduled.