Search in sources :

Example 56 with InputObjectState

use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.

the class ObjectStoreAPIJMXTest method testShadowNoFileLockStore.

@Test
public void testShadowNoFileLockStore() throws Exception {
    final OutputObjectState buff = new OutputObjectState();
    final String tn = "/StateManager/junit";
    System.out.println("Testing shadow file store");
    for (int i = 0; i < 10; i++) {
        Uid u = new Uid();
        pps.write_uncommitted(u, tn, buff);
        pps.commit_state(u, tn);
        assertTrue(prs.currentState(u, tn) != StateStatus.OS_UNCOMMITTED);
        InputObjectState ios = new InputObjectState();
        prs.allObjUids("", ios);
        assertTrue(pps.read_uncommitted(u, tn) == null);
        prs.write_committed(u, tn, buff);
        prs.read_committed(u, tn);
        assertTrue(!pps.remove_uncommitted(u, tn));
        prs.remove_committed(u, tn);
        assertTrue(!prs.hide_state(u, tn));
        assertTrue(!prs.reveal_state(u, tn));
    }
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) Test(org.junit.Test)

Example 57 with InputObjectState

use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.

the class XARecoveryModule method periodicWorkFirstPass.

private synchronized void periodicWorkFirstPass(ScanStates endState) {
    // then we get deadlock on the secondpass
    if (getScanState() == ScanStates.BETWEEN_PASSES) {
        periodicWorkSecondPass();
        // Ensure if originally we are between periodic recovery scans we continue in that state and leave XAResource in STARTRSCAN
        endState = ScanStates.BETWEEN_PASSES;
    }
    // synchronized uses a reentrant lock
    setScanState(ScanStates.FIRST_PASS);
    if (jtaLogger.logger.isDebugEnabled()) {
        jtaLogger.logger.debugv("{0} - first pass", _logName);
    }
    contactedJndiNames.clear();
    _uids = new InputObjectState();
    try {
        if (!_recoveryStore.allObjUids(_recoveryManagerClass.type(), _uids)) {
            jtaLogger.i18NLogger.warn_recovery_alluids();
        }
    } catch (ObjectStoreException e) {
        jtaLogger.i18NLogger.warn_recovery_objstoreerror(e);
    } catch (Exception e) {
        jtaLogger.i18NLogger.warn_recovery_periodicfirstpass(_logName + ".periodicWorkFirstPass", e);
    }
    // JBTM-1354 JCA needs to be able to recover XAResources associated with a subordinate transaction so we have to do at least
    // the start scan to make sure that we have loaded all the XAResources we possibly can to assist subordinate transactions recovering
    // scan using statically configured plugins;
    _resources = resourceInitiatedRecovery();
    // scan using dynamically configured plugins:
    _resources.addAll(resourceInitiatedRecoveryForRecoveryHelpers());
    List<XAResource> resources = new ArrayList<XAResource>(_resources);
    for (XAResource xaResource : resources) {
        try {
            xaRecoveryFirstPass(xaResource);
        } catch (Exception ex) {
            jtaLogger.i18NLogger.warn_recovery_getxaresource(ex);
        }
    }
    if (endState != ScanStates.BETWEEN_PASSES) {
        for (XAResource xaResource : resources) {
            try {
                xaResource.recover(XAResource.TMENDRSCAN);
            } catch (Exception ex) {
                jtaLogger.i18NLogger.warn_recovery_getxaresource(ex);
            }
        }
    }
    setScanState(endState);
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) XAResource(javax.transaction.xa.XAResource) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) XAException(javax.transaction.xa.XAException)

Example 58 with InputObjectState

use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.

the class RecoverConnectableAtomicActionBean method createWrapper.

@Override
protected ActionBeanWrapperInterface createWrapper(UidWrapper w, boolean activate) {
    try {
        InputObjectState state = StoreManager.getRecoveryStore().read_committed(w.getUid(), RecoverConnectableAtomicAction.CONNECTABLE_ATOMIC_ACTION_TYPE);
        connectableAtomicAction = new RecoverConnectableAtomicAction(RecoverConnectableAtomicAction.CONNECTABLE_ATOMIC_ACTION_TYPE, w.getUid(), state);
    } catch (ObjectStoreException e) {
        ;
    } catch (IOException e) {
        ;
    }
    GenericAtomicActionWrapper action = new GenericAtomicActionWrapper(connectableAtomicAction, w);
    if (activate)
        action.activate();
    return action;
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) RecoverConnectableAtomicAction(com.arjuna.ats.internal.jta.recovery.arjunacore.RecoverConnectableAtomicAction) IOException(java.io.IOException)

Example 59 with InputObjectState

use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.

the class XAResourceRecordUnitTest method testPackUnpack.

@Test
public void testPackUnpack() throws Exception {
    ThreadActionData.purgeActions();
    OTSImpleManager.current().contextManager().purgeActions();
    XAResourceRecord xares;
    DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
    Object[] params = new Object[1];
    params[XAResourceRecord.XACONNECTION] = rc;
    xares = new XAResourceRecord(new TransactionImple(), new DummyXA(false), new XidImple(new Uid()), params);
    OutputObjectState os = new OutputObjectState();
    assertTrue(xares.saveState(os));
    xares = new XAResourceRecord();
    InputObjectState is = new InputObjectState(os);
    assertTrue(xares.restoreState(is));
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) DummyRecoverableXAConnection(com.hp.mwtests.ts.jta.common.DummyRecoverableXAConnection) Uid(com.arjuna.ats.arjuna.common.Uid) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) DummyXA(com.hp.mwtests.ts.jta.jts.common.DummyXA) XAResourceRecord(com.arjuna.ats.internal.jta.resources.jts.orbspecific.XAResourceRecord) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) Test(org.junit.Test)

Example 60 with InputObjectState

use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.

the class ServerTransactionUnitTest method test.

@Test
public void test() throws Exception {
    ServerTransaction st = new ServerTransaction(new Uid(), new XidImple(new Uid()));
    OutputObjectState os = new OutputObjectState();
    assertTrue(st.save_state(os, ObjectType.ANDPERSISTENT));
    InputObjectState is = new InputObjectState(os);
    assertTrue(st.restore_state(is, ObjectType.ANDPERSISTENT));
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Uid(com.arjuna.ats.arjuna.common.Uid) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) ServerTransaction(com.arjuna.ats.internal.jta.transaction.jts.subordinate.jca.coordinator.ServerTransaction) Test(org.junit.Test)

Aggregations

InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)133 Uid (com.arjuna.ats.arjuna.common.Uid)83 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)55 Test (org.junit.Test)47 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)42 IOException (java.io.IOException)30 RecoveryStore (com.arjuna.ats.arjuna.objectstore.RecoveryStore)23 ObjectStoreEnvironmentBean (com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean)17 XidImple (com.arjuna.ats.jta.xa.XidImple)9 XAException (javax.transaction.xa.XAException)9 ArrayList (java.util.ArrayList)8 ParticipantStore (com.arjuna.ats.arjuna.objectstore.ParticipantStore)7 Xid (javax.transaction.xa.Xid)6 SubordinateAtomicAction (com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.jca.SubordinateAtomicAction)5 Date (java.util.Date)5 Vector (java.util.Vector)5 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)4 HashedActionStore (com.arjuna.ats.internal.arjuna.objectstore.HashedActionStore)4 NullActionStore (com.arjuna.ats.internal.arjuna.objectstore.NullActionStore)4 TransactionImple (com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple)4