From 5b5a946024368fde0cb582674274633af723a359 Mon Sep 17 00:00:00 2001 From: Kartik Ganesh Date: Fri, 22 Apr 2022 15:59:11 -0700 Subject: [PATCH] IndexSettings now stores the ReplicationType enum instead of a boolean isSegRepEnabled is now computed on the fly by testing the stored ReplicationType value Signed-off-by: Kartik Ganesh --- .../src/main/java/org/opensearch/index/IndexSettings.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/org/opensearch/index/IndexSettings.java b/server/src/main/java/org/opensearch/index/IndexSettings.java index d93310fa794b7..b2f06b01addb6 100644 --- a/server/src/main/java/org/opensearch/index/IndexSettings.java +++ b/server/src/main/java/org/opensearch/index/IndexSettings.java @@ -531,7 +531,7 @@ public final class IndexSettings { private final String nodeName; private final Settings nodeSettings; private final int numberOfShards; - private final Boolean isSegRepEnabled; + private final ReplicationType replicationType; // volatile fields are updated via #updateIndexMetadata(IndexMetadata) under lock private volatile Settings settings; private volatile IndexMetadata indexMetadata; @@ -683,9 +683,7 @@ public IndexSettings(final IndexMetadata indexMetadata, final Settings nodeSetti nodeName = Node.NODE_NAME_SETTING.get(settings); this.indexMetadata = indexMetadata; numberOfShards = settings.getAsInt(IndexMetadata.SETTING_NUMBER_OF_SHARDS, null); - - ReplicationType replicationType = ReplicationType.parseString(settings.get(IndexMetadata.SETTING_REPLICATION_TYPE)); - isSegRepEnabled = ReplicationType.SEGMENT.equals(replicationType); + replicationType = ReplicationType.parseString(settings.get(IndexMetadata.SETTING_REPLICATION_TYPE)); this.searchThrottled = INDEX_SEARCH_THROTTLED.get(settings); this.queryStringLenient = QUERY_STRING_LENIENT_SETTING.get(settings); @@ -924,7 +922,7 @@ public int getNumberOfReplicas() { * Returns true if segment replication is enabled on the index. */ public boolean isSegrepEnabled() { - return Boolean.TRUE.equals(isSegRepEnabled); + return ReplicationType.SEGMENT.equals(replicationType); } /**