public void forget(Xid id) throws UnknownDtxBranchException, IncorrectDtxStateException { DtxBranch branch = getBranch(id); if(branch != null) { synchronized (branch) { if(!branch.hasAssociatedSessions()) { if(branch.getState() != DtxBranch.State.HEUR_COM && branch.getState() != DtxBranch.State.HEUR_RB) { throw new IncorrectDtxStateException("Branch should not be forgotten - " + "it is not heuristically complete", id); } branch.setState(DtxBranch.State.FORGOTTEN); unregisterBranch(branch); } else { throw new IncorrectDtxStateException("Branch was still associated with a session", id); } } } else { throw new UnknownDtxBranchException(id); } }
@Override public void dtxForget(ServerSession session, DtxForget method) { try { session.forgetDtx(method.getXid()); } catch(UnknownDtxBranchException e) { exception(session, method, ExecutionErrorCode.NOT_FOUND, e.getMessage()); } catch(IncorrectDtxStateException e) { exception(session, method, ExecutionErrorCode.ILLEGAL_STATE, e.getMessage()); } }
exception(session, method, ExecutionErrorCode.ILLEGAL_STATE, e.getMessage());
throw new IncorrectDtxStateException("Cannot call one-phase commit on a prepared branch", id); throw new IncorrectDtxStateException("Cannot call two-phase commit on a non-prepared branch", id); throw new IncorrectDtxStateException("Branch was still associated with a session", id);
exception(session, method, ExecutionErrorCode.ILLEGAL_STATE, e.getMessage());
&& branch.getState() != DtxBranch.State.ROLLBACK_ONLY) throw new IncorrectDtxStateException("Cannot prepare a transaction in state " + branch.getState(), id); throw new IncorrectDtxStateException("Branch still has associated sessions", id);
exception(session, method, ExecutionErrorCode.ILLEGAL_STATE, e.getMessage());
throw new IncorrectDtxStateException("Branch was still associated with a session", id);