Search in sources :

Example 16 with ObjectStoreEnvironmentBean

use of com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean in project wildfly by wildfly.

the class ArjunaObjectStoreEnvironmentService method start.

@Override
public void start(StartContext context) throws StartException {
    callbackHandle = pathManagerInjector.getValue().registerCallback(pathRef, PathManager.ReloadServerCallback.create(), PathManager.Event.UPDATED, PathManager.Event.REMOVED);
    String objectStoreDir = pathManagerInjector.getValue().resolveRelativePathEntry(path, pathRef);
    final ObjectStoreEnvironmentBean defaultActionStoreObjectStoreEnvironmentBean = BeanPopulator.getNamedInstance(ObjectStoreEnvironmentBean.class, null);
    if (useJournalStore) {
        HornetqJournalEnvironmentBean hornetqJournalEnvironmentBean = BeanPopulator.getDefaultInstance(com.arjuna.ats.internal.arjuna.objectstore.hornetq.HornetqJournalEnvironmentBean.class);
        hornetqJournalEnvironmentBean.setAsyncIO(enableAsyncIO);
        hornetqJournalEnvironmentBean.setStoreDir(objectStoreDir + "/HornetqObjectStore");
        defaultActionStoreObjectStoreEnvironmentBean.setObjectStoreType("com.arjuna.ats.internal.arjuna.objectstore.hornetq.HornetqObjectStoreAdaptor");
    } else {
        defaultActionStoreObjectStoreEnvironmentBean.setObjectStoreDir(objectStoreDir);
    }
    final ObjectStoreEnvironmentBean stateStoreObjectStoreEnvironmentBean = BeanPopulator.getNamedInstance(ObjectStoreEnvironmentBean.class, "stateStore");
    stateStoreObjectStoreEnvironmentBean.setObjectStoreDir(objectStoreDir);
    final ObjectStoreEnvironmentBean communicationStoreObjectStoreEnvironmentBean = BeanPopulator.getNamedInstance(ObjectStoreEnvironmentBean.class, "communicationStore");
    communicationStoreObjectStoreEnvironmentBean.setObjectStoreDir(objectStoreDir);
    if (useJdbcStore) {
        defaultActionStoreObjectStoreEnvironmentBean.setObjectStoreType("com.arjuna.ats.internal.arjuna.objectstore.jdbc.JDBCStore");
        stateStoreObjectStoreEnvironmentBean.setObjectStoreType("com.arjuna.ats.internal.arjuna.objectstore.jdbc.JDBCStore");
        communicationStoreObjectStoreEnvironmentBean.setObjectStoreType("com.arjuna.ats.internal.arjuna.objectstore.jdbc.JDBCStore");
        defaultActionStoreObjectStoreEnvironmentBean.setJdbcAccess("com.arjuna.ats.internal.arjuna.objectstore.jdbc.accessors.DataSourceJDBCAccess;datasourceName=" + dataSourceJndiName);
        stateStoreObjectStoreEnvironmentBean.setJdbcAccess("com.arjuna.ats.internal.arjuna.objectstore.jdbc.accessors.DataSourceJDBCAccess;datasourceName=" + dataSourceJndiName);
        communicationStoreObjectStoreEnvironmentBean.setJdbcAccess("com.arjuna.ats.internal.arjuna.objectstore.jdbc.accessors.DataSourceJDBCAccess;datasourceName=" + dataSourceJndiName);
        defaultActionStoreObjectStoreEnvironmentBean.setTablePrefix(jdbcSoreConfig.getActionTablePrefix());
        stateStoreObjectStoreEnvironmentBean.setTablePrefix(jdbcSoreConfig.getStateTablePrefix());
        communicationStoreObjectStoreEnvironmentBean.setTablePrefix(jdbcSoreConfig.getCommunicationTablePrefix());
        defaultActionStoreObjectStoreEnvironmentBean.setDropTable(jdbcSoreConfig.isActionDropTable());
        stateStoreObjectStoreEnvironmentBean.setDropTable(jdbcSoreConfig.isStateDropTable());
        communicationStoreObjectStoreEnvironmentBean.setDropTable(jdbcSoreConfig.isCommunicationDropTable());
    }
}
Also used : ObjectStoreEnvironmentBean(com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean) HornetqJournalEnvironmentBean(com.arjuna.ats.internal.arjuna.objectstore.hornetq.HornetqJournalEnvironmentBean)

Example 17 with ObjectStoreEnvironmentBean

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

the class StateManager method setupStore.

/**
 * Make sure the object store is set up, if required.
 *
 * @param rootName
 *            indicates the root of the object store.
 */
