Skip to content

Commit 341562b

Browse files
Add remote path settings to RemoteStoreSettings (#13225)
Signed-off-by: Ashish Singh <ssashish@amazon.com> (cherry picked from commit 9c35a84) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 630da1c commit 341562b

File tree

14 files changed

+133
-89
lines changed

14 files changed

+133
-89
lines changed

server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteRestoreSnapshotIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
import static org.opensearch.index.remote.RemoteStoreEnums.DataCategory.TRANSLOG;
6060
import static org.opensearch.index.remote.RemoteStoreEnums.DataType.DATA;
6161
import static org.opensearch.index.remote.RemoteStoreEnums.DataType.METADATA;
62-
import static org.opensearch.indices.IndicesService.CLUSTER_REMOTE_STORE_PATH_TYPE_SETTING;
62+
import static org.opensearch.indices.RemoteStoreSettings.CLUSTER_REMOTE_STORE_PATH_TYPE_SETTING;
6363
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
6464
import static org.hamcrest.Matchers.equalTo;
6565
import static org.hamcrest.Matchers.greaterThan;

server/src/main/java/org/opensearch/cluster/metadata/MetadataCreateIndexService.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
import org.opensearch.indices.IndexCreationException;
100100
import org.opensearch.indices.IndicesService;
101101
import org.opensearch.indices.InvalidIndexNameException;
102+
import org.opensearch.indices.RemoteStoreSettings;
102103
import org.opensearch.indices.ShardLimitValidator;
103104
import org.opensearch.indices.SystemIndices;
104105
import org.opensearch.indices.replication.common.ReplicationType;
@@ -192,7 +193,8 @@ public MetadataCreateIndexService(
192193
final NamedXContentRegistry xContentRegistry,
193194
final SystemIndices systemIndices,
194195
final boolean forbidPrivateIndexSettings,
195-
final AwarenessReplicaBalance awarenessReplicaBalance
196+
final AwarenessReplicaBalance awarenessReplicaBalance,
197+
final RemoteStoreSettings remoteStoreSettings
196198
) {
197199
this.settings = settings;
198200
this.clusterService = clusterService;
@@ -212,7 +214,7 @@ public MetadataCreateIndexService(
212214
createIndexTaskKey = clusterService.registerClusterManagerTask(ClusterManagerTaskKeys.CREATE_INDEX_KEY, true);
213215
Supplier<Version> minNodeVersionSupplier = () -> clusterService.state().nodes().getMinNodeVersion();
214216
remoteStorePathStrategyResolver = isRemoteDataAttributePresent(settings)
215-
? new RemoteStorePathStrategyResolver(clusterService.getClusterSettings(), minNodeVersionSupplier)
217+
? new RemoteStorePathStrategyResolver(remoteStoreSettings, minNodeVersionSupplier)
216218
: null;
217219
}
218220

server/src/main/java/org/opensearch/common/settings/ClusterSettings.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,6 @@ public void apply(Settings value, Settings current, Settings previous) {
716716

717717
IndicesService.CLUSTER_REMOTE_INDEX_RESTRICT_ASYNC_DURABILITY_SETTING,
718718
IndicesService.CLUSTER_INDEX_RESTRICT_REPLICATION_TYPE_SETTING,
719-
IndicesService.CLUSTER_REMOTE_STORE_PATH_TYPE_SETTING,
720-
IndicesService.CLUSTER_REMOTE_STORE_PATH_HASH_ALGORITHM_SETTING,
721719

722720
AdmissionControlSettings.ADMISSION_CONTROL_TRANSPORT_LAYER_MODE,
723721
CpuBasedAdmissionControllerSettings.CPU_BASED_ADMISSION_CONTROLLER_TRANSPORT_LAYER_MODE,
@@ -734,7 +732,9 @@ public void apply(Settings value, Settings current, Settings previous) {
734732

735733
RemoteStoreSettings.CLUSTER_REMOTE_INDEX_SEGMENT_METADATA_RETENTION_MAX_COUNT_SETTING,
736734
RemoteStoreSettings.CLUSTER_REMOTE_TRANSLOG_BUFFER_INTERVAL_SETTING,
737-
RemoteStoreSettings.CLUSTER_REMOTE_TRANSLOG_TRANSFER_TIMEOUT_SETTING
735+
RemoteStoreSettings.CLUSTER_REMOTE_TRANSLOG_TRANSFER_TIMEOUT_SETTING,
736+
RemoteStoreSettings.CLUSTER_REMOTE_STORE_PATH_TYPE_SETTING,
737+
RemoteStoreSettings.CLUSTER_REMOTE_STORE_PATH_HASH_ALGORITHM_SETTING
738738
)
739739
)
740740
);

server/src/main/java/org/opensearch/index/remote/RemoteStorePathStrategyResolver.java

+6-21
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
package org.opensearch.index.remote;
1010

1111
import org.opensearch.Version;
12-
import org.opensearch.common.settings.ClusterSettings;
1312
import org.opensearch.index.remote.RemoteStoreEnums.PathHashAlgorithm;
1413
import org.opensearch.index.remote.RemoteStoreEnums.PathType;
15-
import org.opensearch.indices.IndicesService;
14+
import org.opensearch.indices.RemoteStoreSettings;
1615

1716
import java.util.function.Supplier;
1817

@@ -23,35 +22,21 @@
2322
*/
2423
public class RemoteStorePathStrategyResolver {
2524

26-
private volatile PathType type;
27-
28-
private volatile PathHashAlgorithm hashAlgorithm;
29-
25+
private final RemoteStoreSettings remoteStoreSettings;
3026
private final Supplier<Version> minNodeVersionSupplier;
3127

32-
public RemoteStorePathStrategyResolver(ClusterSettings clusterSettings, Supplier<Version> minNodeVersionSupplier) {
28+
public RemoteStorePathStrategyResolver(RemoteStoreSettings remoteStoreSettings, Supplier<Version> minNodeVersionSupplier) {
29+
this.remoteStoreSettings = remoteStoreSettings;
3330
this.minNodeVersionSupplier = minNodeVersionSupplier;
34-
type = clusterSettings.get(IndicesService.CLUSTER_REMOTE_STORE_PATH_TYPE_SETTING);
35-
hashAlgorithm = clusterSettings.get(IndicesService.CLUSTER_REMOTE_STORE_PATH_HASH_ALGORITHM_SETTING);
36-
clusterSettings.addSettingsUpdateConsumer(IndicesService.CLUSTER_REMOTE_STORE_PATH_TYPE_SETTING, this::setType);
37-
clusterSettings.addSettingsUpdateConsumer(IndicesService.CLUSTER_REMOTE_STORE_PATH_HASH_ALGORITHM_SETTING, this::setHashAlgorithm);
3831
}
3932

4033
public RemoteStorePathStrategy get() {
4134
PathType pathType;
4235
PathHashAlgorithm pathHashAlgorithm;
4336
// Min node version check ensures that we are enabling the new prefix type only when all the nodes understand it.
44-
pathType = Version.CURRENT.compareTo(minNodeVersionSupplier.get()) <= 0 ? type : PathType.FIXED;
37+
pathType = Version.CURRENT.compareTo(minNodeVersionSupplier.get()) <= 0 ? remoteStoreSettings.getPathType() : PathType.FIXED;
4538
// If the path type is fixed, hash algorithm is not applicable.
46-
pathHashAlgorithm = pathType == PathType.FIXED ? null : hashAlgorithm;
39+
pathHashAlgorithm = pathType == PathType.FIXED ? null : remoteStoreSettings.getPathHashAlgorithm();
4740
return new RemoteStorePathStrategy(pathType, pathHashAlgorithm);
4841
}
49-
50-
private void setType(PathType type) {
51-
this.type = type;
52-
}
53-
54-
private void setHashAlgorithm(PathHashAlgorithm hashAlgorithm) {
55-
this.hashAlgorithm = hashAlgorithm;
56-
}
5742
}

server/src/main/java/org/opensearch/indices/IndicesService.java

-30
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
import org.opensearch.common.CheckedFunction;
6565
import org.opensearch.common.CheckedSupplier;
6666
import org.opensearch.common.Nullable;
67-
import org.opensearch.common.annotation.ExperimentalApi;
6867
import org.opensearch.common.annotation.PublicApi;
6968
import org.opensearch.common.cache.policy.CachedQueryResult;
7069
import org.opensearch.common.cache.service.CacheService;
@@ -127,8 +126,6 @@
127126
import org.opensearch.index.query.QueryRewriteContext;
128127
import org.opensearch.index.recovery.RecoveryStats;
129128
import org.opensearch.index.refresh.RefreshStats;
130-
import org.opensearch.index.remote.RemoteStoreEnums.PathHashAlgorithm;
131-
import org.opensearch.index.remote.RemoteStoreEnums.PathType;
132129
import org.opensearch.index.remote.RemoteStoreStatsTrackerFactory;
133130
import org.opensearch.index.search.stats.SearchStats;
134131
import org.opensearch.index.seqno.RetentionLeaseStats;
@@ -310,33 +307,6 @@ public class IndicesService extends AbstractLifecycleComponent
310307
Property.Final
311308
);
312309

313-
/**
314-
* This setting is used to set the remote store blob store path type strategy. This setting is effective only for
315-
* remote store enabled cluster.
316-
*/
317-
@ExperimentalApi
318-
public static final Setting<PathType> CLUSTER_REMOTE_STORE_PATH_TYPE_SETTING = new Setting<>(
319-
"cluster.remote_store.index.path.type",
320-
PathType.FIXED.toString(),
321-
PathType::parseString,
322-
Property.NodeScope,
323-
Property.Dynamic
324-
);
325-
326-
/**
327-
* This setting is used to set the remote store blob store path hash algorithm strategy. This setting is effective only for
328-
* remote store enabled cluster. This setting will come to effect if the {@link #CLUSTER_REMOTE_STORE_PATH_TYPE_SETTING}
329-
* is either {@code HASHED_PREFIX} or {@code HASHED_INFIX}.
330-
*/
331-
@ExperimentalApi
332-
public static final Setting<PathHashAlgorithm> CLUSTER_REMOTE_STORE_PATH_HASH_ALGORITHM_SETTING = new Setting<>(
333-
"cluster.remote_store.index.path.hash_algorithm",
334-
PathHashAlgorithm.FNV_1A_COMPOSITE_1.toString(),
335-
PathHashAlgorithm::parseString,
336-
Property.NodeScope,
337-
Property.Dynamic
338-
);
339-
340310
/**
341311
* The node's settings.
342312
*/

server/src/main/java/org/opensearch/indices/RemoteStoreSettings.java

+57-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88

99
package org.opensearch.indices;
1010

11+
import org.opensearch.common.annotation.ExperimentalApi;
1112
import org.opensearch.common.annotation.PublicApi;
1213
import org.opensearch.common.settings.ClusterSettings;
1314
import org.opensearch.common.settings.Setting;
1415
import org.opensearch.common.settings.Setting.Property;
1516
import org.opensearch.common.settings.Settings;
1617
import org.opensearch.common.unit.TimeValue;
1718
import org.opensearch.index.IndexSettings;
19+
import org.opensearch.index.remote.RemoteStoreEnums;
1820

1921
/**
2022
* Settings for remote store
@@ -65,12 +67,41 @@ public class RemoteStoreSettings {
6567
Property.Dynamic
6668
);
6769

70+
/**
71+
* This setting is used to set the remote store blob store path type strategy. This setting is effective only for
72+
* remote store enabled cluster.
73+
*/
74+
@ExperimentalApi
75+
public static final Setting<RemoteStoreEnums.PathType> CLUSTER_REMOTE_STORE_PATH_TYPE_SETTING = new Setting<>(
76+
"cluster.remote_store.index.path.type",
77+
RemoteStoreEnums.PathType.FIXED.toString(),
78+
RemoteStoreEnums.PathType::parseString,
79+
Property.NodeScope,
80+
Property.Dynamic
81+
);
82+
83+
/**
84+
* This setting is used to set the remote store blob store path hash algorithm strategy. This setting is effective only for
85+
* remote store enabled cluster. This setting will come to effect if the {@link #CLUSTER_REMOTE_STORE_PATH_TYPE_SETTING}
86+
* is either {@code HASHED_PREFIX} or {@code HASHED_INFIX}.
87+
*/
88+
@ExperimentalApi
89+
public static final Setting<RemoteStoreEnums.PathHashAlgorithm> CLUSTER_REMOTE_STORE_PATH_HASH_ALGORITHM_SETTING = new Setting<>(
90+
"cluster.remote_store.index.path.hash_algorithm",
91+
RemoteStoreEnums.PathHashAlgorithm.FNV_1A_COMPOSITE_1.toString(),
92+
RemoteStoreEnums.PathHashAlgorithm::parseString,
93+
Property.NodeScope,
94+
Property.Dynamic
95+
);
96+
6897
private volatile TimeValue clusterRemoteTranslogBufferInterval;
6998
private volatile int minRemoteSegmentMetadataFiles;
7099
private volatile TimeValue clusterRemoteTranslogTransferTimeout;
100+
private volatile RemoteStoreEnums.PathType pathType;
101+
private volatile RemoteStoreEnums.PathHashAlgorithm pathHashAlgorithm;
71102

72103
public RemoteStoreSettings(Settings settings, ClusterSettings clusterSettings) {
73-
this.clusterRemoteTranslogBufferInterval = CLUSTER_REMOTE_TRANSLOG_BUFFER_INTERVAL_SETTING.get(settings);
104+
clusterRemoteTranslogBufferInterval = CLUSTER_REMOTE_TRANSLOG_BUFFER_INTERVAL_SETTING.get(settings);
74105
clusterSettings.addSettingsUpdateConsumer(
75106
CLUSTER_REMOTE_TRANSLOG_BUFFER_INTERVAL_SETTING,
76107
this::setClusterRemoteTranslogBufferInterval
@@ -82,11 +113,17 @@ public RemoteStoreSettings(Settings settings, ClusterSettings clusterSettings) {
82113
this::setMinRemoteSegmentMetadataFiles
83114
);
84115

85-
this.clusterRemoteTranslogTransferTimeout = CLUSTER_REMOTE_TRANSLOG_TRANSFER_TIMEOUT_SETTING.get(settings);
116+
clusterRemoteTranslogTransferTimeout = CLUSTER_REMOTE_TRANSLOG_TRANSFER_TIMEOUT_SETTING.get(settings);
86117
clusterSettings.addSettingsUpdateConsumer(
87118
CLUSTER_REMOTE_TRANSLOG_TRANSFER_TIMEOUT_SETTING,
88119
this::setClusterRemoteTranslogTransferTimeout
89120
);
121+
122+
pathType = clusterSettings.get(CLUSTER_REMOTE_STORE_PATH_TYPE_SETTING);
123+
clusterSettings.addSettingsUpdateConsumer(CLUSTER_REMOTE_STORE_PATH_TYPE_SETTING, this::setPathType);
124+
125+
pathHashAlgorithm = clusterSettings.get(CLUSTER_REMOTE_STORE_PATH_HASH_ALGORITHM_SETTING);
126+
clusterSettings.addSettingsUpdateConsumer(CLUSTER_REMOTE_STORE_PATH_HASH_ALGORITHM_SETTING, this::setPathHashAlgorithm);
90127
}
91128

92129
public TimeValue getClusterRemoteTranslogBufferInterval() {
@@ -112,4 +149,22 @@ public TimeValue getClusterRemoteTranslogTransferTimeout() {
112149
private void setClusterRemoteTranslogTransferTimeout(TimeValue clusterRemoteTranslogTransferTimeout) {
113150
this.clusterRemoteTranslogTransferTimeout = clusterRemoteTranslogTransferTimeout;
114151
}
152+
153+
@ExperimentalApi
154+
public RemoteStoreEnums.PathType getPathType() {
155+
return pathType;
156+
}
157+
158+
@ExperimentalApi
159+
public RemoteStoreEnums.PathHashAlgorithm getPathHashAlgorithm() {
160+
return pathHashAlgorithm;
161+
}
162+
163+
private void setPathType(RemoteStoreEnums.PathType pathType) {
164+
this.pathType = pathType;
165+
}
166+
167+
private void setPathHashAlgorithm(RemoteStoreEnums.PathHashAlgorithm pathHashAlgorithm) {
168+
this.pathHashAlgorithm = pathHashAlgorithm;
169+
}
115170
}

server/src/main/java/org/opensearch/node/Node.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,8 @@ protected Node(
862862
xContentRegistry,
863863
systemIndices,
864864
forbidPrivateIndexSettings,
865-
awarenessReplicaBalance
865+
awarenessReplicaBalance,
866+
remoteStoreSettings
866867
);
867868
pluginsService.filterPlugins(Plugin.class)
868869
.forEach(

server/src/test/java/org/opensearch/action/admin/indices/rollover/MetadataRolloverServiceTests.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
import org.opensearch.index.mapper.MetadataFieldMapper;
8282
import org.opensearch.index.mapper.RoutingFieldMapper;
8383
import org.opensearch.index.shard.IndexEventListener;
84+
import org.opensearch.indices.DefaultRemoteStoreSettings;
8485
import org.opensearch.indices.IndicesService;
8586
import org.opensearch.indices.InvalidIndexNameException;
8687
import org.opensearch.indices.ShardLimitValidator;
@@ -738,7 +739,8 @@ public void testRolloverClusterState() throws Exception {
738739
null,
739740
systemIndices,
740741
false,
741-
new AwarenessReplicaBalance(Settings.EMPTY, clusterService.getClusterSettings())
742+
new AwarenessReplicaBalance(Settings.EMPTY, clusterService.getClusterSettings()),
743+
DefaultRemoteStoreSettings.INSTANCE
742744
);
743745
MetadataIndexAliasesService indexAliasesService = new MetadataIndexAliasesService(
744746
clusterService,
@@ -876,7 +878,8 @@ public void testRolloverClusterStateForDataStream() throws Exception {
876878
null,
877879
systemIndices,
878880
false,
879-
new AwarenessReplicaBalance(Settings.EMPTY, clusterService.getClusterSettings())
881+
new AwarenessReplicaBalance(Settings.EMPTY, clusterService.getClusterSettings()),
882+
DefaultRemoteStoreSettings.INSTANCE
880883
);
881884
MetadataIndexAliasesService indexAliasesService = new MetadataIndexAliasesService(
882885
clusterService,
@@ -1054,7 +1057,8 @@ public void testRolloverClusterStateForDataStreamNoTemplate() throws Exception {
10541057
null,
10551058
new SystemIndices(emptyMap()),
10561059
false,
1057-
new AwarenessReplicaBalance(Settings.EMPTY, clusterService.getClusterSettings())
1060+
new AwarenessReplicaBalance(Settings.EMPTY, clusterService.getClusterSettings()),
1061+
DefaultRemoteStoreSettings.INSTANCE
10581062
);
10591063
MetadataIndexAliasesService indexAliasesService = new MetadataIndexAliasesService(
10601064
clusterService,

0 commit comments

Comments
 (0)