Skip to content

Commit

Permalink
Updated the validation for search only replica settings (#17093)
Browse files Browse the repository at this point in the history
* Updated the validation for search only replica settings

Signed-off-by: Vinay Krishna Pudyodu <[email protected]>

* Added Changelog and fixed style issues

Signed-off-by: Vinay Krishna Pudyodu <[email protected]>

* Removed the tests as its already covered in SearchOnlyReplicaTests

Signed-off-by: Vinay Krishna Pudyodu <[email protected]>

* Removed the changelog entry as there is not userfacing changes

Signed-off-by: Vinay Krishna Pudyodu <[email protected]>

---------

Signed-off-by: Vinay Krishna Pudyodu <[email protected]>
  • Loading branch information
vinaykpud authored Feb 4, 2025
1 parent b82ed5a commit 865704b
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1055,9 +1055,6 @@ static Settings aggregateIndexSettings(

updateReplicationStrategy(indexSettingsBuilder, request.settings(), settings, combinedTemplateSettings, clusterSettings);
updateRemoteStoreSettings(indexSettingsBuilder, currentState, clusterSettings, settings, request.index());
if (FeatureFlags.isEnabled(FeatureFlags.READER_WRITER_SPLIT_EXPERIMENTAL_SETTING)) {
updateSearchOnlyReplicas(request.settings(), indexSettingsBuilder);
}

if (sourceMetadata != null) {
assert request.resizeType() != null;
Expand Down Expand Up @@ -1094,18 +1091,20 @@ static Settings aggregateIndexSettings(
validateRefreshIntervalSettings(request.settings(), clusterSettings);
validateTranslogFlushIntervalSettingsForCompositeIndex(request.settings(), clusterSettings);
validateTranslogDurabilitySettings(request.settings(), clusterSettings, settings);
if (FeatureFlags.isEnabled(FeatureFlags.READER_WRITER_SPLIT_EXPERIMENTAL_SETTING)) {
validateSearchOnlyReplicasSettings(indexSettings);
}
return indexSettings;
}

private static void updateSearchOnlyReplicas(Settings requestSettings, Settings.Builder builder) {
if (INDEX_NUMBER_OF_SEARCH_REPLICAS_SETTING.exists(builder) && builder.get(SETTING_NUMBER_OF_SEARCH_REPLICAS) != null) {
if (INDEX_NUMBER_OF_SEARCH_REPLICAS_SETTING.get(requestSettings) > 0
&& Boolean.parseBoolean(builder.get(SETTING_REMOTE_STORE_ENABLED)) == false) {
private static void validateSearchOnlyReplicasSettings(Settings indexSettings) {
if (INDEX_NUMBER_OF_SEARCH_REPLICAS_SETTING.exists(indexSettings) && indexSettings.get(SETTING_NUMBER_OF_SEARCH_REPLICAS) != null) {
if (INDEX_NUMBER_OF_SEARCH_REPLICAS_SETTING.get(indexSettings) > 0
&& Boolean.parseBoolean(indexSettings.get(SETTING_REMOTE_STORE_ENABLED)) == false) {
throw new IllegalArgumentException(
"To set " + SETTING_NUMBER_OF_SEARCH_REPLICAS + ", " + SETTING_REMOTE_STORE_ENABLED + " must be set to true"
);
}
builder.put(SETTING_NUMBER_OF_SEARCH_REPLICAS, INDEX_NUMBER_OF_SEARCH_REPLICAS_SETTING.get(requestSettings));
}
}

Expand Down

0 comments on commit 865704b

Please sign in to comment.