Search in sources :

Example 1 with ShadowingStore

use of com.arjuna.ats.internal.arjuna.objectstore.ShadowingStore in project narayana by jbosstm.

the class PersistenceTest method test.

@Test
public void test() {
    boolean passed = false;
    boolean threaded = false;
    long stime = Calendar.getInstance().getTime().getTime();
    ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
    for (int i = 0; i < 1000; i++) {
        try {
            ParticipantStore store = null;
            if (!threaded)
                store = new ShadowingStore(objectStoreEnvironmentBean);
            else
                store = new CacheStore(objectStoreEnvironmentBean);
            byte[] data = new byte[10240];
            OutputObjectState state = new OutputObjectState();
            Uid u = new Uid();
            state.packBytes(data);
            if (store.write_committed(u, "/StateManager/LockManager/foo", state)) {
                passed = true;
            } else
                passed = false;
        } catch (ObjectStoreException e) {
            System.out.println(e.getMessage());
            passed = false;
        } catch (IOException ex) {
            ex.printStackTrace();
            passed = false;
        }
    }
    try {
        Thread.currentThread().sleep(1000);
    } catch (Exception ex) {
    }
    long ftime = Calendar.getInstance().getTime().getTime();
    long timeTaken = ftime - stime;
    System.out.println("time for 1000 write transactions is " + timeTaken);
    try {
        Thread.currentThread().sleep(1000);
    } catch (Exception ex) {
    }
    assertTrue(passed);
}
Also used : ObjectStoreEnvironmentBean(com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) IOException(java.io.IOException) IOException(java.io.IOException) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) Uid(com.arjuna.ats.arjuna.common.Uid) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) ShadowingStore(com.arjuna.ats.internal.arjuna.objectstore.ShadowingStore) CacheStore(com.arjuna.ats.internal.arjuna.objectstore.CacheStore) ParticipantStore(com.arjuna.ats.arjuna.objectstore.ParticipantStore) Test(org.junit.Test)

Example 2 with ShadowingStore

use of com.arjuna.ats.internal.arjuna.objectstore.ShadowingStore in project narayana by jbosstm.

the class ObjectStoreTest method testShadowingStore.

@Test
public void testShadowingStore() throws Exception {
    ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
    objectStoreEnvironmentBean.setLocalOSRoot("tmp");
    ShadowingStore as = new ShadowingStore(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) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) ShadowingStore(com.arjuna.ats.internal.arjuna.objectstore.ShadowingStore) Test(org.junit.Test)

Example 3 with ShadowingStore

use of com.arjuna.ats.internal.arjuna.objectstore.ShadowingStore in project narayana by jbosstm.

the class OtherObjectStoreAPIJMXTest method testShadowingStore.

@Test
public void testShadowingStore() throws Exception {
    ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
    objectStoreEnvironmentBean.setLocalOSRoot("tmp");
    ShadowingStore as = new ShadowingStore(objectStoreEnvironmentBean);
    final OutputObjectState buff = new OutputObjectState();
    final String tn = "/StateManager/junit";
    createMBeans(as, as);
    for (int i = 0; i < 10; i++) {
        Uid u = new Uid();
        psProxy.write_uncommitted(u, tn, buff);
        psProxy.commit_state(u, tn);
        assertTrue(rsProxy.currentState(u, tn) != StateStatus.OS_UNCOMMITTED);
        InputObjectState ios = new InputObjectState();
        rsProxy.allObjUids("", ios);
        assertTrue(psProxy.read_uncommitted(u, tn) == null);
        rsProxy.write_committed(u, tn, buff);
        rsProxy.read_committed(u, tn);
        assertTrue(!psProxy.remove_uncommitted(u, tn));
        rsProxy.remove_committed(u, tn);
        assertTrue(!rsProxy.hide_state(u, tn));
        assertTrue(!rsProxy.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) ShadowingStore(com.arjuna.ats.internal.arjuna.objectstore.ShadowingStore) Test(org.junit.Test)

Aggregations

ObjectStoreEnvironmentBean (com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean)3 Uid (com.arjuna.ats.arjuna.common.Uid)3 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)3 ShadowingStore (com.arjuna.ats.internal.arjuna.objectstore.ShadowingStore)3 Test (org.junit.Test)3 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)2 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)1 ParticipantStore (com.arjuna.ats.arjuna.objectstore.ParticipantStore)1 CacheStore (com.arjuna.ats.internal.arjuna.objectstore.CacheStore)1 IOException (java.io.IOException)1