use of com.arjuna.ats.arjuna.coordinator.RecordListIterator 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.RecordListIterator 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.RecordListIterator in project narayana by jbosstm.
the class EditableAtomicAction method toString.
public String toString() {
if (!_activated)
return "RecoveryAction not activated.";
else {
String printableForm = "ActionStatus: " + ActionStatus.stringForm(super.status());
printableForm += "\nHeuristic Decision: " + TwoPhaseOutcome.stringForm(super.getHeuristicDecision());
if (super.preparedList.size() == 0)
printableForm += "\nNo prepared entries.";
else {
printableForm += "\nPrepared entries:";
RecordListIterator iter = new RecordListIterator(super.preparedList);
AbstractRecord rec = iter.iterate();
int i = 0;
while (rec != null) {
printableForm += "\n[" + i + "] " + rec;
rec = iter.iterate();
i++;
}
}
if (super.heuristicList.size() == 0)
printableForm += "\nNo heuristic entries.";
else {
printableForm += "\nHeuristic entries:";
RecordListIterator iter = new RecordListIterator(super.heuristicList);
AbstractRecord rec = iter.iterate();
int i = 0;
while (rec != null) {
printableForm += "\n[" + i + "] " + rec;
rec = iter.iterate();
i++;
}
}
return printableForm;
}
}
use of com.arjuna.ats.arjuna.coordinator.RecordListIterator in project narayana by jbosstm.
the class EditableAtomicAction method moveHeuristicToPrepared.
/**
* Move a previous heuristic participant back to the prepared list so that recovery
* can try again. If it fails again then it may end up back on the heuristic list.
*/
public void moveHeuristicToPrepared(int index) throws IndexOutOfBoundsException {
if ((index < 0) || (index >= super.heuristicList.size()))
throw new IndexOutOfBoundsException();
else {
if (super.heuristicList.size() == 0)
throw new IndexOutOfBoundsException();
RecordListIterator iter = new RecordListIterator(super.heuristicList);
AbstractRecord rec = iter.iterate();
for (int i = 0; i < index; i++) rec = iter.iterate();
if (rec.forgetHeuristic()) {
/*
* Move from heuristic list to prepared list.
*/
super.heuristicList.remove(rec);
super.preparedList.insert(rec);
if (super.heuristicList.size() == 0)
super.setHeuristicDecision(TwoPhaseOutcome.FINISH_OK);
super.updateState();
} else {
tsLogger.i18NLogger.warn_tools_log_eaa2();
}
}
}
use of com.arjuna.ats.arjuna.coordinator.RecordListIterator in project narayana by jbosstm.
the class EditableAtomicAction method deleteHeuristicParticipant.
/**
* Delete a heuristic participant from the list.
*/
public void deleteHeuristicParticipant(int index) throws IndexOutOfBoundsException {
if ((index < 0) || (index >= super.heuristicList.size()))
throw new IndexOutOfBoundsException();
else {
if (super.heuristicList.size() == 0)
throw new IndexOutOfBoundsException();
RecordListIterator iter = new RecordListIterator(super.heuristicList);
AbstractRecord rec = iter.iterate();
for (int i = 0; i < index; i++) rec = iter.iterate();
super.heuristicList.remove(rec);
if (super.heuristicList.size() == 0)
super.setHeuristicDecision(TwoPhaseOutcome.FINISH_OK);
// if the log is not entry this call will delete the log automatically.
super.updateState();
}
}
Aggregations