use of org.jboss.narayana.rest.integration.api.Vote 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();
}
use of org.jboss.narayana.rest.integration.api.Vote 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;
}
use of org.jboss.narayana.rest.integration.api.Vote in project narayana by jbosstm.
the class ParticipantResource method terminate.
@PUT
@Consumes(TxMediaType.TX_STATUS_MEDIA_TYPE)
@Produces(TxMediaType.TX_STATUS_MEDIA_TYPE)
public Response terminate(@PathParam("participantId") final String participantId, final String content) throws HeuristicException {
if (LOG.isTraceEnabled()) {
LOG.trace("PUT request on ParticipantResource. ParticipantId: " + participantId + ", content: " + content);
}
final ParticipantInformation participantInformation = ParticipantsContainer.getInstance().getParticipantInformation(participantId);
if (participantInformation == null) {
if (LOG.isTraceEnabled()) {
LOG.trace("Participant with id " + participantId + " was not found.");
}
return Response.status(404).build();
}
String status = TxSupport.getStatus(content);
if (TxStatus.isPrepare(status)) {
if (!canPrepare(participantInformation)) {
return Response.status(412).build();
}
Vote vote = prepare(participantInformation);
return voteToResponse(vote);
} else if (TxStatus.isCommit(status)) {
if (!canCommit(participantInformation)) {
return Response.status(412).build();
}
commit(participantInformation);
return Response.ok().entity(TxSupport.toStatusContent(TxStatus.TransactionCommitted.name())).build();
} else if (TxStatus.isCommitOnePhase(status)) {
if (!canCommitOnePhase(participantInformation)) {
return Response.status(412).build();
}
commitOnePhase(participantInformation);
return Response.ok().entity(TxSupport.toStatusContent(TxStatus.TransactionCommittedOnePhase.name())).build();
} else if (TxStatus.isAbort(status)) {
rollback(participantInformation);
return Response.ok().entity(TxSupport.toStatusContent(TxStatus.TransactionRolledBack.name())).build();
}
return Response.status(400).build();
}
use of org.jboss.narayana.rest.integration.api.Vote 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;
}
use of org.jboss.narayana.rest.integration.api.Vote in project narayana by jbosstm.
the class TransactionalService method enlistParticipant.
@POST
public String enlistParticipant(@QueryParam("participantEnlistmentUrl") final String participantEnlistmentUrl, @QueryParam("vote") final String stringVote, @Context final UriInfo uriInfo) {
final Vote vote = stringVoteToVote(stringVote);
final LoggingParticipant participant = new LoggingParticipant(vote);
return ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, participantEnlistmentUrl, participant).toString();
}
Aggregations