use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.
the class ObjectStoreMonitor method main.
@SuppressWarnings("unchecked")
public static void main(String[] args) {
String root = null;
for (int i = 0; i < args.length; i++) {
if (args[i].compareTo("-help") == 0) {
usage();
System.exit(0);
} else {
if (args[i].compareTo("-root") == 0) {
root = args[i + 1];
i++;
arjPropertyManager.getObjectStoreEnvironmentBean().setLocalOSRoot(root);
} else {
System.out.println("Unknown option " + args[i]);
usage();
System.exit(0);
}
}
}
try {
RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
InputObjectState types = new InputObjectState();
if (recoveryStore.allTypes(types)) {
String theName = null;
int count = 0;
try {
boolean endOfList = false;
while (!endOfList) {
theName = types.unpackString();
if (theName.compareTo("") == 0)
endOfList = true;
else {
count++;
System.out.println(count + ": " + theName);
InputObjectState uids = new InputObjectState();
if (recoveryStore.allObjUids(theName, uids)) {
Uid theUid = new Uid(Uid.nullUid());
try {
boolean endOfUids = false;
while (!endOfUids) {
theUid = UidHelper.unpackFrom(uids);
if (theUid.equals(Uid.nullUid()))
endOfUids = true;
else {
System.out.print("\t" + theUid + " state is ");
System.out.print(StateStatus.stateStatusString(recoveryStore.currentState(theUid, theName)));
System.out.println();
}
}
} catch (Exception e) {
// end of uids!
}
}
System.out.println();
}
}
} catch (Exception e) {
System.err.println(e);
// end of list!
}
}
} catch (Exception e) {
System.err.println("Caught unexpected exception: " + e);
}
}
use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.
the class TransactionMonitor method main.
public static void main(String[] args) {
String root = null;
for (int i = 0; i < args.length; i++) {
if (args[i].compareTo("-help") == 0) {
usage();
System.exit(0);
} else {
if (args[i].compareTo("-root") == 0) {
root = args[i + 1];
i++;
} else {
System.out.println("Unknown option " + args[i]);
usage();
System.exit(0);
}
}
}
/* Determine transaction (BasicAction) type name */
BasicAction ba = new BasicAction();
String baType = ba.type();
if (baType.charAt(0) == '/')
baType = baType.substring(1);
try {
RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
InputObjectState types = new InputObjectState();
if (recoveryStore.allTypes(types)) {
String theName = null;
int count = 0;
try {
boolean endOfList = false;
while (!endOfList) {
theName = types.unpackString();
if (theName.compareTo("") == 0)
endOfList = true;
else if (theName.startsWith(baType)) {
count++;
System.out.println(count + ": " + theName);
InputObjectState uids = new InputObjectState();
if (recoveryStore.allObjUids(theName, uids)) {
Uid theUid = new Uid(Uid.nullUid());
try {
boolean endOfUids = false;
while (!endOfUids) {
theUid = UidHelper.unpackFrom(uids);
if (theUid.equals(Uid.nullUid()))
endOfUids = true;
else {
System.out.print("\t" + theUid + " state is ");
System.out.print(StateStatus.stateStatusString(recoveryStore.currentState(theUid, theName)));
System.out.println();
}
}
} catch (Exception e) {
// end of uids!
}
}
System.out.println();
}
}
} catch (Exception e) {
System.err.println(e);
// end of list!
}
}
} catch (Exception e) {
System.err.println("Caught unexpected exception: " + e);
}
}
use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.
the class LogStoreTest2 method test.
@Test
public void test() {
arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreType(LogStore.class.getName());
// the byteman script will manage this
// System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "10000");
RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
final int numberOfTransactions = 1000;
final Uid[] ids = new Uid[numberOfTransactions];
final int fakeData = 0xdeedbaaf;
// use unique path to prevent pollution from other tests
final String type = "/StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction/TestTest";
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();
}
}
try {
recoveryStore.remove_committed(ids[0], type);
} catch (final Exception ex) {
ex.printStackTrace();
}
/*
try {
*/
/*
* Give the purger thread a chance to run and delete
* the entry.
*/
/*
Thread.sleep(12000);
}
catch (final Exception ex) {
}
*/
InputObjectState ios = new InputObjectState();
boolean passed = false;
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())) {
passed = true;
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 == ids.length - 1) && passed) {
if (recoveryStore.currentState(ids[0], type) != StateStatus.OS_UNKNOWN)
passed = false;
else {
if (recoveryStore.currentState(ids[1], type) != StateStatus.OS_COMMITTED)
passed = false;
}
} else {
passed = false;
System.err.println("Expected " + ids.length + " and got " + numberOfEntries);
}
}
} catch (final Exception ex) {
ex.printStackTrace();
}
assertTrue(passed);
}
use of com.arjuna.ats.arjuna.objectstore.RecoveryStore 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.objectstore.RecoveryStore 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);
}
Aggregations