use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException 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;
}
use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.
the class TransactionImple method createXid.
protected Xid createXid(boolean branch, XAModifier theModifier, XAResource xaResource) throws IOException, ObjectStoreException {
int eisName = 0;
if (branch) {
if (_xaResourceRecordWrappingPlugin != null) {
eisName = _xaResourceRecordWrappingPlugin.getEISName(xaResource);
}
}
Xid xid = new XidImple(_theTransaction.get_uid(), branch, eisName);
if (theModifier != null) {
try {
xid = theModifier.createXid((XidImple) xid);
} catch (Exception e) {
e.printStackTrace();
}
}
return xid;
}
use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.
the class JCAServerTransactionRecoveryModule method periodicWorkFirstPass.
@Override
public void periodicWorkFirstPass() {
try {
RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
InputObjectState states = new InputObjectState();
if (recoveryStore.allObjUids(ServerTransaction.getType(), states) && (states.notempty())) {
boolean finished = false;
do {
Uid uid = UidHelper.unpackFrom(states);
if (uid.notEquals(Uid.nullUid())) {
SubordinationManager.getTransactionImporter().recoverTransaction(uid);
} else {
finished = true;
}
} while (!finished);
}
} catch (ObjectStoreException | XAException | IOException e) {
e.printStackTrace();
}
}
use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.
the class GenericRecoveryCoordinator method replay_completion.
/**
* Respond to a replay_completion request for the RecoveryCoordinator
* identified by parameter id.
*/
protected static Status replay_completion(RecoveryCoordinatorId id, Resource res) throws SystemException, NotPrepared {
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("GenericRecoveryCoordinator(" + id._RCUid + ").replay_completion(" + (res != null ? "resource supplied)" : "null resource)"));
}
Status currentStatus = Status.StatusUnknown;
/*
* First check to see if the transaction is active by asking the
* per-process contact.
* If alive, return the status reported by the
* transaction. If not alive then try and recover the
* transaction from the intentions list.
*/
boolean transactionActive = true;
try {
currentStatus = get_status(id._actionUid, id._originalProcessUid);
} catch (Inactive e) {
// original process is dead.
transactionActive = false;
}
if (currentStatus == Status.StatusNoTransaction) {
/*
* There is no intentions list, so the transaction either
* committed or rolled back. However, this routine is only
* ever called by replay_completion, which means that there
* is a resource (hopefully one which was participating in
* the transaction) that is in doubt as to the
* transaction's outcome. If the transaction had committed,
* then this resource would know of the outcome. Therefore,
* it must have rolled back!
*/
/*
* Unfortunately the last statement is wrong. There is a timing
* issue here: the resource recovery may be doing an upcall while
* the downcall (from coordinator recovery) is going on and
* removing the log. What can then happen is that a resource may
* see a commit folled by a rollback.
*/
currentStatus = Status.StatusRolledBack;
}
if (!transactionActive) {
// original process is dead, so reasonable for us to try to
// recover
/*
* The RecoveredTransactionReplayer is a threaded object
* so we can get the status and return it while the
* replayer does the phase 2 commit in a new thread.
*/
String tranType = ((id._isServerTransaction) ? ServerTransaction.typeName() : ArjunaTransactionImple.typeName());
try {
if (id._isServerTransaction && (StoreManager.getRecoveryStore().currentState(id._actionUid, ServerTransaction.typeName() + "/JCA") != StateStatus.OS_UNKNOWN)) {
tranType = tranType + "/JCA";
}
} catch (ObjectStoreException e) {
// Can't read store
}
com.arjuna.ats.internal.jts.recovery.transactions.RecoveredTransactionReplayer replayer = new com.arjuna.ats.internal.jts.recovery.transactions.RecoveredTransactionReplayer(id._actionUid, tranType);
// this will cause the activatation attempt
currentStatus = replayer.getStatus();
if ((replayer.getRecoveryStatus() != com.arjuna.ats.internal.jts.recovery.transactions.RecoveryStatus.ACTIVATE_FAILED) && (res != null)) {
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("GenericRecoveryCoordinator - swapping Resource for RC " + id._RCUid);
}
replayer.swapResource(id._RCUid, res);
}
if (replayer.getRecoveryStatus() != com.arjuna.ats.internal.jts.recovery.transactions.RecoveryStatus.ACTIVATE_FAILED) {
replayer.replayPhase2();
} else {
replayer.tidyup();
/*
* The transaction didn't activate so we have a
* rollback situation but we can't rollback the
* resource that we have been given through the
* intentions list but we can issue rollback
* directly. This is configurable through the System
* properties.
*/
currentStatus = Status.StatusRolledBack;
}
}
if (currentStatus == Status.StatusRolledBack) {
if (_issueRecoveryRollback) {
ResourceCompletor resourceCompletor = new ResourceCompletor(res, ResourceCompletor.ROLLBACK);
resourceCompletor.start();
}
}
if (currentStatus == Status.StatusActive)
throw new NotPrepared();
return currentStatus;
}
use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.
the class FactoryContactItem method restoreMe.
private boolean restoreMe() {
try {
InputObjectState objstate = getStore().read_committed(_uid, _pseudoTypeName);
if (// not in object store any more
objstate == null)
return false;
if (restore_state(objstate)) {
return true;
}
jtsLogger.i18NLogger.warn_recovery_contact_FactoryContactItem_5();
} catch (ObjectStoreException exo) {
// this shouldn't happen, because we shouldn't be looking for a factory
// that was never recorded
jtsLogger.i18NLogger.warn_recovery_contact_FactoryContactItem_6();
}
return false;
}
Aggregations