public class AwarenessAllocationDecider extends AllocationDecider
AllocationDecider controls shard allocation based on
awareness key-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_id key like:
node.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 Amazone 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 zone1 even if zone2 fails 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
| Modifier and Type | Field and Description |
|---|---|
static String |
CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTES |
static String |
CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP |
static String |
NAME |
deprecationLogger, logger, settings| Constructor and Description |
|---|
AwarenessAllocationDecider()
Creates a new
AwarenessAllocationDecider instance |
AwarenessAllocationDecider(Settings settings)
Creates a new
AwarenessAllocationDecider instance from given settings |
AwarenessAllocationDecider(Settings settings,
NodeSettingsService nodeSettingsService) |
| Modifier and Type | Method and Description |
|---|---|
String[] |
awarenessAttributes()
Get the attributes defined by this instance
|
Decision |
canAllocate(ShardRouting shardRouting,
RoutingNode node,
RoutingAllocation allocation)
Returns a
Decision whether the given shard routing can be
allocated on the given node. |
Decision |
canRemain(ShardRouting shardRouting,
RoutingNode node,
RoutingAllocation allocation)
Returns a
Decision whether the given shard routing can be remain
on the given node. |
canAllocate, canAllocate, canAllocate, canRebalance, canRebalancelogDeprecatedSetting, logRemovedSetting, nodeNamepublic static final String NAME
public static final String CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTES
public static final String CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP
public AwarenessAllocationDecider()
AwarenessAllocationDecider instancepublic AwarenessAllocationDecider(Settings settings)
AwarenessAllocationDecider instance from given settingssettings - Settings to use@Inject public AwarenessAllocationDecider(Settings settings, NodeSettingsService nodeSettingsService)
public String[] awarenessAttributes()
public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation)
AllocationDeciderDecision whether the given shard routing can be
allocated on the given node. The default is Decision.ALWAYS.canAllocate in class AllocationDeciderpublic Decision canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation)
AllocationDeciderDecision whether the given shard routing can be remain
on the given node. The default is Decision.ALWAYS.canRemain in class AllocationDeciderCopyright © 2009–2017. All rights reserved.