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());
}
}
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());
}
}
}
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();
// }
}
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);
}
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));
}
}
Aggregations