Class ConcurrentTestTimedCommandGenerator

  extended by org.eigenbase.test.concurrent.ConcurrentTestCommandGenerator
      extended by org.eigenbase.test.concurrent.ConcurrentTestTimedCommandGenerator

public class ConcurrentTestTimedCommandGenerator
extends ConcurrentTestCommandGenerator

ConcurrentTestTimedCommandGenerator extends ConcurrentTestCommandGenerator and repeats the configured command sequence until a certain amount of time has elapsed.

The command sequence is always completed in full, even if the time limit has been exceeded. Therefore, the time limit can only be considered the minimum length of time that the test will run and not a guarantee of how long the test will take.

$Id: //open/dev/farrago/src/org/eigenbase/test/concurrent/ $
Stephan Zuercher

Nested Class Summary
private  class ConcurrentTestTimedCommandGenerator.TimedIterator
          TimedIterator is an Iterator that repeats a given collection's elements until System.currentTimeMillis() >= endTimeMillis.
Nested classes/interfaces inherited from class org.eigenbase.test.concurrent.ConcurrentTestCommandGenerator
ConcurrentTestCommandGenerator.AbstractCommand, ConcurrentTestCommandGenerator.AutoSynchronizationCommand, ConcurrentTestCommandGenerator.FailedThread, ConcurrentTestCommandGenerator.SynchronizationCommand
Field Summary
private  long endTimeMillis
private  int runTimeSeconds
Fields inherited from class org.eigenbase.test.concurrent.ConcurrentTestCommandGenerator
debug, debugStream, jdbcProps, jdbcURL
Constructor Summary
ConcurrentTestTimedCommandGenerator(int runTimeSeconds)
          Constructs a new ConcurrentTestTimedCommandGenerator that will run for at least the given amount of time.
Method Summary
(package private)  Iterator getCommandIterator(Integer threadId)
          Retrieves an Iterator based on the configured commands.
(package private)  void printCommands(PrintStream out, Integer threadId)
          Outputs command sequence and notes how long the sequence will be repeated.
Methods inherited from class org.eigenbase.test.concurrent.ConcurrentTestCommandGenerator
addCloseCommand, addCommand, addCommitCommand, addDdlCommand, addExplainCommand, addFetchAndCompareCommand, addInsertCommand, addPrepareCommand, addRollbackCommand, addSleepCommand, addSynchronizationCommand, customErrorHandler, execute, failed, getCommands, getFailedThreads, getThreadIds, getThreadName, hasValidSynchronization, innerExecute, postExecute, requiresCustomErrorHandling, setDataSource, setDebug, setDebug, setThreadName, synchronizeCommandSets
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


private int runTimeSeconds


private long endTimeMillis
Constructor Detail


public ConcurrentTestTimedCommandGenerator(int runTimeSeconds)
Constructs a new ConcurrentTestTimedCommandGenerator that will run for at least the given amount of time. See ConcurrentTestTimedCommandGenerator for more information on the semantics of run-time length.

runTimeSeconds - minimum run-time length, in seconds
Method Detail


Iterator getCommandIterator(Integer threadId)
Retrieves an Iterator based on the configured commands. This Iterator, when it reaches the end of the command list will compare the current time with the test's end time. If there is time left, the Iterator will repeat the command sequence.

The test's end time is computed by taking the value of System.currentTimeMillis() the first time this method is called (across all thread IDs) and adding the configured run time.

getCommandIterator in class ConcurrentTestCommandGenerator
threadId - the thread ID to get an Iterator on


void printCommands(PrintStream out,
                   Integer threadId)
Outputs command sequence and notes how long the sequence will be repeated.

printCommands in class ConcurrentTestCommandGenerator