RATIS-1470. Add peerId option to group list#564
Merged
szetszwo merged 7 commits intoapache:masterfrom Dec 16, 2021
Merged
Conversation
Contributor
Author
|
@maobaolong @szetszwo Can you please take a look? Thanks |
Contributor
Author
|
Here is the testing result. |
maobaolong
reviewed
Dec 15, 2021
Member
maobaolong
left a comment
There was a problem hiding this comment.
@ferhui Thanks for this great contribution, this looks good overall,
Would you like to use org.apache.commons.cli.OptionGroup to simplify the exclusive logic between the SERVER_ADDRESS_OPTION_NAME and PEER_ID_OPTION_NAME options?
Contributor
Author
|
@maobaolong Thanks for review! Updated |
szetszwo
reviewed
Dec 15, 2021
Contributor
szetszwo
left a comment
There was a problem hiding this comment.
@ferhui , thanks for working on this. Some minor comments inlined. Below is the suggested change.
public int run(CommandLine cl) throws IOException {
super.run(cl);
final RaftPeerId peerId;
final String address;
if (cl.hasOption(PEER_ID_OPTION_NAME)) {
peerId = RaftPeerId.getRaftPeerId(cl.getOptionValue(PEER_ID_OPTION_NAME));
address = getRaftGroup().getPeer(peerId).getAddress();
} else if (cl.hasOption(SERVER_ADDRESS_OPTION_NAME)) {
address = cl.getOptionValue(SERVER_ADDRESS_OPTION_NAME);
peerId = RaftUtils.getPeerId(parseInetSocketAddress(address));
} else {
throw new IllegalArgumentException(
"Both " + PEER_ID_OPTION_NAME + " and " + SERVER_ADDRESS_OPTION_NAME + " options are missing.");
}
try(final RaftClient raftClient = RaftUtils.createClient(getRaftGroup())) {
GroupListReply reply = raftClient.getGroupManagementApi(peerId).list();
processReply(reply, () -> String.format("Failed to get group information of peerId %s (server %s)",
peerId, address));
printf(String.format("The peerId %s (server %s) is in %d groups, and the groupIds is: %s",
peerId, address, reply.getGroupIds().size(), reply.getGroupIds()));
}
return 0;
}
ratis-shell/src/main/java/org/apache/ratis/shell/cli/sh/group/GroupListCommand.java
Outdated
Show resolved
Hide resolved
ratis-shell/src/main/java/org/apache/ratis/shell/cli/sh/group/GroupListCommand.java
Outdated
Show resolved
Hide resolved
ratis-shell/src/main/java/org/apache/ratis/shell/cli/sh/group/GroupListCommand.java
Show resolved
Hide resolved
ratis-shell/src/main/java/org/apache/ratis/shell/cli/sh/group/GroupListCommand.java
Outdated
Show resolved
Hide resolved
szetszwo
approved these changes
Dec 16, 2021
Contributor
szetszwo
left a comment
There was a problem hiding this comment.
+1 the change looks good.
Contributor
Author
|
@szetszwo @maobaolong Thanks for your review! |
symious
pushed a commit
to symious/ratis
that referenced
this pull request
Feb 27, 2024
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?
Add one new option peerId to shell command of group list
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/RATIS-1470
How was this patch tested?
Test by command line manually