|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.test.concurrent.ConcurrentTestCommandGenerator org.eigenbase.test.concurrent.ConcurrentTestCommandScript
public class ConcurrentTestCommandScript
ConcurrentTestCommandScript creates instances of ConcurrentTestCommand
that perform specific actions in a specific
order and within the context of a test thread (ConcurrentTestCommandExecutor
).
Actions are loaded from a script (see package javadoc for script format).
A single ConcurrentTestCommandScript creates commands for multiple threads. Each thread is represented by an integer "thread ID" and, optionally, a String thread name. Thread IDs may take on any positive integer value and may be a sparse set (e.g. 1, 2, 5). Thread names may be any String.
When each command is created, it is associated with a thread and given an
execution order. Execution order values are positive integers, must be unique
within a thread, and may be a sparse set.
See ConcurrentTestCommandGenerator.synchronizeCommandSets()
for other
considerations.
Nested Class Summary | |
---|---|
private class |
ConcurrentTestCommandScript.CommandParser
|
private static class |
ConcurrentTestCommandScript.CommandWithTimeout
|
private static class |
ConcurrentTestCommandScript.CommandWithTimeoutAndRowLimit
|
private class |
ConcurrentTestCommandScript.EchoCommand
|
private class |
ConcurrentTestCommandScript.FetchAndPrintCommand
FetchAndPrintCommand executes a previously prepared statement stored inthe ConcurrentTestCommandExecutor and then outputs the returned rows. |
private class |
ConcurrentTestCommandScript.PrepareCommand
PrepareCommand creates a PreparedStatement , which is saved as the
current statement of its test thread. |
private class |
ConcurrentTestCommandScript.PrintCommand
|
private class |
ConcurrentTestCommandScript.ResultsReader
|
private class |
ConcurrentTestCommandScript.SelectCommand
SelectCommand creates and executes a SQL select statement, with optional timeout and row limit. |
private class |
ConcurrentTestCommandScript.ShellCommand
|
private class |
ConcurrentTestCommandScript.SqlCommand
SelectCommand creates and executes a SQL select statement, with optional timeout. |
private static class |
ConcurrentTestCommandScript.StateAction
|
private static class |
ConcurrentTestCommandScript.StateDatum
|
private static class |
ConcurrentTestCommandScript.Tool
|
private class |
ConcurrentTestCommandScript.VariableTable
|
Nested classes/interfaces inherited from class org.eigenbase.test.concurrent.ConcurrentTestCommandGenerator |
---|
ConcurrentTestCommandGenerator.AbstractCommand, ConcurrentTestCommandGenerator.AutoSynchronizationCommand, ConcurrentTestCommandGenerator.FailedThread, ConcurrentTestCommandGenerator.SynchronizationCommand |
Field Summary | |
---|---|
private static int |
BUF_SIZE
|
private static String |
CLEANUP
|
private static String |
CLEANUP_STATE
|
private static Integer |
CLEANUP_THREAD_ID
|
private List<String> |
cleanupCommands
|
private static String |
CLOSE
|
private static char[] |
dashes
|
private Boolean |
disabled
|
private static String |
DISABLED
|
private static String |
ECHO
|
private static int |
ECHO_LEN
|
private static String |
ENABLED
|
private static String |
END
|
private static String |
EOF
|
private static String |
EOF_STATE
|
private static String |
ERR
|
private static int |
ERR_LEN
|
private long |
executionStartTime
|
private static String |
FETCH
|
private static int |
FETCH_LEN
|
private static String |
INCLUDE
|
private static int |
INCLUDE_LEN
|
private Boolean |
lockstep
|
private static String |
LOCKSTEP
|
private static String |
NOLOCKSTEP
|
private static String |
POST_CLEANUP_STATE
|
private static String |
POST_SETUP_STATE
|
private static String |
POST_THREAD_STATE
|
private static String |
PRE_SETUP_STATE
|
private static String |
PREPARE
|
private static int |
PREPARE_LEN
|
private static String |
PRINT
|
private static int |
PRINT_LEN
|
private boolean |
quiet
|
private static String |
REPEAT
|
private static int |
REPEAT_LEN
|
private static int |
REPEAT_READ_AHEAD_LIMIT
|
private static String |
REPEAT_STATE
|
private static String |
ROWLIMIT
|
private static int |
ROWLIMIT_LEN
|
private File |
scriptDirectory
|
private static String |
SETUP
|
private static String |
SETUP_STATE
|
private static Integer |
SETUP_THREAD_ID
|
private List<String> |
setupCommands
|
private static String |
SHELL
|
private static int |
SHELL_LEN
|
private Pattern |
shellWildcardPattern
|
private static String |
SLEEP
|
private static int |
SLEEP_LEN
|
private static char[] |
spaces
|
private static String |
SQL
|
private static String |
SQL_STATE
|
private static ConcurrentTestCommandScript.StateAction[] |
STATE_TABLE
|
private static String |
SYNC
|
private static String |
THREAD
|
private static int |
THREAD_LEN
|
private static String |
THREAD_STATE
|
private Map<Integer,BufferedWriter> |
threadBufferedWriters
|
private Map<Integer,ConcurrentTestCommandScript.ResultsReader> |
threadResultsReaders
|
private Map<Integer,StringWriter> |
threadStringWriters
|
private static String |
TIMEOUT
|
private static int |
TIMEOUT_LEN
|
private static String |
VAR
|
private static int |
VAR_LEN
|
private ConcurrentTestCommandScript.VariableTable |
vars
|
private boolean |
verbose
|
Fields inherited from class org.eigenbase.test.concurrent.ConcurrentTestCommandGenerator |
---|
debug, debugStream, jdbcProps, jdbcURL |
Constructor Summary | |
---|---|
ConcurrentTestCommandScript()
|
|
ConcurrentTestCommandScript(String filename)
Constructs and prepares a new ConcurrentTestCommandScript. |
Method Summary | |
---|---|
private void |
addThreadWriters(Integer threadId)
|
private Map<Integer,String[]> |
collectResults()
Builds a map of thread ids to result data for the thread. |
(package private) void |
customErrorHandler(ConcurrentTestCommandExecutor executor)
Custom error handling occurs here if ConcurrentTestCommandGenerator.requiresCustomErrorHandling() returns true. |
void |
execute()
Executes the script |
void |
executeCleanup()
|
protected void |
executeCommands(int threadID,
List<String> commands)
|
void |
executeSetup()
|
private String |
getFormattedThreadName(Integer id)
|
private BufferedWriter |
getThreadWriter(Integer threadId)
Retrieves the output stream for the given thread id. |
boolean |
isDisabled()
|
private boolean |
isSelect(String sql)
Determines if a block of SQL is a select statment or not. |
static void |
main(String[] args)
Client tool that connects via jdbc and runs one or more mtsql on that connection. |
private void |
prepare(String filename,
List<String> bindings)
Gets ready to execute: loads script FILENAME applying external variable BINDINGS. |
void |
printResults(BufferedWriter out)
|
private void |
printThreadResults(BufferedWriter out,
String[] threadResult)
|
(package private) boolean |
requiresCustomErrorHandling()
Causes errors to be send here for custom handling. |
void |
setQuiet(boolean val)
|
void |
setVerbose(boolean val)
|
private void |
storeMessage(Integer threadId,
String message)
Saves a message to be printed with the thread's output. |
private void |
storeResults(Integer threadId,
ResultSet rset,
boolean withTimeout)
|
private void |
storeSql(Integer threadId,
String sql)
Saves a SQL command to be printed with the thread's output. |
boolean |
useLockstep()
|
Methods inherited from class org.eigenbase.test.concurrent.ConcurrentTestCommandGenerator |
---|
addCloseCommand, addCommand, addCommitCommand, addDdlCommand, addExplainCommand, addFetchAndCompareCommand, addInsertCommand, addPrepareCommand, addRollbackCommand, addSleepCommand, addSynchronizationCommand, failed, getCommandIterator, getCommands, getFailedThreads, getThreadIds, getThreadName, hasValidSynchronization, innerExecute, postExecute, printCommands, 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 static final String PRE_SETUP_STATE
private static final String SETUP_STATE
private static final String POST_SETUP_STATE
private static final String CLEANUP_STATE
private static final String POST_CLEANUP_STATE
private static final String THREAD_STATE
private static final String REPEAT_STATE
private static final String SQL_STATE
private static final String POST_THREAD_STATE
private static final String EOF_STATE
private static final String VAR
private static final String LOCKSTEP
private static final String NOLOCKSTEP
private static final String ENABLED
private static final String DISABLED
private static final String SETUP
private static final String CLEANUP
private static final String END
private static final String THREAD
private static final String REPEAT
private static final String SYNC
private static final String TIMEOUT
private static final String ROWLIMIT
private static final String PREPARE
private static final String PRINT
private static final String FETCH
private static final String CLOSE
private static final String SLEEP
private static final String ERR
private static final String ECHO
private static final String INCLUDE
private static final String SHELL
private static final String SQL
private static final String EOF
private static final ConcurrentTestCommandScript.StateAction[] STATE_TABLE
private static final int FETCH_LEN
private static final int PREPARE_LEN
private static final int PRINT_LEN
private static final int REPEAT_LEN
private static final int SLEEP_LEN
private static final int THREAD_LEN
private static final int TIMEOUT_LEN
private static final int ROWLIMIT_LEN
private static final int ERR_LEN
private static final int ECHO_LEN
private static final int SHELL_LEN
private static final int INCLUDE_LEN
private static final int VAR_LEN
private static final char[] spaces
private static final char[] dashes
private static final int BUF_SIZE
private static final int REPEAT_READ_AHEAD_LIMIT
private static final Integer SETUP_THREAD_ID
private static final Integer CLEANUP_THREAD_ID
private boolean quiet
private boolean verbose
private Boolean lockstep
private Boolean disabled
private ConcurrentTestCommandScript.VariableTable vars
private File scriptDirectory
private long executionStartTime
private List<String> setupCommands
private List<String> cleanupCommands
private Map<Integer,BufferedWriter> threadBufferedWriters
private Map<Integer,StringWriter> threadStringWriters
private Map<Integer,ConcurrentTestCommandScript.ResultsReader> threadResultsReaders
private final Pattern shellWildcardPattern
Constructor Detail |
---|
public ConcurrentTestCommandScript() throws IOException
IOException
public ConcurrentTestCommandScript(String filename) throws IOException
IOException
Method Detail |
---|
private void prepare(String filename, List<String> bindings) throws IOException
IOException
public void execute() throws Exception
execute
in class ConcurrentTestCommandGenerator
Exception
- if no connection found or if a thread operation is
interruptedprivate void addThreadWriters(Integer threadId)
public void setQuiet(boolean val)
public void setVerbose(boolean val)
public boolean useLockstep()
public boolean isDisabled()
public void executeSetup() throws Exception
Exception
public void executeCleanup() throws Exception
Exception
protected void executeCommands(int threadID, List<String> commands) throws Exception
Exception
private void storeResults(Integer threadId, ResultSet rset, boolean withTimeout) throws SQLException
SQLException
private boolean isSelect(String sql)
private Map<Integer,String[]> collectResults()
String[2]
containing the thread name and the
thread's output.
private String getFormattedThreadName(Integer id)
public void printResults(BufferedWriter out) throws IOException
IOException
private void printThreadResults(BufferedWriter out, String[] threadResult) throws IOException
IOException
boolean requiresCustomErrorHandling()
customErrorHandler(ConcurrentTestCommandExecutor)
.
requiresCustomErrorHandling
in class ConcurrentTestCommandGenerator
void customErrorHandler(ConcurrentTestCommandExecutor executor)
ConcurrentTestCommandGenerator
ConcurrentTestCommandGenerator.requiresCustomErrorHandling()
returns true. Default implementation does
nothing.
customErrorHandler
in class ConcurrentTestCommandGenerator
private BufferedWriter getThreadWriter(Integer threadId)
private void storeSql(Integer threadId, String sql)
private void storeMessage(Integer threadId, String message)
public static void main(String[] args)
Usage: mtsql [-vgq] -u SERVER -d DRIVER [-n USER][-p PASSWORD] [VAR=VAL]... SCRIPT [SCRIPT]...
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |