MTOperation[][] stressTest = new MTOperation[numThreads + 1][];
// thread 0
MTOperation[] thread0 = new MTOperation[5 + numThreads];
thread0[0] = new MTOperation(MTOperation.CF_BY_TX_LOOKUP);
thread0[1] = new MTOperation(MTOperation.TM_BEGIN, 10);
thread0[2] = new MTOperation(MTOperation.CF_GET_CONN, 0);
for (int i = 0; i < numThreads; i++)
{
thread0[3+i] = new MTOperation(MTOperation.XX_WAIT_FOR_SIGNAL, i+1);
}
thread0[3 + numThreads] = new MTOperation(MTOperation.CN_CLOSE_CONN, 0);
thread0[4 + numThreads] = new MTOperation(MTOperation.TM_COMMIT);
stressTest[0] = thread0;
// threads 1 -> numThreads
for (int i = 1; i <= numThreads; i++)
{
stressTest[i] = new MTOperation[] {
new MTOperation(MTOperation.CF_BY_TX_LOOKUP),
new MTOperation(MTOperation.XX_WAIT_FOR_TX, 10),
new MTOperation(MTOperation.TM_RESUME, 10),
new MTOperation(MTOperation.CF_GET_CONN, 1000+i),
new MTOperation(MTOperation.XX_SLEEP_RANDOM),
new MTOperation(MTOperation.CF_GET_CONN, 2000+i),
new MTOperation(MTOperation.XX_SLEEP_RANDOM),
new MTOperation(MTOperation.CF_GET_CONN, 3000+i),
new MTOperation(MTOperation.XX_SLEEP_RANDOM),
new MTOperation(MTOperation.CN_CLOSE_CONN, 3000+i),
new MTOperation(MTOperation.XX_SLEEP_RANDOM),
new MTOperation(MTOperation.CN_CLOSE_CONN, 2000+i),
new MTOperation(MTOperation.XX_SLEEP_RANDOM),
new MTOperation(MTOperation.CN_CLOSE_CONN, 1000+i),
new MTOperation(MTOperation.TM_SUSPEND, 10),
new MTOperation(MTOperation.XX_POST_SIGNAL, i)
};
}
runTest(stressTest);
}