// 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
// agreed to rollback. Therefore, we need not worry about
// who aborted
// and who committed.
throw new HeurRollbackException ( getHeuristicMessages () );
}
else if ( res == TerminationResult.HEUR_HAZARD ) {
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 HeurHazardStateHandler ( this,
hazards );