@SuppressWarnings("unchecked")
protected synchronized void setupStore(String rootName, String objectStoreType) {
    if (tsLogger.logger.isTraceEnabled()) {
        tsLogger.logger.trace("StateManager::setupStore ( " + ((rootName != null) ? rootName : "null") + " )");
    }
    if (!loadObjectState())
        return;
    if (participantStore != null)
        return;
    if (rootName == null)
        rootName = arjPropertyManager.getObjectStoreEnvironmentBean().getLocalOSRoot();
    if (storeRoot != null) {
        if ((rootName == null) || (rootName.compareTo("") == 0) || (rootName.compareTo(storeRoot) == 0)) {
            return;
        }
        /* No - destroy old store and create new */
        participantStore = null;
    }
    if (rootName == null) {
        rootName = "";
    }
    /* Create store now */
    storeRoot = new String(rootName);
    if ((myType == ObjectType.ANDPERSISTENT) || (myType == ObjectType.NEITHER)) {
        int sharedStatus = ((objectModel == ObjectModel.SINGLE) ? StateType.OS_UNSHARED : StateType.OS_SHARED);
        participantStore = StoreManager.setupStore(rootName, sharedStatus);
    } else {
        try {
            participantStore = new TwoPhaseVolatileStore(new ObjectStoreEnvironmentBean());
        } catch (final Throwable ex) {
            tsLogger.i18NLogger.warn_StateManager_13();
            throw new FatalError(tsLogger.i18NLogger.get_StateManager_14());
        }
    }
}
Also used : ObjectStoreEnvironmentBean(com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean) FatalError(com.arjuna.ats.arjuna.exceptions.FatalError) TwoPhaseVolatileStore(com.arjuna.ats.internal.arjuna.objectstore.TwoPhaseVolatileStore)

Example 18 with ObjectStoreEnvironmentBean

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

the class JDBCStoreTest method testStateMachine.

@Test
public void testStateMachine() throws SQLException, ObjectStoreException, Exception {
    ObjectStoreEnvironmentBean jdbcStoreEnvironmentBean = BeanPopulator.getDefaultInstance(ObjectStoreEnvironmentBean.class);
    ObjectStoreAPI api = new JDBCStore(jdbcStoreEnvironmentBean);
    InputObjectState states = new InputObjectState();
    api.allObjUids("typeName", states);
    Uid unpacked = UidHelper.unpackFrom(states);
    if (unpacked.notEquals(Uid.nullUid())) {
        fail("Did not expect uids to start with");
    }
    Uid uid = new Uid();
    assertTrue(api.read_committed(uid, "typeName") == null);
    assertTrue(api.write_uncommitted(uid, "typeName", new OutputObjectState()));
    assertTrue(api.commit_state(uid, "typeName"));
    assertTrue(api.read_committed(uid, "typeName") != null);
    assertFalse(api.commit_state(uid, "typeName"));
    assertTrue(api.hide_state(uid, "typeName"));
    assertTrue(api.reveal_state(uid, "typeName"));
    byte[] buff = new byte[10496000 + 1];
    OutputObjectState outputObjectState = new OutputObjectState(new Uid(), "tName");
    outputObjectState.packBytes(buff);
    assertFalse(api.write_uncommitted(uid, "typeName", outputObjectState));
    String toTest = "Hello - this is a test";
    buff = new String(toTest).getBytes();
    outputObjectState = new OutputObjectState();
    outputObjectState.packBytes(buff);
    assertTrue(api.write_committed(uid, "typeName", outputObjectState));
    InputObjectState read_state = api.read_committed(uid, "typeName");
    assertTrue(new String(read_state.unpackBytes()).equals(toTest));
    assertTrue(read_state.type(), read_state.type().equals("typeName"));
    states = new InputObjectState();
    api.allObjUids("typeName", states);
    boolean foundUid = false;
    do {
        Uid uidFound = UidHelper.unpackFrom(states);
        if (uidFound.notEquals(Uid.nullUid())) {
            assertTrue(uidFound.equals(uid));
            foundUid = true;
        } else {
            if (!foundUid) {
                fail("Did not find the UID");
            }
            break;
        }
    } while (true);
    assertFalse(api.remove_uncommitted(uid, "typeName"));
    assertTrue(api.remove_committed(uid, "typeName"));
    assertFalse(api.remove_committed(uid, "typeName"));
    api.stop();
// }
}
Also used : ObjectStoreEnvironmentBean(com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) Uid(com.arjuna.ats.arjuna.common.Uid) JDBCStore(com.arjuna.ats.internal.arjuna.objectstore.jdbc.JDBCStore) ObjectStoreAPI(com.arjuna.ats.arjuna.objectstore.ObjectStoreAPI) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) Test(org.junit.Test)

Example 19 with ObjectStoreEnvironmentBean

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

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

the class ObjectStoreTest method testHashedActionStore.

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