Skip to content

Commit

Permalink
Add support to create index with remote store by default
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Bansal <bansvaru@amazon.com>
  • Loading branch information
linuxpi committed Apr 2, 2023
1 parent 285b450 commit 41b9ae8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions distribution/src/config/opensearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ ${path.logs}
#
#action.destructive_requires_name: true
#
# ---------------------------------- Remote Store -----------------------------------
# Controls whether cluster imposes index creation only with remote store enabled
#opensearch.remote_store.enabled.force: true
#
#
# Repository to use while enforcing remote store for an index
# opensearch.remote_store.repo.default: my-repo-1
#
# ---------------------------------- Experimental Features -----------------------------------
#
# Gates the visibility of the index setting that allows changing of replication type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import org.opensearch.common.settings.IndexScopedSettings;
import org.opensearch.common.settings.Setting;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.util.FeatureFlags;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.common.xcontent.XContentHelper;
import org.opensearch.env.Environment;
Expand All @@ -91,6 +92,7 @@
import org.opensearch.indices.InvalidIndexNameException;
import org.opensearch.indices.ShardLimitValidator;
import org.opensearch.indices.SystemIndices;
import org.opensearch.indices.replication.common.ReplicationType;
import org.opensearch.threadpool.ThreadPool;

import java.io.IOException;
Expand Down Expand Up @@ -123,6 +125,9 @@
import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_INDEX_UUID;
import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS;
import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS;
import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_REMOTE_STORE_ENABLED;
import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_REMOTE_STORE_REPOSITORY;
import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_REPLICATION_TYPE;
import static org.opensearch.cluster.metadata.Metadata.DEFAULT_REPLICA_COUNT_SETTING;

/**
Expand Down Expand Up @@ -874,6 +879,8 @@ static Settings aggregateIndexSettings(
indexSettingsBuilder.put(IndexMetadata.SETTING_INDEX_PROVIDED_NAME, request.getProvidedName());
indexSettingsBuilder.put(SETTING_INDEX_UUID, UUIDs.randomBase64UUID());

updateRemoteStoreSettings(indexSettingsBuilder);

if (sourceMetadata != null) {
assert request.resizeType() != null;
prepareResizeIndexSettings(
Expand Down Expand Up @@ -906,6 +913,17 @@ static Settings aggregateIndexSettings(
return indexSettings;
}

private static void updateRemoteStoreSettings(Settings.Builder settings) {
if (FeatureFlags.isEnabled(FeatureFlags.REMOTE_STORE) && FeatureFlags.isEnabled(FeatureFlags.REPLICATION_TYPE)) {
if ("true".equalsIgnoreCase(System.getProperty("opensearch.remote_store.enabled.force"))) {
settings
.put(SETTING_REPLICATION_TYPE, ReplicationType.SEGMENT)
.put(SETTING_REMOTE_STORE_ENABLED, "true")
.put(SETTING_REMOTE_STORE_REPOSITORY, System.getProperty("opensearch.remote_store.repo.default")).build();
}
}
}

public static void validateStoreTypeSettings(Settings settings) {
// deprecate simplefs store type:
if (IndexModule.Type.SIMPLEFS.match(IndexModule.INDEX_STORE_TYPE_SETTING.get(settings))) {
Expand Down

0 comments on commit 41b9ae8

Please sign in to comment.