Exemple #1
0
    @SuppressWarnings({"UnusedDeclaration"})
    @PUT
    @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();
      }

      work.vStatus = vStatus;
      work.syncCount += 1;

      if (vStatus == 1 && "V_PREPARE".equals(work.fault))
        return Response.status(HttpURLConnection.HTTP_CONFLICT).build();
      else if (vStatus == 2 && "V_COMMIT".equals(work.fault))
        return Response.status(HttpURLConnection.HTTP_CONFLICT).build();

      return Response.ok().build();
    }
Exemple #2
0
 public boolean inTxn() {
   return status != null && TxStatus.fromStatus(status).isActive();
   // return TxSupport.isActive(status);
 }