diff --git a/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java b/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java index 5dcf23ae52294..bd07e4bdcc60c 100644 --- a/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java +++ b/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java @@ -697,6 +697,7 @@ public void apply(Settings value, Settings current, Settings previous) { // Settings related to Searchable Snapshots Node.NODE_SEARCH_CACHE_SIZE_SETTING, + Node.NODE_SEARCH_CACHE_BLOCK_SHIFT_SETTING, FileCacheSettings.DATA_TO_FILE_CACHE_SIZE_RATIO_SETTING, // Settings related to Remote Refresh Segment Pressure diff --git a/server/src/main/java/org/opensearch/node/Node.java b/server/src/main/java/org/opensearch/node/Node.java index 96a716af7f1a1..33093a89123be 100644 --- a/server/src/main/java/org/opensearch/node/Node.java +++ b/server/src/main/java/org/opensearch/node/Node.java @@ -383,6 +383,13 @@ public class Node implements Closeable { Property.NodeScope ); + public static final Setting NODE_SEARCH_CACHE_BLOCK_SHIFT_SETTING = new Setting<>( + "node.search.cache.block_size", + s -> (DiscoveryNode.isDedicatedSearchNode(s)) ? "23" : ZERO, + Node::validateFileCacheBlockSizeShift, + Property.NodeScope + ); + private static final String CLIENT_TYPE = "node"; /** @@ -2061,6 +2068,21 @@ private static String validateFileCacheSize(String capacityRaw) { return capacityRaw; } + private static String validateFileCacheBlockSizeShift(String blockSizeShiftRaw) { + int shift = Integer.parseInt(blockSizeShiftRaw); + if (shift >= 31 || shift <= 10) { + throw new SettingsException( + "Unable to initialize the " + + DiscoveryNodeRole.SEARCH_ROLE.roleName() + + " node: " + + NODE_SEARCH_CACHE_BLOCK_SHIFT_SETTING.getKey() + + " must be between 10 and 30" + ); + } + + return blockSizeShiftRaw; + } + /** * Returns the {@link FileCache} instance for remote search node * Note: Visible for testing