Package com.atomikos.icatch

Examples of com.atomikos.icatch.RollbackException


        // Recursive prepare-calls should be avoided for not deadlocking rollback/commit methods
        // 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


            //See case 23334
            String msg = "Error in committing: " + error.getMessage() + " - rolling back instead";
            LOGGER.logWarning ( msg , error );
            try {
          rollback ( getCoordinator().isRecoverableWhileActive().booleanValue() , false );
          throw new RollbackException ( msg );
            } catch ( HeurCommitException e ) {
          LOGGER.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
                        Integer sibnum = (Integer) cascadeList_.get ( p );
                        if ( sibnum != null ) // null for local participant!
                            p.setGlobalSiblingCount ( sibnum.intValue () );
                        p.setCascadeList ( cascadeList_ );
                    }
                    propagator_.submitPropagationMessage ( cm );
                }
            } // 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 agreed to rollback.
View Full Code Here

        else if ( prepareCalled ) {
            throw new HeurHazardException ( ret );
        } else {
            // prepare NOT called -> subordinate timed out
            // and must have rolled back
            throw new RollbackException ();
        }
        return ret;
    }
View Full Code Here

            // the outcome.
            // In order to have certainty, a client participant
            // wrapper should be used to force 2PC and
            // logging.

            throw new RollbackException ( "Transaction was rolled back." );
        }

    }
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

        }

        if ( ct_.getState().equals ( TxState.MARKED_ABORT ) ) {
          // happens if synchronization has called setRollbackOnly
          rollback();
          throw new RollbackException ( "The transaction was set to rollback only" );
        }

        // for loop to make sure that new registrations are possible during callback
        for ( int i = 0; i < subtxawares_.size (); i++ ) {
          SubTxAwareParticipant subtxaware = (SubTxAwareParticipant) subtxawares_.get ( i );
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 {
          rollbackWithAfterCompletionNotification(new RollbackCallback() {
            public HeuristicMessage[] doRollback()
                throws HeurCommitException,
                HeurMixedException, SysException,
                HeurHazardException, IllegalStateException {
              return rollbackFromWithinCallback(getCoordinator().isRecoverableWhileActive().booleanValue(),false);
            }});
          throw new RollbackException ( msg , error);
            } 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 {
                    rollbackWithAfterCompletionNotification(new RollbackCallback() {
            public HeuristicMessage[] doRollback()
                throws HeurCommitException,
                HeurMixedException, SysException,
                HeurHazardException, IllegalStateException {
              return rollbackFromWithinCallback(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

        } catch ( XAException xaerr ) {
          String msg = interpretErrorCode ( resourcename_ , "prepare" , xid_ , xaerr.errorCode );
            Configuration.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

        // Recursive prepare-calls should be avoided for not deadlocking rollback/commit methods
        // 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

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.