Search in sources :

Example 16 with Uid

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;
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) SubordinateAtomicAction(com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.jca.SubordinateAtomicAction) RecoveryStore(com.arjuna.ats.arjuna.objectstore.RecoveryStore) XAException(javax.transaction.xa.XAException) HashSet(java.util.HashSet)

Example 17 with Uid

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);
    }
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid)

Example 18 with Uid

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));
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) Xid(javax.transaction.xa.Xid) TransactionManager(com.arjuna.mw.wst11.TransactionManager)

Example 19 with Uid

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!");
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) AtomicAction(com.arjuna.ats.arjuna.AtomicAction) Container(org.jboss.stm.Container)

Example 20 with Uid

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.
    }
}
Also used : PreparedTransactionInfo(org.apache.activemq.artemis.core.journal.PreparedTransactionInfo) JournalLoadInformation(org.apache.activemq.artemis.core.journal.JournalLoadInformation) Uid(com.arjuna.ats.arjuna.common.Uid) RecordInfo(org.apache.activemq.artemis.core.journal.RecordInfo) InputBuffer(com.arjuna.ats.arjuna.state.InputBuffer) LinkedList(java.util.LinkedList) List(java.util.List) TransactionFailureCallback(org.apache.activemq.artemis.core.journal.TransactionFailureCallback) LinkedList(java.util.LinkedList)

Aggregations

Uid (com.arjuna.ats.arjuna.common.Uid)402 Test (org.junit.Test)185 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)83 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)74 XidImple (com.arjuna.ats.jta.xa.XidImple)71 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)57 IOException (java.io.IOException)48 Xid (javax.transaction.xa.Xid)44 XAException (javax.transaction.xa.XAException)40 SubordinateTransaction (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction)32 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)31 RecoveryStore (com.arjuna.ats.arjuna.objectstore.RecoveryStore)27 SoapFault11 (com.arjuna.webservices11.SoapFault11)22 Transaction (javax.transaction.Transaction)18 ObjectStoreEnvironmentBean (com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean)17 Vector (java.util.Vector)17 XATerminator (javax.resource.spi.XATerminator)15 TransactionImporter (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.TransactionImporter)14 Enumeration (java.util.Enumeration)13 SystemException (org.omg.CORBA.SystemException)13