Class AllocationService


  • public class AllocationService
    extends java.lang.Object
    This service manages the node allocation of a cluster. For this reason the AllocationService keeps AllocationDeciders to choose nodes for shard allocation. This class also manages new nodes joining the cluster and rerouting of shards.
    • 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.

      • 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 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