Class AwarenessAllocationDecider
- java.lang.Object
-
- org.elasticsearch.common.component.AbstractComponent
-
- org.elasticsearch.cluster.routing.allocation.decider.AllocationDecider
-
- org.elasticsearch.cluster.routing.allocation.decider.AwarenessAllocationDecider
-
public class AwarenessAllocationDecider extends AllocationDecider
ThisAllocationDecidercontrols shard allocation based onawarenesskey-value pairs defined in the node configuration. Awareness explicitly controls where replicas should be allocated based on attributes like node or physical rack locations. Awareness attributes accept arbitrary configuration keys like a rack data-center identifier. For example the setting:cluster.routing.allocation.awareness.attributes: rack_id
will cause allocations to be distributed over different racks such that ideally at least one replicas of the all shard is available on the same rack. To enable allocation awareness in this example nodes should contain a value for the
rack_idkey like:node.attr.rack_id:1
Awareness can also be used to prevent over-allocation in the case of node or even "zone" failure. For example in cloud-computing infrastructures like Amazon AWS a cluster might span over multiple "zones". Awareness can be used to distribute replicas to individual zones by setting:
cluster.routing.allocation.awareness.attributes: zone
and forcing allocation to be aware of the following zone the data resides in:
cluster.routing.allocation.awareness.force.zone.values: zone1,zone2
In contrast to regular awareness this setting will prevent over-allocation on
zone1even ifzone2fails partially or becomes entirely unavailable. Nodes that belong to a certain zone / group should be started with the zone id configured on the node-level settings like:node.zone: zone1
-
-
Field Summary
Fields Modifier and Type Field Description static Setting<java.util.List<java.lang.String>>CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTE_SETTINGstatic Setting<Settings>CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP_SETTINGstatic java.lang.StringNAME-
Fields inherited from class org.elasticsearch.common.component.AbstractComponent
deprecationLogger, logger, settings
-
-
Constructor Summary
Constructors Constructor Description AwarenessAllocationDecider(Settings settings, ClusterSettings clusterSettings)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DecisioncanAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation)Returns aDecisionwhether the given shard routing can be allocated on the given node.DecisioncanRemain(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation)Returns aDecisionwhether the given shard routing can be remain on the given node.-
Methods inherited from class org.elasticsearch.common.component.AbstractComponent
logDeprecatedSetting, logRemovedSetting, nodeName
-
Methods inherited from class org.elasticsearch.cluster.routing.allocation.decider.AllocationDecider
canAllocate, canAllocate, canAllocate, canForceAllocatePrimary, canRebalance, canRebalance
-
-
-
-
Field Detail
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTE_SETTING
public static final Setting<java.util.List<java.lang.String>> CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTE_SETTING
-
-
Constructor Detail
-
AwarenessAllocationDecider
public AwarenessAllocationDecider(Settings settings, ClusterSettings clusterSettings)
-
-
Method Detail
-
canAllocate
public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation)
Description copied from class:AllocationDeciderReturns aDecisionwhether the given shard routing can be allocated on the given node. The default isDecision.ALWAYS.- Overrides:
canAllocatein classAllocationDecider
-
canRemain
public Decision canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation)
Description copied from class:AllocationDeciderReturns aDecisionwhether the given shard routing can be remain on the given node. The default isDecision.ALWAYS.- Overrides:
canRemainin classAllocationDecider
-
-