Search in sources :

Example 41 with InputObjectState

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

the class LockManagerProxyUnitTest method testBasicSaveRestore.

public void testBasicSaveRestore() {
    BasicLockable sample = new BasicLockable();
    LockManagerProxy<BasicLockable> proxy = new LockManagerProxy<BasicLockable>(sample);
    OutputObjectState os = new OutputObjectState();
    assertNotNull(proxy.type());
    assertTrue(proxy.save_state(os, ObjectType.RECOVERABLE));
    InputObjectState ios = new InputObjectState(os);
    sample._isState = -1;
    sample._isNotState = -1;
    assertTrue(proxy.restore_state(ios, ObjectType.RECOVERABLE));
    assertTrue(sample._isState == 4);
    assertTrue(sample._isNotState == -1);
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState)

Example 42 with InputObjectState

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

the class LockManagerProxyUnitTest method testExtendedSaveRestore.

public void testExtendedSaveRestore() {
    ExtendedLockable sample = new ExtendedLockable();
    LockManagerProxy<ExtendedLockable> proxy = new LockManagerProxy<ExtendedLockable>(sample);
    OutputObjectState os = new OutputObjectState();
    assertNotNull(proxy.type());
    assertTrue(proxy.save_state(os, ObjectType.RECOVERABLE));
    InputObjectState ios = new InputObjectState(os);
    sample._isState = new Double(0.0);
    sample._isNotState = new Integer(0);
    sample.set("");
    assertTrue(proxy.restore_state(ios, ObjectType.RECOVERABLE));
    assertTrue(sample._isState.doubleValue() == 1.234);
    assertTrue(sample._isNotState.intValue() == 0);
    assertEquals(sample.get(), "Hello World");
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState)

Example 43 with InputObjectState

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

the class SubordinateBACoordinatorRecoveryModule method periodicWorkFirstPass.

/**
 * This is called periodically by the RecoveryManager
 */
public void periodicWorkFirstPass() {
    // Transaction type
    boolean SubordinateCoordinators = false;
    // uids per transaction type
    InputObjectState acc_uids = new InputObjectState();
    try {
        if (RecoveryLogger.logger.isDebugEnabled()) {
            RecoveryLogger.logger.debug("StatusModule: first pass ");
        }
        SubordinateCoordinators = _recoveryStore.allObjUids(_transactionType, acc_uids);
    } catch (ObjectStoreException ex) {
        RecoveryLogger.i18NLogger.warn_coordinator_ba_SubordinateCoordinatorRecoveryModule_1(ex);
    }
    if (SubordinateCoordinators) {
        _transactionUidVector = processTransactions(acc_uids);
    }
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException)

Example 44 with InputObjectState

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

the class ATParticipantRecoveryModule method periodicWorkFirstPass.

/**
 * This is called periodically by the RecoveryManager
 */
public void periodicWorkFirstPass() {
    // Transaction type
    boolean ATParticipants = false;
    // uids per transaction type
    InputObjectState acc_uids = new InputObjectState();
    try {
        if (RecoveryLogger.logger.isDebugEnabled()) {
            RecoveryLogger.logger.debug("ATParticipantRecoveryModule: first pass");
        }
        ATParticipants = _recoveryStore.allObjUids(_participantType, acc_uids);
    } catch (ObjectStoreException ex) {
        RecoveryLogger.i18NLogger.warn_participant_at_ATParticipantRecoveryModule_1(ex);
    }
    if (ATParticipants) {
        _participantUidVector = processParticipants(acc_uids);
    }
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException)

Example 45 with InputObjectState

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

the class TransactionStatusConnectionManager method updateTSMI.

/**
 * Examine the Object Store for any new TrasactionStatusManagerItem
 * objects, and add to local hash table.
 */
public void updateTSMI() {
    boolean tsmis = false;
    InputObjectState uids = new InputObjectState();
    Vector tsmiVector = new Vector();
    try {
        tsmis = _recoveryStore.allObjUids(_typeName, uids);
    } catch (ObjectStoreException ex) {
        tsLogger.i18NLogger.warn_recovery_TransactionStatusConnectionManager_2(ex);
    }
    if (tsmis) {
        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 (tsLogger.logger.isDebugEnabled()) {
                        tsLogger.logger.debug("found process uid " + newUid);
                    }
                    tsmiVector.addElement(newUid);
                }
            } catch (Exception ex) {
                moreUids = false;
            }
        }
    }
    // for each TransactionStatusManager found, if their is
    // not an entry in the local hash table for it then add it.
    Enumeration tsmiEnum = tsmiVector.elements();
    while (tsmiEnum.hasMoreElements()) {
        Uid currentUid = (Uid) tsmiEnum.nextElement();
        String process_id = currentUid.getHexPid();
        if (!_tscTable.containsKey(process_id)) {
            TransactionStatusConnector tsc = new TransactionStatusConnector(process_id, currentUid);
            if (tsc.isDead()) {
                tsc.delete();
                tsc = null;
            } else {
                _tscTable.put(process_id, tsc);
            }
            if (tsLogger.logger.isDebugEnabled()) {
                tsLogger.logger.debug("added TransactionStatusConnector to table for process uid " + process_id);
            }
        }
    }
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) Uid(com.arjuna.ats.arjuna.common.Uid) Enumeration(java.util.Enumeration) TransactionStatusConnector(com.arjuna.ats.internal.arjuna.recovery.TransactionStatusConnector) Vector(java.util.Vector) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException)

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