use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.
the class RecoverAtomicActionTest 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);
RecoverAtomicAction rAA = new RecoverAtomicAction(kungfuTx, ActionStatus.COMMITTED);
if (!rAA.activate()) {
rAA.replayPhase2();
if (recoveryStore.currentState(kungfuTx, tn) == StateStatus.OS_UNKNOWN)
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 JTATransactionLogXAResourceOrphanFilter method transactionLog.
/**
* Is there a log file for this transaction?
*
* @param xid the transaction to check.
*
* @return <code>boolean</code>true if there is a log file,
* <code>false</code> if there isn't.
* @throws ObjectStoreException If there is a problem accessing the object store
* @throws IOException In case the data from the object store is corrupted
*/
private boolean transactionLog(Xid xid) throws ObjectStoreException, IOException {
RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
String transactionType = new AtomicAction().type();
XidImple theXid = new XidImple(xid);
Uid u = theXid.getTransactionUid();
if (jtaLogger.logger.isDebugEnabled()) {
jtaLogger.logger.debug("Checking whether Xid " + theXid + " exists in ObjectStore.");
}
if (!u.equals(Uid.nullUid())) {
if (jtaLogger.logger.isDebugEnabled()) {
jtaLogger.logger.debug("Looking for " + u + " and " + transactionType);
}
if (containsCommitMarkableResourceRecord(u) || recoveryStore.currentState(u, transactionType) != StateStatus.OS_UNKNOWN) {
if (jtaLogger.logger.isDebugEnabled()) {
jtaLogger.logger.debug("Found record for " + theXid);
}
return true;
} else {
if (jtaLogger.logger.isDebugEnabled()) {
jtaLogger.logger.debug("No record found for " + theXid);
}
}
} else {
jtaLogger.i18NLogger.info_recovery_notaxid(XAHelper.xidToString(xid));
}
return false;
}
use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.
the class SubordinateAtomicActionRecoveryModule method periodicWorkFirstPass.
@Override
public void periodicWorkFirstPass() {
/*
* Requires going through the objectstore for the states of imported
* transactions - this is just to make sure the server control are loaded into memory.
*
* The EIS will call XATerminator::recover() for actual crash recovery
*/
RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
InputObjectState states = new InputObjectState();
// only look in the JCA section of the object store
Uid uid = null;
try {
if (recoveryStore.allObjUids(SubordinateAtomicAction.getType(), states) && (states.notempty())) {
while (true) {
uid = UidHelper.unpackFrom(states);
if (uid.notEquals(Uid.nullUid())) {
SubordinationManager.getTransactionImporter().recoverTransaction(uid);
} else {
break;
}
}
}
recoveryScanCompletedWithoutError = true;
} catch (ObjectStoreException | XAException | IOException e) {
jtaLogger.i18NLogger.warn_could_not_recover_subordinate(uid, e);
recoveryScanCompletedWithoutError = false;
}
if (!validatePosition()) {
recoveryScanCompletedWithoutError = false;
}
}
use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.
the class CommitMarkableResourceRecordRecoveryModule method moveRecord.
private void moveRecord(Uid uid, String from, String to) throws ObjectStoreException {
RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
InputObjectState state = recoveryStore.read_committed(uid, from);
if (state != null) {
if (!recoveryStore.write_committed(uid, to, new OutputObjectState(state))) {
tsLogger.logger.error("Could not move an: " + to + " uid: " + uid);
} else if (!recoveryStore.remove_committed(uid, from)) {
tsLogger.logger.error("Could not remove a: " + from + " uid: " + uid);
}
} else {
tsLogger.logger.error("Could not read an: " + from + " uid: " + uid);
}
}
use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.
the class SubordinateJTAXAResourceOrphanFilter method transactionLog.
/**
* Is there a log file for this transaction?
*
* @param recoveredResourceXid
* the transaction to check.
*
* @return <code>boolean</code>true if there is a log file,
* <code>false</code> if there isn't.
*/
private boolean transactionLog(Xid recoveredResourceXid, String recoveredResourceNodeName) {
XidImple theXid = new XidImple(recoveredResourceXid);
Uid u = theXid.getTransactionUid();
if (jtaLogger.logger.isDebugEnabled()) {
jtaLogger.logger.debug("Checking whether Xid " + theXid + " exists in ObjectStore.");
}
if (!u.equals(Uid.nullUid())) {
RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
String transactionType = SubordinateAtomicAction.getType();
if (jtaLogger.logger.isDebugEnabled()) {
jtaLogger.logger.debug("Looking for " + u + " and " + transactionType);
}
InputObjectState states = new InputObjectState();
try {
if (recoveryStore.allObjUids(transactionType, states) && (states.notempty())) {
Stack values = new Stack();
boolean finished = false;
do {
Uid uid = null;
try {
uid = UidHelper.unpackFrom(states);
} catch (IOException ex) {
ex.printStackTrace();
finished = true;
}
if (uid.notEquals(Uid.nullUid())) {
SubordinateAtomicAction tx = new SubordinateAtomicAction(uid, true);
XidImple transactionXid = (XidImple) tx.getXid();
if (transactionXid != null && transactionXid.isSameTransaction(recoveredResourceXid)) {
if (jtaLogger.logger.isDebugEnabled()) {
jtaLogger.logger.debug("Found record for " + theXid);
}
return true;
}
} else
finished = true;
} while (!finished);
if (jtaLogger.logger.isDebugEnabled()) {
jtaLogger.logger.debug("No record found for " + theXid);
}
} else {
jtaLogger.i18NLogger.info_recovery_notaxid(XAHelper.xidToString(recoveredResourceXid));
}
} catch (ObjectStoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return false;
}
Aggregations