use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.
the class BAParticipantRecoveryModule method doRecoverParticipant.
private void doRecoverParticipant(Uid recoverUid) {
if (RecoveryLogger.logger.isDebugEnabled()) {
RecoveryLogger.logger.debug("participant type is " + _participantType + " uid is " + recoverUid.toString());
}
// we don't need to use a lock here because we only attempt the read
// when the uid is inactive which means it cannto be pulled out form under our
// feet at commit. uniqueness of uids also means we can't be foiled by a reused
// uid.
XTSBARecoveryManager recoveryManager = XTSBARecoveryManager.getRecoveryManager();
if (!recoveryManager.isParticipantPresent(recoverUid)) {
// an application recovery module so we need to load it
try {
// retrieve the data for the participant
InputObjectState inputState = _recoveryStore.read_committed(recoverUid, _participantType);
if (inputState != null) {
try {
String participantRecordClazzName = inputState.unpackString();
try {
// create a participant engine instance and tell it to recover itself
Class participantRecordClazz = Class.forName(participantRecordClazzName);
BAParticipantRecoveryRecord participantRecord = (BAParticipantRecoveryRecord) participantRecordClazz.newInstance();
participantRecord.restoreState(inputState);
// ok, now insert into recovery map if needed
XTSBARecoveryManager.getRecoveryManager().addParticipantRecoveryRecord(recoverUid, participantRecord);
} catch (ClassNotFoundException cnfe) {
// oh boy, not supposed to happen -- n.b. either the user deployed 1.0
// last time and 1.1 this time or vice versa or something is rotten in
// the state of Danmark
RecoveryLogger.i18NLogger.error_participant_ba_BAParticipantRecoveryModule_4(participantRecordClazzName, recoverUid, cnfe);
} catch (InstantiationException ie) {
// this is also worrying, log an error
RecoveryLogger.i18NLogger.error_participant_ba_BAParticipantRecoveryModule_5(participantRecordClazzName, recoverUid, ie);
} catch (IllegalAccessException iae) {
// this is another configuration problem, log an error
RecoveryLogger.i18NLogger.error_participant_ba_BAParticipantRecoveryModule_5(participantRecordClazzName, recoverUid, iae);
}
} catch (IOException ioe) {
// hmm, record corrupted? log this as a warning
RecoveryLogger.i18NLogger.warn_participant_ba_BAParticipantRecoveryModule_6(recoverUid, ioe);
}
} else {
// hmm, it ought not to be able to disappear unless the recovery manager knows about it
// this is an error!
RecoveryLogger.i18NLogger.error_participant_ba_BAParticipantRecoveryModule_7(recoverUid);
}
} catch (ObjectStoreException ose) {
// if the object store is not working this is serious
RecoveryLogger.i18NLogger.error_participant_ba_BAParticipantRecoveryModule_8(recoverUid, ose);
}
}
}
use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.
the class ObjStoreBrowserImpl method types.
@Override
public List<String> types() {
recordTypes.clear();
InputObjectState types = new InputObjectState();
try {
if (StoreManager.getRecoveryStore().allTypes(types)) {
String typeName;
do {
try {
typeName = types.unpackString();
if (!recordTypes.contains(typeName))
recordTypes.add(typeName);
} catch (IOException e) {
typeName = "";
}
} while (typeName.length() != 0);
}
} catch (ObjectStoreException e) {
System.out.println(e);
}
return recordTypes;
}
use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.
the class StateManager 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 commited now or not.
*
* @return <code>true</code> on success, <code>false</code> otherwise.
*/
public synchronized boolean deactivate(String rootName, boolean commit) {
if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("StateManager::deactivate(" + ((rootName != null) ? rootName : "null") + ", " + commit + ") for object-id " + objectUid);
}
boolean result = false;
if ((currentlyActivated && (myType == ObjectType.ANDPERSISTENT)) || loadObjectState()) {
setupStore(rootName);
if ((currentStatus == ObjectStatus.ACTIVE_NEW) || (currentStatus == ObjectStatus.ACTIVE)) {
String tn = type();
OutputObjectState newState = new OutputObjectState(objectUid, tn);
if (save_state(newState, myType)) {
try {
if (commit)
result = participantStore.write_committed(objectUid, tn, newState);
else
result = participantStore.write_uncommitted(objectUid, tn, newState);
} catch (ObjectStoreException e) {
tsLogger.i18NLogger.warn_StateManager_3(e);
result = false;
}
} else {
tsLogger.i18NLogger.warn_StateManager_4();
}
/*
* Not needed any more because activation record does this when
* all actions are forgotten. if (result) currentStatus =
* ObjectStatus.PASSIVE;
*/
}
} else {
result = true;
}
return result;
}
use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.
the class BasicActionFinalizer method updateState.
protected void updateState() {
if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("BasicAction::updateState() for action-id " + get_uid());
}
if (actionType == ActionType.TOP_LEVEL) {
/*
* make sure the object store is set up for a top-level atomic
* action.
*/
getStore();
if (((failedList != null) && (failedList.size() > 0)) || ((heuristicList != null) && (heuristicList.size() > 0)) || ((preparedList != null) && (preparedList.size() > 0))) {
/*
* Re-write the BasicAction record with the failed list
*/
Uid u = getSavingUid();
String tn = type();
OutputObjectState state = new OutputObjectState(u, tn);
if (!save_state(state, ObjectType.ANDPERSISTENT)) {
tsLogger.i18NLogger.warn_coordinator_BasicAction_64();
// what else?
}
if (state.notempty()) {
try {
if (!transactionStore.write_committed(u, tn, state)) {
tsLogger.i18NLogger.warn_coordinator_BasicAction_65();
}
} catch (ObjectStoreException e) {
// just log a warning since the intentions list has already been written
tsLogger.logger.warn(e);
}
}
} else {
try {
if (savedIntentionList) {
if (transactionStore.remove_committed(getSavingUid(), type())) {
savedIntentionList = false;
}
}
} catch (ObjectStoreException e) {
tsLogger.i18NLogger.warn_coordinator_BasicAction_70(e);
}
}
}
}
use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.
the class BasicActionFinalizer method activate.
/**
* Overloaded version of activate -- sets up the store, performs read_state
* followed by restore_state. The root of the object store to use is
* specified in the <code>root</code> parameter.
*
* @return <code>true</code> if successful, <code>false</code>
* otherwise.
*/
public boolean activate(String root) {
if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("BasicAction::activate() for action-id " + get_uid());
}
boolean restored = false;
// Set up store
ParticipantStore aaStore = getStore();
if (aaStore == null)
return false;
try {
// Read object state
InputObjectState oState = aaStore.read_committed(getSavingUid(), type());
if (oState != null) {
synchronized (this) {
restored = restore_state(oState, ObjectType.ANDPERSISTENT);
}
oState = null;
} else {
tsLogger.i18NLogger.warn_coordinator_BasicAction_5(get_uid(), type());
restored = false;
}
return restored;
} catch (ObjectStoreException e) {
tsLogger.logger.warn(e);
return false;
}
}
Aggregations