}
public void run() throws Exception {
spaceOnlySetup();
TesterTransactionManager mgr = new TesterTransactionManager();
TesterTransaction tt = mgr.create();
// an entry that should be there at the start
SimpleEntry toTake = new SimpleEntry("toTake", 1, 13);
writeEntry(null, toTake);
logger.log(Level.INFO, "wrote entry " + toTake);
// the entry written under the transaction
SimpleEntry written = new SimpleEntry("tester", 17, 29);
logger.log(Level.INFO, "wrote entry " + written);
writeEntry(tt.transaction, written);
tt.assertParticipants(1); // just to be sure
Entry taken = space.take(toTake, tt.transaction, 0);
assertEquals(taken, toTake, "reading 'toTake' entry");
if (!active) {
tt.sendPrepare(); // get the transaction prepared
if (tt.localGetState() != PREPARED) {
throw new TestException(
"state is "
+ TxnConstants.getName(tt.localGetState())
+ ", should be " + TxnConstants.getName(PREPARED));
}
}
shutdown(0); // shut down the space
/*
* Only do this test if we're not active -- active txns should
* be effectively aborted at this point, so they have no stage
* that exists after a shutdown and before the transaction
* completion
*/
if (!active) {
/*
* try to see transacted stuff under a null transaction:
* should fail
*/
canSee(toTake, null, "txn not yet completed");
canSee(written, null, "txn not yet completed");
if (wait) {
/*
* sleep long enough for the 15-second retries plus
* 5 for slop
*/
long sleepTime = (15 * SECONDS * (throwRemote + 1)
+ 5 * SECONDS);
tt.setState(abort ? ABORTED : COMMITTED);
logger.log(Level.INFO, "transaction state set to "
+ TxnConstants.getName(tt.localGetState())
+ ", sleeping " + sleepTime);
if (throwRemote > 0) {
tt.getStateFailCnt(throwRemote);
}
// give the participant a chance to ask
Thread.sleep(sleepTime);
} else {
if (abort) {
tt.sendAbort();
} else {
tt.sendCommit();
}
}
}
if (abort) {