Class ConcurrentTestCommandExecutor

  • All Implemented Interfaces:
    java.lang.Runnable

    class ConcurrentTestCommandExecutor
    extends java.lang.Thread
    ConcurrentTestCommandExecutor is a thread that executes a sequence of commands on a JDBC connection.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  ConcurrentTestCommandExecutor.Sync
      Synchronization object that allows multiple ConcurrentTestCommandExecutors to execute commands in lock-step.
      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
    • Constructor Summary

      Constructors 
      Constructor Description
      ConcurrentTestCommandExecutor​(int threadId, java.lang.String threadName, java.lang.String jdbcURL, java.util.Properties jdbcProps, java.lang.Iterable<ConcurrentTestCommand> commands, ConcurrentTestCommandExecutor.Sync synchronizer, java.io.PrintStream debugPrintStream)
      Constructs a ConcurrentTestCommandExecutor with the given thread ID, JDBC URL, commands and synchronization object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clearStatement()
      Clears the thread's current JDBC statement.
      java.sql.Connection getConnection()
      Obtains the thread's JDBC connection.
      java.lang.Throwable getFailureCause()
      Checks whether an exception occurred during execution.
      ConcurrentTestCommand getFailureCommand()  
      java.lang.String getFailureLocation()
      Returns location (e.g., command number) for exception returned by getFailureCause().
      java.sql.Statement getStatement()
      Obtains the thread's current JDBC statement.
      ConcurrentTestCommandExecutor.Sync getSynchronizer()
      Retrieves the object used to synchronize threads at a point in the list of commands.
      java.lang.Integer getThreadId()  
      private void handleError​(java.lang.Throwable error, java.lang.String when, ConcurrentTestCommand command)
      Handles details of an exception during execution.
      void run()
      Executes the configured commands.
      void setStatement​(java.sql.Statement stmt)
      Sets the thread's current JDBC statement.
      • Methods inherited from class java.lang.Thread

        activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • threadId

        private java.lang.Integer threadId
        The id for this thread.
      • jdbcURL

        private java.lang.String jdbcURL
        JDBC URL to connect with.
      • jdbcProps

        private java.util.Properties jdbcProps
        JDBC Connection properties.
      • connection

        private java.sql.Connection connection
        JDBC connection for commands.
      • statement

        private java.sql.Statement statement
        Current JDBC Statement. May be null.
      • error

        private java.lang.Throwable error
        First exception thrown by the thread.
      • when

        private java.lang.String when
        Location of error.
      • debugPrintStream

        private final java.io.PrintStream debugPrintStream
        Debugging print stream. May be null.
    • Constructor Detail

      • ConcurrentTestCommandExecutor

        ConcurrentTestCommandExecutor​(int threadId,
                                      java.lang.String threadName,
                                      java.lang.String jdbcURL,
                                      java.util.Properties jdbcProps,
                                      java.lang.Iterable<ConcurrentTestCommand> commands,
                                      ConcurrentTestCommandExecutor.Sync synchronizer,
                                      java.io.PrintStream debugPrintStream)
        Constructs a ConcurrentTestCommandExecutor with the given thread ID, JDBC URL, commands and synchronization object.
        Parameters:
        threadId - the thread ID (see ConcurrentTestCommandGenerator)
        threadName - the thread's name
        jdbcURL - the JDBC URL to connect to
        jdbcProps - JDBC Connection properties (user, password, etc.)
        commands - the sequence of commands to execute -- null elements indicate no-ops
        synchronizer - synchronization object (may not be null);
        debugPrintStream - if non-null a PrintStream to use for debugging output (may help debugging thread synchronization
    • Method Detail

      • run

        public void run()
        Executes the configured commands.
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread
      • handleError

        private void handleError​(java.lang.Throwable error,
                                 java.lang.String when,
                                 ConcurrentTestCommand command)
        Handles details of an exception during execution.
      • getConnection

        public java.sql.Connection getConnection()
        Obtains the thread's JDBC connection.
      • getStatement

        public java.sql.Statement getStatement()
        Obtains the thread's current JDBC statement. May return null.
      • setStatement

        public void setStatement​(java.sql.Statement stmt)
        Sets the thread's current JDBC statement. To clear the JDBC statement use clearStatement().
      • clearStatement

        public void clearStatement()
        Clears the thread's current JDBC statement. To set the JDBC statement use setStatement(Statement).
      • getFailureCause

        public java.lang.Throwable getFailureCause()
        Checks whether an exception occurred during execution. If this method returns null, the thread's commands all succeeded. If this method returns non-null, see getFailureLocation() for details on which command caused the failure.
      • getFailureLocation

        public java.lang.String getFailureLocation()
        Returns location (e.g., command number) for exception returned by getFailureCause().
      • getThreadId

        public java.lang.Integer getThreadId()