Class 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.

    • Field Detail

      • runTimeSeconds

        private int runTimeSeconds
      • endTimeMillis

        private long endTimeMillis
    • Constructor Detail

      • ConcurrentTestTimedCommandGenerator

        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.
        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 class ConcurrentTestCommandGenerator
        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 class ConcurrentTestCommandGenerator