From f495cad371a8eb82ef1e74b0a312c51877ff932b Mon Sep 17 00:00:00 2001 From: Shubh Sahu Date: Fri, 3 Jan 2025 16:17:28 +0530 Subject: [PATCH] Addressing comments Signed-off-by: Shubh Sahu --- .../opensearch/index/shard/IndexShard.java | 1 - .../repositories/FilterRepository.java | 4 -- .../opensearch/repositories/Repository.java | 37 +++++++++++++++++++ 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/org/opensearch/index/shard/IndexShard.java b/server/src/main/java/org/opensearch/index/shard/IndexShard.java index 3608085c6cbb0..ce4f0d01f74ca 100644 --- a/server/src/main/java/org/opensearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/opensearch/index/shard/IndexShard.java @@ -1629,7 +1629,6 @@ public org.apache.lucene.util.Version minimumCompatibleVersion() { * @return Tuple(Tuple(primaryTerm, commitGeneration), indexFilesToFileLengthMap) * @throws IOException */ - public Tuple, Map> acquireLastRemoteUploadedIndexCommit() throws IOException { if (!indexSettings.isAssignedOnRemoteNode()) { throw new IllegalStateException("Index is not assigned on Remote Node"); diff --git a/server/src/main/java/org/opensearch/repositories/FilterRepository.java b/server/src/main/java/org/opensearch/repositories/FilterRepository.java index d5a844dbb9055..188d61e00f206 100644 --- a/server/src/main/java/org/opensearch/repositories/FilterRepository.java +++ b/server/src/main/java/org/opensearch/repositories/FilterRepository.java @@ -237,9 +237,7 @@ public void snapshotRemoteStoreIndexShard( String shardStateIdentifier, IndexShardSnapshotStatus snapshotStatus, long primaryTerm, - long commitGeneration, long startTime, - Map indexFilesToFileLengthMap, ActionListener listener ) { in.snapshotRemoteStoreIndexShard( @@ -250,9 +248,7 @@ public void snapshotRemoteStoreIndexShard( shardStateIdentifier, snapshotStatus, primaryTerm, - commitGeneration, startTime, - indexFilesToFileLengthMap, listener ); } diff --git a/server/src/main/java/org/opensearch/repositories/Repository.java b/server/src/main/java/org/opensearch/repositories/Repository.java index 5b91baff2c43c..eeadc25cac3c9 100644 --- a/server/src/main/java/org/opensearch/repositories/Repository.java +++ b/server/src/main/java/org/opensearch/repositories/Repository.java @@ -402,6 +402,43 @@ void snapshotShard( * @param startTime start time of the snapshot commit, this will be used as the start time for snapshot. * @param listener listener invoked on completion */ + default void snapshotRemoteStoreIndexShard( + Store store, + SnapshotId snapshotId, + IndexId indexId, + IndexCommit snapshotIndexCommit, + @Nullable String shardStateIdentifier, + IndexShardSnapshotStatus snapshotStatus, + long primaryTerm, + long startTime, + ActionListener listener + ) { + throw new UnsupportedOperationException(); + } + + /** + * Adds a reference of remote store data for a index commit point. + *

+ * The index commit point can be obtained by using {@link org.opensearch.index.engine.Engine#acquireLastIndexCommit} method. + * Or for closed index can be obtained by reading last remote uploaded metadata by using {@link org.opensearch.index.shard.IndexShard#acquireLastRemoteUploadedIndexCommit} method. + * Repository implementations shouldn't release the snapshot index commit point. It is done by the method caller. + *

+ * As snapshot process progresses, implementation of this method should update {@link IndexShardSnapshotStatus} object and check + * {@link IndexShardSnapshotStatus#isAborted()} to see if the snapshot process should be aborted. + * @param store store to be snapshotted + * @param snapshotId snapshot id + * @param indexId id for the index being snapshotted + * @param snapshotIndexCommit commit point + * @param shardStateIdentifier a unique identifier of the state of the shard that is stored with the shard's snapshot and used + * to detect if the shard has changed between snapshots. If {@code null} is passed as the identifier + * snapshotting will be done by inspecting the physical files referenced by {@code snapshotIndexCommit} + * @param snapshotStatus snapshot status + * @param primaryTerm current Primary Term + * @param commitGeneration current commit generation + * @param startTime start time of the snapshot commit, this will be used as the start time for snapshot. + * @param indexFilesToFileLengthMap map of index files to file length + * @param listener listener invoked on completion + */ default void snapshotRemoteStoreIndexShard( Store store, SnapshotId snapshotId,