public class DiskThresholdDecider extends AllocationDecider
DiskThresholdDecider
checks that the node a shard is potentially
being allocated to has enough disk space.
It has three configurable settings, all of which can be changed dynamically:
cluster.routing.allocation.disk.watermark.low
is the low disk
watermark. New shards will not allocated to a node with usage higher than this,
although this watermark may be passed by allocating a shard. It defaults to
0.85 (85.0%).
cluster.routing.allocation.disk.watermark.high
is the high disk
watermark. If a node has usage higher than this, shards are not allowed to
remain on the node. In addition, if allocating a shard to a node causes the
node to pass this watermark, it will not be allowed. It defaults to
0.90 (90.0%).
Both watermark settings are expressed in terms of used disk percentage, or
exact byte values for free space (like "500mb")
cluster.routing.allocation.disk.threshold_enabled
is used to
enable or disable this decider. It defaults to false (disabled).Modifier and Type | Field and Description |
---|---|
static Setting<java.lang.Boolean> |
CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING |
static Setting<java.lang.String> |
CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING |
static Setting<java.lang.Boolean> |
CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING |
static Setting<java.lang.String> |
CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING |
static Setting<TimeValue> |
CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL_SETTING |
static java.lang.String |
NAME |
deprecationLogger, logger, settings
Constructor and Description |
---|
DiskThresholdDecider(Settings settings) |
DiskThresholdDecider(Settings settings,
ClusterSettings clusterSettings,
ClusterInfoService infoService,
Client client) |
Modifier and Type | Method and Description |
---|---|
DiskUsage |
averageUsage(RoutingNode node,
ImmutableOpenMap<java.lang.String,DiskUsage> usages)
Returns a
DiskUsage for the RoutingNode using the
average usage of other nodes in the disk usage map. |
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. |
double |
freeDiskPercentageAfterShardAssigned(DiskUsage usage,
java.lang.Long shardSize)
Given the DiskUsage for a node and the size of the shard, return the
percentage of free disk if the shard were to be allocated to the node.
|
ByteSizeValue |
getFreeBytesThresholdHigh() |
ByteSizeValue |
getFreeBytesThresholdLow() |
java.lang.Double |
getFreeDiskThresholdHigh() |
java.lang.Double |
getFreeDiskThresholdLow() |
TimeValue |
getRerouteInterval() |
java.lang.Double |
getUsedDiskThresholdHigh() |
java.lang.Double |
getUsedDiskThresholdLow() |
boolean |
isEnabled() |
boolean |
isIncludeRelocations() |
static long |
sizeOfRelocatingShards(RoutingNode node,
ClusterInfo clusterInfo,
boolean subtractShardsMovingAway,
java.lang.String dataPath)
Returns the size of all shards that are currently being relocated to
the node, but may not be finished transferring yet.
|
ByteSizeValue |
thresholdBytesFromWatermark(java.lang.String watermark,
java.lang.String settingName)
Attempts to parse the watermark into a
ByteSizeValue , returning
a ByteSizeValue of 0 bytes if the value cannot be parsed. |
double |
thresholdPercentageFromWatermark(java.lang.String watermark)
Attempts to parse the watermark into a percentage, returning 100.0% if
it cannot be parsed.
|
static java.lang.String |
validWatermarkSetting(java.lang.String watermark,
java.lang.String settingName)
Checks if a watermark string is a valid percentage or byte size value,
|
canAllocate, canAllocate, canAllocate, canRebalance, canRebalance
logDeprecatedSetting, logRemovedSetting, nodeName
public static final java.lang.String NAME
public static final Setting<java.lang.Boolean> CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING
public static final Setting<java.lang.String> CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING
public static final Setting<java.lang.String> CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING
public static final Setting<java.lang.Boolean> CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING
public DiskThresholdDecider(Settings settings)
@Inject public DiskThresholdDecider(Settings settings, ClusterSettings clusterSettings, ClusterInfoService infoService, Client client)
public java.lang.Double getFreeDiskThresholdLow()
public java.lang.Double getFreeDiskThresholdHigh()
public java.lang.Double getUsedDiskThresholdLow()
public java.lang.Double getUsedDiskThresholdHigh()
public ByteSizeValue getFreeBytesThresholdLow()
public ByteSizeValue getFreeBytesThresholdHigh()
public boolean isIncludeRelocations()
public boolean isEnabled()
public TimeValue getRerouteInterval()
public static long sizeOfRelocatingShards(RoutingNode node, ClusterInfo clusterInfo, boolean subtractShardsMovingAway, java.lang.String dataPath)
public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation)
AllocationDecider
Decision
whether the given shard routing can be
allocated on the given node. The default is Decision.ALWAYS
.canAllocate
in class AllocationDecider
public Decision canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation)
AllocationDecider
Decision
whether the given shard routing can be remain
on the given node. The default is Decision.ALWAYS
.canRemain
in class AllocationDecider
public DiskUsage averageUsage(RoutingNode node, ImmutableOpenMap<java.lang.String,DiskUsage> usages)
DiskUsage
for the RoutingNode
using the
average usage of other nodes in the disk usage map.node
- Node to return an averaged DiskUsage object forusages
- Map of nodeId to DiskUsage for all known nodespublic double freeDiskPercentageAfterShardAssigned(DiskUsage usage, java.lang.Long shardSize)
usage
- A DiskUsage for the node to have space computed forshardSize
- Size in bytes of the shardpublic double thresholdPercentageFromWatermark(java.lang.String watermark)
public ByteSizeValue thresholdBytesFromWatermark(java.lang.String watermark, java.lang.String settingName)
ByteSizeValue
, returning
a ByteSizeValue of 0 bytes if the value cannot be parsed.public static java.lang.String validWatermarkSetting(java.lang.String watermark, java.lang.String settingName)