only send intiial state recived after sending join request, just when we actually get a new cluster state that includes us. Also, handle no nodes to send to with generic transport nodes action.
This commit is contained in:
parent
a0ead02299
commit
d0cdbeffba
|
@ -19,15 +19,22 @@
|
|||
|
||||
package org.elasticsearch.action;
|
||||
|
||||
import org.elasticsearch.index.shard.IndexShardException;
|
||||
import org.elasticsearch.ElasticSearchException;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class PrimaryNotStartedActionException extends IndexShardException {
|
||||
public class PrimaryNotStartedActionException extends ElasticSearchException {
|
||||
|
||||
public PrimaryNotStartedActionException(ShardId shardId, String message) {
|
||||
super(shardId, message);
|
||||
super(buildMessage(shardId, message));
|
||||
}
|
||||
|
||||
private static String buildMessage(ShardId shardId, String message) {
|
||||
if (shardId == null) {
|
||||
return message;
|
||||
}
|
||||
return "[" + shardId.index() + "][" + shardId.id() + "]" + message;
|
||||
}
|
||||
}
|
|
@ -88,7 +88,6 @@ public abstract class TransportNodesOperationAction<Request extends NodesOperati
|
|||
return nodesIds;
|
||||
}
|
||||
|
||||
|
||||
private class AsyncAction {
|
||||
|
||||
private final Request request;
|
||||
|
@ -117,11 +116,27 @@ public abstract class TransportNodesOperationAction<Request extends NodesOperati
|
|||
nodesIds[index++] = node.id();
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < nodesIds.length; i++) {
|
||||
if (nodesIds[i].equals("_local")) {
|
||||
nodesIds[i] = clusterState.nodes().localNodeId();
|
||||
} else if (nodesIds[i].equals("_master")) {
|
||||
nodesIds[i] = clusterState.nodes().masterNodeId();
|
||||
}
|
||||
}
|
||||
this.nodesIds = filterNodeIds(clusterState.nodes(), nodesIds);
|
||||
this.responses = new AtomicReferenceArray<Object>(nodesIds.length);
|
||||
this.responses = new AtomicReferenceArray<Object>(this.nodesIds.length);
|
||||
}
|
||||
|
||||
private void start() {
|
||||
if (nodesIds.length == 0) {
|
||||
// nothing to notify
|
||||
threadPool.execute(new Runnable() {
|
||||
@Override public void run() {
|
||||
listener.onResponse(newResponse(request, responses));
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
for (final String nodeId : nodesIds) {
|
||||
final DiscoveryNode node = clusterState.nodes().nodes().get(nodeId);
|
||||
if (nodeId.equals("_local") || nodeId.equals(clusterState.nodes().localNodeId())) {
|
||||
|
|
|
@ -137,8 +137,10 @@ public class InternalClusterService extends AbstractLifecycleComponent<ClusterSe
|
|||
updateTasksExecutor.execute(new Runnable() {
|
||||
@Override public void run() {
|
||||
if (!lifecycle.started()) {
|
||||
logger.debug("processing [{}]: ignoring, cluster_service not started", source);
|
||||
return;
|
||||
}
|
||||
logger.debug("processing [{}]: execute", source);
|
||||
ClusterState previousClusterState = clusterState;
|
||||
try {
|
||||
clusterState = updateTask.execute(previousClusterState);
|
||||
|
@ -215,6 +217,10 @@ public class InternalClusterService extends AbstractLifecycleComponent<ClusterSe
|
|||
if (updateTask instanceof ProcessedClusterStateUpdateTask) {
|
||||
((ProcessedClusterStateUpdateTask) updateTask).clusterStateProcessed(clusterState);
|
||||
}
|
||||
|
||||
logger.debug("processing [{}]: done applying updated cluster_state", source);
|
||||
} else {
|
||||
logger.debug("processing [{}]: no change in cluster_state", source);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -291,7 +291,8 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
}
|
||||
|
||||
@Override public void clusterStateProcessed(ClusterState clusterState) {
|
||||
sendInitialStateEventIfNeeded();
|
||||
// don't send initial state event, since we want to get the cluster state from the master that includes us first
|
||||
// sendInitialStateEventIfNeeded();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue