Module org.elasticsearch.server
Class WeightFunction
java.lang.Object
org.elasticsearch.cluster.routing.allocation.allocator.WeightFunction
This class is the primary weight function used to create balanced over nodes and shards in the cluster.
Currently this function has 3 properties:
index balance- balance property over shards per indexshard balance- balance property over shards per cluster
Each of these properties are expressed as factor such that the properties factor defines the relative
importance of the property for the weight function. For example if the weight function should calculate
the weights only based on a global (shard) balance the index balance can be set to 0.0 and will
in turn have no effect on the distribution.
-
weightindex(node, index) = indexBalance * (node.numShards(index) - avgShardsPerNode(index)) -
weightnode(node, index) = shardBalance * (node.numShards() - avgShardsPerNode)
weight(node, index) = weightindex(node, index) + weightnode(node, index)-
Constructor Summary
ConstructorsConstructorDescriptionWeightFunction(float shardBalance, float indexBalance, float writeLoadBalance, float diskUsageBalance) -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleavgDiskUsageInBytesPerNode(ClusterInfo clusterInfo, Metadata metadata, RoutingNodes routingNodes) static floatavgShardPerNode(Metadata metadata, RoutingNodes routingNodes) static doubleavgWriteLoadPerNode(WriteLoadForecaster writeLoadForecaster, Metadata metadata, RoutingNodes routingNodes) floatcalculateNodeWeight(int nodeNumShards, float avgShardsPerNode, double nodeWriteLoad, double avgWriteLoadPerNode, double diskUsageInBytes, double avgDiskUsageInBytesPerNode)
-
Constructor Details
-
WeightFunction
public WeightFunction(float shardBalance, float indexBalance, float writeLoadBalance, float diskUsageBalance)
-
-
Method Details
-
calculateNodeWeight
public float calculateNodeWeight(int nodeNumShards, float avgShardsPerNode, double nodeWriteLoad, double avgWriteLoadPerNode, double diskUsageInBytes, double avgDiskUsageInBytesPerNode) -
avgShardPerNode
-
avgWriteLoadPerNode
public static double avgWriteLoadPerNode(WriteLoadForecaster writeLoadForecaster, Metadata metadata, RoutingNodes routingNodes) -
avgDiskUsageInBytesPerNode
public static double avgDiskUsageInBytesPerNode(ClusterInfo clusterInfo, Metadata metadata, RoutingNodes routingNodes)
-