use of com.arjuna.ats.arjuna.common.Uid 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;
}
use of com.arjuna.ats.arjuna.common.Uid in project narayana by jbosstm.
the class ParticipantsManagerImpl method enlistVolatileParticipant.
@Override
public void enlistVolatileParticipant(final String volatileParticipantEnlistmentURL, final VolatileParticipant volatileParticipant) {
if (LOG.isTraceEnabled()) {
LOG.trace("ParticipantsManagerImpl.enlistVolatileParticipant: volatileParticipantEnlistmentURL=" + volatileParticipantEnlistmentURL + ", volatileParticipant=" + volatileParticipant);
}
if (baseUrl == null) {
throw new IllegalStateException("Base URL was not defined.");
}
final String participantId = new Uid().toString();
final String participantUrl = getVolatileParticipantUrl(participantId, baseUrl);
enlistVolatileParticipant(participantUrl, volatileParticipantEnlistmentURL);
ParticipantsContainer.getInstance().addVolatileParticipant(participantId, volatileParticipant);
if (LOG.isTraceEnabled()) {
LOG.trace("ParticipantsManagerImpl.enlistVolatileParticipant: participant enlisted. participantId=" + participantId + ", participantUrl=" + participantUrl);
}
}
use of com.arjuna.ats.arjuna.common.Uid in project narayana by jbosstm.
the class InboundBridgeManager method createMapping.
/**
* Create the JTA transaction mapping and support objects for a given WS transaction context.
*
* @param externalTxId The WS-AT tx identifier.
* @throws WrongStateException
* @throws UnknownTransactionException
* @throws com.arjuna.wst.SystemException
* @throws AlreadyRegisteredException
*/
private static synchronized void createMapping(String externalTxId) throws XAException, WrongStateException, UnknownTransactionException, com.arjuna.wst.SystemException, javax.transaction.SystemException, AlreadyRegisteredException {
txbridgeLogger.logger.trace("InboundBridgeManager.createMapping(externalTxId=" + externalTxId + ")");
if (inboundBridgeMappings.containsKey(externalTxId)) {
return;
}
TransactionManager transactionManager = TransactionManagerFactory.transactionManager();
// Xid for driving the subordinate,
// shared by the bridge (thread assoc) and Participant (termination via XATerminator)
Xid xid = XATxConverter.getXid(new Uid(), false, BridgeDurableParticipant.XARESOURCE_FORMAT_ID);
BridgeDurableParticipant bridgeDurableParticipant = new BridgeDurableParticipant(externalTxId, xid);
// construct the participantId in such as way as we can recognise it at recovery time:
String participantId = org.jboss.jbossts.txbridge.inbound.BridgeDurableParticipant.TYPE_IDENTIFIER + new Uid().toString();
transactionManager.enlistForDurableTwoPhase(bridgeDurableParticipant, participantId);
BridgeVolatileParticipant bridgeVolatileParticipant = new BridgeVolatileParticipant(externalTxId, xid);
transactionManager.enlistForVolatileTwoPhase(bridgeVolatileParticipant, new Uid().toString());
inboundBridgeMappings.put(externalTxId, new InboundBridge(xid));
}
use of com.arjuna.ats.arjuna.common.Uid in project narayana by jbosstm.
the class SampleVerticle2 method start.
public void start() {
LocalMap<String, String> map = vertx.sharedData().getLocalMap("demo.mymap");
Container<Sample> theContainer = new Container<>("Demo", Container.TYPE.PERSISTENT, Container.MODEL.SHARED);
String uidName = map.get(ClientVerticle.LEADER);
Sample obj1 = theContainer.clone(new SampleLockable(10), new Uid(uidName));
AtomicAction A = new AtomicAction();
int value = -1;
int initialValue = -1;
boolean shouldCommit = true;
A.begin();
try {
initialValue = obj1.value();
obj1.increment();
} catch (final Throwable ex) {
ex.printStackTrace();
shouldCommit = false;
}
try {
if (shouldCommit) {
obj1.increment();
value = obj1.value();
}
} catch (final Throwable ex) {
ex.printStackTrace();
shouldCommit = false;
}
if (shouldCommit)
A.commit();
else {
A.abort();
value = -1;
}
System.err.println("SampleVerticle2 initialised state with: " + value);
if (value == initialValue + 2)
System.err.println("SampleVerticle2 SUCCEEDED!");
else
System.err.println("SampleVerticle2 FAILED!");
}
use of com.arjuna.ats.arjuna.common.Uid in project narayana by jbosstm.
the class HornetqJournalStore method start.
public void start() throws Exception {
journal.start();
List<RecordInfo> committedRecords = new LinkedList<RecordInfo>();
List<PreparedTransactionInfo> preparedTransactions = new LinkedList<PreparedTransactionInfo>();
TransactionFailureCallback failureCallback = new TransactionFailureCallback() {
public void failedTransaction(long l, List<RecordInfo> recordInfos, List<RecordInfo> recordInfos1) {
tsLogger.i18NLogger.warn_journal_load_error();
}
};
JournalLoadInformation journalLoadInformation = journal.load(committedRecords, preparedTransactions, failureCallback);
maxID.set(journalLoadInformation.getMaxID());
if (!preparedTransactions.isEmpty()) {
tsLogger.i18NLogger.warn_journal_load_error();
}
for (RecordInfo record : committedRecords) {
InputBuffer inputBuffer = new InputBuffer(record.data);
Uid uid = UidHelper.unpackFrom(inputBuffer);
String typeName = inputBuffer.unpackString();
getContentForType(typeName).put(uid, record);
// don't unpack the rest yet, we may never need it. read_committed does it on demand.
}
}
Aggregations