Skip to content

Commit

Permalink
Add cluster setting for searchable snapshot local cache block size
Browse files Browse the repository at this point in the history
  • Loading branch information
finnegancarroll committed Jul 15, 2024
1 parent afa479b commit 021eb08
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions server/src/main/java/org/opensearch/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,13 @@ public class Node implements Closeable {
Property.NodeScope
);

public static final Setting<String> 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";

/**
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 021eb08

Please sign in to comment.