Class ConcurrentTestTimedCommandGenerator
- java.lang.Object
-
- org.apache.calcite.test.concurrent.ConcurrentTestCommandGenerator
-
- org.apache.calcite.test.concurrent.ConcurrentTestTimedCommandGenerator
-
public class ConcurrentTestTimedCommandGenerator extends ConcurrentTestCommandGenerator
ConcurrentTestTimedCommandGenerator extendsConcurrentTestCommandGenerator
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
ConcurrentTestTimedCommandGenerator.TimedIterator<E>
TimedIterator is an Iterator that repeats a given collection's elements untilSystem.currentTimeMillis() ≥ endTimeMillis
.-
Nested classes/interfaces inherited from class org.apache.calcite.test.concurrent.ConcurrentTestCommandGenerator
ConcurrentTestCommandGenerator.AbstractCommand, ConcurrentTestCommandGenerator.AutoSynchronizationCommand, ConcurrentTestCommandGenerator.FailedThread, ConcurrentTestCommandGenerator.SynchronizationCommand
-
-
Field Summary
Fields Modifier and Type Field Description private long
endTimeMillis
private int
runTimeSeconds
-
Fields inherited from class org.apache.calcite.test.concurrent.ConcurrentTestCommandGenerator
debug, debugStream, jdbcProps, jdbcURL
-
-
Constructor Summary
Constructors Constructor Description ConcurrentTestTimedCommandGenerator(int runTimeSeconds)
Constructs a new ConcurrentTestTimedCommandGenerator that will run for at least the given amount of time.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) java.lang.Iterable<ConcurrentTestCommand>
getCommandIterable(int threadId)
Retrieves an Iterator based on the configured commands.(package private) void
printCommands(java.io.PrintStream out, java.lang.Integer threadId)
Outputs command sequence and notes how long the sequence will be repeated.-
Methods inherited from class org.apache.calcite.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
-
-
-
-
Constructor Detail
-
ConcurrentTestTimedCommandGenerator
public ConcurrentTestTimedCommandGenerator(int runTimeSeconds)
Constructs a new ConcurrentTestTimedCommandGenerator that will run for at least the given amount of time. SeeConcurrentTestTimedCommandGenerator
for more information on the semantics of run-time length.- Parameters:
runTimeSeconds
- minimum run-time length, in seconds
-
-
Method Detail
-
getCommandIterable
java.lang.Iterable<ConcurrentTestCommand> getCommandIterable(int 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.- Overrides:
getCommandIterable
in classConcurrentTestCommandGenerator
- Parameters:
threadId
- the thread ID to get an Iterator on
-
printCommands
void printCommands(java.io.PrintStream out, java.lang.Integer threadId)
Outputs command sequence and notes how long the sequence will be repeated.- Overrides:
printCommands
in classConcurrentTestCommandGenerator
-
-