use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.
the class ExtendedResourceUnitTest method test.
@Test
public void test() throws Exception {
DemoArjunaResource ares = new DemoArjunaResource();
ArjunaTransactionImple tx = new ArjunaTransactionImple(null);
ExtendedResourceRecord res1 = new ExtendedResourceRecord(false, new Uid(), ares.getReference(), null, new Uid(), tx);
ExtendedResourceRecord res2 = new ExtendedResourceRecord(false, new Uid(), ares.getReference(), null, new Uid(), tx);
assertTrue(res1.resourceHandle() != null);
assertTrue(res1.value() != null);
assertFalse(res1.propagateOnAbort());
assertFalse(res1.propagateOnCommit());
assertTrue(res1.order().notEquals(Uid.nullUid()));
assertEquals(res1.typeIs(), 101);
assertTrue(res1.order() != null);
res1.setValue(null);
res1.print(new PrintWriter(new ByteArrayOutputStream()));
OutputObjectState os = new OutputObjectState();
assertTrue(res1.save_state(os, ObjectType.ANDPERSISTENT));
InputObjectState is = new InputObjectState(os);
assertTrue(res1.restore_state(is, ObjectType.ANDPERSISTENT));
assertFalse(res2.doSave());
assertFalse(res1.shouldAdd(res2));
assertFalse(res1.shouldAlter(res2));
assertFalse(res1.shouldMerge(res2));
assertFalse(res1.shouldReplace(res2));
res1 = new ExtendedResourceRecord();
assertTrue(res1.getRCUid().notEquals(res2.getRCUid()));
res1.alter(res2);
res1.merge(res2);
}
use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.
the class BusinessAgreementWithCoordinatorCompletionStub method restoreState.
public boolean restoreState(final InputObjectState ios) {
try {
final String id = ios.unpackString();
final String eprValue = ios.unpackString();
final XMLStreamReader reader = SoapUtils.getXMLStreamReader(new StringReader(eprValue));
StreamHelper.checkNextStartTag(reader, QNAME_BACCWS_PARTICIPANT);
String eprefText = reader.getElementText();
StreamSource source = new StreamSource(new StringReader(eprefText));
final W3CEndpointReference endpointReference = new W3CEndpointReference(source);
String ns = ios.unpackString();
final String localPart = ios.unpackString();
String prefix = ios.unpackString();
if ("".equals(ns)) {
ns = null;
}
if ("".equals(prefix)) {
prefix = null;
}
QName statename = new QName(ns, localPart, prefix);
State state = State.toState11(statename);
// if we already have an engine from a previous recovery scan or because
// we had a heuristic outcome then reuse it with luck it will have been committed
// or aborted between the last scan and this one
// note that whatever happens it will not have been removed from the table
// because it is marked as recovered
participant = (CoordinatorCompletionCoordinatorEngine) CoordinatorCompletionCoordinatorProcessor.getProcessor().getCoordinator(id);
if (participant == null) {
participant = new CoordinatorCompletionCoordinatorEngine(id, endpointReference, state, true);
}
return true;
} catch (final Throwable th) {
WSTLogger.i18NLogger.error_wst11_stub_BusinessAgreementWithCoordinatorCompletionStub_3(th);
return false;
}
}
use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.
the class SubordinateATCoordinatorRecoveryModule method periodicWorkFirstPass.
/**
* This is called periodically by the RecoveryManager
*/
public void periodicWorkFirstPass() {
// Transaction type
boolean SubordinateCoordinators = false;
// uids per transaction type
InputObjectState acc_uids = new InputObjectState();
try {
if (RecoveryLogger.logger.isDebugEnabled()) {
RecoveryLogger.logger.debug("StatusModule: first pass ");
}
SubordinateCoordinators = _recoveryStore.allObjUids(_transactionType, acc_uids);
} catch (ObjectStoreException ex) {
RecoveryLogger.i18NLogger.warn_coordinator_at_SubordinateATCoordinatorRecoveryModule_1(ex);
}
if (SubordinateCoordinators) {
_transactionUidVector = processTransactions(acc_uids);
}
}
use of com.arjuna.ats.arjuna.state.InputObjectState in project narayana by jbosstm.
the class BAParticipantRecoveryModule method periodicWorkFirstPass.
/**
* This is called periodically by the RecoveryManager
*/
public void periodicWorkFirstPass() {
// Transaction type
boolean BAParticipants = false;
// uids per transaction type
InputObjectState acc_uids = new InputObjectState();
try {
if (RecoveryLogger.logger.isDebugEnabled()) {
RecoveryLogger.logger.debug("BAParticipantRecoveryModule: first pass");
}
BAParticipants = _recoveryStore.allObjUids(_participantType, acc_uids);
} catch (ObjectStoreException ex) {
RecoveryLogger.i18NLogger.warn_participant_ba_BAParticipantRecoveryModule_1(ex);
}
if (BAParticipants) {
_participantUidVector = processParticipants(acc_uids);
}
}
use of com.arjuna.ats.arjuna.state.InputObjectState 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);
}
}
}
Aggregations