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