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");
}
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;
}
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);
}
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) {
}
}
}
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));
}
}
Aggregations