Skip to content

Commit 284f32c

Browse files
author
Gagan Singh Saini
committed
Resolving Comments
Signed-off-by: Gagan Singh Saini <[email protected]>
1 parent 22d6926 commit 284f32c

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

server/src/main/java/org/opensearch/cluster/routing/allocation/DiskThresholdSettings.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ public class DiskThresholdSettings {
6060
Setting.Property.Dynamic,
6161
Setting.Property.NodeScope
6262
);
63+
public static final Setting<Boolean> CLUSTER_ROUTING_ALLOCATION_WARM_DISK_THRESHOLD_ENABLED_SETTING = Setting.boolSetting(
64+
"cluster.routing.allocation.disk.warm_threshold_enabled",
65+
true,
66+
Setting.Property.Dynamic,
67+
Setting.Property.NodeScope
68+
);
6369
public static final Setting<Boolean> ENABLE_FOR_SINGLE_DATA_NODE = Setting.boolSetting(
6470
"cluster.routing.allocation.disk.watermark.enable_for_single_data_node",
6571
false,
@@ -118,6 +124,7 @@ public class DiskThresholdSettings {
118124
private volatile boolean includeRelocations;
119125
private volatile boolean createIndexBlockAutoReleaseEnabled;
120126
private volatile boolean enabled;
127+
private volatile boolean warmThresholdEnabled;
121128
private volatile TimeValue rerouteInterval;
122129
private volatile Double freeDiskThresholdFloodStage;
123130
private volatile ByteSizeValue freeBytesThresholdFloodStage;
@@ -144,13 +151,15 @@ public DiskThresholdSettings(Settings settings, ClusterSettings clusterSettings)
144151
this.includeRelocations = CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING.get(settings);
145152
this.rerouteInterval = CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL_SETTING.get(settings);
146153
this.enabled = CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.get(settings);
154+
this.warmThresholdEnabled = CLUSTER_ROUTING_ALLOCATION_WARM_DISK_THRESHOLD_ENABLED_SETTING.get(settings);
147155
this.createIndexBlockAutoReleaseEnabled = CLUSTER_CREATE_INDEX_BLOCK_AUTO_RELEASE.get(settings);
148156
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING, this::setLowWatermark);
149157
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING, this::setHighWatermark);
150158
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_DISK_FLOOD_STAGE_WATERMARK_SETTING, this::setFloodStage);
151159
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING, this::setIncludeRelocations);
152160
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL_SETTING, this::setRerouteInterval);
153161
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING, this::setEnabled);
162+
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_WARM_DISK_THRESHOLD_ENABLED_SETTING, this::setWarmThresholdEnabled);
154163
clusterSettings.addSettingsUpdateConsumer(CLUSTER_CREATE_INDEX_BLOCK_AUTO_RELEASE, this::setCreateIndexBlockAutoReleaseEnabled);
155164
}
156165

@@ -316,6 +325,10 @@ private void setEnabled(boolean enabled) {
316325
this.enabled = enabled;
317326
}
318327

328+
private void setWarmThresholdEnabled(boolean enabled) {
329+
this.warmThresholdEnabled = enabled;
330+
}
331+
319332
private void setLowWatermark(String lowWatermark) {
320333
// Watermark is expressed in terms of used data, but we need "free" data watermark
321334
this.lowWatermarkRaw = lowWatermark;
@@ -395,6 +408,10 @@ public boolean isEnabled() {
395408
return enabled;
396409
}
397410

411+
public boolean isWarmThresholdEnabled() {
412+
return warmThresholdEnabled;
413+
}
414+
398415
public TimeValue getRerouteInterval() {
399416
return rerouteInterval;
400417
}

server/src/main/java/org/opensearch/cluster/routing/allocation/decider/DiskThresholdDecider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing
169169

170170
// For this case WarmDiskThresholdDecider Decider will take decision
171171
if (REMOTE_CAPABLE.equals(getNodePool(node)) && REMOTE_CAPABLE.equals(getShardPool(shardRouting, allocation))) {
172-
return super.canAllocate(shardRouting, node, allocation);
172+
return Decision.ALWAYS;
173173
} else if (REMOTE_CAPABLE.equals(getShardPool(shardRouting, allocation))) {
174174
return Decision.NO;
175175
}
@@ -439,7 +439,7 @@ public Decision canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAl
439439

440440
// For this case WarmDiskThresholdDecider Decider will take decision
441441
if (REMOTE_CAPABLE.equals(getNodePool(node)) && REMOTE_CAPABLE.equals(getShardPool(shardRouting, allocation))) {
442-
return super.canAllocate(shardRouting, node, allocation);
442+
return Decision.ALWAYS;
443443
} else if (REMOTE_CAPABLE.equals(getShardPool(shardRouting, allocation))) {
444444
return Decision.NO;
445445
}

server/src/main/java/org/opensearch/cluster/routing/allocation/decider/WarmDiskThresholdDecider.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ private long calculateTotalAddressableRemoteSize(RoutingNode node, RoutingAlloca
287287

288288
private Decision earlyTerminate(RoutingNode node, RoutingAllocation allocation) {
289289
// Always allow allocation if the decider is disabled
290-
if (diskThresholdSettings.isEnabled() == false) {
291-
return allocation.decision(Decision.YES, NAME, "the disk threshold decider is disabled");
290+
if (diskThresholdSettings.isWarmThresholdEnabled() == false) {
291+
return allocation.decision(Decision.YES, NAME, "the warm disk threshold decider is disabled");
292292
}
293293

294294
// Allow allocation regardless if only a single data node is available
@@ -316,6 +316,12 @@ private Decision earlyTerminate(RoutingNode node, RoutingAllocation allocation)
316316
}
317317
return allocation.decision(Decision.YES, NAME, "File Cache Stat is unavailable");
318318
}
319+
320+
double remoteDataRatio = fileCacheSettings.getRemoteDataRatio();
321+
if (remoteDataRatio == 0) {
322+
return allocation.decision(Decision.YES, NAME, "Remote data ratio is set to 0, no limit on allocation");
323+
}
324+
319325
return null;
320326
}
321327

0 commit comments

Comments
 (0)