public void viewAccepted(View view) {
if (logmon.isLoggable(BasicLevel.DEBUG))
logmon.log(BasicLevel.DEBUG,"==== viewAccepted: " + view);
// Eventually get new coordinator address
Vector mbrs = view.getMembers();
coordinatorAddr = (Address) mbrs.elementAt(0);
if (logmon.isLoggable(BasicLevel.DEBUG))
logmon.log(BasicLevel.DEBUG,
"JGroups setView: " + coordinator + ", " + state);
if (coordinator) {
// Test that the server is always master.
if (! coordinatorAddr.equals(myAddr)) {
logmon.log(BasicLevel.FATAL, "Bad view for coordinator");
throw new RuntimeException("Bad view for coordinator");
}
return;
}
if ((state != RUNNING) && (! coordinatorAddr.equals(myAddr))) {
// Ask current state to the new coordinator.
try {
sendTo(coordinatorAddr,new HAStateRequest(myAddr));
state = INITIALIZING;
} catch (Exception exc) {
logmon.log(BasicLevel.ERROR,"JGroups sendTo()",exc);
}
}
if ((mbrs.size() >= nbClusterExpected) &&
coordinatorAddr.equals(myAddr)) {
// This server is the new master !
coordinator = true;
// Starts the service
startConsAndServ();