Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] Support centralize snapshot creation #15569

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix :server:japicmp failure
Signed-off-by: Anshu Agarwal <anshukag@amazon.com>
  • Loading branch information
Anshu Agarwal committed Sep 3, 2024
commit 282e451647b6000c65d7751aa7bdda8cb66e0e77
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,27 @@ public void initializeSnapshot(SnapshotId snapshotId, List<IndexId> indices, Met
in.initializeSnapshot(snapshotId, indices, metadata);
}

@Override
public void finalizeSnapshot(
ShardGenerations shardGenerations,
long repositoryStateId,
Metadata clusterMetadata,
SnapshotInfo snapshotInfo,
Version repositoryMetaVersion,
Function<ClusterState, ClusterState> stateTransformer,
ActionListener<RepositoryData> listener
) {
in.finalizeSnapshot(
shardGenerations,
repositoryStateId,
clusterMetadata,
snapshotInfo,
repositoryMetaVersion,
stateTransformer,
listener
);
}

@Override
public void finalizeSnapshot(
ShardGenerations shardGenerations,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,30 @@ default Repository create(RepositoryMetadata metadata, Function<String, Reposito
@Deprecated
void initializeSnapshot(SnapshotId snapshotId, List<IndexId> indices, Metadata metadata);

/**
* Finalizes snapshotting process
* <p>
* This method is called on cluster-manager after all shards are snapshotted.
*
* @param shardGenerations updated shard generations
* @param repositoryStateId the unique id identifying the state of the repository when the snapshot began
* @param clusterMetadata cluster metadata
* @param snapshotInfo SnapshotInfo instance to write for this snapshot
* @param repositoryMetaVersion version of the updated repository metadata to write
* @param stateTransformer a function that filters the last cluster state update that the snapshot finalization will execute and
* is used to remove any state tracked for the in-progress snapshot from the cluster state
* @param listener listener to be invoked with the new {@link RepositoryData} after completing the snapshot
*/
void finalizeSnapshot(
ShardGenerations shardGenerations,
long repositoryStateId,
Metadata clusterMetadata,
SnapshotInfo snapshotInfo,
Version repositoryMetaVersion,
Function<ClusterState, ClusterState> stateTransformer,
ActionListener<RepositoryData> listener
);

/**
* Finalizes snapshotting process
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1790,6 +1790,28 @@ private void executeOneStaleIndexDelete(
}
}

@Override
public void finalizeSnapshot(
final ShardGenerations shardGenerations,
final long repositoryStateId,
final Metadata clusterMetadata,
SnapshotInfo snapshotInfo,
Version repositoryMetaVersion,
Function<ClusterState, ClusterState> stateTransformer,
final ActionListener<RepositoryData> listener
) {
finalizeSnapshot(
shardGenerations,
repositoryStateId,
clusterMetadata,
snapshotInfo,
repositoryMetaVersion,
stateTransformer,
Priority.NORMAL,
listener
);
}

@Override
public void finalizeSnapshot(
final ShardGenerations shardGenerations,
Expand Down
32 changes: 32 additions & 0 deletions server/src/main/java/org/opensearch/snapshots/SnapshotInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,38 @@ public SnapshotInfo(SnapshotsInProgress.Entry entry) {
);
}

public SnapshotInfo(
SnapshotId snapshotId,
List<String> indices,
List<String> dataStreams,
long startTime,
String reason,
long endTime,
int totalShards,
List<SnapshotShardFailure> shardFailures,
Boolean includeGlobalState,
Map<String, Object> userMetadata,
Boolean remoteStoreIndexShallowCopy
) {
this(
snapshotId,
indices,
dataStreams,
snapshotState(reason, shardFailures),
reason,
Version.CURRENT,
startTime,
endTime,
totalShards,
totalShards - shardFailures.size(),
shardFailures,
includeGlobalState,
userMetadata,
remoteStoreIndexShallowCopy,
0
);
}

public SnapshotInfo(
SnapshotId snapshotId,
List<String> indices,
Expand Down
Loading