Search in sources :

Example 21 with Prepared

use of org.jboss.narayana.rest.integration.api.Prepared in project narayana by jbosstm.

the class InboundBridgeParticipant method commitOnePhase.

@Override
public void commitOnePhase() {
    if (LOG.isTraceEnabled()) {
        LOG.trace("InboundBridgeParticipant.commitOnePhase: xid=" + xid);
    }
    startBridge();
    final Vote outcome = prepareSubordinate();
    if (LOG.isTraceEnabled()) {
        LOG.trace("InboundBridgeParticipant.commitOnePhase: xid=" + xid + ", outcome=" + outcome);
    }
    if (outcome instanceof Prepared) {
        try {
            commitSubordinate();
        } catch (HeuristicException e) {
        }
    }
    cleanup();
}
Also used : HeuristicException(org.jboss.narayana.rest.integration.api.HeuristicException) Vote(org.jboss.narayana.rest.integration.api.Vote) Prepared(org.jboss.narayana.rest.integration.api.Prepared)

Example 22 with Prepared

use of org.jboss.narayana.rest.integration.api.Prepared in project narayana by jbosstm.

the class InboundBridgeParticipant method prepare.

@Override
public Vote prepare() {
    if (LOG.isTraceEnabled()) {
        LOG.trace("InboundBridgeParticipant.prepare: xid=" + xid);
    }
    startBridge();
    final Vote outcome = prepareSubordinate();
    if (!(outcome instanceof Prepared)) {
        cleanup();
    } else {
        stopBridge();
    }
    if (LOG.isTraceEnabled()) {
        LOG.trace("InboundBridgeParticipant.prepare: xid=" + xid + ", outcome=" + outcome.getClass().getName());
    }
    return outcome;
}
Also used : Vote(org.jboss.narayana.rest.integration.api.Vote) Prepared(org.jboss.narayana.rest.integration.api.Prepared)

Example 23 with Prepared

use of org.jboss.narayana.rest.integration.api.Prepared in project wildfly by wildfly.

the class ParticipantTestCase method testCommitOnePhase.

@Test
public void testCommitOnePhase() {
    txSupport.startTx();
    LoggingParticipant participant = new LoggingParticipant(new Prepared());
    ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), participant);
    txSupport.commitTx();
    Assert.assertEquals(Arrays.asList(new String[] { "commitOnePhase" }), participant.getInvocations());
}
Also used : LoggingParticipant(org.wildfly.test.extension.rts.common.LoggingParticipant) Prepared(org.jboss.narayana.rest.integration.api.Prepared) Test(org.junit.Test)

Example 24 with Prepared

use of org.jboss.narayana.rest.integration.api.Prepared in project wildfly by wildfly.

the class ParticipantTestCase method testReadOnly.

@Test
public void testReadOnly() {
    txSupport.startTx();
    final List<LoggingParticipant> participants = Arrays.asList(new LoggingParticipant[] { new LoggingParticipant(new ReadOnly()), new LoggingParticipant(new Prepared()), new LoggingParticipant(new Prepared()) });
    for (LoggingParticipant p : participants) {
        ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), p);
    }
    txSupport.commitTx();
    // One of the participants was only prepared, while other two were prepared and committed.
    Assert.assertEquals(5, participants.get(0).getInvocations().size() + participants.get(1).getInvocations().size() + participants.get(2).getInvocations().size());
    for (LoggingParticipant p : participants) {
        if (p.getInvocations().size() == 1) {
            Assert.assertEquals(Arrays.asList(new String[] { "prepare" }), p.getInvocations());
        } else {
            Assert.assertEquals(Arrays.asList(new String[] { "prepare", "commit" }), p.getInvocations());
        }
    }
}
Also used : LoggingParticipant(org.wildfly.test.extension.rts.common.LoggingParticipant) ReadOnly(org.jboss.narayana.rest.integration.api.ReadOnly) Prepared(org.jboss.narayana.rest.integration.api.Prepared) Test(org.junit.Test)

Example 25 with Prepared

use of org.jboss.narayana.rest.integration.api.Prepared in project narayana by jbosstm.

the class ParticipantResource method prepare.

private Vote prepare(final ParticipantInformation participantInformation) throws HeuristicException {
    if (isHeuristic(participantInformation)) {
        return prepareHeuristic(participantInformation);
    }
    participantInformation.setStatus(TxStatus.TransactionPreparing.name());
    final Vote vote;
    try {
        vote = participantInformation.getParticipant().prepare();
    } catch (ParticipantException e) {
        participantInformation.setStatus(TxStatus.TransactionActive.name());
        throw e;
    }
    if (vote instanceof Aborted) {
        rollback(participantInformation);
    } else if (vote instanceof Prepared) {
        participantInformation.setStatus(TxStatus.TransactionPrepared.name());
        RecoveryManager.getInstance().persistParticipantInformation(participantInformation);
    } else if (vote instanceof ReadOnly) {
        readOnly(participantInformation);
    }
    return vote;
}
Also used : ReadOnly(org.jboss.narayana.rest.integration.api.ReadOnly) Vote(org.jboss.narayana.rest.integration.api.Vote) Prepared(org.jboss.narayana.rest.integration.api.Prepared) ParticipantException(org.jboss.narayana.rest.integration.api.ParticipantException) Aborted(org.jboss.narayana.rest.integration.api.Aborted)

Aggregations

Prepared (org.jboss.narayana.rest.integration.api.Prepared)36 Test (org.junit.Test)33 LoggingParticipant (org.jboss.narayana.rest.integration.test.common.LoggingParticipant)25 ParticipantInformation (org.jboss.narayana.rest.integration.ParticipantInformation)12 Response (javax.ws.rs.core.Response)10 LoggingParticipant (org.wildfly.test.extension.rts.common.LoggingParticipant)6 Aborted (org.jboss.narayana.rest.integration.api.Aborted)4 HeuristicParticipant (org.jboss.narayana.rest.integration.test.common.HeuristicParticipant)4 ReadOnly (org.jboss.narayana.rest.integration.api.ReadOnly)3 Vote (org.jboss.narayana.rest.integration.api.Vote)3 Uid (com.arjuna.ats.arjuna.common.Uid)2 HttpResponseException (org.jboss.jbossts.star.provider.HttpResponseException)2 TransactionStatusElement (org.jboss.jbossts.star.util.media.txstatusext.TransactionStatusElement)2 LoggingVolatileParticipant (org.jboss.narayana.rest.integration.test.common.LoggingVolatileParticipant)2 JSONArray (org.codehaus.jettison.json.JSONArray)1 HeuristicException (org.jboss.narayana.rest.integration.api.HeuristicException)1 ParticipantException (org.jboss.narayana.rest.integration.api.ParticipantException)1 TestParticipantDeserializer (org.jboss.narayana.rest.integration.test.common.TestParticipantDeserializer)1