use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.
the class BaseTest method readObjectStoreRecord.
protected static OSRecordHolder readObjectStoreRecord(String type) {
try {
RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
InputObjectState states = new InputObjectState();
if (recoveryStore.allObjUids(type, states) && states.notempty()) {
Uid uid = UidHelper.unpackFrom(states);
if (uid.notEquals(Uid.nullUid())) {
InputObjectState ios = recoveryStore.read_committed(uid, type);
return new OSRecordHolder(uid, type, ios);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.
the class BaseTest method clearObjectStore.
private static void clearObjectStore(String type) {
try {
RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
InputObjectState states = new InputObjectState();
if (recoveryStore.allObjUids(type, states) && states.notempty()) {
boolean finished = false;
do {
Uid uid = UidHelper.unpackFrom(states);
if (uid.notEquals(Uid.nullUid())) {
recoveryStore.remove_committed(uid, type);
} else {
finished = true;
}
} while (!finished);
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.
the class RecoveryManager method recoverParticipants.
private void recoverParticipants() {
if (ParticipantsManagerFactory.getInstance().getBaseUrl() != null) {
final RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
final InputObjectState states = new InputObjectState();
try {
if (recoveryStore.allObjUids(PARTICIPANT_INFORMATION_RECORD_TYPE, states)) {
Uid uid;
while ((uid = UidHelper.unpackFrom(states)).notEquals(Uid.nullUid())) {
final ParticipantInformation participantInformation = recreateParticipantInformation(recoveryStore, uid);
if (participantInformation != null) {
ParticipantsContainer.getInstance().addParticipantInformation(participantInformation.getId(), participantInformation);
}
}
}
} catch (ObjectStoreException e) {
LOG.warn(e.getMessage(), e);
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
}
} else {
LOG.warn("Participants cannot be loaded from the object store, because base URL was not set.");
}
}
use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.
the class RecoveryManager method persistParticipantInformation.
public void persistParticipantInformation(final ParticipantInformation participantInformation) {
if (LOG.isTraceEnabled()) {
LOG.trace("RecoveryManager.persistParticipantInformation: participantInformation=" + participantInformation);
}
if (!isRecoverableParticipant(participantInformation.getParticipant())) {
if (LOG.isTraceEnabled()) {
LOG.trace("RecoveryManager.persistParticipantInformation: participant is not recoverable");
}
return;
}
try {
final RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
final OutputObjectState state = getParticipantInformationOutputState(participantInformation);
final Uid uid = new Uid(participantInformation.getId());
recoveryStore.write_committed(uid, PARTICIPANT_INFORMATION_RECORD_TYPE, state);
} catch (Exception e) {
LOG.warn("Failure while persisting participant information.", e);
}
}
use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.
the class InboundBridgeRecoveryModule method getUidsToRecover.
/**
* Returns UIDs of JTA subordinate transactions with format id specified in inbound bridge class which were found in
* transaction log.
*
* @return Set<Uid>
*/
private Set<Uid> getUidsToRecover() {
if (LOG.isTraceEnabled()) {
LOG.trace("InboundBridgeRecoveryModule.getUidsToRecover");
}
final Set<Uid> uids = new HashSet<Uid>();
try {
final RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
final InputObjectState states = new InputObjectState();
// Only look in the JCA section of the object store
if (recoveryStore.allObjUids(SubordinateAtomicAction.getType(), states) && states.notempty()) {
boolean finished = false;
do {
final Uid uid = UidHelper.unpackFrom(states);
if (uid.notEquals(Uid.nullUid())) {
final SubordinateAtomicAction saa = new SubordinateAtomicAction(uid, true);
if (saa.getXid().getFormatId() == InboundBridge.XARESOURCE_FORMAT_ID) {
uids.add(uid);
}
} else {
finished = true;
}
} while (!finished);
}
} catch (Exception e) {
LOG.warn(e.getMessage(), e);
}
return uids;
}
Aggregations