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