|
48 | 48 | import org.opensearch.cluster.routing.allocation.DiskThresholdSettings;
|
49 | 49 | import org.opensearch.cluster.routing.allocation.RoutingAllocation;
|
50 | 50 | import org.opensearch.common.settings.ClusterSettings;
|
51 |
| -import org.opensearch.common.settings.Setting; |
52 | 51 | import org.opensearch.common.settings.Settings;
|
53 | 52 | import org.opensearch.core.common.Strings;
|
54 | 53 | import org.opensearch.core.common.unit.ByteSizeValue;
|
55 | 54 | import org.opensearch.core.index.Index;
|
56 | 55 | import org.opensearch.core.index.shard.ShardId;
|
57 | 56 | import org.opensearch.index.store.remote.filecache.FileCacheSettings;
|
58 |
| -import org.opensearch.index.store.remote.filecache.FileCacheStats; |
59 | 57 | import org.opensearch.snapshots.SnapshotShardSizeInfo;
|
60 | 58 |
|
61 | 59 | import java.util.List;
|
62 | 60 | import java.util.Map;
|
63 | 61 | import java.util.Set;
|
64 |
| -import java.util.stream.Collectors; |
65 |
| -import java.util.stream.StreamSupport; |
66 | 62 |
|
67 | 63 | import static org.opensearch.cluster.routing.RoutingPool.REMOTE_CAPABLE;
|
68 | 64 | import static org.opensearch.cluster.routing.RoutingPool.getNodePool;
|
69 | 65 | import static org.opensearch.cluster.routing.RoutingPool.getShardPool;
|
70 | 66 | import static org.opensearch.cluster.routing.allocation.DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING;
|
71 | 67 | import static org.opensearch.cluster.routing.allocation.DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING;
|
| 68 | +import static org.opensearch.cluster.routing.allocation.DiskThresholdSettings.ENABLE_FOR_SINGLE_DATA_NODE; |
72 | 69 |
|
73 | 70 | /**
|
74 | 71 | * The {@link DiskThresholdDecider} checks that the node a shard is potentially
|
@@ -101,12 +98,6 @@ public class DiskThresholdDecider extends AllocationDecider {
|
101 | 98 |
|
102 | 99 | public static final String NAME = "disk_threshold";
|
103 | 100 |
|
104 |
| - public static final Setting<Boolean> ENABLE_FOR_SINGLE_DATA_NODE = Setting.boolSetting( |
105 |
| - "cluster.routing.allocation.disk.watermark.enable_for_single_data_node", |
106 |
| - false, |
107 |
| - Setting.Property.NodeScope |
108 |
| - ); |
109 |
| - |
110 | 101 | private final DiskThresholdSettings diskThresholdSettings;
|
111 | 102 | private final boolean enableForSingleDataNode;
|
112 | 103 | private final FileCacheSettings fileCacheSettings;
|
@@ -176,44 +167,9 @@ public static long sizeOfRelocatingShards(
|
176 | 167 | public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) {
|
177 | 168 | ClusterInfo clusterInfo = allocation.clusterInfo();
|
178 | 169 |
|
179 |
| - /* |
180 |
| - The following block enables allocation for remote shards within safeguard limits of the filecache. |
181 |
| - */ |
| 170 | + // For this case WarmDiskThresholdDecider Decider will take decision |
182 | 171 | if (REMOTE_CAPABLE.equals(getNodePool(node)) && REMOTE_CAPABLE.equals(getShardPool(shardRouting, allocation))) {
|
183 |
| - final double dataToFileCacheSizeRatio = fileCacheSettings.getRemoteDataRatio(); |
184 |
| - // we don't need to check the ratio |
185 |
| - if (dataToFileCacheSizeRatio <= 0.1f) { |
186 |
| - return Decision.YES; |
187 |
| - } |
188 |
| - |
189 |
| - final List<ShardRouting> remoteShardsOnNode = StreamSupport.stream(node.spliterator(), false) |
190 |
| - .filter(shard -> shard.primary() && REMOTE_CAPABLE.equals(getShardPool(shard, allocation))) |
191 |
| - .collect(Collectors.toList()); |
192 |
| - final long currentNodeRemoteShardSize = remoteShardsOnNode.stream() |
193 |
| - .map(ShardRouting::getExpectedShardSize) |
194 |
| - .mapToLong(Long::longValue) |
195 |
| - .sum(); |
196 |
| - |
197 |
| - final long shardSize = getExpectedShardSize( |
198 |
| - shardRouting, |
199 |
| - 0L, |
200 |
| - allocation.clusterInfo(), |
201 |
| - allocation.snapshotShardSizeInfo(), |
202 |
| - allocation.metadata(), |
203 |
| - allocation.routingTable() |
204 |
| - ); |
205 |
| - |
206 |
| - final FileCacheStats fileCacheStats = clusterInfo.getNodeFileCacheStats().getOrDefault(node.nodeId(), null); |
207 |
| - final long nodeCacheSize = fileCacheStats != null ? fileCacheStats.getTotal().getBytes() : 0; |
208 |
| - final long totalNodeRemoteShardSize = currentNodeRemoteShardSize + shardSize; |
209 |
| - if (dataToFileCacheSizeRatio > 0.0f && totalNodeRemoteShardSize > dataToFileCacheSizeRatio * nodeCacheSize) { |
210 |
| - return allocation.decision( |
211 |
| - Decision.NO, |
212 |
| - NAME, |
213 |
| - "file cache limit reached - remote shard size will exceed configured safeguard ratio" |
214 |
| - ); |
215 |
| - } |
216 |
| - return Decision.YES; |
| 172 | + return Decision.ALWAYS; |
217 | 173 | } else if (REMOTE_CAPABLE.equals(getShardPool(shardRouting, allocation))) {
|
218 | 174 | return Decision.NO;
|
219 | 175 | }
|
@@ -481,12 +437,11 @@ public Decision canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAl
|
481 | 437 | throw new IllegalArgumentException("Shard [" + shardRouting + "] is not allocated on node: [" + node.nodeId() + "]");
|
482 | 438 | }
|
483 | 439 |
|
484 |
| - /* |
485 |
| - The following block prevents movement for remote shards since they do not use the local storage as |
486 |
| - the primary source of data storage. |
487 |
| - */ |
| 440 | + // For this case WarmDiskThresholdDecider Decider will take decision |
488 | 441 | if (REMOTE_CAPABLE.equals(getNodePool(node)) && REMOTE_CAPABLE.equals(getShardPool(shardRouting, allocation))) {
|
489 | 442 | return Decision.ALWAYS;
|
| 443 | + } else if (REMOTE_CAPABLE.equals(getShardPool(shardRouting, allocation))) { |
| 444 | + return Decision.NO; |
490 | 445 | }
|
491 | 446 |
|
492 | 447 | final ClusterInfo clusterInfo = allocation.clusterInfo();
|
|
0 commit comments