|
@@ -59,6 +59,8 @@ import static org.elasticsearch.cluster.InternalClusterInfoService.shardIdentifi
|
|
|
*/
|
|
|
public class DiskThresholdDecider extends AllocationDecider {
|
|
|
|
|
|
+ public static final String NAME = "disk_threshold";
|
|
|
+
|
|
|
private volatile Double freeDiskThresholdLow;
|
|
|
private volatile Double freeDiskThresholdHigh;
|
|
|
private volatile ByteSizeValue freeBytesThresholdLow;
|
|
@@ -129,11 +131,11 @@ public class DiskThresholdDecider extends AllocationDecider {
|
|
|
|
|
|
public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) {
|
|
|
if (!enabled) {
|
|
|
- return allocation.decision(Decision.YES, "disk threshold decider disabled");
|
|
|
+ return allocation.decision(Decision.YES, NAME, "disk threshold decider disabled");
|
|
|
}
|
|
|
// Allow allocation regardless if only a single node is available
|
|
|
if (allocation.nodes().size() <= 1) {
|
|
|
- return allocation.decision(Decision.YES, "only a single node is present");
|
|
|
+ return allocation.decision(Decision.YES, NAME, "only a single node is present");
|
|
|
}
|
|
|
|
|
|
ClusterInfo clusterInfo = allocation.clusterInfo();
|
|
@@ -141,7 +143,7 @@ public class DiskThresholdDecider extends AllocationDecider {
|
|
|
if (logger.isTraceEnabled()) {
|
|
|
logger.trace("Cluster info unavailable for disk threshold decider, allowing allocation.");
|
|
|
}
|
|
|
- return allocation.decision(Decision.YES, "cluster info unavailable");
|
|
|
+ return allocation.decision(Decision.YES, NAME, "cluster info unavailable");
|
|
|
}
|
|
|
|
|
|
Map<String, DiskUsage> usages = clusterInfo.getNodeDiskUsages();
|
|
@@ -150,7 +152,7 @@ public class DiskThresholdDecider extends AllocationDecider {
|
|
|
if (logger.isTraceEnabled()) {
|
|
|
logger.trace("Unable to determine disk usages for disk-aware allocation, allowing allocation");
|
|
|
}
|
|
|
- return allocation.decision(Decision.YES, "disk usages unavailable");
|
|
|
+ return allocation.decision(Decision.YES, NAME, "disk usages unavailable");
|
|
|
}
|
|
|
|
|
|
DiskUsage usage = usages.get(node.nodeId());
|
|
@@ -175,7 +177,7 @@ public class DiskThresholdDecider extends AllocationDecider {
|
|
|
logger.debug("Less than the required {} free bytes threshold ({} bytes free) on node {}, preventing allocation",
|
|
|
freeBytesThresholdLow, freeBytes, node.nodeId());
|
|
|
}
|
|
|
- return allocation.decision(Decision.NO, "less than required [%s] free on node, free: [%s]",
|
|
|
+ return allocation.decision(Decision.NO, NAME, "less than required [%s] free on node, free: [%s]",
|
|
|
freeBytesThresholdLow, new ByteSizeValue(freeBytes));
|
|
|
}
|
|
|
if (freeDiskPercentage < freeDiskThresholdLow) {
|
|
@@ -183,7 +185,7 @@ public class DiskThresholdDecider extends AllocationDecider {
|
|
|
logger.debug("Less than the required {}% free disk threshold ({}% free) on node [{}], preventing allocation",
|
|
|
freeDiskThresholdLow, freeDiskPercentage, node.nodeId());
|
|
|
}
|
|
|
- return allocation.decision(Decision.NO, "less than required [%d%%] free disk on node, free: [%d%%]",
|
|
|
+ return allocation.decision(Decision.NO, NAME, "less than required [%d%%] free disk on node, free: [%d%%]",
|
|
|
freeDiskThresholdLow, freeDiskThresholdLow);
|
|
|
}
|
|
|
|
|
@@ -195,26 +197,26 @@ public class DiskThresholdDecider extends AllocationDecider {
|
|
|
if (freeBytesAfterShard < freeBytesThresholdHigh.bytes()) {
|
|
|
logger.warn("After allocating, node [{}] would have less than the required {} free bytes threshold ({} bytes free), preventing allocation",
|
|
|
node.nodeId(), freeBytesThresholdHigh, freeBytesAfterShard);
|
|
|
- return allocation.decision(Decision.NO, "after allocation less than required [%s] free on node, free: [%s]",
|
|
|
+ return allocation.decision(Decision.NO, NAME, "after allocation less than required [%s] free on node, free: [%s]",
|
|
|
freeBytesThresholdLow, new ByteSizeValue(freeBytesAfterShard));
|
|
|
}
|
|
|
if (freeSpaceAfterShard < freeDiskThresholdHigh) {
|
|
|
logger.warn("After allocating, node [{}] would have less than the required {}% free disk threshold ({}% free), preventing allocation",
|
|
|
node.nodeId(), freeDiskThresholdHigh, freeSpaceAfterShard);
|
|
|
- return allocation.decision(Decision.NO, "after allocation less than required [%d%%] free disk on node, free: [%d%%]",
|
|
|
+ return allocation.decision(Decision.NO, NAME, "after allocation less than required [%d%%] free disk on node, free: [%d%%]",
|
|
|
freeDiskThresholdLow, freeSpaceAfterShard);
|
|
|
}
|
|
|
|
|
|
- return allocation.decision(Decision.YES, "enough disk for shard on node, free: [%s]", new ByteSizeValue(freeBytes));
|
|
|
+ return allocation.decision(Decision.YES, NAME, "enough disk for shard on node, free: [%s]", new ByteSizeValue(freeBytes));
|
|
|
}
|
|
|
|
|
|
public Decision canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) {
|
|
|
if (!enabled) {
|
|
|
- return allocation.decision(Decision.YES, "disk threshold decider disabled");
|
|
|
+ return allocation.decision(Decision.YES, NAME, "disk threshold decider disabled");
|
|
|
}
|
|
|
// Allow allocation regardless if only a single node is available
|
|
|
if (allocation.nodes().size() <= 1) {
|
|
|
- return allocation.decision(Decision.YES, "only a single node is present");
|
|
|
+ return allocation.decision(Decision.YES, NAME, "only a single node is present");
|
|
|
}
|
|
|
|
|
|
ClusterInfo clusterInfo = allocation.clusterInfo();
|
|
@@ -222,7 +224,7 @@ public class DiskThresholdDecider extends AllocationDecider {
|
|
|
if (logger.isTraceEnabled()) {
|
|
|
logger.trace("Cluster info unavailable for disk threshold decider, allowing allocation.");
|
|
|
}
|
|
|
- return allocation.decision(Decision.YES, "cluster info unavailable");
|
|
|
+ return allocation.decision(Decision.YES, NAME, "cluster info unavailable");
|
|
|
}
|
|
|
|
|
|
Map<String, DiskUsage> usages = clusterInfo.getNodeDiskUsages();
|
|
@@ -230,7 +232,7 @@ public class DiskThresholdDecider extends AllocationDecider {
|
|
|
if (logger.isTraceEnabled()) {
|
|
|
logger.trace("Unable to determine disk usages for disk-aware allocation, allowing allocation");
|
|
|
}
|
|
|
- return allocation.decision(Decision.YES, "disk usages unavailable");
|
|
|
+ return allocation.decision(Decision.YES, NAME, "disk usages unavailable");
|
|
|
}
|
|
|
|
|
|
DiskUsage usage = usages.get(node.nodeId());
|
|
@@ -255,7 +257,7 @@ public class DiskThresholdDecider extends AllocationDecider {
|
|
|
logger.debug("Less than the required {} free bytes threshold ({} bytes free) on node {}, shard cannot remain",
|
|
|
freeBytesThresholdHigh, freeBytes, node.nodeId());
|
|
|
}
|
|
|
- return allocation.decision(Decision.NO, "after allocation less than required [%s] free on node, free: [%s]",
|
|
|
+ return allocation.decision(Decision.NO, NAME, "after allocation less than required [%s] free on node, free: [%s]",
|
|
|
freeBytesThresholdHigh, new ByteSizeValue(freeBytes));
|
|
|
}
|
|
|
if (freeDiskPercentage < freeDiskThresholdHigh) {
|
|
@@ -263,11 +265,11 @@ public class DiskThresholdDecider extends AllocationDecider {
|
|
|
logger.debug("Less than the required {}% free disk threshold ({}% free) on node {}, shard cannot remain",
|
|
|
freeDiskThresholdHigh, freeDiskPercentage, node.nodeId());
|
|
|
}
|
|
|
- return allocation.decision(Decision.NO, "after allocation less than required [%d%%] free disk on node, free: [%d%%]",
|
|
|
+ return allocation.decision(Decision.NO, NAME, "after allocation less than required [%d%%] free disk on node, free: [%d%%]",
|
|
|
freeDiskThresholdHigh, freeDiskPercentage);
|
|
|
}
|
|
|
|
|
|
- return allocation.decision(Decision.YES, "enough disk for shard to remain on node, free: [%s]", new ByteSizeValue(freeBytes));
|
|
|
+ return allocation.decision(Decision.YES, NAME, "enough disk for shard to remain on node, free: [%s]", new ByteSizeValue(freeBytes));
|
|
|
}
|
|
|
|
|
|
/**
|