Class AllocationService
- java.lang.Object
-
- org.elasticsearch.cluster.routing.allocation.AllocationService
-
public class AllocationService extends java.lang.Object
This service manages the node allocation of a cluster. For this reason theAllocationService
keepsAllocationDeciders
to choose nodes for shard allocation. This class also manages new nodes joining the cluster and rerouting of shards.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AllocationService.CommandsResult
this class is used to describe results of applying a set ofAllocationCommand
-
Constructor Summary
Constructors Constructor Description AllocationService(AllocationDeciders allocationDeciders, ShardsAllocator shardsAllocator, ClusterInfoService clusterInfoService)
AllocationService(AllocationDeciders allocationDeciders, GatewayAllocator gatewayAllocator, ShardsAllocator shardsAllocator, ClusterInfoService clusterInfoService)
-
Method Summary
Modifier and Type Method Description ClusterState
applyFailedShard(ClusterState clusterState, ShardRouting failedShard, boolean markAsStale)
ClusterState
applyFailedShards(ClusterState clusterState, java.util.List<FailedShard> failedShards)
ClusterState
applyFailedShards(ClusterState clusterState, java.util.List<FailedShard> failedShards, java.util.List<StaleShard> staleShards)
Applies the failed shards.ClusterState
applyStartedShards(ClusterState clusterState, java.util.List<ShardRouting> startedShards)
Applies the started shards.protected ClusterState
buildResultAndLogHealthChange(ClusterState oldState, RoutingAllocation allocation, java.lang.String reason)
void
cleanCaches()
protected long
currentNanoTime()
override this to control time based decisions during allocationClusterState
disassociateDeadNodes(ClusterState clusterState, boolean reroute, java.lang.String reason)
unassigned an shards that are associated with nodes that are no longer part of the cluster, potentially promoting replicas if needed.ClusterState
reroute(ClusterState clusterState, java.lang.String reason)
Reroutes the routing table based on the live nodes.protected ClusterState
reroute(ClusterState clusterState, java.lang.String reason, boolean debug)
Reroutes the routing table based on the live nodes.AllocationService.CommandsResult
reroute(ClusterState clusterState, AllocationCommands commands, boolean explain, boolean retryFailed)
void
setGatewayAllocator(GatewayAllocator gatewayAllocator)
-
-
-
Constructor Detail
-
AllocationService
public AllocationService(AllocationDeciders allocationDeciders, GatewayAllocator gatewayAllocator, ShardsAllocator shardsAllocator, ClusterInfoService clusterInfoService)
-
AllocationService
public AllocationService(AllocationDeciders allocationDeciders, ShardsAllocator shardsAllocator, ClusterInfoService clusterInfoService)
-
-
Method Detail
-
setGatewayAllocator
public void setGatewayAllocator(GatewayAllocator gatewayAllocator)
-
applyStartedShards
public ClusterState applyStartedShards(ClusterState clusterState, java.util.List<ShardRouting> startedShards)
Applies the started shards. Note, only initializing ShardRouting instances that exist in the routing table should be provided as parameter and no duplicates should be contained.If the same instance of the
ClusterState
is returned, then no change has been made.
-
buildResultAndLogHealthChange
protected ClusterState buildResultAndLogHealthChange(ClusterState oldState, RoutingAllocation allocation, java.lang.String reason)
-
applyFailedShard
public ClusterState applyFailedShard(ClusterState clusterState, ShardRouting failedShard, boolean markAsStale)
-
applyFailedShards
public ClusterState applyFailedShards(ClusterState clusterState, java.util.List<FailedShard> failedShards)
-
applyFailedShards
public ClusterState applyFailedShards(ClusterState clusterState, java.util.List<FailedShard> failedShards, java.util.List<StaleShard> staleShards)
Applies the failed shards. Note, only assigned ShardRouting instances that exist in the routing table should be provided as parameter. Also applies a list of allocation ids to remove from the in-sync set for shard copies for which there are no routing entries in the routing table.If the same instance of ClusterState is returned, then no change has been made.
-
disassociateDeadNodes
public ClusterState disassociateDeadNodes(ClusterState clusterState, boolean reroute, java.lang.String reason)
unassigned an shards that are associated with nodes that are no longer part of the cluster, potentially promoting replicas if needed.
-
reroute
public AllocationService.CommandsResult reroute(ClusterState clusterState, AllocationCommands commands, boolean explain, boolean retryFailed)
-
reroute
public ClusterState reroute(ClusterState clusterState, java.lang.String reason)
Reroutes the routing table based on the live nodes.If the same instance of ClusterState is returned, then no change has been made.
-
reroute
protected ClusterState reroute(ClusterState clusterState, java.lang.String reason, boolean debug)
Reroutes the routing table based on the live nodes.If the same instance of ClusterState is returned, then no change has been made.
-
currentNanoTime
protected long currentNanoTime()
override this to control time based decisions during allocation
-
cleanCaches
public void cleanCaches()
-
-