Skip to content

Commit

Permalink
IndexSettings now stores the ReplicationType enum instead of a boolean
Browse files Browse the repository at this point in the history
isSegRepEnabled is now computed on the fly by testing the stored ReplicationType value

Signed-off-by: Kartik Ganesh <[email protected]>
  • Loading branch information
kartg committed Apr 22, 2022
1 parent e5c27c9 commit 5b5a946
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions server/src/main/java/org/opensearch/index/IndexSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 5b5a946

Please sign in to comment.