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