use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.
the class TransactionStatusConnectionManager method updateTSMI.
/**
* Examine the Object Store for any new TrasactionStatusManagerItem
* objects, and add to local hash table.
*/
public void updateTSMI() {
boolean tsmis = false;
InputObjectState uids = new InputObjectState();
Vector tsmiVector = new Vector();
try {
tsmis = _recoveryStore.allObjUids(_typeName, uids);
} catch (ObjectStoreException ex) {
tsLogger.i18NLogger.warn_recovery_TransactionStatusConnectionManager_2(ex);
}
if (tsmis) {
Uid theUid = null;
boolean moreUids = true;
while (moreUids) {
try {
theUid = UidHelper.unpackFrom(uids);
if (theUid.equals(Uid.nullUid())) {
moreUids = false;
} else {
Uid newUid = new Uid(theUid);
if (tsLogger.logger.isDebugEnabled()) {
tsLogger.logger.debug("found process uid " + newUid);
}
tsmiVector.addElement(newUid);
}
} catch (Exception ex) {
moreUids = false;
}
}
}
// for each TransactionStatusManager found, if their is
// not an entry in the local hash table for it then add it.
Enumeration tsmiEnum = tsmiVector.elements();
while (tsmiEnum.hasMoreElements()) {
Uid currentUid = (Uid) tsmiEnum.nextElement();
String process_id = currentUid.getHexPid();
if (!_tscTable.containsKey(process_id)) {
TransactionStatusConnector tsc = new TransactionStatusConnector(process_id, currentUid);
if (tsc.isDead()) {
tsc.delete();
tsc = null;
} else {
_tscTable.put(process_id, tsc);
}
if (tsLogger.logger.isDebugEnabled()) {
tsLogger.logger.debug("added TransactionStatusConnector to table for process uid " + process_id);
}
}
}
}
use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.
the class StateManager method activate.
/**
* This operation activates an object. Activation of an object may entail
* loading its passive state from the object store and unpacking it into the
* memory resident form, or it may simply be a no-op. Full activation is
* only necessary if the object is currently marked as being PASSIVE (that
* is, the object was constructed as being of type ANDPERSISTENT with an
* existing uid and has not already been activated). Objects that are not of
* type ANDPERSISTENT or are persistent but have not yet been saved in an
* object store (so-called new persistent objects) are unaffected by this
* function. Returns false if PASSIVE object cannot be loaded from object
* store, true otherwise.
*
* @return <code>true</code> on success, <code>false</code> otherwise.
* @see com.arjuna.ats.arjuna.objectstore.ObjectStore
*/
public synchronized boolean activate(String rootName) {
if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("StateManager::activate( " + ((rootName != null) ? rootName : "null") + ") for object-id " + objectUid);
}
if (myType == ObjectType.NEITHER) {
return true;
}
if (currentStatus == ObjectStatus.DESTROYED)
return false;
BasicAction action = null;
int oldStatus = currentStatus;
boolean result = true;
/* assume 'succeeds' */
boolean forceAR = false;
/*
* Check if this action has logged its presence before. If not we force
* creation of an ActivationRecord so that each thread/action tree has
* an ActivationRecord in it. This allows us to passivate the object
* when the last thread has finished with it, i.e., when the last
* ActivationRecord is gone.
*/
action = BasicAction.Current();
if ((action != null) && (action.status() == ActionStatus.RUNNING)) {
synchronized (mutex) {
createLists();
if (usingActions.get(action.get_uid()) == null) {
/*
* May cause us to add parent as well as child.
*/
usingActions.put(action.get_uid(), action);
forceAR = true;
}
}
}
if (forceAR || (currentStatus == ObjectStatus.PASSIVE) || (currentStatus == ObjectStatus.PASSIVE_NEW)) {
if (loadObjectState()) {
setupStore(rootName);
}
if (currentStatus == ObjectStatus.PASSIVE) {
if (loadObjectState()) {
InputObjectState oldState = null;
try {
oldState = participantStore.read_committed(objectUid, type());
} catch (ObjectStoreException e) {
e.printStackTrace();
oldState = null;
}
if (oldState != null) {
if ((result = restore_state(oldState, ObjectType.ANDPERSISTENT))) {
currentStatus = ObjectStatus.ACTIVE;
}
oldState = null;
} else {
tsLogger.i18NLogger.warn_StateManager_2(objectUid, type());
return false;
}
} else {
if (currentStatus == ObjectStatus.PASSIVE_NEW)
currentStatus = ObjectStatus.ACTIVE_NEW;
else
currentStatus = ObjectStatus.ACTIVE;
}
} else {
if (currentStatus == ObjectStatus.PASSIVE_NEW)
currentStatus = ObjectStatus.ACTIVE_NEW;
else
currentStatus = ObjectStatus.ACTIVE;
}
if (forceAR || ((currentStatus == ObjectStatus.ACTIVE) || (currentStatus == ObjectStatus.PASSIVE_NEW)) && (action != null)) {
int arStatus = AddOutcome.AR_ADDED;
ActivationRecord ar = new ActivationRecord(oldStatus, this, action);
if ((arStatus = action.add(ar)) != AddOutcome.AR_ADDED) {
ar = null;
if (forceAR) {
synchronized (mutex) {
usingActions.remove(action.get_uid());
}
}
if (arStatus == AddOutcome.AR_REJECTED)
result = false;
} else {
/*
* We never reset activated, so we can optimise state
* loading/unloading in the case of SINGLE object model
*/
currentlyActivated = activated = true;
}
} else {
if (currentStatus == ObjectStatus.ACTIVE_NEW)
currentlyActivated = activated = true;
}
}
return result;
}
use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.
the class BasicActionFinalizer method deactivate.
/**
* This operation deactivates a persistent object. It behaves in a similar
* manner to the activate operation, but has an extra argument which defines
* whether the object's state should be committed or written as a shadow.
*
* The root of the object store is <code>null</code>. It is assumed that
* this is being called during a transaction commit.
*
* @return <code>true</code> on success, <code>false</code> otherwise.
*/
public boolean deactivate() {
if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("BasicAction::deactivate() for action-id " + get_uid());
}
boolean deactivated = false;
// Set up store
ParticipantStore aaStore = getStore();
if (aaStore == null)
return false;
try {
// Write object state
OutputObjectState oState = new OutputObjectState();
if (save_state(oState, ObjectType.ANDPERSISTENT)) {
deactivated = aaStore.write_committed(getSavingUid(), type(), oState);
oState = null;
} else {
deactivated = false;
}
/**
* If we failed to deactivate then output warning *
*/
if (!deactivated) {
tsLogger.i18NLogger.warn_coordinator_BasicAction_5a(get_uid(), type());
}
} catch (ObjectStoreException e) {
tsLogger.logger.warn(e);
deactivated = false;
}
return deactivated;
}
use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.
the class TORecoveryModule method periodicWorkSecondPass.
public void periodicWorkSecondPass() {
if (txojLogger.logger.isDebugEnabled()) {
txojLogger.logger.debug("TORecoveryModule - second pass");
}
Enumeration uncommittedObjects = _uncommittedTOTable.keys();
while (uncommittedObjects.hasMoreElements()) {
Uid objUid = (Uid) uncommittedObjects.nextElement();
String objType = (String) _uncommittedTOTable.get(objUid);
try {
if (_objectStore.currentState(objUid, objType) == StateStatus.OS_UNCOMMITTED) {
recoverObject(objUid, objType);
} else {
if (txojLogger.logger.isDebugEnabled()) {
txojLogger.logger.debug("Object (" + objUid + ", " + objType + ") is no longer uncommitted.");
}
}
} catch (ObjectStoreException ose) {
if (txojLogger.logger.isDebugEnabled()) {
txojLogger.logger.debug("Object (" + objUid + ", " + objType + ") no longer exists.");
}
}
}
}
use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.
the class XARecoveryModule method periodicWorkFirstPass.
private synchronized void periodicWorkFirstPass(ScanStates endState) {
// then we get deadlock on the secondpass
if (getScanState() == ScanStates.BETWEEN_PASSES) {
periodicWorkSecondPass();
// Ensure if originally we are between periodic recovery scans we continue in that state and leave XAResource in STARTRSCAN
endState = ScanStates.BETWEEN_PASSES;
}
// synchronized uses a reentrant lock
setScanState(ScanStates.FIRST_PASS);
if (jtaLogger.logger.isDebugEnabled()) {
jtaLogger.logger.debugv("{0} - first pass", _logName);
}
contactedJndiNames.clear();
_uids = new InputObjectState();
try {
if (!_recoveryStore.allObjUids(_recoveryManagerClass.type(), _uids)) {
jtaLogger.i18NLogger.warn_recovery_alluids();
}
} catch (ObjectStoreException e) {
jtaLogger.i18NLogger.warn_recovery_objstoreerror(e);
} catch (Exception e) {
jtaLogger.i18NLogger.warn_recovery_periodicfirstpass(_logName + ".periodicWorkFirstPass", e);
}
// JBTM-1354 JCA needs to be able to recover XAResources associated with a subordinate transaction so we have to do at least
// the start scan to make sure that we have loaded all the XAResources we possibly can to assist subordinate transactions recovering
// scan using statically configured plugins;
_resources = resourceInitiatedRecovery();
// scan using dynamically configured plugins:
_resources.addAll(resourceInitiatedRecoveryForRecoveryHelpers());
List<XAResource> resources = new ArrayList<XAResource>(_resources);
for (XAResource xaResource : resources) {
try {
xaRecoveryFirstPass(xaResource);
} catch (Exception ex) {
jtaLogger.i18NLogger.warn_recovery_getxaresource(ex);
}
}
if (endState != ScanStates.BETWEEN_PASSES) {
for (XAResource xaResource : resources) {
try {
xaResource.recover(XAResource.TMENDRSCAN);
} catch (Exception ex) {
jtaLogger.i18NLogger.warn_recovery_getxaresource(ex);
}
}
}
setScanState(endState);
}
Aggregations