use of com.arjuna.ats.jta.recovery.XAResourceOrphanFilter in project narayana by jbosstm.
the class XAResourceOrphanFilterTest method testSubordinateJTAXAResourceOrphanFilter.
@Test
public void testSubordinateJTAXAResourceOrphanFilter() throws HeuristicRollbackException, HeuristicMixedException, HeuristicCommitException, SystemException, RollbackException, XAException {
XAResourceOrphanFilter orphanFilter = new SubordinateJTAXAResourceOrphanFilter();
XidImple xid = (XidImple) XATxConverter.getXid(Uid.nullUid(), false, XATxConverter.FORMAT_ID);
XATxConverter.setSubordinateNodeName(xid.getXID(), TxControl.getXANodeName());
List<String> xaRecoveryNodes = jtaPropertyManager.getJTAEnvironmentBean().getXaRecoveryNodes();
try {
jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(Arrays.asList("2"));
assertEquals(XAResourceOrphanFilter.Vote.ABSTAIN, orphanFilter.checkXid(xid));
jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(Arrays.asList("1"));
assertEquals(XAResourceOrphanFilter.Vote.ROLLBACK, orphanFilter.checkXid(xid));
} finally {
jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(xaRecoveryNodes);
}
}
use of com.arjuna.ats.jta.recovery.XAResourceOrphanFilter in project narayana by jbosstm.
the class XAResourceOrphanFilterTest method testJTATransactionLogOrphanFilter.
@Test
public void testJTATransactionLogOrphanFilter() {
XAResourceOrphanFilter orphanFilter = new JTATransactionLogXAResourceOrphanFilter();
Xid notJTAFormatId = XATxConverter.getXid(new Uid(), false, 0);
assertEquals(XAResourceOrphanFilter.Vote.ABSTAIN, orphanFilter.checkXid(notJTAFormatId));
Xid jtaFormatId = XATxConverter.getXid(new Uid(), false, XATxConverter.FORMAT_ID);
assertEquals(XAResourceOrphanFilter.Vote.ABSTAIN, orphanFilter.checkXid(jtaFormatId));
}
use of com.arjuna.ats.jta.recovery.XAResourceOrphanFilter in project narayana by jbosstm.
the class XAResourceOrphanFilterTest method testJTANodeNameXAResourceOrphanFilter.
@Test
public void testJTANodeNameXAResourceOrphanFilter() {
XAResourceOrphanFilter orphanFilter = new JTANodeNameXAResourceOrphanFilter();
Xid notJTAFormatId = XATxConverter.getXid(new Uid(), false, 0);
assertEquals(XAResourceOrphanFilter.Vote.ABSTAIN, orphanFilter.checkXid(notJTAFormatId));
List<String> recoveryNodes = new LinkedList<String>();
recoveryNodes.add("1");
jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(recoveryNodes);
String notRecoverableNodeName = "2";
TxControl.setXANodeName(notRecoverableNodeName);
Xid jtaNotRecoverableNodeName = XATxConverter.getXid(new Uid(), false, XATxConverter.FORMAT_ID);
assertEquals(XAResourceOrphanFilter.Vote.ABSTAIN, orphanFilter.checkXid(jtaNotRecoverableNodeName));
String recoverableNodeName = "1";
TxControl.setXANodeName(recoverableNodeName);
Xid jtaRecoverableNodeName = XATxConverter.getXid(new Uid(), false, XATxConverter.FORMAT_ID);
assertEquals(XAResourceOrphanFilter.Vote.ROLLBACK, orphanFilter.checkXid(jtaRecoverableNodeName));
recoveryNodes.clear();
recoveryNodes.add(NodeNameXAResourceOrphanFilter.RECOVER_ALL_NODES);
jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(recoveryNodes);
assertEquals(XAResourceOrphanFilter.Vote.ROLLBACK, orphanFilter.checkXid(jtaNotRecoverableNodeName));
assertEquals(XAResourceOrphanFilter.Vote.ROLLBACK, orphanFilter.checkXid(jtaRecoverableNodeName));
}
use of com.arjuna.ats.jta.recovery.XAResourceOrphanFilter in project narayana by jbosstm.
the class TestJDBCStoreOffline method test.
@Test
public void test() throws NotSupportedException, SystemException, IllegalStateException, RollbackException, SecurityException, HeuristicMixedException, HeuristicRollbackException, NamingException {
arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreType(JDBCStore.class.getName());
arjPropertyManager.getObjectStoreEnvironmentBean().setJdbcAccess(TestJDBCAccess.class.getName());
javax.transaction.TransactionManager tm = TransactionManager.transactionManager();
tm.begin();
tm.getTransaction().enlistResource(new DummyXAResource());
tm.getTransaction().enlistResource(new DummyXAResource());
tm.commit();
assertTrue(commitCount == 1);
FAULT_JDBC = true;
jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(Arrays.asList(new String[] { "1" }));
jtaPropertyManager.getJTAEnvironmentBean().setXaResourceOrphanFilters(Arrays.asList(new XAResourceOrphanFilter[] { new com.arjuna.ats.internal.jta.recovery.arjunacore.JTATransactionLogXAResourceOrphanFilter(), new com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter() }));
jtaPropertyManager.getJTAEnvironmentBean().setXaResourceRecoveries(Arrays.asList(new XAResourceRecovery[] { new DummyXAResourceRecovery() }));
jtaPropertyManager.getJTAEnvironmentBean().setOrphanSafetyInterval(1);
recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryBackoffPeriod(2);
recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryModules(Arrays.asList(new RecoveryModule[] { new XARecoveryModule() }));
RecoveryManager manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT);
manager.scan();
assertFalse(rollbackCalled);
}
Aggregations