diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/blobstore/BlobReuseExistingNodeAllocation.java b/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/blobstore/BlobReuseExistingNodeAllocation.java index 439a3891143..aabb1de3c49 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/blobstore/BlobReuseExistingNodeAllocation.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/blobstore/BlobReuseExistingNodeAllocation.java @@ -62,7 +62,7 @@ public class BlobReuseExistingNodeAllocation extends NodeAllocation { this.indicesService = indicesService; this.transportNodesListShardStoreMetaData = transportNodesListShardStoreMetaData; - this.listTimeout = componentSettings.getAsTime("list_timeout", TimeValue.timeValueSeconds(60)); + this.listTimeout = componentSettings.getAsTime("list_timeout", TimeValue.timeValueSeconds(30)); } @Override public boolean allocate(NodeAllocations nodeAllocations, RoutingNodes routingNodes, DiscoveryNodes nodes) { @@ -102,6 +102,25 @@ public class BlobReuseExistingNodeAllocation extends NodeAllocation { continue; } + // pre-check if it can be allocated to any node that currently exists, so we won't list the store for it for nothing + boolean canBeAllocatedToAtLeastOneNode = false; + for (DiscoveryNode discoNode : nodes.dataNodes().values()) { + RoutingNode node = routingNodes.node(discoNode.id()); + if (node == null) { + continue; + } + // if its THROTTLING, we are not going to allocate it to this node, so ignore it as well + if (nodeAllocations.canAllocate(shard, node, routingNodes).allocate()) { + canBeAllocatedToAtLeastOneNode = true; + break; + } + } + + if (!canBeAllocatedToAtLeastOneNode) { + continue; + } + + // go and fetch the shard store data for it TransportNodesListShardStoreMetaData.NodesStoreFilesMetaData nodesStoreFilesMetaData = transportNodesListShardStoreMetaData.list(shard.shardId(), false, nodes.dataNodes().keySet(), listTimeout).actionGet(); if (logger.isDebugEnabled()) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetaData.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetaData.java index 5d4f19ff997..e9dd75a133f 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetaData.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetaData.java @@ -26,7 +26,6 @@ import org.elasticsearch.action.support.nodes.*; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.stream.StreamInput; @@ -87,19 +86,6 @@ public class TransportNodesListShardStoreMetaData extends TransportNodesOperatio return new NodeStoreFilesMetaData(); } - /** - * We only need to ask data nodes for shard allocation information. - */ - @Override protected String[] filterNodeIds(DiscoveryNodes nodes, String[] nodesIds) { - List dataNodeIds = Lists.newArrayList(); - for (String nodeId : nodesIds) { - if (nodes.get(nodeId).dataNode()) { - dataNodeIds.add(nodeId); - } - } - return dataNodeIds.toArray(new String[dataNodeIds.size()]); - } - @Override protected NodesStoreFilesMetaData newResponse(Request request, AtomicReferenceArray responses) { final List nodeStoreFilesMetaDatas = Lists.newArrayList(); final List failures = Lists.newArrayList();