use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.
the class ObjectStoreTest method testTwoVolatileStores.
@Test
public void testTwoVolatileStores() throws Exception {
ObjectStoreEnvironmentBean objectStoreEnvironmentBean1 = new ObjectStoreEnvironmentBean();
objectStoreEnvironmentBean1.setLocalOSRoot("tmp");
ObjectStoreEnvironmentBean objectStoreEnvironmentBean2 = new ObjectStoreEnvironmentBean();
objectStoreEnvironmentBean2.setLocalOSRoot("tmp2");
objectStoreEnvironmentBean2.setVolatileStoreSupportAllObjUids(true);
VolatileStore as1 = new VolatileStore(objectStoreEnvironmentBean1);
VolatileStore as2 = new VolatileStore(objectStoreEnvironmentBean2);
final OutputObjectState buff = new OutputObjectState();
final String tn = "/StateManager/junit";
try {
as1.allObjUids("", new InputObjectState());
fail("testTwoVolatileStores: allObjUids should have failed");
} catch (final Exception ex) {
}
try {
as1.allTypes(new InputObjectState());
fail("testTwoVolatileStores: allTypes should have failed");
} catch (final Exception ex) {
}
try {
as2.allObjUids("", new InputObjectState());
} catch (final Exception ex) {
fail("testTwoVolatileStores: allObjUids should have passed");
}
try {
as2.allTypes(new InputObjectState());
} catch (final Exception ex) {
fail("testTwoVolatileStores: allTypes should have passed");
}
}
use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.
the class AllObjUidsTest method test.
@Test
public void test() throws IOException, ObjectStoreException {
RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
String type = "/StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction/DummyAtomicAction";
InputObjectState ios = new InputObjectState();
recoveryStore.allObjUids(type, ios, StateStatus.OS_UNKNOWN);
Uid uid = UidHelper.unpackFrom(ios);
assertEquals(Uid.nullUid(), uid);
ios = new InputObjectState();
recoveryStore.allObjUids(type, ios, StateStatus.OS_COMMITTED);
uid = UidHelper.unpackFrom(ios);
assertEquals(Uid.nullUid(), uid);
ios = new InputObjectState();
recoveryStore.allObjUids(type, ios, StateStatus.OS_UNCOMMITTED);
uid = UidHelper.unpackFrom(ios);
assertEquals(Uid.nullUid(), uid);
}
use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.
the class CachedTest method run.
public void run() {
byte[] data = new byte[1024];
OutputObjectState state = new OutputObjectState(new Uid(), "type");
Uid u = new Uid();
try {
state.packBytes(data);
if (participantStore.write_committed(u, TYPE, state)) {
Thread.yield();
InputObjectState s = participantStore.read_committed(u, TYPE);
Thread.yield();
if (s != null) {
if (participantStore.remove_committed(u, TYPE))
passed = true;
} else
System.err.println("No state found while trying to read " + u);
}
} catch (Exception ex) {
ex.printStackTrace();
}
System.err.println("Thread for " + u + " " + ((passed) ? "succeeded" : "failed"));
}
use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.
the class LogStoreRecoveryTest method test.
@Test
public void test() {
RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
final int numberOfTransactions = 1000;
final Uid[] ids = new Uid[numberOfTransactions];
final int fakeData = 0xdeedbaaf;
final String type = "/StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction/LogStoreRecoveryTest";
for (int i = 0; i < numberOfTransactions; i++) {
OutputObjectState dummyState = new OutputObjectState();
try {
dummyState.packInt(fakeData);
ids[i] = new Uid();
recoveryStore.write_committed(ids[i], type, dummyState);
} catch (final Exception ex) {
ex.printStackTrace();
}
}
for (int i = 0; i < numberOfTransactions / 2; i++) {
try {
recoveryStore.remove_committed(ids[i], type);
} catch (final Exception ex) {
ex.printStackTrace();
}
}
/*
try {
*/
/*
* Give the purger thread a chance to run and delete
* the entries we've "removed" (really only marked as
* being removable.)
*/
/*
Thread.sleep(12000);
}
catch (final Exception ex) {
}
*/
/*
* Now get a list of entries to work on.
*/
InputObjectState ios = new InputObjectState();
boolean passed = true;
try {
if (recoveryStore.allObjUids(type, ios, StateStatus.OS_UNKNOWN)) {
Uid id = new Uid(Uid.nullUid());
int numberOfEntries = 0;
do {
try {
id = UidHelper.unpackFrom(ios);
} catch (Exception ex) {
id = Uid.nullUid();
}
if (id.notEquals(Uid.nullUid())) {
numberOfEntries++;
boolean found = false;
for (int i = 0; i < ids.length; i++) {
if (id.equals(ids[i]))
found = true;
}
if (passed && !found) {
passed = false;
System.err.println("Found unexpected transaction!");
}
}
} while (id.notEquals(Uid.nullUid()));
if ((numberOfEntries == numberOfTransactions / 2) && passed) {
System.err.println("Would attempt recovery on " + numberOfEntries + " dead transactions.");
} else {
passed = false;
System.err.println("Expected " + (numberOfTransactions / 2) + " and got " + numberOfEntries);
}
}
} catch (final Exception ex) {
ex.printStackTrace();
}
assertTrue(passed);
}
use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.
the class OtherObjectStoreAPIJMXTest 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";
createMBeans(as, as);
for (int i = 0; i < 10; i++) {
Uid u = new Uid();
psProxy.write_uncommitted(u, tn, buff);
psProxy.commit_state(u, tn);
assertTrue(rsProxy.currentState(u, tn) != StateStatus.OS_UNCOMMITTED);
InputObjectState ios = new InputObjectState();
rsProxy.allObjUids("", ios);
assertTrue(psProxy.read_uncommitted(u, tn) == null);
rsProxy.write_committed(u, tn, buff);
rsProxy.read_committed(u, tn);
assertTrue(!as.remove_uncommitted(u, tn));
rsProxy.remove_committed(u, tn);
assertTrue(!rsProxy.hide_state(u, tn));
assertTrue(!rsProxy.reveal_state(u, tn));
}
}
Aggregations