use of com.arjuna.ats.arjuna.recovery.RecoverAtomicAction in project narayana by jbosstm.
the class LogStoreReactivationTest2 method test.
@Test
public void test() {
arjPropertyManager.getCoordinatorEnvironmentBean().setCommitOnePhase(false);
arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreType(LogStore.class.getName());
arjPropertyManager.getObjectStoreEnvironmentBean().setSynchronousRemoval(true);
// the byteman script will enforce this
// System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "1000000"); // essentially infinite
AtomicAction A = new AtomicAction();
Uid txId = A.get_uid();
System.err.println("IMPORTANT: if there are warnings about USER_DEF_FIRST0 then the test has failed!");
A.begin();
A.add(new BasicRecord());
A.commit();
RecoverAtomicAction rAA = new RecoverAtomicAction(txId, ActionStatus.COMMITTED);
rAA.replayPhase2();
}
use of com.arjuna.ats.arjuna.recovery.RecoverAtomicAction in project narayana by jbosstm.
the class AtomicActionRecoveryModule method doRecoverTransaction.
private void doRecoverTransaction(Uid recoverUid) {
boolean commitThisTransaction = true;
// Retrieve the transaction status from its original process.
int theStatus = _transactionStatusConnectionMgr.getTransactionStatus(_transactionType, recoverUid);
boolean inFlight = isTransactionInMidFlight(theStatus);
String Status = ActionStatus.stringForm(theStatus);
if (tsLogger.logger.isDebugEnabled()) {
tsLogger.logger.debug("transaction type is " + _transactionType + " uid is " + recoverUid.toString() + "\n ActionStatus is " + Status + " in flight is " + inFlight);
}
if (!inFlight) {
try {
RecoverAtomicAction rcvAtomicAction = new RecoverAtomicAction(recoverUid, theStatus);
rcvAtomicAction.replayPhase2();
} catch (Exception ex) {
tsLogger.i18NLogger.warn_recovery_AtomicActionRecoveryModule_2(recoverUid, ex);
}
}
}
use of com.arjuna.ats.arjuna.recovery.RecoverAtomicAction in project narayana by jbosstm.
the class LogStoreReactivationTest method test.
@Test
public void test() {
arjPropertyManager.getCoordinatorEnvironmentBean().setCommitOnePhase(false);
arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreType(LogStore.class.getName());
arjPropertyManager.getObjectStoreEnvironmentBean().setSynchronousRemoval(false);
// the byteman script will enforce this
// System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "1000000"); // essentially infinite
AtomicAction A = new AtomicAction();
Uid txId = A.get_uid();
System.err.println("IMPORTANT: ignore warnings about USER_DEF_FIRST0 as they are expected due to BasicRecord usage!");
A.begin();
A.add(new BasicRecord());
A.commit();
RecoverAtomicAction rAA = new RecoverAtomicAction(txId, ActionStatus.COMMITTED);
rAA.replayPhase2();
}
use of com.arjuna.ats.arjuna.recovery.RecoverAtomicAction in project narayana by jbosstm.
the class RecoverAtomicActionTest method test.
@Test
public void test() {
RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
OutputObjectState fluff = new OutputObjectState();
Uid kungfuTx = new Uid();
boolean passed = false;
final String tn = new AtomicAction().type();
try {
UidHelper.packInto(kungfuTx, fluff);
System.err.println("Creating dummy log");
recoveryStore.write_committed(kungfuTx, tn, fluff);
if (recoveryStore.currentState(kungfuTx, tn) == StateStatus.OS_COMMITTED) {
System.err.println("Wrote dummy transaction " + kungfuTx);
RecoverAtomicAction rAA = new RecoverAtomicAction(kungfuTx, ActionStatus.COMMITTED);
if (!rAA.activate()) {
rAA.replayPhase2();
if (recoveryStore.currentState(kungfuTx, tn) == StateStatus.OS_UNKNOWN)
passed = true;
}
} else
System.err.println("State is not committed!");
} catch (final Exception ex) {
ex.printStackTrace();
}
assertTrue(passed);
}
use of com.arjuna.ats.arjuna.recovery.RecoverAtomicAction in project narayana by jbosstm.
the class XARecoveryModuleUnitTest method testRecoverFromMultipleXAResourceRecovery.
@Test
public void testRecoverFromMultipleXAResourceRecovery() throws Exception {
// Make sure the file doesn't exist
assertFalse(new File("XARR.txt").exists());
ArrayList<String> r = new ArrayList<String>();
AtomicAction aa = new AtomicAction();
aa.begin();
assertEquals(AddOutcome.AR_ADDED, aa.add(new XAResourceRecord(null, new XARRTestResource(), new XidImple(aa), null)));
Class c = BasicAction.class;
Method method = c.getDeclaredMethod("prepare", boolean.class);
method.setAccessible(true);
int result = (Integer) method.invoke(aa, new Object[] { true });
assertEquals(result, TwoPhaseOutcome.PREPARE_OK);
// Make sure the file exists
assertTrue(new File("XARR.txt").exists());
// AtomicActionRecoveryModule aaRecoveryModule = new AtomicActionRecoveryModule();
// aaRecoveryModule.periodicWorkFirstPass();
// aaRecoveryModule.periodicWorkSecondPass();
RecordTypeManager.manager().add(new RecordTypeMap() {
@SuppressWarnings("unchecked")
public Class getRecordClass() {
return XAResourceRecord.class;
}
public int getType() {
return RecordType.JTA_RECORD;
}
});
List<String> xarn = new ArrayList<String>();
xarn.add(NodeNameXAResourceOrphanFilter.RECOVER_ALL_NODES);
jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(xarn);
XARecoveryModule xaRecoveryModule = new XARecoveryModule();
Field safetyIntervalMillis = RecoveryXids.class.getDeclaredField("safetyIntervalMillis");
safetyIntervalMillis.setAccessible(true);
safetyIntervalMillis.set(null, 0);
xaRecoveryModule.addXAResourceRecoveryHelper(new XARROne());
xaRecoveryModule.addXAResourceRecoveryHelper(new XARRTwo());
xaRecoveryModule.addXAResourceOrphanFilter(new com.arjuna.ats.internal.jta.recovery.arjunacore.JTATransactionLogXAResourceOrphanFilter());
xaRecoveryModule.addXAResourceOrphanFilter(new com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter());
RecoveryManager.manager().addModule(xaRecoveryModule);
// This is done rather than using the AtomicActionRecoveryModule as the transaction is inflight
RecoverAtomicAction rcvAtomicAction = new RecoverAtomicAction(aa.get_uid(), ActionStatus.COMMITTED);
rcvAtomicAction.replayPhase2();
// The XARM would execute next
xaRecoveryModule.periodicWorkFirstPass();
xaRecoveryModule.periodicWorkSecondPass();
// Make sure the file doesn't exist
assertFalse(new File("XARR.txt").exists());
aa.abort();
}
Aggregations