From 021eb08f52f94f4d992a0529340137cf4f4220f6 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Mon, 15 Jul 2024 09:10:56 -0700 Subject: [PATCH] Add cluster setting for searchable snapshot local cache block size --- .../common/settings/ClusterSettings.java | 1 + .../main/java/org/opensearch/node/Node.java | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) 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