Package com.atomikos.icatch

Examples of com.atomikos.icatch.RollbackException


        // If a recursive prepare re-enters, then it will see a voting
        // state -> reject.
        // Note that this may also avoid some legal prepares,
        // but only rarely
        if ( getState ().equals ( TxState.PREPARING ) )
            throw new RollbackException ( "Recursion detected" );

        int ret = Participant.READ_ONLY + 1;
        synchronized ( fsm_ ) {
          ret = stateHandler_.prepare ();
          if ( ret == Participant.READ_ONLY ) {
View Full Code Here


          
            } catch ( HeurCommitException hc ) {
                throw new HeurMixedException ( hc.getHeuristicMessages() );
            }

            throw new RollbackException ( "Orphans detected." );
        }

        try {
          try {
            getCoordinator ().setState ( TxState.PREPARING );
          } catch ( RuntimeException error ) {
            //See case 23334
            String msg = "Error in preparing: " + error.getMessage() + " - rolling back instead";
            Configuration.logWarning ( msg , error );
            try {
          super.rollback ( getCoordinator().isRecoverableWhileActive().booleanValue() , false );
          throw new RollbackException ( msg );
            } catch ( HeurCommitException e ) {
          Configuration.logWarning ( "Illegal heuristic commit during rollback before prepare:" + e );
          throw new HeurMixedException ( e.getHeuristicMessages() );
        }
          }
            count = participants.size ();
            result = new PrepareResult ( count );
            Enumeration enumm = participants.elements ();
            while ( enumm.hasMoreElements () ) {
                Participant p = (Participant) enumm.nextElement ();
                PrepareMessage pm = new PrepareMessage ( p, result );
                if ( getCascadeList () != null && p.getURI () != null ) { // null
                                                                            // for
                                                                            // OTS
                                                                            // case?
                    Integer sibnum = (Integer) getCascadeList ().get (
                            p.getURI () );
                    if ( sibnum != null ) // null for local participant!
                        p.setGlobalSiblingCount ( sibnum.intValue () );
                    p.setCascadeList ( getCascadeList () );
                }

                getPropagator ().submitPropagationMessage ( pm );
                // this will trigger sending the message
            } // while

            // now wait for all replies and act accordingly
            result.waitForReplies ();

            boolean voteOK = result.allYes ();
            setReadOnlyTable ( result.getReadOnlyTable () );
            // indoubttable_ = result.getIndoubtTable();
            allReadOnly = result.allReadOnly ();

            if ( !voteOK ) {
                // addErrorMessages(result.getMessages());

                int res = result.getResult ();
                // FOLLOWING CODE REMOVED:
                // DURING PREPARE, NO CONTRACTS ARE BROKEN
                // IF PREPARE FAILS. the only danger is that
                // some servers vote yes and remain indoubt,
                // but that is a heuristic case at these
                // remote sites, but not locally.
                // indeed, locally there is no uncertainty
                // about the outcome, because we will
                // roll back and vote no!
                // THEREFORE, WE CAN FORGET ABOUT ANY
                // INDOUBT SERVERS; IF THEY INQUIRE, WE WILL
                // SAY ABORTED.

                // if (res == Result.HEUR_MIXED) {
                // rollback ( true );
                // throw new HeurMixedException(getHeuristicMessages());
                // }
                // else if (res == Result.HEUR_COMMIT) {
                // commit ( true, false );
                // throw new HeurCommitException(getHeuristicMessages());
                // }
                // else if (res == Result.HEUR_HAZARD) {
                // rollback ( true );
                // throw new HeurMixedException(getHeuristicMessages());
                // }
                // else {

                // resolve indoubt situations and return NO vote.
                try {
                    rollback ( true, false );
                } catch ( HeurCommitException hc ) {
                    // can not happen:
                    // heuristic commit means that ALL subordinate work
                    // as been committed heuristically.
                    // this is impossible since it assumes that ALL
                    // participants voted YES in the first place,
                    // which contradicts the fact that we are dealing with
                    // !voteOK
                    errors.push ( hc );
                    throw new SysException ( "Unexpected heuristic: "
                            + hc.getMessage (), errors );
                }
                throw new RollbackException ( "Prepare: " + "NO vote" );

                // } //else
            } // if (!voteOK)
        } catch ( RuntimeException runerr ) {
            errors.push ( runerr );
View Full Code Here

    protected void commit () throws SysException,
            java.lang.IllegalStateException, RollbackException
    {
        rollbackWithStateCheck ();
        throw new RollbackException ( "Transaction set to rollback only" );
    }
View Full Code Here

            //See case 23334
            String msg = "Error in committing: " + error.getMessage() + " - rolling back instead";
            Configuration.logWarning ( msg , error );
            try {
          rollback ( getCoordinator().isRecoverableWhileActive().booleanValue() , false );
          throw new RollbackException ( msg );
            } catch ( HeurCommitException e ) {
          Configuration.logWarning ( "Illegal heuristic commit during rollback:" + e );
          throw new HeurMixedException ( e.getHeuristicMessages() );
        }
          }
     

            // start messages
            Enumeration enumm = participants.elements ();
            while ( enumm.hasMoreElements () ) {
                Participant p = (Participant) enumm.nextElement ();
                if ( !readOnlyTable_.containsKey ( p ) ) {
                    CommitMessage cm = new CommitMessage ( p, commitresult,
                            onePhase );

                    // if onephase: set cascadelist anyway, because if the
                    // participant is a REMOTE one, then it might have
                    // multiple participants that are not visible here!

                    if ( onePhase && cascadeList_ != null ) { // null for OTS
                                                                // case?
                        Integer sibnum = (Integer) cascadeList_.get ( p );
                        if ( sibnum != null ) // null for local participant!
                            p.setGlobalSiblingCount ( sibnum.intValue () );
                        p.setCascadeList ( cascadeList_ );
                    }
                    propagator_.submitPropagationMessage ( cm );
                    // this will trigger sending the message
                }
            } // while

            commitresult.waitForReplies ();
            int res = commitresult.getResult ();

            if ( res != TerminationResult.ALL_OK ) {

                if ( res == TerminationResult.HEUR_MIXED ) {
                    Hashtable hazards = commitresult.getPossiblyIndoubts ();
                    Hashtable heuristics = commitresult
                            .getHeuristicParticipants ();
                    addToHeuristicMap ( heuristics );
                    enumm = participants.elements ();
                    while ( enumm.hasMoreElements () ) {
                        Participant p = (Participant) enumm.nextElement ();
                        if ( !heuristics.containsKey ( p ) )
                            addToHeuristicMap ( p, TxState.TERMINATED );
                    }
                    nextStateHandler = new HeurMixedStateHandler ( this,
                            hazards );

                    coordinator_.setStateHandler ( nextStateHandler );
                    throw new HeurMixedException ( getHeuristicMessages () );
                }

                else if ( res == TerminationResult.ROLLBACK ) {
                    // 1PC and rolled back before commit arrived.
                    nextStateHandler = new TerminatedStateHandler ( this );
                    coordinator_.setStateHandler ( nextStateHandler );
                    throw new RollbackException ( "Rolled back already." );
                } else if ( res == TerminationResult.HEUR_ROLLBACK ) {
                    nextStateHandler = new HeurAbortedStateHandler ( this );
                    coordinator_.setStateHandler ( nextStateHandler );
                    // Here, we do NOT need to add extra information, since ALL
                    // participants
View Full Code Here

        } catch ( XAException xaerr ) {
          String msg = interpretErrorCode ( resourcename_ , "prepare" , xid_ , xaerr.errorCode );
            LOGGER.logWarning ( msg , xaerr ); // see case 84253
            if ( (XAException.XA_RBBASE <= xaerr.errorCode)
                    && (xaerr.errorCode <= XAException.XA_RBEND) ) {
                throw new RollbackException ( msg );
            } else {
                errors.push ( xaerr );
                throw new SysException ( msg , errors );
            }
        }
View Full Code Here

        } catch ( XAException xaerr ) {
              String msg = interpretErrorCode ( resourcename_ , "prepare" , xid_ , xaerr.errorCode );
            if ( Configuration.isDebugLoggingEnabled() ) Configuration.logDebug ( msg , xaerr );
            if ( (XAException.XA_RBBASE <= xaerr.errorCode)
                    && (xaerr.errorCode <= XAException.XA_RBEND) ) {
                throw new RollbackException ( msg );
            } else {
                errors.push ( xaerr );
                throw new SysException ( msg , errors );
            }
        }
