use of com.arjuna.ats.arjuna.coordinator.AbstractRecord in project narayana by jbosstm.
the class Transaction method findParticipant.
private RESTRecord findParticipant(String participantUrl) {
if (pendingList != null) {
RecordListIterator i = new RecordListIterator(pendingList);
AbstractRecord r;
while ((r = i.iterate()) != null) {
if (r instanceof RESTRecord) {
RESTRecord rr = (RESTRecord) r;
if (rr.getParticipantURI().equals(participantUrl))
return rr;
}
}
}
return null;
}
use of com.arjuna.ats.arjuna.coordinator.AbstractRecord in project narayana by jbosstm.
the class Transaction method findLRAParticipant.
private LRARecord findLRAParticipant(String participantUrl, boolean remove, RecordList list) {
if (list != null) {
RecordListIterator i = new RecordListIterator(list);
AbstractRecord r;
if (participantUrl.indexOf(',') != -1)
participantUrl = LRARecord.extractCompensator(participantUrl);
while ((r = i.iterate()) != null) {
if (r instanceof LRARecord) {
LRARecord rr = (LRARecord) r;
// can't use == because this may be a recovery scenario
if (rr.getCompensator().equals(participantUrl)) {
if (remove)
list.remove(rr);
return rr;
}
}
}
}
return null;
}
use of com.arjuna.ats.arjuna.coordinator.AbstractRecord in project narayana by jbosstm.
the class Transaction method save_list.
private boolean save_list(OutputObjectState os, int ot, RecordList list) {
if (list != null && list.size() > 0) {
AbstractRecord first, temp;
first = temp = list.getFront();
while (temp != null) {
list.putRear(temp);
if (!temp.doSave())
return false;
try {
os.packInt(temp.typeIs());
if (!temp.save_state(os, ot))
return false;
} catch (IOException e) {
return false;
}
temp = list.getFront();
if (temp == first) {
list.putFront(temp);
temp = null;
}
}
}
try {
os.packInt(RecordType.NONE_RECORD);
} catch (IOException e) {
return false;
}
return true;
}
use of com.arjuna.ats.arjuna.coordinator.AbstractRecord in project narayana by jbosstm.
the class ActionBean method setStatus.
/**
* Request a change in status of a participant. For example if a record has a
* heuristic status then this method could be used to move it back into the
* prepared state so that the recovery system can replay phase 2 of the
* commitment protocol
* @param logrec the record whose status is to be changed
* @param newStatus the desired status
* @return true if the status was changed
*/
public boolean setStatus(LogRecordWrapper logrec, ParticipantStatus newStatus) {
ParticipantStatus lt = logrec.getListType();
AbstractRecord targRecord = logrec.getRecord();
RecordList oldList = ra.getRecords(lt);
RecordList newList = ra.getRecords(newStatus);
// move the record from currList to targList
if (oldList.remove(targRecord)) {
if (newList.insert(targRecord)) {
if (lt.equals(ParticipantStatus.HEURISTIC)) {
switch(newStatus) {
case FAILED:
ra.clearHeuristicDecision(TwoPhaseOutcome.FINISH_ERROR);
break;
case PENDING:
ra.clearHeuristicDecision(TwoPhaseOutcome.NOT_PREPARED);
break;
case PREPARED:
ra.clearHeuristicDecision(TwoPhaseOutcome.PREPARE_OK);
break;
case READONLY:
ra.clearHeuristicDecision(TwoPhaseOutcome.PREPARE_READONLY);
break;
default:
break;
}
}
ra.doUpdateState();
return true;
}
}
return false;
}
use of com.arjuna.ats.arjuna.coordinator.AbstractRecord in project narayana by jbosstm.
the class ArjunaTransactionImple method register_resource.
/**
* Resources are only registered with the current transaction, whereas
* subtransaction aware resources are registered with their parents when the
* current transaction ends.
*/
public RecoveryCoordinator register_resource(Resource r) throws SystemException, Inactive {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::register_resource ( " + r + " ) - called for " + get_uid());
}
if (r == null)
throw new BAD_PARAM(0, CompletionStatus.COMPLETED_NO);
currentStatus = determineStatus(this);
if (currentStatus != Status.StatusActive) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::register_resource - transaction not active: " + Utility.stringStatus(currentStatus));
}
if (currentStatus == Status.StatusMarkedRollback) {
throw new TRANSACTION_ROLLEDBACK(ExceptionCodes.MARKED_ROLLEDBACK, CompletionStatus.COMPLETED_NO);
} else
throw new Inactive();
}
AbstractRecord corbaRec = null;
BasicAction registerIn = this;
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple " + get_uid() + " ::register_resource: ");
}
//
// Creation of recovery coordinator (DBI)
//
//
// Pack the params:
// [0] = Transaction* this
//
int index = 0;
Object[] params = new Object[10];
params[index++] = this;
RecoveryCoordinator recoveryCoordinator = null;
Uid recoveryCoordinatorUid = null;
try {
recoveryCoordinator = RecoveryCreator.createRecoveryCoordinator(r, params);
if (recoveryCoordinator == null)
throw new BAD_OPERATION("RecoveryCoordinator " + jtsLogger.i18NLogger.get_orbspecific_coordinator_rcnotcreated());
} catch (NO_IMPLEMENT ex) {
/*
* This is legal, and is meant to show that this ORB or
* configuration simply doesn't support crash recovery.
*/
recoveryCoordinator = null;
} catch (SystemException e) {
jtsLogger.i18NLogger.warn_orbspecific_coordinator_rccreate(get_uid(), e);
try {
rollback_only();
} catch (Inactive ex1) {
} catch (SystemException ex2) {
jtsLogger.i18NLogger.warn_orbspecific_coordinator_rbofail("ArjunaTransactionImple.register_resource", get_uid(), ex2);
throw ex2;
}
throw e;
}
if (recoveryCoordinator != null) {
//
// We got a RecoveryCoordinator, so unpack the other return values:
// [0] = RecoveryCoordinator Uid*
//
index = 0;
recoveryCoordinatorUid = (Uid) params[index++];
} else {
//
// We didn't get a RecoveryCoordinator, so we don't assume that
// the other return values have been populated.
//
recoveryCoordinatorUid = Uid.nullUid();
}
try {
SubtransactionAwareResource staResource = org.omg.CosTransactions.SubtransactionAwareResourceHelper.narrow(r);
if (staResource != null) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " - subtransaction aware resource: YES");
}
/*
* If here the narrow was ok so we have a subtran aware
* resource.
*/
Coordinator coord = null;
if (parentHandle != null) {
/*
* If we are a SubTranResource then we get registered with
* the current transaction and its parents upon completion.
* The first parameter to the record indicates whether we
* should be propagated (registered) with the parent
* transaction.
*/
coord = parentHandle.get_coordinator();
}
corbaRec = createOTSRecord(true, r, coord, recoveryCoordinatorUid);
coord = null;
staResource = null;
} else
throw new BAD_PARAM(0, CompletionStatus.COMPLETED_NO);
} catch (BAD_PARAM ex) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " - subtransaction aware resource: NO");
}
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple " + get_uid() + " ::register_resource: Simple resource - " + ex);
}
corbaRec = createOTSRecord(true, r, null, recoveryCoordinatorUid);
} catch (Unavailable e1) {
throw new Inactive();
} catch (SystemException e2) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " : catch (SystemException) - " + e2);
}
throw e2;
} catch (Exception e3) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " : catch (...) - " + e3);
}
throw new UNKNOWN(e3.toString(), ExceptionCodes.UNKNOWN_EXCEPTION, CompletionStatus.COMPLETED_NO);
}
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " : try end");
}
if (registerIn.add(corbaRec) != AddOutcome.AR_ADDED) {
corbaRec = null;
throw new INVALID_TRANSACTION(ExceptionCodes.ADD_FAILED, CompletionStatus.COMPLETED_NO);
} else {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " : resource registered");
}
}
return recoveryCoordinator;
}
Aggregations