|
@@ -20,14 +20,20 @@
|
|
|
package org.elasticsearch.gateway;
|
|
|
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
+import org.elasticsearch.cluster.routing.RoutingNode;
|
|
|
import org.elasticsearch.cluster.routing.RoutingNodes;
|
|
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
|
|
import org.elasticsearch.cluster.routing.allocation.AllocateUnassignedDecision;
|
|
|
import org.elasticsearch.cluster.routing.allocation.AllocationDecision;
|
|
|
+import org.elasticsearch.cluster.routing.allocation.NodeAllocationResult;
|
|
|
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
|
|
|
+import org.elasticsearch.cluster.routing.allocation.decider.Decision;
|
|
|
import org.elasticsearch.common.component.AbstractComponent;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* An abstract class that implements basic functionality for allocating
|
|
|
* shards to nodes based on shard copies that already exist in the cluster.
|
|
@@ -85,4 +91,17 @@ public abstract class BaseGatewayShardAllocator extends AbstractComponent {
|
|
|
public abstract AllocateUnassignedDecision makeAllocationDecision(ShardRouting unassignedShard,
|
|
|
RoutingAllocation allocation,
|
|
|
Logger logger);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Builds decisions for all nodes in the cluster, so that the explain API can provide information on
|
|
|
+ * allocation decisions for each node, while still waiting to allocate the shard (e.g. due to fetching shard data).
|
|
|
+ */
|
|
|
+ protected List<NodeAllocationResult> buildDecisionsForAllNodes(ShardRouting shard, RoutingAllocation allocation) {
|
|
|
+ List<NodeAllocationResult> results = new ArrayList<>();
|
|
|
+ for (RoutingNode node : allocation.routingNodes()) {
|
|
|
+ Decision decision = allocation.deciders().canAllocate(shard, node, allocation);
|
|
|
+ results.add(new NodeAllocationResult(node.node(), null, decision));
|
|
|
+ }
|
|
|
+ return results;
|
|
|
+ }
|
|
|
}
|