RATIS-1498. Take snapshot on specific ratis server#586
Merged
szetszwo merged 2 commits intoapache:masterfrom Jan 23, 2022
Merged
RATIS-1498. Take snapshot on specific ratis server#586szetszwo merged 2 commits intoapache:masterfrom
szetszwo merged 2 commits intoapache:masterfrom
Conversation
Contributor
Author
|
@szetszwo I changed the API related to take shanpshot, PTAL, thx! The result of the CI test has nothing to do with this code change. |
szetszwo
reviewed
Jan 23, 2022
Contributor
szetszwo
left a comment
There was a problem hiding this comment.
@codings-dan , thanks for working on this. We should support the case server == null. See the comment inlined.
|
|
||
| /** Get the {@link SnapshotManagementApi}. */ | ||
| SnapshotManagementApi getSnapshotManagementApi(); | ||
| /** Get the {@link SnapshotManagementApi} for the given server. */ |
Contributor
There was a problem hiding this comment.
We should support null as below:
/**
* If server != null, return the {@link SnapshotManagementApi} for the given server.
* Otherwise, return the {@link SnapshotManagementApi} for the group.
*/
Comment on lines
+41
to
+44
| final RaftClientReply reply = client.io().sendRequestWithRetry( | ||
| () -> SnapshotManagementRequest.newCreate(client.getId(), server, | ||
| client.getGroupId(), callId, timeoutMs)); | ||
| return reply; |
Contributor
There was a problem hiding this comment.
We should support the case the server == null. When server == null, use client.getLeaderId() as before.
return client.io().sendRequestWithRetry(() -> SnapshotManagementRequest.newCreate(client.getId(),
Optional.ofNullable(server).orElseGet(client::getLeaderId), client.getGroupId(), callId, timeoutMs));
| if (cl.hasOption(PEER_ID_OPTION_NAME)) { | ||
| peerId = RaftPeerId.getRaftPeerId(cl.getOptionValue(PEER_ID_OPTION_NAME)); | ||
| } else { | ||
| peerId = raftClient.getLeaderId(); |
Contributor
There was a problem hiding this comment.
Just set peerId = null. The leader could change so that we should getLeaderId right before sending the rpc.
szetszwo
approved these changes
Jan 23, 2022
Contributor
szetszwo
left a comment
There was a problem hiding this comment.
+1 the change looks good.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
subtask of Support snapshot command: Take snapshot on specific ratis server
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/RATIS-1498
How was this patch tested?
UT