Skip to content

Commit 7586b7d

Browse files
committed
address commens and add ut's
Signed-off-by: Sandeep Kumawat <2025sandeepkumawat@gmail.com>
1 parent fc368da commit 7586b7d

22 files changed

+353
-201
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,8 @@ public void addRemoteStoreCustomMetadata(IndexMetadata.Builder tmpImdBuilder, bo
590590
Map<String, String> remoteCustomData = new HashMap<>();
591591

592592
// Determine if the ckp would be stored as translog metadata
593-
boolean isCkpAsTranslogMetadata = remoteStoreCustomMetadataResolver.isCkpAsTranslogMetadata();
594-
remoteCustomData.put(RemoteStoreEnums.CKP_AS_METADATA, Boolean.toString(isCkpAsTranslogMetadata));
593+
boolean isTranslogMetadataEnabled = remoteStoreCustomMetadataResolver.isTranslogMetadataEnabled();
594+
remoteCustomData.put(RemoteStoreEnums.TRANSLOG_METADATA, Boolean.toString(isTranslogMetadataEnabled));
595595

596596
// Determine the path type for use using the remoteStorePathResolver.
597597
RemoteStorePathStrategy newPathStrategy = remoteStoreCustomMetadataResolver.getPathStrategy();

server/src/main/java/org/opensearch/common/blobstore/BlobStore.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ default Map<Metric, Map<String, Long>> extendedStats() {
7272
default void reload(RepositoryMetadata repositoryMetadata) {}
7373

7474
/**
75-
* Returns a boolean indicating if blobStore support object metadata upload
75+
* Returns a boolean indicating if blobStore has object metadata support enabled
7676
*/
77-
default boolean isBlobMetadataSupported() {
77+
default boolean isBlobMetadataEnabled() {
7878
return false;
7979
}
8080

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ public void apply(Settings value, Settings current, Settings previous) {
740740
RemoteStoreSettings.CLUSTER_REMOTE_STORE_PATH_TYPE_SETTING,
741741
RemoteStoreSettings.CLUSTER_REMOTE_STORE_PATH_HASH_ALGORITHM_SETTING,
742742
RemoteStoreSettings.CLUSTER_REMOTE_MAX_TRANSLOG_READERS,
743-
RemoteStoreSettings.CLUSTER_REMOTE_STORE_TRANSLOG_CKP_AS_METADATA
743+
RemoteStoreSettings.CLUSTER_REMOTE_STORE_TRANSLOG_TRANSLOG_METADATA
744744
)
745745
)
746746
);

server/src/main/java/org/opensearch/index/IndexSettings.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ public static IndexMergePolicy fromString(String text) {
763763
private final boolean widenIndexSortType;
764764
private final boolean assignedOnRemoteNode;
765765
private final RemoteStorePathStrategy remoteStorePathStrategy;
766-
private final boolean ckpAsTranslogMetadata;
766+
private final boolean isTranslogMetadataEnabled;
767767

768768
/**
769769
* The maximum age of a retention lease before it is considered expired.
@@ -990,7 +990,7 @@ public IndexSettings(final IndexMetadata indexMetadata, final Settings nodeSetti
990990
assignedOnRemoteNode = RemoteStoreNodeAttribute.isRemoteDataAttributePresent(this.getNodeSettings());
991991
remoteStorePathStrategy = RemoteStoreUtils.determineRemoteStorePathStrategy(indexMetadata);
992992

993-
ckpAsTranslogMetadata = RemoteStoreUtils.determineCkpAsTranslogMetadata(indexMetadata);
993+
isTranslogMetadataEnabled = RemoteStoreUtils.determineisTranslogMetadataEnabled(indexMetadata);
994994

995995
setEnableFuzzySetForDocId(scopedSettings.get(INDEX_DOC_ID_FUZZY_SET_ENABLED_SETTING));
996996
setDocIdFuzzySetFalsePositiveProbability(scopedSettings.get(INDEX_DOC_ID_FUZZY_SET_FALSE_POSITIVE_PROBABILITY_SETTING));
@@ -1915,7 +1915,7 @@ public RemoteStorePathStrategy getRemoteStorePathStrategy() {
19151915
return remoteStorePathStrategy;
19161916
}
19171917

1918-
public boolean isCkpAsTranslogMetadata() {
1919-
return ckpAsTranslogMetadata;
1918+
public boolean isTranslogMetadataEnabled() {
1919+
return isTranslogMetadataEnabled;
19201920
}
19211921
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public static boolean indexHasRemoteCustomMetadata(IndexMetadata indexMetadata)
171171
Map<String, String> customMetadata = indexMetadata.getCustomData(REMOTE_STORE_CUSTOM_KEY);
172172
return Objects.nonNull(customMetadata)
173173
&& Objects.nonNull(customMetadata.get(PathType.NAME))
174-
&& Objects.nonNull(customMetadata.get(RemoteStoreEnums.CKP_AS_METADATA));
174+
&& Objects.nonNull(customMetadata.get(RemoteStoreEnums.TRANSLOG_METADATA));
175175
}
176176

177177
public static void updateRemoteStoreSettings(Settings.Builder settingsBuilder, String segmentRepository, String translogRepository) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public RemoteStorePathStrategy getPathStrategy() {
4242
return new RemoteStorePathStrategy(pathType, pathHashAlgorithm);
4343
}
4444

45-
public boolean isCkpAsTranslogMetadata() {
46-
return Version.CURRENT.compareTo(minNodeVersionSupplier.get()) <= 0 && remoteStoreSettings.isCkpAsTranslogMetadata();
45+
public boolean isTranslogMetadataEnabled() {
46+
return Version.V_2_15_0.compareTo(minNodeVersionSupplier.get()) <= 0 && remoteStoreSettings.isTranslogMetadataEnabled();
4747
}
4848

4949
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
@ExperimentalApi
3737
public class RemoteStoreEnums {
3838

39-
public static final String CKP_AS_METADATA = "ckp-as-metadata";
39+
public static final String TRANSLOG_METADATA = "translog-metadata";
4040

4141
/**
4242
* Categories of the data in Remote store.

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
import static org.opensearch.indices.RemoteStoreSettings.CLUSTER_REMOTE_STORE_PATH_HASH_ALGORITHM_SETTING;
3434
import static org.opensearch.indices.RemoteStoreSettings.CLUSTER_REMOTE_STORE_PATH_TYPE_SETTING;
35-
import static org.opensearch.indices.RemoteStoreSettings.CLUSTER_REMOTE_STORE_TRANSLOG_CKP_AS_METADATA;
35+
import static org.opensearch.indices.RemoteStoreSettings.CLUSTER_REMOTE_STORE_TRANSLOG_TRANSLOG_METADATA;
3636

3737
/**
3838
* Utils for remote store
@@ -185,11 +185,11 @@ public static RemoteStorePathStrategy determineRemoteStorePathStrategy(IndexMeta
185185
/**
186186
* Determines whether translog ckp upload as metadata allowed or not
187187
*/
188-
public static boolean determineCkpAsTranslogMetadata(IndexMetadata indexMetadata) {
188+
public static boolean determineisTranslogMetadataEnabled(IndexMetadata indexMetadata) {
189189
Map<String, String> remoteCustomData = indexMetadata.getCustomData(IndexMetadata.REMOTE_STORE_CUSTOM_KEY);
190-
assert remoteCustomData == null || remoteCustomData.containsKey(RemoteStoreEnums.CKP_AS_METADATA);
191-
if (remoteCustomData != null && remoteCustomData.containsKey(RemoteStoreEnums.CKP_AS_METADATA)) {
192-
return Boolean.parseBoolean(remoteCustomData.get(RemoteStoreEnums.CKP_AS_METADATA));
190+
assert remoteCustomData == null || remoteCustomData.containsKey(RemoteStoreEnums.TRANSLOG_METADATA);
191+
if (remoteCustomData != null && remoteCustomData.containsKey(RemoteStoreEnums.TRANSLOG_METADATA)) {
192+
return Boolean.parseBoolean(remoteCustomData.get(RemoteStoreEnums.TRANSLOG_METADATA));
193193
}
194194
return false;
195195
}
@@ -209,8 +209,8 @@ public static Map<String, String> determineRemoteStoreCustomMetadataDuringMigrat
209209
Version minNodeVersion = discoveryNodes.getMinNodeVersion();
210210

211211
boolean ckpAsMetadata = Version.CURRENT.compareTo(minNodeVersion) <= 0
212-
&& CLUSTER_REMOTE_STORE_TRANSLOG_CKP_AS_METADATA.get(clusterSettings);
213-
remoteCustomData.put(RemoteStoreEnums.CKP_AS_METADATA, Boolean.toString(ckpAsMetadata));
212+
&& CLUSTER_REMOTE_STORE_TRANSLOG_TRANSLOG_METADATA.get(clusterSettings);
213+
remoteCustomData.put(RemoteStoreEnums.TRANSLOG_METADATA, Boolean.toString(ckpAsMetadata));
214214

215215
RemoteStoreEnums.PathType pathType = Version.CURRENT.compareTo(minNodeVersion) <= 0
216216
? CLUSTER_REMOTE_STORE_PATH_TYPE_SETTING.get(clusterSettings)

server/src/main/java/org/opensearch/index/shard/IndexShard.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4982,7 +4982,7 @@ public void deleteTranslogFilesFromRemoteTranslog() throws IOException {
49824982
getThreadPool(),
49834983
indexSettings.getRemoteStorePathStrategy(),
49844984
remoteStoreSettings,
4985-
indexSettings().isCkpAsTranslogMetadata()
4985+
indexSettings().isTranslogMetadataEnabled()
49864986
);
49874987
}
49884988

@@ -5009,7 +5009,7 @@ public void syncTranslogFilesFromRemoteTranslog() throws IOException {
50095009
remoteStoreSettings,
50105010
logger,
50115011
shouldSeedRemoteStore(),
5012-
indexSettings().isCkpAsTranslogMetadata()
5012+
indexSettings().isTranslogMetadataEnabled()
50135013
);
50145014
}
50155015

server/src/main/java/org/opensearch/index/translog/RemoteFsTranslog.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public class RemoteFsTranslog extends Translog {
9191
private static final int SYNC_PERMIT = 1;
9292
private final Semaphore syncPermit = new Semaphore(SYNC_PERMIT);
9393
private final AtomicBoolean pauseSync = new AtomicBoolean(false);
94-
boolean ckpAsTranslogMetadata;
94+
boolean isTranslogMetadataEnabled;
9595

9696
public RemoteFsTranslog(
9797
TranslogConfig config,
@@ -111,8 +111,7 @@ public RemoteFsTranslog(
111111
this.startedPrimarySupplier = startedPrimarySupplier;
112112
this.remoteTranslogTransferTracker = remoteTranslogTransferTracker;
113113
fileTransferTracker = new FileTransferTracker(shardId, remoteTranslogTransferTracker);
114-
ckpAsTranslogMetadata = isCkpAsTranslogMetadata(indexSettings().isCkpAsTranslogMetadata(), blobStoreRepository);
115-
;
114+
isTranslogMetadataEnabled = isTranslogMetadataEnabled(indexSettings().isTranslogMetadataEnabled(), blobStoreRepository);
116115
this.translogTransferManager = buildTranslogTransferManager(
117116
blobStoreRepository,
118117
threadPool,
@@ -121,7 +120,7 @@ public RemoteFsTranslog(
121120
remoteTranslogTransferTracker,
122121
indexSettings().getRemoteStorePathStrategy(),
123122
remoteStoreSettings,
124-
ckpAsTranslogMetadata
123+
isTranslogMetadataEnabled
125124
);
126125
try {
127126
download(translogTransferManager, location, logger, config.shouldSeedRemote());
@@ -160,8 +159,8 @@ public RemoteFsTranslog(
160159
}
161160
}
162161

163-
private static boolean isCkpAsTranslogMetadata(boolean ckpAsTranslogMetadata, BlobStoreRepository blobStoreRepository) {
164-
return blobStoreRepository.blobStore().isBlobMetadataSupported() && ckpAsTranslogMetadata;
162+
private static boolean isTranslogMetadataEnabled(boolean isTranslogMetadataEnabled, BlobStoreRepository blobStoreRepository) {
163+
return blobStoreRepository.blobStore().isBlobMetadataEnabled() && isTranslogMetadataEnabled;
165164
}
166165

167166
// visible for testing
@@ -178,7 +177,7 @@ public static void download(
178177
RemoteStoreSettings remoteStoreSettings,
179178
Logger logger,
180179
boolean seedRemote,
181-
boolean ckpAsTranslogMetadata
180+
boolean isTranslogMetadataEnabled
182181
) throws IOException {
183182
assert repository instanceof BlobStoreRepository : String.format(
184183
Locale.ROOT,
@@ -188,7 +187,7 @@ public static void download(
188187
BlobStoreRepository blobStoreRepository = (BlobStoreRepository) repository;
189188
// We use a dummy stats tracker to ensure the flow doesn't break.
190189
// TODO: To be revisited as part of https://github.com/opensearch-project/OpenSearch/issues/7567
191-
ckpAsTranslogMetadata = isCkpAsTranslogMetadata(ckpAsTranslogMetadata, blobStoreRepository);
190+
isTranslogMetadataEnabled = isTranslogMetadataEnabled(isTranslogMetadataEnabled, blobStoreRepository);
192191
RemoteTranslogTransferTracker remoteTranslogTransferTracker = new RemoteTranslogTransferTracker(shardId, 1000);
193192
FileTransferTracker fileTransferTracker = new FileTransferTracker(shardId, remoteTranslogTransferTracker);
194193
TranslogTransferManager translogTransferManager = buildTranslogTransferManager(
@@ -199,7 +198,7 @@ public static void download(
199198
remoteTranslogTransferTracker,
200199
pathStrategy,
201200
remoteStoreSettings,
202-
ckpAsTranslogMetadata
201+
isTranslogMetadataEnabled
203202
);
204203
RemoteFsTranslog.download(translogTransferManager, location, logger, seedRemote);
205204
logger.trace(remoteTranslogTransferTracker.toString());
@@ -305,7 +304,7 @@ public static TranslogTransferManager buildTranslogTransferManager(
305304
RemoteTranslogTransferTracker tracker,
306305
RemoteStorePathStrategy pathStrategy,
307306
RemoteStoreSettings remoteStoreSettings,
308-
boolean ckpAsTranslogMetadata
307+
boolean isTranslogMetadataEnabled
309308
) {
310309
assert Objects.nonNull(pathStrategy);
311310
String indexUUID = shardId.getIndex().getUUID();
@@ -335,7 +334,7 @@ public static TranslogTransferManager buildTranslogTransferManager(
335334
fileTransferTracker,
336335
tracker,
337336
remoteStoreSettings,
338-
ckpAsTranslogMetadata
337+
isTranslogMetadataEnabled
339338
);
340339
}
341340

@@ -614,13 +613,13 @@ public static void cleanup(
614613
ThreadPool threadPool,
615614
RemoteStorePathStrategy pathStrategy,
616615
RemoteStoreSettings remoteStoreSettings,
617-
boolean ckpAsTranslogMetadata
616+
boolean isTranslogMetadataEnabled
618617
) throws IOException {
619618
assert repository instanceof BlobStoreRepository : "repository should be instance of BlobStoreRepository";
620619
BlobStoreRepository blobStoreRepository = (BlobStoreRepository) repository;
621620
// We use a dummy stats tracker to ensure the flow doesn't break.
622621
// TODO: To be revisited as part of https://github.com/opensearch-project/OpenSearch/issues/7567
623-
ckpAsTranslogMetadata = isCkpAsTranslogMetadata(ckpAsTranslogMetadata, blobStoreRepository);
622+
isTranslogMetadataEnabled = isTranslogMetadataEnabled(isTranslogMetadataEnabled, blobStoreRepository);
624623
RemoteTranslogTransferTracker remoteTranslogTransferTracker = new RemoteTranslogTransferTracker(shardId, 1000);
625624
FileTransferTracker fileTransferTracker = new FileTransferTracker(shardId, remoteTranslogTransferTracker);
626625
TranslogTransferManager translogTransferManager = buildTranslogTransferManager(
@@ -631,7 +630,7 @@ public static void cleanup(
631630
remoteTranslogTransferTracker,
632631
pathStrategy,
633632
remoteStoreSettings,
634-
ckpAsTranslogMetadata
633+
isTranslogMetadataEnabled
635634
);
636635
// clean up all remote translog files
637636
translogTransferManager.deleteTranslogFiles();

0 commit comments

Comments
 (0)