use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.
the class ObjectStateQuery method main.
@SuppressWarnings("unchecked")
public static void main(String[] args) {
String uid = null;
String type = null;
for (int i = 0; i < args.length; i++) {
if (args[i].compareTo("-help") == 0) {
usage();
System.exit(0);
} else {
if (args[i].compareTo("-uid") == 0) {
uid = args[i + 1];
i++;
} else {
if (args[i].compareTo("-type") == 0) {
type = args[i + 1];
i++;
} else {
System.out.println("Unknown option " + args[i]);
usage();
System.exit(0);
}
}
}
}
try {
RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
System.out.println("Status is " + recoveryStore.currentState(new Uid(uid), type));
InputObjectState buff = new InputObjectState();
recoveryStore.allObjUids(type, buff, StateStatus.OS_UNCOMMITTED);
Uid u = UidHelper.unpackFrom(buff);
System.out.println("got " + u);
} 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 ExposeAllLogsTest method test.
private void test(boolean exposeAllLogsViaJMX) throws Exception {
RecoveryStore store = StoreManager.getRecoveryStore();
Set<Uid> uids;
Map<Uid, ObjectName> uids2 = new HashMap<Uid, ObjectName>();
JMXServer agent = JMXServer.getAgent();
// create a record that by default the tooling does not expose
byte[] data = new byte[10240];
OutputObjectState state = new OutputObjectState();
Uid u = new Uid();
state.packBytes(data);
assertTrue(store.write_committed(u, FOO_TYPE, state));
// check that the record is not exposed
probeObjectStore(false, false);
// get uids via the object store API
uids = getUids(store, new HashSet<Uid>(), FOO_TYPE);
// and validate that there is a uid corresponding to u
assertTrue(uids.contains(u));
// get uids via JMX
getUids(uids2, agent.queryNames(osMBeanName + ",*", null));
// and validate that there is no MBean corresponding to u
assertFalse(uids2.containsKey(u));
// now try the same but tell the browser to expose all log records
probeObjectStore(true, exposeAllLogsViaJMX);
// and get the uids for log record MBeans
uids2.clear();
getUids(uids2, agent.queryNames(osMBeanName + ",*", null));
// and validate that there is now an MBean corresponding to u
assertTrue(uids2.containsKey(u));
// test that the MBean remove operation works
agent.getServer().invoke(uids2.get(u), "remove", null, null);
// check that both the log record and the MBean were removed
uids.clear();
getUids(store, uids, FOO_TYPE);
assertFalse(uids.contains(u));
uids2.clear();
getUids(uids2, agent.queryNames(osMBeanName + ",*", null));
assertFalse(uids2.containsKey(u));
}
use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.
the class LogMoveTest method test.
@Test
public void test() {
RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
OutputObjectState fluff = new OutputObjectState();
Uid kungfuTx = new Uid();
boolean passed = false;
final String tn = new AtomicAction().type();
try {
UidHelper.packInto(kungfuTx, fluff);
System.err.println("Creating dummy log");
recoveryStore.write_committed(kungfuTx, tn, fluff);
if (recoveryStore.currentState(kungfuTx, tn) == StateStatus.OS_COMMITTED) {
System.err.println("Wrote dummy transaction " + kungfuTx);
// quicker to deal with scanner directly
ExpiredTransactionScanner scanner = new ExpiredTransactionScanner(tn, "/StateManager/ExpiredEntries");
scanner.scan();
scanner.scan();
if (recoveryStore.currentState(kungfuTx, tn) == StateStatus.OS_COMMITTED)
System.err.println("Transaction log not moved!");
else {
System.err.println("Transaction log moved!");
passed = true;
}
} else
System.err.println("State is not committed!");
} catch (final Exception ex) {
ex.printStackTrace();
}
assertTrue(passed);
}
use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.
the class ResourceManagerFailureUnitTest method getUidsCount.
private int getUidsCount() throws Exception {
final RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
InputObjectState states = new InputObjectState();
int counter = 0;
if (recoveryStore.allObjUids(XAResourceRecord.typeName(), states) && states.notempty()) {
while (UidHelper.unpackFrom(states).notEquals(Uid.nullUid())) {
counter++;
}
}
return counter;
}
use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.
the class OTM method getTransactions.
@SuppressWarnings("unchecked")
private synchronized void getTransactions(DefaultMutableTreeNode machineName) {
removeTransactions();
scanningNode = machineName;
DefaultMutableTreeNode top = new DefaultMutableTreeNode(scanningNode);
try {
RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
InputObjectState types = new InputObjectState();
if (recoveryStore.allTypes(types)) {
String fullPathName = null;
boolean found = false;
try {
boolean endOfList = false;
DefaultMutableTreeNode currentNode = null;
DefaultMutableTreeNode currentRoot = top;
topTran.add(currentRoot);
while (!endOfList) {
fullPathName = types.unpackString();
if (fullPathName.compareTo("") == 0)
endOfList = true;
else {
found = true;
InputObjectState uids = new InputObjectState();
String nodeName = stripName(fullPathName);
currentNode = new DefaultMutableTreeNode(nodeName);
addDirectory(currentNode, fullPathName);
currentRoot = findRoot(top, currentNode);
currentRoot.add(currentNode);
if (recoveryStore.allObjUids(fullPathName, 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 {
DefaultMutableTreeNode tranID = new DefaultMutableTreeNode(theUid.stringForm());
tranID.add(new DefaultMutableTreeNode(new String("status: " + statusToString(recoveryStore.currentState(theUid, fullPathName)))));
currentNode.add(tranID);
}
}
} catch (Exception e) {
// end of uids!
}
}
}
if (!found)
currentRoot.add(emptyTx);
}
} catch (Exception e) {
// end of list!
}
}
} catch (Exception e) {
System.err.println(e);
}
DefaultTreeModel model = (DefaultTreeModel) transactions.getModel();
model.reload();
transactions.repaint();
}
Aggregations