Search in sources :

Example 16 with InputObjectState

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

the class ObjStoreBrowser method getTypes.

private Collection<String> getTypes() {
    Collection<String> allTypes = new ArrayList<String>();
    InputObjectState types = new InputObjectState();
    try {
        if (StoreManager.getRecoveryStore().allTypes(types)) {
            while (true) {
                try {
                    String typeName = canonicalType(types.unpackString());
                    if (typeName.length() == 0)
                        break;
                    allTypes.add(typeName);
                } catch (IOException e1) {
                    break;
                }
            }
        }
    } catch (ObjectStoreException e) {
        if (tsLogger.logger.isTraceEnabled())
            tsLogger.logger.trace(e.toString());
    }
    return allTypes;
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) IOException(java.io.IOException)

Example 17 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 {
    XAResourceRecord xares;
    DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
    Object[] params = new Object[1];
    params[XAResourceRecord.XACONNECTION] = rc;
    xares = new XAResourceRecord(new TransactionImple(0), new DummyXA(false), new XidImple(new Uid()), params);
    OutputObjectState os = new OutputObjectState();
    assertTrue(xares.save_state(os, ObjectType.ANDPERSISTENT));
    InputObjectState is = new InputObjectState(os);
    assertTrue(xares.restore_state(is, ObjectType.ANDPERSISTENT));
    xares = new XAResourceRecord(new TransactionImple(0), new DummyXA(false), new XidImple(new Uid()), null);
    os = new OutputObjectState();
    assertTrue(xares.save_state(os, ObjectType.ANDPERSISTENT));
    is = new InputObjectState(os);
    assertTrue(xares.restore_state(is, ObjectType.ANDPERSISTENT));
}
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.common.DummyXA) XAResourceRecord(com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord) TransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) Test(org.junit.Test)

Example 18 with InputObjectState

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

the class OnePhaseUnitTest method test.

@Test
public void test() throws Exception {
    DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
    Object[] obj = new Object[1];
    SampleOnePhaseResource res = new SampleOnePhaseResource();
    obj[XAResourceRecord.XACONNECTION] = rc;
    XAOnePhaseResource xares = new XAOnePhaseResource(res, new XidImple(new Uid()), obj);
    OutputObjectState os = new OutputObjectState();
    xares.pack(os);
    InputObjectState is = new InputObjectState(os);
    xares.unpack(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) XAOnePhaseResource(com.arjuna.ats.internal.jta.resources.arjunacore.XAOnePhaseResource) SampleOnePhaseResource(com.hp.mwtests.ts.jta.common.SampleOnePhaseResource) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) Test(org.junit.Test)

Example 19 with InputObjectState

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

the class TransactionRecoveryModule method periodicWorkFirstPass.

/**
 * This is called periodically by the RecoveryManager
 */
protected void periodicWorkFirstPass() {
    jtsLogger.i18NLogger.info_recovery_transactions_TransactionRecoveryModule_11();
    // Sanity check - make sure we know what type of transaction we're looking for
    if (_transactionType == null) {
        jtsLogger.i18NLogger.warn_recovery_transactions_TransactionRecoveryModule_2();
        return;
    }
    // Build a Vector of transaction Uids found in the ObjectStore
    _transactionUidVector = new Vector();
    InputObjectState uids = new InputObjectState();
    boolean anyTransactions = false;
    try {
        if (jtsLogger.logger.isDebugEnabled()) {
            jtsLogger.logger.debug("TransactionRecoveryModule: scanning for " + _transactionType);
        }
        anyTransactions = _recoveryStore.allObjUids(_transactionType, uids);
    } catch (ObjectStoreException e1) {
        jtsLogger.i18NLogger.warn_recovery_transactions_TransactionRecoveryModule_4(e1);
    }
    if (anyTransactions) {
        Uid theUid = null;
        boolean moreUids = true;
        while (moreUids) {
            try {
                theUid = UidHelper.unpackFrom(uids);
                if (theUid.equals(Uid.nullUid())) {
                    moreUids = false;
                } else {
                    Uid newUid = new Uid(theUid);
                    if (jtsLogger.logger.isDebugEnabled()) {
                        jtsLogger.logger.debug("found transaction " + newUid);
                    }
                    _transactionUidVector.addElement(newUid);
                }
            } catch (Exception e2) {
                moreUids = false;
            }
        }
    }
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) Uid(com.arjuna.ats.arjuna.common.Uid) Vector(java.util.Vector) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException)

Example 20 with InputObjectState

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

the class ExpiredContactScanner method scan.

/**
 * This is called periodically by the RecoveryManager
 */
public void scan() {
    // calculate the time before which items will be removed
    Date oldestSurviving = new Date(new Date().getTime() - _expiryTime * 1000);
    if (jtsLogger.logger.isDebugEnabled()) {
        jtsLogger.logger.debug("ExpiredContactScanner - scanning to remove items from before " + _timeFormat.format(oldestSurviving));
    }
    try {
        InputObjectState uids = new InputObjectState();
        // find the uids of all the contact items
        if (_recoveryStore.allObjUids(_itemTypeName, uids)) {
            Uid theUid = null;
            boolean endOfUids = false;
            while (!endOfUids) {
                // extract a uid
                theUid = UidHelper.unpackFrom(uids);
                if (theUid.equals(Uid.nullUid()))
                    endOfUids = true;
                else {
                    Uid newUid = new Uid(theUid);
                    FactoryContactItem anItem = FactoryContactItem.recreate(newUid);
                    if (anItem != null) {
                        Date timeOfDeath = anItem.getDeadTime();
                        if (timeOfDeath != null && timeOfDeath.before(oldestSurviving)) {
                            jtsLogger.i18NLogger.info_recovery_ExpiredContactScanner_3(newUid);
                            _recoveryStore.remove_committed(newUid, _itemTypeName);
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
    // end of uids!
    }
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) Uid(com.arjuna.ats.arjuna.common.Uid) Date(java.util.Date)

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