View Full Code Here

    public int prepare () throws RollbackException, HeurHazardException,
            HeurMixedException, SysException
    {
        // prepare MUST fail: rollback only!
        throw new RollbackException ( msg_.toString () );
    }
View Full Code Here

            throws HeurRollbackException, HeurHazardException,
            HeurMixedException, RollbackException, SysException
    {
        // if onePhase then this method will be called;
        // make sure rollback is indicated.
        throw new RollbackException ( msg_.toString () );
    }
View Full Code Here

            } catch ( HeurCommitException hc ) {
                throw new HeurMixedException ( hc.getHeuristicMessages() );
            }

            throw new RollbackException ( "Orphans detected." );
        }

        try {
          try {
            getCoordinator().setState ( TxState.PREPARING );
          } catch ( RuntimeException error ) {
            //See case 23334
            String msg = "Error in preparing: " + error.getMessage() + " - rolling back instead";
            LOGGER.logWarning ( msg , error );
            try {
          super.rollback ( getCoordinator().isRecoverableWhileActive().booleanValue() , false );
          throw new RollbackException ( msg );
            } catch ( HeurCommitException e ) {
          LOGGER.logWarning ( "Illegal heuristic commit during rollback before prepare:" + e );
          throw new HeurMixedException ( e.getHeuristicMessages() );
        }
          }
            count = participants.size ();
            result = new PrepareResult ( count );
            Enumeration enumm = participants.elements ();
            while ( enumm.hasMoreElements () ) {
                Participant p = (Participant) enumm.nextElement ();
                PrepareMessage pm = new PrepareMessage ( p, result );
                if ( getCascadeList () != null && p.getURI () != null ) { //null for OTS
                    Integer sibnum = (Integer) getCascadeList ().get ( p.getURI () );
                    if ( sibnum != null ) { // null for local participant!
                        p.setGlobalSiblingCount ( sibnum.intValue () );
                    }
                    p.setCascadeList ( getCascadeList () );
                }

                getPropagator ().submitPropagationMessage ( pm );
            } // while

            result.waitForReplies ();

            boolean voteOK = result.allYes ();
            setReadOnlyTable ( result.getReadOnlyTable () );
            allReadOnly = result.allReadOnly ();

            if ( !voteOK ) {

                int res = result.getResult ();
              
                try {
                    rollback ( true, false );
                } catch ( HeurCommitException hc ) {
                    // should not happen:
                    // means that ALL subordinate work committed heuristically.
                    // this is impossible since it assumes that ALL
                    // participants voted YES in the first place,
                    // which contradicts the fact that we are dealing with
                    // !voteOK
                    errors.push ( hc );
                    throw new SysException ( "Unexpected heuristic: "
                            + hc.getMessage (), errors );
                }
                throw new RollbackException ( "Prepare: " + "NO vote" );
            
            }
        } catch ( RuntimeException runerr ) {
            errors.push ( runerr );
            throw new SysException ( "Error in prepare: " + runerr.getMessage (), errors );
View Full Code Here

    protected void commit () throws SysException,
            java.lang.IllegalStateException, RollbackException
    {
        rollbackWithStateCheck();
        throw new RollbackException ( "Transaction set to rollback only" );
    }
View Full Code Here

TOP

Related Classes of com.atomikos.icatch.RollbackException

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.