Esempio n. 1
0
  public String setStatus(ParticipantStatus newState) {
    if (getListType().equals(newState)) return "participant is prepared for recovery";

    /*
     * Only move a heuristic to the prepared list if it hasn't already committed or rolled back
     */
    if (newState.equals(ParticipantStatus.PREPARED)
        && getListType().equals(ParticipantStatus.HEURISTIC)) {
      HeuristicStatus heuristicStatus = HeuristicStatus.valueOf(getHeuristicStatus());

      if (heuristicStatus.equals(HeuristicStatus.HEURISTIC_COMMIT)
          || heuristicStatus.equals(HeuristicStatus.HEURISTIC_ROLLBACK)) {
        return "participant has already committed or rolled back";
      }
    }

    if (parent != null && parent.setStatus(this, newState)) {
      listType = newState;

      if (newState == ParticipantStatus.PREPARED)
        return "participant recovery will be attempted during the next recovery pass";

      return "participant status change was successful";
    } else {
      return "participant status change failed";
    }
  }
Esempio n. 2
0
  @Override
  public String getHeuristicStatus() {
    Object heuristicInformation = rec.value();
    HeuristicStatus hs;

    if (heuristicInformation != null && heuristicInformation instanceof HeuristicInformation) {
      HeuristicInformation hi = (HeuristicInformation) heuristicInformation;
      hs = HeuristicStatus.intToStatus(hi.getHeuristicType());
    } else {
      hs = HeuristicStatus.UNKNOWN;
    }

    return hs.name();
  }