cdx.scorebot.app.tester
Class NetworkTester
java.lang.Object
java.lang.Thread
cdx.scorebot.app.tester.NetworkTester
- All Implemented Interfaces:
- java.lang.Runnable
public class NetworkTester
- extends java.lang.Thread
Multi-threaded program which executes a NetworkTestPackage for a TesterApp
(and listens to it). This class is a thread so it can run in parallel with
the GUI and get commands from the GUI. The run() method of this class will
continuously run until told to stop. It does two things:
1) The main thread schedules tests and executes commands from the GUI.
2) A secondary thread runs a single test when ordered.
This allows the main thread to continue scheduling and responding to the
GUI. The main scheduling thread creates a Job for any TestItem which
should run in the next schedule horizon (specified by the user).
The main thread checks for commands from the GUI and schedules tests at
a specified interval. When triggered to stop running by stopRunning(),
the scheduling loop will terminate within one schedulingInterval. However,
before flagging itself as done (as reflected by hasStoppedRunning()) it
will wait for the test currently running to finish.
The Logger by default is just to System.out, but may be supplied by the
user in the constructor. Whenever a test is scheduled, this is sent to the
Logger. The running of each individual test and their results are also logged.
All test results are also saved as TestEvent objects serialized as XML to
files named /.tev.
- Author:
- David Underhill
Nested classes/interfaces inherited from class java.lang.Thread |
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
DEFAULT_SCHEDULING_HORIZON
public static final int DEFAULT_SCHEDULING_HORIZON
- default scheduling horizon in seconds
- See Also:
- Constant Field Values
DEFAULT_SCHEDULING_INTERVAL
public static final int DEFAULT_SCHEDULING_INTERVAL
- default number of seconds between checks to see which jobs need to be scheduled
- See Also:
- Constant Field Values
NetworkTester
public NetworkTester(NetworkTestPackage config)
- uses the default scheduling horizon with no scheduled downtimes to start
- Parameters:
config
- the network test package to execute
NetworkTester
public NetworkTester(NetworkTestPackage config,
ScheduledDowntimes downtimes,
JListBound lstDowntimes,
FlexLogger logger)
- uses the default scheduling horizon
- Parameters:
config
- the network test package to executedowntimes
- times when tests should not be executedlstDowntimes
- list which holds the downtimeslogger
- stream to log to
NetworkTester
public NetworkTester(NetworkTestPackage config,
ScheduledDowntimes downtimes,
JListBound lstDowntimes,
FlexLogger logger,
int schedHorizonSec)
- user-specified scheduling horizon
- Parameters:
config
- the network test package to executedowntimes
- times when tests should not be executedlstDowntimes
- list which holds the downtimeslogger
- stream to log toschedHorizonSec
- scheduling horizon in seconds (how far in advance a job may be scheduled)
run
public void run()
- runs the main scheduling loop
- Specified by:
run
in interface java.lang.Runnable
- Overrides:
run
in class java.lang.Thread
isDowntime
public boolean isDowntime()
- whether or not we are currently in a downtime (i.e. no scheduling/testing)
- Returns:
- true if we are currently in a downtime
prune
public void prune()
- remove downtimes which end in the past
scheduleTest
public void scheduleTest(TestItem item,
long runDelayInMS)
- Manually inserts a test into the scheduled tests queue.
- Parameters:
item
- the test item to runrunDelayInMS
- the number milliseconds from now to schedule the test for
getConfig
public NetworkTestPackage getConfig()
- gets the config (allows downtime insertion)
getDowntimes
public ScheduledDowntimes getDowntimes()
- gets the currently scheduled downtimes
getLogger
public FlexLogger getLogger()
- gets the FlexLogger which is logging events which occur
getNextJobLabel
public javax.swing.JLabel getNextJobLabel()
- gets the label used to log the next job to run
setNextJobLabel
public void setNextJobLabel(javax.swing.JLabel lblNextJob)
- sets the label used to log the next job to run
getSchedulingHorizon
public int getSchedulingHorizon()
- gets how far in advance a job may be scheduled in seconds
setSchedulingHorizon
public void setSchedulingHorizon(int schedulingHorizonSec)
- sets how far in advance a job may be scheduled in seconds
getSchedulingInterval
public long getSchedulingInterval()
- gets the interval at which tests are scheduled and GUI commands are executed
- Returns:
- number of milliseconds in an interval
setSchedulingInterval
public void setSchedulingInterval(long schedulingInterval)
- sets the interval at which tests are scheduled and GUI commands are executed
- Parameters:
schedulingInterval
- number of milliseconds in an interval (must be > 0 or this value be ignored)
stopRunning
public void stopRunning()
- signals for the main loop to stop
hasStoppedRunning
public boolean hasStoppedRunning()
- whether or not the main loop has terminated
hasFinishedPreparations
public boolean hasFinishedPreparations()
setHasFinishedPreparations
public void setHasFinishedPreparations(boolean hasFinishedPreparations)