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