public void run() throws Exception {
TransactionManager mgr = null;
Transaction.Created cr = null;
ServerTransaction str = null;
TestParticipant[] parts = null;
TestParticipant tp = null;
startTxnMgr();
// Create a number of TestParticipants
logger.log(Level.INFO,
"RollForwardErrorTest: creating " + NUM_PARTICIPANTS
+ " participants");
parts = TxnTestUtils.createParticipants(NUM_PARTICIPANTS);
/*
* All Participants will join and vote prepared. One, randomly
* chosen Participant will throw an exception when asked
* to roll forward. There are two major cases for this,
* the first time a RemoteException is thrown. The second
* time, a TransactionException is thrown.
*/
mgr = manager();
if (DEBUG) {
logger.log(Level.INFO, "RollForwardErrorTest: run: mgr = " + mgr);
}
cr = TransactionFactory.create(mgr, Lease.FOREVER);
str = (ServerTransaction) cr.transaction;
logger.log(Level.INFO, "RollForwardErrorTest: setting behavior for "
+ NUM_PARTICIPANTS + " participants");
TxnTestUtils.setBulkBehavior(OP_JOIN, parts);
TxnTestUtils.setBulkBehavior(OP_VOTE_PREPARED, parts);
tp = TxnTestUtils.chooseOne(parts);
tp.setBehavior(OP_EXCEPTION_ON_COMMIT);
tp.setBehavior(EXCEPTION_REMOTE);
TxnTestUtils.doBulkBehavior(cr.transaction, parts);
logger.log(Level.INFO, "RollForwardErrorTest: commiting the txn");
cr.transaction.commit();
cr = TransactionFactory.create(mgr, Lease.FOREVER);
str = (ServerTransaction) cr.transaction;
logger.log(Level.INFO, "RollForwardErrorTest: setting behavior for "
+ NUM_PARTICIPANTS + " participants");
tp.clearBehavior(EXCEPTION_REMOTE);
tp.setBehavior(EXCEPTION_TRANSACTION);
TxnTestUtils.doBulkBehavior(cr.transaction, parts);
logger.log(Level.INFO, "RollForwardErrorTest: commiting the txn");
cr.transaction.commit();
return;