Globals.getBrokerResources().getKString(
BrokerResources.X_ADMIN_CHANGE_MASTER_NOT_FROM_JMSRA));
}
ClusterManager cm = Globals.getClusterManager();
BrokerMQAddress self = (BrokerMQAddress)cm.getMQAddress();
BrokerMQAddress master = (cm.getMasterBroker() == null ?
null:(BrokerMQAddress)cm.getMasterBroker().getBrokerURL());
BrokerMQAddress newmba = BrokerMQAddress.createAddress(newmb);
BrokerMQAddress oldmba = null;
if (oldmb != null) {
oldmba = BrokerMQAddress.createAddress(oldmb);
}
if (notificationOnly) {
if (master == null) {
emsg = "IllegalStateException for notification "+
MessageType.getString(MessageType.CHANGE_CLUSTER_MASTER_BROKER)+
": No master broker";
logger.log(logger.ERROR, emsg);
sendReply(Status.ERROR, emsg, con, cmd_msg);
Broker.getBroker().exit(1, emsg, BrokerEvent.Type.ERROR);
throw new IllegalStateException(emsg);
}
if (newmba.equals(self)) {
if (!master.equals(self)) {
emsg = "IllegalStateException for notification "+
MessageType.getString(MessageType.CHANGE_CLUSTER_MASTER_BROKER)+
": This broker, which has master broker "+master+
", is not the master broker as expected";
logger.log(logger.ERROR, emsg);
sendReply(Status.ERROR, emsg, con, cmd_msg);
Broker.getBroker().exit(1, emsg, BrokerEvent.Type.ERROR);
return true;
}
}
if (oldmba != null && oldmba.equals(self)) {
if (!master.equals(newmba)) {
emsg = "IllegalStateException for notification "+
MessageType.getString(MessageType.CHANGE_CLUSTER_MASTER_BROKER)+
": This broker, which is the old master broker "+oldmba+
", does not have "+newmba+" as the master broker as expected";
logger.log(logger.ERROR, emsg);
sendReply(Status.ERROR, emsg, con, cmd_msg);
Broker.getBroker().exit(1, emsg, BrokerEvent.Type.ERROR);
return true;
}
}
sendReply(Status.OK, null, con, cmd_msg);
return true;
}
if (master == null) {
throw new BrokerException(Globals.getBrokerResources().getKString(
BrokerResources.X_CLUSTER_NO_MASTER_BROKER_REJECT_CHANGE_MASTER),
Status.PRECONDITION_FAILED);
}
if (newmba.equals(master)) {
logger.log(logger.INFO, Globals.getBrokerResources().getKString(
BrokerResources.I_CLUSTER_CHANGE_MASTER_BROKER_SAME, newmba));
sendReply(Status.OK, null, con, cmd_msg);
return true;
}
if (oldmba == null) {
oldmba = master;
}
if (!oldmba.equals(master)) {
throw new BrokerException(Globals.getBrokerResources().getKString(
BrokerResources.X_CLUSTER_CHANGE_MASTER_BROKER_MISMATCH,
oldmba.toString(), master), Status.PRECONDITION_FAILED);
}
if (!self.equals(master)) {
if (!Globals.isJMSRAManagedBroker()) {
throw new BrokerException(Globals.getBrokerResources().getKString(
BrokerResources.X_CLUSTER_THIS_BROKER_NOT_MASTER_BROKER_REJECT_CHANGE_MASTER,