Search in sources :

Example 1 with CacheStore

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

the class WriteCachedTest method test.

@Test
public void test() throws ObjectStoreException {
    boolean passed = true;
    String cacheSize = "20480";
    int threads = 10;
    Thread[] t = new Thread[threads];
    System.setProperty("com.arjuna.ats.internal.arjuna.objectstore.cacheStore.size", cacheSize);
    ParticipantStore store = new CacheStore(new ObjectStoreEnvironmentBean());
    long stime = Calendar.getInstance().getTime().getTime();
    for (int i = 0; (i < threads) && passed; i++) {
        try {
            t[i] = new WriterThread(store);
            t[i].start();
        } catch (Exception ex) {
            ex.printStackTrace();
            passed = false;
        }
    }
    for (int j = 0; j < threads; j++) {
        try {
            t[j].join();
            passed = passed && ((WriterThread) t[j]).passed;
        } catch (Exception ex) {
        }
    }
    long ftime = Calendar.getInstance().getTime().getTime();
    long timeTaken = ftime - stime;
    System.out.println("time for " + threads + " users is " + timeTaken);
    try {
        store.sync();
    } catch (Exception ex) {
    }
    assertTrue(passed);
}
Also used : ObjectStoreEnvironmentBean(com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean) CacheStore(com.arjuna.ats.internal.arjuna.objectstore.CacheStore) ParticipantStore(com.arjuna.ats.arjuna.objectstore.ParticipantStore) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) Test(org.junit.Test)

Example 2 with CacheStore

use of com.arjuna.ats.internal.arjuna.objectstore.CacheStore 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 3 with CacheStore

use of com.arjuna.ats.internal.arjuna.objectstore.CacheStore 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 4 with CacheStore

use of com.arjuna.ats.internal.arjuna.objectstore.CacheStore 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 5 with CacheStore

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

the class CachedTest method test.

@Test
public void test() throws Exception {
    int cacheSize = 2048;
    int threads = 100;
    Thread[] t = new Thread[threads];
    ObjectStoreEnvironmentBean objectStoreEnvironmentBean = arjPropertyManager.getObjectStoreEnvironmentBean();
    objectStoreEnvironmentBean.setCacheStoreSize(cacheSize);
    ParticipantStore store = new CacheStore(objectStoreEnvironmentBean);
    long stime = Calendar.getInstance().getTime().getTime();
    for (int i = 0; i < threads; i++) {
        System.err.println("i: " + i);
        t[i] = new ThreadWriter(store);
        t[i].start();
    }
    for (int j = 0; j < threads; j++) {
        System.err.println("j: " + j);
        t[j].join();
        assertTrue(((ThreadWriter) t[j]).passed);
    }
    long ftime = Calendar.getInstance().getTime().getTime();
    long timeTaken = ftime - stime;
    store.sync();
    System.err.println("time for " + threads + " users is " + timeTaken);
}
Also used : ObjectStoreEnvironmentBean(com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean) CacheStore(com.arjuna.ats.internal.arjuna.objectstore.CacheStore) ParticipantStore(com.arjuna.ats.arjuna.objectstore.ParticipantStore) Test(org.junit.Test)

Aggregations

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