From d0cdbeffba3de8165d533634a8e8a5d13d5a4039 Mon Sep 17 00:00:00 2001 From: kimchy Date: Sat, 10 Jul 2010 15:43:49 +0300 Subject: [PATCH] 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. --- .../PrimaryNotStartedActionException.java | 15 +++++++++++---- .../nodes/TransportNodesOperationAction.java | 19 +++++++++++++++++-- .../service/InternalClusterService.java | 6 ++++++ .../discovery/zen/ZenDiscovery.java | 3 ++- 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/PrimaryNotStartedActionException.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/PrimaryNotStartedActionException.java index fc73c3875da..25df2ccce27 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/PrimaryNotStartedActionException.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/PrimaryNotStartedActionException.java @@ -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; } } \ No newline at end of file diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesOperationAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesOperationAction.java index 40ea81d7f23..454e6ee0c6d 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesOperationAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesOperationAction.java @@ -88,7 +88,6 @@ public abstract class TransportNodesOperationAction(nodesIds.length); + this.responses = new AtomicReferenceArray(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())) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/service/InternalClusterService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/service/InternalClusterService.java index c93f610cfc7..3382ffe5474 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/service/InternalClusterService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/service/InternalClusterService.java @@ -137,8 +137,10 @@ public class InternalClusterService extends AbstractLifecycleComponent 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(); } }); }