88
88
import org .opensearch .index .mapper .MapperService ;
89
89
import org .opensearch .index .mapper .MapperService .MergeReason ;
90
90
import org .opensearch .index .query .QueryShardContext ;
91
- import org .opensearch .index .remote .RemoteStorePathType ;
92
- import org .opensearch .index .remote .RemoteStorePathTypeResolver ;
91
+ import org .opensearch .index .remote .RemoteStoreEnums .PathHashAlgorithm ;
92
+ import org .opensearch .index .remote .RemoteStoreEnums .PathType ;
93
+ import org .opensearch .index .remote .RemoteStorePathStrategy ;
94
+ import org .opensearch .index .remote .RemoteStorePathStrategyResolver ;
93
95
import org .opensearch .index .shard .IndexSettingProvider ;
94
96
import org .opensearch .index .translog .Translog ;
95
97
import org .opensearch .indices .IndexCreationException ;
@@ -171,7 +173,7 @@ public class MetadataCreateIndexService {
171
173
private AwarenessReplicaBalance awarenessReplicaBalance ;
172
174
173
175
@ Nullable
174
- private final RemoteStorePathTypeResolver remoteStorePathTypeResolver ;
176
+ private final RemoteStorePathStrategyResolver remoteStorePathStrategyResolver ;
175
177
176
178
public MetadataCreateIndexService (
177
179
final Settings settings ,
@@ -204,8 +206,8 @@ public MetadataCreateIndexService(
204
206
205
207
// Task is onboarded for throttling, it will get retried from associated TransportClusterManagerNodeAction.
206
208
createIndexTaskKey = clusterService .registerClusterManagerTask (ClusterManagerTaskKeys .CREATE_INDEX_KEY , true );
207
- remoteStorePathTypeResolver = isRemoteDataAttributePresent (settings )
208
- ? new RemoteStorePathTypeResolver (clusterService .getClusterSettings ())
209
+ remoteStorePathStrategyResolver = isRemoteDataAttributePresent (settings )
210
+ ? new RemoteStorePathStrategyResolver (clusterService .getClusterSettings ())
209
211
: null ;
210
212
}
211
213
@@ -554,7 +556,7 @@ IndexMetadata buildAndValidateTemporaryIndexMetadata(
554
556
tmpImdBuilder .setRoutingNumShards (routingNumShards );
555
557
tmpImdBuilder .settings (indexSettings );
556
558
tmpImdBuilder .system (isSystem );
557
- addRemoteStorePathTypeInCustomData (tmpImdBuilder , true );
559
+ addRemoteStorePathStrategyInCustomData (tmpImdBuilder , true );
558
560
559
561
// Set up everything, now locally create the index to see that things are ok, and apply
560
562
IndexMetadata tempMetadata = tmpImdBuilder .build ();
@@ -569,19 +571,27 @@ IndexMetadata buildAndValidateTemporaryIndexMetadata(
569
571
* @param tmpImdBuilder index metadata builder.
570
572
* @param assertNullOldType flag to verify that the old remote store path type is null
571
573
*/
572
- public void addRemoteStorePathTypeInCustomData (IndexMetadata .Builder tmpImdBuilder , boolean assertNullOldType ) {
573
- if (remoteStorePathTypeResolver != null ) {
574
+ public void addRemoteStorePathStrategyInCustomData (IndexMetadata .Builder tmpImdBuilder , boolean assertNullOldType ) {
575
+ if (remoteStorePathStrategyResolver != null ) {
574
576
// It is possible that remote custom data exists already. In such cases, we need to only update the path type
575
577
// in the remote store custom data map.
576
578
Map <String , String > existingRemoteCustomData = tmpImdBuilder .removeCustom (IndexMetadata .REMOTE_STORE_CUSTOM_KEY );
577
579
Map <String , String > remoteCustomData = existingRemoteCustomData == null
578
580
? new HashMap <>()
579
581
: new HashMap <>(existingRemoteCustomData );
580
582
// Determine the path type for use using the remoteStorePathResolver.
581
- String newPathType = remoteStorePathTypeResolver .getType ().toString ();
582
- String oldPathType = remoteCustomData .put (RemoteStorePathType .NAME , newPathType );
583
- assert !assertNullOldType || Objects .isNull (oldPathType );
584
- logger .trace (() -> new ParameterizedMessage ("Added new path type {}, replaced old path type {}" , newPathType , oldPathType ));
583
+ RemoteStorePathStrategy newPathStrategy = remoteStorePathStrategyResolver .get ();
584
+ String oldPathType = remoteCustomData .put (PathType .NAME , newPathStrategy .getType ().name ());
585
+ String oldHashAlgorithm = remoteCustomData .put (PathHashAlgorithm .NAME , newPathStrategy .getHashAlgorithm ().name ());
586
+ assert !assertNullOldType || (Objects .isNull (oldPathType ) && Objects .isNull (oldHashAlgorithm ));
587
+ logger .trace (
588
+ () -> new ParameterizedMessage (
589
+ "Added newPathStrategy={}, replaced oldPathType={} oldHashAlgorithm={}" ,
590
+ newPathStrategy ,
591
+ oldPathType ,
592
+ oldHashAlgorithm
593
+ )
594
+ );
585
595
tmpImdBuilder .putCustom (IndexMetadata .REMOTE_STORE_CUSTOM_KEY , remoteCustomData );
586
596
}
587
597
}
0 commit comments