Search in sources :

Example 1 with ObjectStoreEnvironmentBean

use of com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean in project narayana by jbosstm.

the class EmptyObjectStore method main.

public static void main(String[] args) {
    Setup orbClass = null;
    try {
        boolean needOrb = true;
        for (int i = 0; i < args.length; i++) {
            if (args[i].equals("-local")) {
                needOrb = false;
            }
        }
        if (needOrb) {
            Class c = Thread.currentThread().getContextClassLoader().loadClass("org.jboss.jbossts.qa.Utils.OrbSetup");
            orbClass = (Setup) c.newInstance();
            orbClass.start(args);
        }
        ObjectStoreEnvironmentBean storeEnvBean = BeanPopulator.getNamedInstance(ObjectStoreEnvironmentBean.class, null);
        if (storeEnvBean.getObjectStoreType() != null && storeEnvBean.getObjectStoreType().contains("JDBCStore")) {
            // ensure that all relevant JDBC store tables are cleared
            BeanPopulator.getNamedInstance(ObjectStoreEnvironmentBean.class, "stateStore").setDropTable(true);
            BeanPopulator.getNamedInstance(ObjectStoreEnvironmentBean.class, "stateStore").setCreateTable(true);
            BeanPopulator.getNamedInstance(ObjectStoreEnvironmentBean.class, "communicationStore").setDropTable(true);
            BeanPopulator.getNamedInstance(ObjectStoreEnvironmentBean.class, "communicationStore").setCreateTable(true);
            storeEnvBean.setDropTable(true);
            storeEnvBean.setCreateTable(true);
            // the first get on a store initializes it (which, for a JDBC store, includes table reinitialization)
            StoreManager.getParticipantStore();
            StoreManager.getRecoveryStore();
            StoreManager.getCommunicationStore();
            StoreManager.getTxOJStore();
        } else {
            String objectStoreDirName = arjPropertyManager.getObjectStoreEnvironmentBean().getObjectStoreDir();
            System.out.println("Emptying " + objectStoreDirName);
            if (objectStoreDirName != null) {
                File objectStoreDir = new File(objectStoreDirName);
                removeContents(objectStoreDir);
            } else {
                System.err.println("Unable to find the ObjectStore root.");
                System.out.println("Failed");
            }
        }
        emptyPIDStore();
    } catch (Exception exception) {
        System.err.println("EmptyObjectStore.main: " + exception);
        exception.printStackTrace(System.err);
    }
    try {
        if (orbClass != null) {
            orbClass.stop();
        }
    } catch (Exception exception) {
        System.err.println("EmptyObjectStore.main: " + exception);
        exception.printStackTrace(System.err);
    }
    System.out.println("Passed");
}
Also used : ObjectStoreEnvironmentBean(com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean) File(java.io.File)

Example 2 with ObjectStoreEnvironmentBean

use of com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean in project narayana by jbosstm.

the class ObjStoreBrowserTest method tryRemove.

private HeuristicTestData tryRemove(boolean failForget, boolean ignoreMBeanHeuristics, HeuristicTestData hd) throws MBeanException, MalformedObjectNameException {
    ObjectStoreEnvironmentBean osEnv = arjPropertyManager.getObjectStoreEnvironmentBean();
    osEnv.setIgnoreMBeanHeuristics(ignoreMBeanHeuristics);
    hd.failureXAResource.setRefuseForget(hd.failureXAResource.getXid(), failForget);
    // remove the bean via JMX
    hd.resourceBean.remove();
    // assert that forget was called on the resource
    assertEquals(1, hd.failureXAResource.getForgetCount(hd.failureXAResource.getXid()));
    osb.probe();
    return hd;
}
Also used : ObjectStoreEnvironmentBean(com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean)

Example 3 with ObjectStoreEnvironmentBean

use of com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean 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 4 with ObjectStoreEnvironmentBean

use of com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean in project narayana by jbosstm.

the class ObjectStoreTest method testVolatileStore.

@Test
public void testVolatileStore() throws Exception {
    ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
    objectStoreEnvironmentBean.setLocalOSRoot("tmp");
    VolatileStore as = new VolatileStore(objectStoreEnvironmentBean);
    final OutputObjectState buff = new OutputObjectState();
    final String tn = "/StateManager/junit";
    for (int i = 0; i < 100; i++) {
        Uid u = new Uid();
        InputObjectState ios = new InputObjectState();
        try {
            as.allObjUids("", ios);
        } catch (final Exception ex) {
        }
        try {
            assertTrue(as.read_uncommitted(u, tn) == null);
        } catch (final Exception ex) {
        }
        try {
            as.commit_state(u, tn);
        } catch (final Exception ex) {
        }
        as.write_committed(u, tn, buff);
        assertTrue(as.currentState(u, tn) == StateStatus.OS_COMMITTED);
        as.read_committed(u, tn);
        try {
            assertTrue(as.remove_uncommitted(u, tn));
        } catch (final Exception ex) {
        }
        as.remove_committed(u, tn);
        try {
            assertTrue(as.hide_state(u, tn));
        } catch (final Exception ex) {
        }
        try {
            assertTrue(as.reveal_state(u, tn));
        } catch (final Exception ex) {
        }
    }
}
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) IOException(java.io.IOException) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) VolatileStore(com.arjuna.ats.internal.arjuna.objectstore.VolatileStore) TwoPhaseVolatileStore(com.arjuna.ats.internal.arjuna.objectstore.TwoPhaseVolatileStore) Test(org.junit.Test)

Example 5 with ObjectStoreEnvironmentBean

use of com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean in project narayana by jbosstm.

the class ObjectStoreTest method testHashedStore.

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

Aggregations

ObjectStoreEnvironmentBean (com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean)35 Test (org.junit.Test)22 Uid (com.arjuna.ats.arjuna.common.Uid)17 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)17 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)17 TwoPhaseVolatileStore (com.arjuna.ats.internal.arjuna.objectstore.TwoPhaseVolatileStore)7 CacheStore (com.arjuna.ats.internal.arjuna.objectstore.CacheStore)5 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)4 HashedActionStore (com.arjuna.ats.internal.arjuna.objectstore.HashedActionStore)4 NullActionStore (com.arjuna.ats.internal.arjuna.objectstore.NullActionStore)4 VolatileStore (com.arjuna.ats.internal.arjuna.objectstore.VolatileStore)4 IOException (java.io.IOException)4 ParticipantStore (com.arjuna.ats.arjuna.objectstore.ParticipantStore)3 ShadowingStore (com.arjuna.ats.internal.arjuna.objectstore.ShadowingStore)3 FatalError (com.arjuna.ats.arjuna.exceptions.FatalError)2 StoreManager (com.arjuna.ats.arjuna.objectstore.StoreManager)2 ActionStore (com.arjuna.ats.internal.arjuna.objectstore.ActionStore)2 HashedStore (com.arjuna.ats.internal.arjuna.objectstore.HashedStore)2 CoordinatorEnvironmentBean (com.arjuna.ats.arjuna.common.CoordinatorEnvironmentBean)1 CoreEnvironmentBean (com.arjuna.ats.arjuna.common.CoreEnvironmentBean)1