Package org.jboss.jbossts.star.util

Examples of org.jboss.jbossts.star.util.TxStatus


    @Path("{pId}/{tId}/volatile-participant")
    public Response synchronizations(@PathParam("pId") @DefaultValue("") String pId,
            @PathParam("tId") @DefaultValue("") String tId, String content) {

        Work work = faults.get(pId);
        TxStatus txStatus;
        int vStatus;

        if (work == null)
            return Response.ok().build();

        txStatus = content != null ? TxStatus.fromStatus(content) : TxStatus.TransactionStatusUnknown;

        vStatus = txStatus.equals(TxStatus.TransactionStatusUnknown) ? 1 : 2;

        if (vStatus == 2 && work.vStatus == 0) {
            // afterCompletion but coordinator never called beforeCompletion
            return Response.status(HttpURLConnection.HTTP_BAD_REQUEST).build();
        }
View Full Code Here


    @PUT
    @Path("{pId}/{tId}/terminator")
    public Response terminate(@PathParam("pId") @DefaultValue("") String pId, @PathParam("tId") @DefaultValue("") String tId,
            String content) {

        TxStatus status = TxSupport.toTxStatus(content);

        // String status = TxSupport.getStatus(content);
        Work work = faults.get(pId);

        if (work == null)
            return Response.status(HttpURLConnection.HTTP_NOT_FOUND).build();

        String fault = work.fault;

        if (status.isPrepare()) {
            if ("READONLY".equals(fault)) {
                // faults.remove(pId);
                work.status = TxStatus.TransactionReadOnly.name();
            } else if ("PREPARE_FAIL".equals(fault)) {
                // faults.remove(pId);
                return Response.status(HttpURLConnection.HTTP_CONFLICT).build();
                // throw new WebApplicationException(HttpURLConnection.HTTP_CONFLICT);
            } else {
                if ("PDELAY".equals(fault)) {
                    try {
                        Thread.sleep(2000);
                    } catch (InterruptedException e) {
                    }
                }
                work.status = TxStatus.TransactionPrepared.name();
            }
        } else if (status.isCommit() || status.isCommitOnePhase()) {
            if ("H_HAZARD".equals(fault))
                work.status = TxStatus.TransactionHeuristicHazard.name();
            else if ("H_ROLLBACK".equals(fault))
                work.status = TxStatus.TransactionHeuristicRollback.name();
            else if ("H_MIXED".equals(fault))
                work.status = TxStatus.TransactionHeuristicMixed.name();
            else {
                if ("CDELAY".equals(fault)) {
                    try {
                        Thread.sleep(3000);
                    } catch (InterruptedException e) {
                        // ok
                    }
                }
                work.status = status.isCommitOnePhase() ? TxStatus.TransactionCommittedOnePhase.name()
                        : TxStatus.TransactionCommitted.name();

                work.end(true);
            }
        } else if (status.isAbort()) {
            if ("H_HAZARD".equals(fault))
                work.status = TxStatus.TransactionHeuristicHazard.name();
            else if ("H_COMMIT".equals(fault))
                work.status = TxStatus.TransactionHeuristicCommit.name();
            else if ("H_MIXED".equals(fault))
View Full Code Here

            LOG.trace("LoggingRestATResource.terminateParticipant(" + content + ")");
        }

        invocations.add("LoggingRestATResource.terminateParticipant(" + content + ")");

        TxStatus txStatus = TxSupport.toTxStatus(content);
        String responseStatus = null;

        if (txStatus.isPrepare()) {
            responseStatus = TxStatus.TransactionPrepared.name();

        } else if (txStatus.isCommit()) {
            responseStatus = TxStatus.TransactionCommitted.name();

        } else if (txStatus.isCommitOnePhase()) {
            responseStatus = TxStatus.TransactionCommittedOnePhase.name();

        } else if (txStatus.isAbort()) {
            responseStatus = TxStatus.TransactionRolledBack.name();
        }

        if (responseStatus == null) {
            return Response.status(HttpURLConnection.HTTP_BAD_REQUEST).build();
View Full Code Here

TOP

Related Classes of org.jboss.jbossts.star.util.TxStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.