use of com.arjuna.ats.internal.jta.transaction.arjunacore.AtomicAction in project narayana by jbosstm.
the class JTATransactionLogXAResourceOrphanFilter method transactionLog.
/**
* Is there a log file for this transaction?
*
* @param xid the transaction to check.
*
* @return <code>boolean</code>true if there is a log file,
* <code>false</code> if there isn't.
* @throws ObjectStoreException If there is a problem accessing the object store
* @throws IOException In case the data from the object store is corrupted
*/
private boolean transactionLog(Xid xid) throws ObjectStoreException, IOException {
RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
String transactionType = new AtomicAction().type();
XidImple theXid = new XidImple(xid);
Uid u = theXid.getTransactionUid();
if (jtaLogger.logger.isDebugEnabled()) {
jtaLogger.logger.debug("Checking whether Xid " + theXid + " exists in ObjectStore.");
}
if (!u.equals(Uid.nullUid())) {
if (jtaLogger.logger.isDebugEnabled()) {
jtaLogger.logger.debug("Looking for " + u + " and " + transactionType);
}
if (containsCommitMarkableResourceRecord(u) || recoveryStore.currentState(u, transactionType) != StateStatus.OS_UNKNOWN) {
if (jtaLogger.logger.isDebugEnabled()) {
jtaLogger.logger.debug("Found record for " + theXid);
}
return true;
} else {
if (jtaLogger.logger.isDebugEnabled()) {
jtaLogger.logger.debug("No record found for " + theXid);
}
}
} else {
jtaLogger.i18NLogger.info_recovery_notaxid(XAHelper.xidToString(xid));
}
return false;
}
use of com.arjuna.ats.internal.jta.transaction.arjunacore.AtomicAction 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