Search in sources :

Example 26 with InputObjectState

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

the class ObjectStoreTest method testShadowNoFileLockStore.

@Test
public void testShadowNoFileLockStore() throws Exception {
    ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
    objectStoreEnvironmentBean.setLocalOSRoot("tmp");
    ShadowNoFileLockStore as = new ShadowNoFileLockStore(objectStoreEnvironmentBean);
    final OutputObjectState buff = new OutputObjectState();
    final String tn = "/StateManager/junit";
    for (int i = 0; i < 100; i++) {
        Uid u = new Uid();
        as.write_uncommitted(u, tn, buff);
        as.commit_state(u, tn);
        assertTrue(as.currentState(u, tn) != StateStatus.OS_UNCOMMITTED);
        InputObjectState ios = new InputObjectState();
        as.allObjUids("", ios);
        assertTrue(as.read_uncommitted(u, tn) == null);
        as.write_committed(u, tn, buff);
        as.read_committed(u, tn);
        assertTrue(!as.remove_uncommitted(u, tn));
        as.remove_committed(u, tn);
        assertTrue(!as.hide_state(u, tn));
        assertTrue(!as.reveal_state(u, tn));
    }
}
Also used : ObjectStoreEnvironmentBean(com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean) Uid(com.arjuna.ats.arjuna.common.Uid) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) ShadowNoFileLockStore(com.arjuna.ats.internal.arjuna.objectstore.ShadowNoFileLockStore) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) Test(org.junit.Test)

Example 27 with InputObjectState

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

the class ObjectStoreTest method testCacheStore.

// @Test
public void testCacheStore() throws Exception {
    ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
    objectStoreEnvironmentBean.setLocalOSRoot("tmp");
    CacheStore as = new CacheStore(objectStoreEnvironmentBean);
    final OutputObjectState buff = new OutputObjectState();
    final String tn = "/StateManager/junit";
    for (int i = 0; i < 100; i++) {
        Uid u = new Uid();
        as.write_uncommitted(u, tn, buff);
        as.commit_state(u, tn);
        assertTrue(as.currentState(u, tn) != StateStatus.OS_UNCOMMITTED);
        InputObjectState ios = new InputObjectState();
        as.allObjUids("", ios);
        // may or may not be there if cache flush hasn't happened
        as.read_uncommitted(u, tn);
        as.write_committed(u, tn, buff);
        as.read_committed(u, tn);
        // may or may not be there if cache flush hasn't happened
        as.remove_uncommitted(u, tn);
        as.remove_committed(u, tn);
        assertTrue(!as.hide_state(u, tn));
        assertTrue(!as.reveal_state(u, tn));
    }
}
Also used : ObjectStoreEnvironmentBean(com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean) Uid(com.arjuna.ats.arjuna.common.Uid) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) CacheStore(com.arjuna.ats.internal.arjuna.objectstore.CacheStore)

Example 28 with InputObjectState

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

the class ObjectStoreTest method getAllTypes.

private Collection<String> getAllTypes(ObjectStore store) throws Exception {
    Collection<String> allTypes = new ArrayList<>();
    InputObjectState types = new InputObjectState();
    assertTrue(store.allTypes(types));
    while (true) {
        try {
            String typeName = types.unpackString();
            if (typeName.length() == 0)
                break;
            allTypes.add(typeName);
        } catch (IOException e1) {
            break;
        }
    }
    return allTypes;
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Example 29 with InputObjectState

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

the class RemoveCachedTest method test.

@Test
public void test() throws IOException, ObjectStoreException {
    boolean passed = true;
    RecoveryStore store = new CacheStore(new ObjectStoreEnvironmentBean());
    String type = "ArjunaMS/Destinations/a3d6227_dc656_3b77ce7e_2/Messages";
    InputObjectState buff = new InputObjectState();
    if (store.allObjUids(type, buff, StateStatus.OS_COMMITTED)) {
        Uid toRemove = new Uid(Uid.nullUid());
        do {
            toRemove = UidHelper.unpackFrom(buff);
            if (toRemove.notEquals(Uid.nullUid())) {
                System.err.println("Removing " + toRemove + "\n");
                if (store.remove_committed(toRemove, type))
                    passed = true;
                else {
                    System.err.println("Failed for " + toRemove);
                    passed = false;
                }
            }
        } while (toRemove.notEquals(Uid.nullUid()));
    }
    assertTrue(passed);
}
Also used : ObjectStoreEnvironmentBean(com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) Uid(com.arjuna.ats.arjuna.common.Uid) CacheStore(com.arjuna.ats.internal.arjuna.objectstore.CacheStore) RecoveryStore(com.arjuna.ats.arjuna.objectstore.RecoveryStore) Test(org.junit.Test)

Example 30 with InputObjectState

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

the class ExpiredTransactionScanner method scan.

/**
 * This is called periodically by the RecoveryManager
 */
public void scan() {
    boolean initialScan = false;
    if (_scanM == null) {
        _scanM = new Hashtable();
        initialScan = true;
    }
    try {
        InputObjectState uids = new InputObjectState();
        if (_recoveryStore.allObjUids(_typeName, 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);
                    if (initialScan)
                        _scanM.put(newUid, newUid);
                    else {
                        if (!_scanM.contains(newUid)) {
                            if (_scanN == null)
                                _scanN = new Hashtable();
                            _scanN.put(newUid, newUid);
                        } else // log is present in this iteration, so move it
                        {
                            tsLogger.i18NLogger.info_recovery_ExpiredTransactionScanner_4(newUid);
                            try {
                                moveEntry(newUid);
                            } catch (Exception ex) {
                                tsLogger.i18NLogger.warn_recovery_ExpiredTransactionScanner_2(newUid, ex);
                                _scanN.put(newUid, newUid);
                            }
                        }
                    }
                }
            }
            if (_scanN != null) {
                _scanM = _scanN;
                _scanN = null;
            }
        }
    } catch (Exception e) {
    // end of uids!
    }
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) Uid(com.arjuna.ats.arjuna.common.Uid) Hashtable(java.util.Hashtable) 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