Class DiskThresholdDecider



  • public class DiskThresholdDecider
    extends AllocationDecider
    The 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).
    • Field Detail

      • CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED

        public static final String CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED
        See Also:
        Constant Field Values
      • CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK

        public static final String CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK
        See Also:
        Constant Field Values
      • CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK

        public static final String CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK
        See Also:
        Constant Field Values
      • CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS

        public static final String CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS
        See Also:
        Constant Field Values
      • CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL

        public static final String CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL
        See Also:
        Constant Field Values
    • Method Detail

      • getFreeDiskThresholdLow

        public Double getFreeDiskThresholdLow()
      • getFreeDiskThresholdHigh

        public Double getFreeDiskThresholdHigh()
      • getUsedDiskThresholdLow

        public Double getUsedDiskThresholdLow()
      • getUsedDiskThresholdHigh

        public Double getUsedDiskThresholdHigh()
      • getFreeBytesThresholdLow

        public ByteSizeValue getFreeBytesThresholdLow()
      • getFreeBytesThresholdHigh

        public ByteSizeValue getFreeBytesThresholdHigh()
      • isIncludeRelocations

        public boolean isIncludeRelocations()
      • isEnabled

        public boolean isEnabled()
      • getRerouteInterval

        public TimeValue getRerouteInterval()
      • sizeOfRelocatingShards

        public long sizeOfRelocatingShards(RoutingNode node,
                                           Map<String,Long> shardSizes,
                                           boolean subtractShardsMovingAway)
        Returns the size of all shards that are currently being relocated to the node, but may not be finished transfering yet. If subtractShardsMovingAway is set then the size of shards moving away is subtracted from the total size of all shards
      • averageUsage

        public DiskUsage averageUsage(RoutingNode node,
                                      Map<String,DiskUsage> usages)
        Returns a DiskUsage for the RoutingNode using the average usage of other nodes in the disk usage map.
        Parameters:
        node - Node to return an averaged DiskUsage object for
        usages - Map of nodeId to DiskUsage for all known nodes
        Returns:
        DiskUsage representing given node using the average disk usage
      • freeDiskPercentageAfterShardAssigned

        public double freeDiskPercentageAfterShardAssigned(DiskUsage usage,
                                                           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.
        Parameters:
        usage - A DiskUsage for the node to have space computed for
        shardSize - Size in bytes of the shard
        Returns:
        Percentage of free space after the shard is assigned to the node
      • thresholdPercentageFromWatermark

        public double thresholdPercentageFromWatermark(String watermark)
        Attempts to parse the watermark into a percentage, returning 100.0% if it cannot be parsed.
      • thresholdBytesFromWatermark

        public ByteSizeValue thresholdBytesFromWatermark(String watermark)
        Attempts to parse the watermark into a ByteSizeValue, returning a ByteSizeValue of 0 bytes if the value cannot be parsed.
      • validWatermarkSetting

        public boolean validWatermarkSetting(String watermark)
        Checks if a watermark string is a valid percentage or byte size value, returning true if valid, false if invalid.