Search in sources :

Example 56 with XidImple

use of com.arjuna.ats.jta.xa.XidImple in project narayana by jbosstm.

the class CommitMarkableResourceRecordBean method init.

private void init() {
    jndiName = getUid().stringForm();
    className = "unavailable";
    eisProductName = "unavailable";
    eisProductVersion = "unavailable";
    timeout = 0;
    heuristic = -1;
    xidImple = new XidImple(new XID());
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) XID(com.arjuna.ats.internal.jta.xa.XID)

Example 57 with XidImple

use of com.arjuna.ats.jta.xa.XidImple in project narayana by jbosstm.

the class XARecoveryModuleUnitTest method testFailures.

@Test
public void testFailures() throws Exception {
    XARecoveryModule xarm = new XARecoveryModule();
    Class[] parameterTypes = new Class[2];
    Uid u = new Uid();
    Xid x = new XidImple();
    parameterTypes[0] = Xid.class;
    parameterTypes[1] = Uid.class;
    Method m = xarm.getClass().getDeclaredMethod("addFailure", parameterTypes);
    m.setAccessible(true);
    Object[] parameters = new Object[2];
    parameters[0] = x;
    parameters[1] = u;
    m.invoke(xarm, parameters);
    parameterTypes = new Class[1];
    parameterTypes[0] = Xid.class;
    parameters = new Object[1];
    parameters[0] = x;
    m = xarm.getClass().getDeclaredMethod("previousFailure", parameterTypes);
    m.setAccessible(true);
    Uid ret = (Uid) m.invoke(xarm, parameters);
    assertEquals(ret, u);
    parameterTypes = new Class[2];
    parameterTypes[0] = Xid.class;
    parameterTypes[1] = Uid.class;
    parameters = new Object[2];
    parameters[0] = x;
    parameters[1] = u;
    m = xarm.getClass().getDeclaredMethod("removeFailure", parameterTypes);
    m.setAccessible(true);
    m.invoke(xarm, parameters);
    m = xarm.getClass().getDeclaredMethod("clearAllFailures", (Class[]) null);
    m.setAccessible(true);
    m.invoke(xarm, (Object[]) null);
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Uid(com.arjuna.ats.arjuna.common.Uid) Xid(javax.transaction.xa.Xid) Method(java.lang.reflect.Method) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule) Test(org.junit.Test)

Example 58 with XidImple

use of com.arjuna.ats.jta.xa.XidImple in project narayana by jbosstm.

the class XARecoveryModuleUnitTest method testXAResourceOrphanFilter.

@Test
public void testXAResourceOrphanFilter() throws Exception {
    XAResourceOrphanFilter xaResourceOrphanFilter = new DummyXAResourceOrphanFilter(XAResourceOrphanFilter.Vote.ROLLBACK);
    XARecoveryModule xarm = new XARecoveryModule();
    xarm.addXAResourceOrphanFilter(xaResourceOrphanFilter);
    Class[] parameterTypes = new Class[2];
    parameterTypes[0] = XAResource.class;
    parameterTypes[1] = Xid.class;
    Method m = xarm.getClass().getDeclaredMethod("handleOrphan", parameterTypes);
    m.setAccessible(true);
    Object[] parameters = new Object[2];
    parameters[0] = new RecoveryXAResource();
    parameters[1] = new XidImple();
    m.invoke(xarm, parameters);
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Method(java.lang.reflect.Method) RecoveryXAResource(com.hp.mwtests.ts.jta.common.RecoveryXAResource) JTANodeNameXAResourceOrphanFilter(com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter) XAResourceOrphanFilter(com.arjuna.ats.jta.recovery.XAResourceOrphanFilter) NodeNameXAResourceOrphanFilter(com.arjuna.ats.internal.jta.recovery.arjunacore.NodeNameXAResourceOrphanFilter) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule) Test(org.junit.Test)

Example 59 with XidImple

use of com.arjuna.ats.jta.xa.XidImple in project narayana by jbosstm.

the class XARecoveryModuleUnitTest method testRecover.

@Test
public void testRecover() throws Exception {
    ArrayList<String> r = new ArrayList<String>();
    TransactionImple tx = new TransactionImple(0);
    assertTrue(tx.enlistResource(new RecoveryXAResource()));
    assertEquals(tx.doPrepare(), TwoPhaseOutcome.PREPARE_OK);
    r.add("com.hp.mwtests.ts.jta.recovery.DummyXARecoveryResource");
    jtaPropertyManager.getJTAEnvironmentBean().setXaResourceRecoveryClassNames(r);
    XARecoveryModule xarm = new XARecoveryModule();
    assertNull(xarm.getNewXAResource(new XAResourceRecord(null, null, new XidImple(), null)));
    for (int i = 0; i < 11; i++) {
        xarm.periodicWorkFirstPass();
        xarm.periodicWorkSecondPass();
    }
    assertTrue(xarm.getNewXAResource(new XAResourceRecord(null, null, new XidImple(new Uid()), null)) == null);
    assertNull(xarm.getNewXAResource(new XAResourceRecord(null, null, new XidImple(), null)));
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Uid(com.arjuna.ats.arjuna.common.Uid) XAResourceRecord(com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord) TransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.jca.TransactionImple) ArrayList(java.util.ArrayList) RecoveryXAResource(com.hp.mwtests.ts.jta.common.RecoveryXAResource) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule) Test(org.junit.Test)

Example 60 with XidImple

use of com.arjuna.ats.jta.xa.XidImple 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();
}
Also used : JTANodeNameXAResourceOrphanFilter(com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter) ArrayList(java.util.ArrayList) AtomicAction(com.arjuna.ats.internal.jta.transaction.arjunacore.AtomicAction) RecoverAtomicAction(com.arjuna.ats.arjuna.recovery.RecoverAtomicAction) Field(java.lang.reflect.Field) RecoverAtomicAction(com.arjuna.ats.arjuna.recovery.RecoverAtomicAction) XidImple(com.arjuna.ats.jta.xa.XidImple) XAResourceRecord(com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord) BasicAction(com.arjuna.ats.arjuna.coordinator.BasicAction) Method(java.lang.reflect.Method) RecordTypeMap(com.arjuna.ats.arjuna.coordinator.abstractrecord.RecordTypeMap) File(java.io.File) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule) Test(org.junit.Test)

Aggregations

XidImple (com.arjuna.ats.jta.xa.XidImple)90 Uid (com.arjuna.ats.arjuna.common.Uid)71 Test (org.junit.Test)71 Xid (javax.transaction.xa.Xid)35 XAException (javax.transaction.xa.XAException)28 SubordinateTransaction (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction)27 Transaction (javax.transaction.Transaction)16 XATerminator (javax.resource.spi.XATerminator)15 TransactionImporter (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.TransactionImporter)12 XATerminatorImple (com.arjuna.ats.internal.jta.transaction.jts.jca.XATerminatorImple)10 IOException (java.io.IOException)10 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)9 XAOnePhaseResource (com.arjuna.ats.internal.jta.resources.arjunacore.XAOnePhaseResource)9 XAResourceRecord (com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord)9 XARecoveryModule (com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule)8 SampleOnePhaseResource (com.hp.mwtests.ts.jta.common.SampleOnePhaseResource)8 RollbackException (javax.transaction.RollbackException)8 SystemException (javax.transaction.SystemException)8 XAResource (javax.transaction.xa.XAResource)8 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)7