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.threshold
- A threshold to set the minimal optimization
value of operations that should be performed
These parameters are combined in a BalancedShardsAllocator.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.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 Setting<java.lang.Float> |
INDEX_BALANCE_FACTOR_SETTING |
static Setting<java.lang.Float> |
SHARD_BALANCE_FACTOR_SETTING |
static Setting<java.lang.Float> |
THRESHOLD_SETTING |
deprecationLogger, logger, settings
Constructor and Description |
---|
BalancedShardsAllocator(Settings settings) |
BalancedShardsAllocator(Settings settings,
ClusterSettings clusterSettings) |
Modifier and Type | Method and Description |
---|---|
boolean |
allocate(RoutingAllocation allocation)
Allocates shards to nodes in the cluster.
|
float |
getIndexBalance()
Returns the index related weight factor.
|
float |
getShardBalance()
Returns the shard related weight factor.
|
float |
getThreshold()
Returns the currently configured delta threshold
|
java.util.Map<DiscoveryNode,java.lang.Float> |
weighShard(RoutingAllocation allocation,
ShardRouting shard)
Returns a map of node to a float "weight" of where the allocator would like to place the shard.
|
logDeprecatedSetting, logRemovedSetting, nodeName
public static final Setting<java.lang.Float> INDEX_BALANCE_FACTOR_SETTING
public static final Setting<java.lang.Float> SHARD_BALANCE_FACTOR_SETTING
public static final Setting<java.lang.Float> THRESHOLD_SETTING
public BalancedShardsAllocator(Settings settings)
@Inject public BalancedShardsAllocator(Settings settings, ClusterSettings clusterSettings)
public java.util.Map<DiscoveryNode,java.lang.Float> weighShard(RoutingAllocation allocation, ShardRouting shard)
ShardsAllocator
weighShard
in interface ShardsAllocator
allocation
- current node allocationshard
- shard to weighpublic boolean allocate(RoutingAllocation allocation)
ShardsAllocator
allocate
in interface ShardsAllocator
allocation
- current node allocationtrue
if the allocation has changed, otherwise false
public float getThreshold()
public float getIndexBalance()
public float getShardBalance()