} 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 );