use of com.arjuna.ats.arjuna.state.InputObjectState 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.state.InputObjectState 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.state.InputObjectState in project narayana by jbosstm.
the class ActionStatusService method getOsStatus.
/**
* Obtains the status for the specified transaction Uid when
* the transaction type is unknown.
*/
private int getOsStatus(Uid tranUid) {
int action_status = ActionStatus.INVALID;
Vector matchingUidVector = new Vector();
Vector matchingUidTypeVector = new Vector();
try {
InputObjectState types = new InputObjectState();
// find all types
if (_recoveryStore.allTypes(types)) {
String theTypeName = null;
boolean endOfList = false;
while (!endOfList) {
// extract a type
theTypeName = types.unpackString();
if (theTypeName.compareTo("") == 0) {
endOfList = true;
} else {
InputObjectState uids = new InputObjectState();
boolean endOfUids = false;
if (_recoveryStore.allObjUids(theTypeName, uids)) {
Uid theUid = null;
while (!endOfUids) {
// extract a uid
theUid = UidHelper.unpackFrom(uids);
if (theUid.equals(Uid.nullUid())) {
endOfUids = true;
} else if (theUid.equals(tranUid)) {
// add to vector
matchingUidVector.addElement(tranUid);
matchingUidTypeVector.addElement(theTypeName);
tsLogger.i18NLogger.info_recovery_ActionStatusService_4(tranUid);
}
}
} else {
// Errors contacting recovery store for the list of uids it has for a type so return INVALID state
return action_status;
}
}
}
} else {
// Errors contacting recovery store for the list of types it holds so return INVALID state
return action_status;
}
} catch (Exception ex) {
tsLogger.i18NLogger.warn_recovery_ActionStatusService_5(tranUid, ex);
// Read invalid data from the objectstore so return INVALID state
return action_status;
}
int uidVectorSize = matchingUidVector.size();
int first_index = 0;
if (uidVectorSize == 0) {
// no state means aborted because of presumed abort rules
action_status = ActionStatus.ABORTED;
} else if (uidVectorSize == 1) {
Uid uid = (Uid) matchingUidVector.get(first_index);
String typeName = (String) matchingUidTypeVector.get(first_index);
action_status = getObjectStoreStatus(uid, typeName);
} else if (uidVectorSize > 1) {
// find root of hierarchy
Uid rootUid = (Uid) matchingUidVector.get(first_index);
String rootTypeName = (String) matchingUidTypeVector.get(first_index);
for (int index = first_index + 1; index < uidVectorSize; index++) {
String typeName = (String) matchingUidTypeVector.get(index);
if (typeName.length() < rootTypeName.length()) {
rootTypeName = typeName;
rootUid = (Uid) matchingUidVector.get(index);
}
}
action_status = getObjectStoreStatus(rootUid, rootTypeName);
}
return action_status;
}
use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.
the class HornetqJournalStore method read_committed.
/**
* Read the object's committed state.
*
* @param uid The object to work on.
* @param typeName The type of the object to work on.
* @return the state of the object.
* @throws ObjectStoreException if things go wrong.
*/
public InputObjectState read_committed(Uid uid, String typeName) throws ObjectStoreException {
RecordInfo record = getContentForType(typeName).get(uid);
if (record == null) {
return null;
}
// not too much of an issue as log reads are done for recovery only.
try {
InputBuffer inputBuffer = new InputBuffer(record.data);
UidHelper.unpackFrom(inputBuffer);
inputBuffer.unpackString();
return new InputObjectState(uid, typeName, inputBuffer.unpackBytes());
} catch (Exception e) {
throw new ObjectStoreException(e);
}
}
use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.
the class LogStore method allObjUids.
public final InputObjectState allObjUids() throws ObjectStoreException {
OutputObjectState state = new OutputObjectState();
Iterator<Uid> iter = _ids.keySet().iterator();
try {
while (iter.hasNext()) {
UidHelper.packInto(iter.next(), state);
}
// don't forget to null terminate
UidHelper.packInto(Uid.nullUid(), state);
} catch (final IOException ex) {
throw new ObjectStoreException(ex);
}
return new InputObjectState(state);
}
Aggregations