|
|
@@ -33,6 +33,7 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
|
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
import org.elasticsearch.common.unit.TimeValue;
|
|
|
+import org.elasticsearch.discovery.zen.NotMasterException;
|
|
|
import org.elasticsearch.threadpool.ThreadPool;
|
|
|
import org.elasticsearch.transport.*;
|
|
|
|
|
|
@@ -255,11 +256,11 @@ public class MasterFaultDetection extends FaultDetection {
|
|
|
if (exp instanceof ConnectTransportException || exp.getCause() instanceof ConnectTransportException) {
|
|
|
handleTransportDisconnect(masterToPing);
|
|
|
return;
|
|
|
- } else if (exp.getCause() instanceof NoLongerMasterException) {
|
|
|
+ } else if (exp.getCause() instanceof NotMasterException) {
|
|
|
logger.debug("[master] pinging a master {} that is no longer a master", masterNode);
|
|
|
notifyMasterFailure(masterToPing, "no longer master");
|
|
|
return;
|
|
|
- } else if (exp.getCause() instanceof NotMasterException) {
|
|
|
+ } else if (exp.getCause() instanceof ThisIsNotTheMasterYouAreLookingForException) {
|
|
|
logger.debug("[master] pinging a master {} that is not the master", masterNode);
|
|
|
notifyMasterFailure(masterToPing, "not master");
|
|
|
return;
|
|
|
@@ -292,20 +293,14 @@ public class MasterFaultDetection extends FaultDetection {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- static class NoLongerMasterException extends ElasticsearchIllegalStateException {
|
|
|
- @Override
|
|
|
- public Throwable fillInStackTrace() {
|
|
|
- return null;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- static class NotMasterException extends ElasticsearchIllegalStateException {
|
|
|
+ /** Thrown when a ping reaches the wrong node */
|
|
|
+ static class ThisIsNotTheMasterYouAreLookingForException extends ElasticsearchIllegalStateException {
|
|
|
|
|
|
- NotMasterException(String msg) {
|
|
|
+ ThisIsNotTheMasterYouAreLookingForException(String msg) {
|
|
|
super(msg);
|
|
|
}
|
|
|
|
|
|
- NotMasterException() {
|
|
|
+ ThisIsNotTheMasterYouAreLookingForException() {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -334,13 +329,13 @@ public class MasterFaultDetection extends FaultDetection {
|
|
|
// check if we are really the same master as the one we seemed to be think we are
|
|
|
// this can happen if the master got "kill -9" and then another node started using the same port
|
|
|
if (!request.masterNodeId.equals(nodes.localNodeId())) {
|
|
|
- throw new NotMasterException();
|
|
|
+ throw new ThisIsNotTheMasterYouAreLookingForException();
|
|
|
}
|
|
|
|
|
|
// ping from nodes of version < 1.4.0 will have the clustername set to null
|
|
|
if (request.clusterName != null && !request.clusterName.equals(clusterName)) {
|
|
|
logger.trace("master fault detection ping request is targeted for a different [{}] cluster then us [{}]", request.clusterName, clusterName);
|
|
|
- throw new NotMasterException("master fault detection ping request is targeted for a different [" + request.clusterName + "] cluster then us [" + clusterName + "]");
|
|
|
+ throw new ThisIsNotTheMasterYouAreLookingForException("master fault detection ping request is targeted for a different [" + request.clusterName + "] cluster then us [" + clusterName + "]");
|
|
|
}
|
|
|
|
|
|
// when we are elected as master or when a node joins, we use a cluster state update thread
|
|
|
@@ -360,7 +355,7 @@ public class MasterFaultDetection extends FaultDetection {
|
|
|
// if we are no longer master, fail...
|
|
|
DiscoveryNodes nodes = currentState.nodes();
|
|
|
if (!nodes.localNodeMaster()) {
|
|
|
- throw new NoLongerMasterException();
|
|
|
+ throw new NotMasterException();
|
|
|
}
|
|
|
if (!nodes.nodeExists(request.nodeId)) {
|
|
|
throw new NodeDoesNotExistOnMasterException();
|