public class EvenShardsCountAllocator extends AbstractComponent implements ShardsAllocator
ShardsAllocator
that tries to balance shards across nodes in the
cluster such that each node holds approximatly the same number of shards. The
allocations algorithm operates on a cluster ie. is index-agnostic. While the
number of shards per node might be balanced across the cluster a single node
can hold mulitple shards from a single index such that the shard of an index
are not necessarily balanced across nodes. Yet, due to high-level
decisions
multiple instances of the same shard
won't be allocated on the same node.
During re-balancing
the allocator takes
shards from the most busy nodes and tries to relocate the shards to
the least busy node until the number of shards per node are equal for all
nodes in the cluster or until no shards can be relocated anymore.
componentSettings, logger, settings
Constructor and Description |
---|
EvenShardsCountAllocator(Settings settings) |
Modifier and Type | Method and Description |
---|---|
boolean |
allocateUnassigned(RoutingAllocation allocation)
Assign all unassigned shards to nodes
|
void |
applyFailedShards(FailedRerouteAllocation allocation)
Applies changes on failed nodes based on the implemented algorithm.
|
void |
applyStartedShards(StartedRerouteAllocation allocation)
Applies changes on started nodes based on the implemented algorithm.
|
boolean |
move(MutableShardRouting shardRouting,
RoutingNode node,
RoutingAllocation allocation)
Moves a shard from the given node to other node.
|
boolean |
rebalance(RoutingAllocation allocation)
Rebalancing number of shards on all nodes
|
nodeName
public void applyStartedShards(StartedRerouteAllocation allocation)
ShardsAllocator
ShardRoutingState.STARTED
from ShardRoutingState.RELOCATING
this allocator might apply some cleanups on the node that used to hold the shard.applyStartedShards
in interface ShardsAllocator
allocation
- all started shards
public void applyFailedShards(FailedRerouteAllocation allocation)
ShardsAllocator
applyFailedShards
in interface ShardsAllocator
allocation
- all failed shards
public boolean allocateUnassigned(RoutingAllocation allocation)
ShardsAllocator
allocateUnassigned
in interface ShardsAllocator
allocation
- current node allocationtrue
if the allocation has changed, otherwise false
public boolean rebalance(RoutingAllocation allocation)
ShardsAllocator
rebalance
in interface ShardsAllocator
allocation
- current node allocationtrue
if the allocation has changed, otherwise false
public boolean move(MutableShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation)
ShardsAllocator
move
in interface ShardsAllocator
shardRouting
- the shard to movenode
- A node containing the shardallocation
- current node allocationtrue
if the allocation has changed, otherwise false
Copyright © 2009–2015. All rights reserved.