public class BalancedShardsAllocator extends AbstractComponent implements ShardsAllocator
BalancedShardsAllocator
re-balances the nodes allocations
within an cluster based on a BalancedShardsAllocator.WeightFunction
. The clusters balance is defined by four parameters which can be set
in the cluster update API that allows changes in real-time:
cluster.routing.allocation.balance.shard
- The shard balance defines the weight factor
for shards allocated on a RoutingNode
cluster.routing.allocation.balance.index
- The index balance defines a factor to the number
of ShardRouting
s per index allocated on a specific nodecluster.routing.allocation.balance.primary
- the primary balance defines a weight factor for
the number of primaries of a specific index allocated on a nodecluster.routing.allocation.balance.threshold
- A threshold to set the minimal optimization
value of operations that should be performedBalancedShardsAllocator.WeightFunction
that allows calculation of node weights which
are used to re-balance shards based on global as well as per-index factors.Modifier and Type | Class and Description |
---|---|
static class |
BalancedShardsAllocator.Balancer
|
static class |
BalancedShardsAllocator.Operation
An enum that donates the actual operation the
BalancedShardsAllocator.WeightFunction is
applied to. |
static class |
BalancedShardsAllocator.WeightFunction
This class is the primary weight function used to create balanced over nodes and shards in the cluster.
|
Modifier and Type | Field and Description |
---|---|
static String |
SETTING_INDEX_BALANCE_FACTOR |
static String |
SETTING_PRIMARY_BALANCE_FACTOR |
static String |
SETTING_SHARD_BALANCE_FACTOR |
static String |
SETTING_THRESHOLD |
componentSettings, logger, settings
Constructor and Description |
---|
BalancedShardsAllocator(Settings settings) |
BalancedShardsAllocator(Settings settings,
NodeSettingsService nodeSettingsService) |
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.
|
float |
getIndexBalance()
Returns the index related weight factor.
|
float |
getPrimaryBalance()
Returns the primary related weight factor.
|
float |
getShardBalance()
Returns the shard related weight factor.
|
float |
getThreshold()
Returns the currently configured delta threshold
|
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 static final String SETTING_THRESHOLD
public static final String SETTING_INDEX_BALANCE_FACTOR
public static final String SETTING_SHARD_BALANCE_FACTOR
public static final String SETTING_PRIMARY_BALANCE_FACTOR
public BalancedShardsAllocator(Settings settings)
@Inject public BalancedShardsAllocator(Settings settings, NodeSettingsService nodeSettingsService)
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
public float getThreshold()
public float getIndexBalance()
public float getPrimaryBalance()
public float getShardBalance()
Copyright © 2009–2015. All rights reserved.