|
45 | 45 | import org.opensearch.common.unit.ByteSizeUnit;
|
46 | 46 | import org.opensearch.common.unit.ByteSizeValue;
|
47 | 47 | import org.opensearch.common.unit.TimeValue;
|
| 48 | +import org.opensearch.common.util.FeatureFlags; |
48 | 49 | import org.opensearch.index.translog.Translog;
|
49 | 50 | import org.opensearch.indices.replication.common.ReplicationType;
|
50 | 51 | import org.opensearch.ingest.IngestService;
|
|
59 | 60 | import java.util.function.Function;
|
60 | 61 | import java.util.function.UnaryOperator;
|
61 | 62 |
|
| 63 | +import static org.opensearch.common.util.FeatureFlags.SEARCHABLE_SNAPSHOT_EXTENDED_COMPATIBILITY; |
62 | 64 | import static org.opensearch.index.mapper.MapperService.INDEX_MAPPING_DEPTH_LIMIT_SETTING;
|
63 | 65 | import static org.opensearch.index.mapper.MapperService.INDEX_MAPPING_FIELD_NAME_LENGTH_LIMIT_SETTING;
|
64 | 66 | import static org.opensearch.index.mapper.MapperService.INDEX_MAPPING_NESTED_DOCS_LIMIT_SETTING;
|
65 | 67 | import static org.opensearch.index.mapper.MapperService.INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTING;
|
66 | 68 | import static org.opensearch.index.mapper.MapperService.INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING;
|
| 69 | +import static org.opensearch.index.store.remote.directory.RemoteSnapshotDirectory.SEARCHABLE_SNAPSHOT_EXTENDED_COMPATIBILITY_MINIMUM_VERSION; |
67 | 70 |
|
68 | 71 | /**
|
69 | 72 | * This class encapsulates all index level settings and handles settings updates.
|
@@ -585,6 +588,9 @@ public final class IndexSettings {
|
585 | 588 | private final boolean isRemoteTranslogStoreEnabled;
|
586 | 589 | private final String remoteStoreTranslogRepository;
|
587 | 590 | private final String remoteStoreRepository;
|
| 591 | + private final boolean isRemoteSnapshot; |
| 592 | + private Version extendedCompatibilitySnapshotVersion; |
| 593 | + |
588 | 594 | // volatile fields are updated via #updateIndexMetadata(IndexMetadata) under lock
|
589 | 595 | private volatile Settings settings;
|
590 | 596 | private volatile IndexMetadata indexMetadata;
|
@@ -748,6 +754,14 @@ public IndexSettings(final IndexMetadata indexMetadata, final Settings nodeSetti
|
748 | 754 | isRemoteTranslogStoreEnabled = settings.getAsBoolean(IndexMetadata.SETTING_REMOTE_TRANSLOG_STORE_ENABLED, false);
|
749 | 755 | remoteStoreTranslogRepository = settings.get(IndexMetadata.SETTING_REMOTE_TRANSLOG_STORE_REPOSITORY);
|
750 | 756 | remoteStoreRepository = settings.get(IndexMetadata.SETTING_REMOTE_STORE_REPOSITORY);
|
| 757 | + isRemoteSnapshot = IndexModule.Type.REMOTE_SNAPSHOT.match(this.settings); |
| 758 | + |
| 759 | + if (isRemoteSnapshot && FeatureFlags.isEnabled(SEARCHABLE_SNAPSHOT_EXTENDED_COMPATIBILITY)) { |
| 760 | + extendedCompatibilitySnapshotVersion = SEARCHABLE_SNAPSHOT_EXTENDED_COMPATIBILITY_MINIMUM_VERSION; |
| 761 | + } else { |
| 762 | + extendedCompatibilitySnapshotVersion = Version.CURRENT.minimumIndexCompatibilityVersion(); |
| 763 | + } |
| 764 | + |
751 | 765 | this.searchThrottled = INDEX_SEARCH_THROTTLED.get(settings);
|
752 | 766 | this.queryStringLenient = QUERY_STRING_LENIENT_SETTING.get(settings);
|
753 | 767 | this.queryStringAnalyzeWildcard = QUERY_STRING_ANALYZE_WILDCARD.get(nodeSettings);
|
@@ -1017,6 +1031,22 @@ public String getRemoteStoreTranslogRepository() {
|
1017 | 1031 | return remoteStoreTranslogRepository;
|
1018 | 1032 | }
|
1019 | 1033 |
|
| 1034 | + /** |
| 1035 | + * Returns true if this is remote/searchable snapshot |
| 1036 | + */ |
| 1037 | + public boolean isRemoteSnapshot() { |
| 1038 | + return isRemoteSnapshot; |
| 1039 | + } |
| 1040 | + |
| 1041 | + /** |
| 1042 | + * If this is a remote snapshot and the extended compatibility |
| 1043 | + * feature flag is enabled, this returns the minimum {@link Version} |
| 1044 | + * supported. In all other cases, the return value is null. |
| 1045 | + */ |
| 1046 | + public Version getExtendedCompatibilitySnapshotVersion() { |
| 1047 | + return extendedCompatibilitySnapshotVersion; |
| 1048 | + } |
| 1049 | + |
1020 | 1050 | /**
|
1021 | 1051 | * Returns the node settings. The settings returned from {@link #getSettings()} are a merged version of the
|
1022 | 1052 | * index settings and the node settings where node settings are overwritten by index settings.
|
|
0 commit comments