szetszwo commented on code in PR #867:
URL: https://github.com/apache/ratis/pull/867#discussion_r1152805331
##########
ratis-proto/src/main/proto/Raft.proto:
##########
@@ -538,6 +538,7 @@ message RoleInfoProto {
FollowerInfoProto followerInfo = 5;
CandidateInfoProto candidateInfo = 6;
}
+ RaftConfigurationProto conf = 7;
Review Comment:
Sorry, let add the `conf` to `GroupInfoReplyProto` instead since it also has
the group.
##########
ratis-shell/src/main/java/org/apache/ratis/shell/cli/sh/command/AbstractRatisCommand.java:
##########
@@ -215,4 +217,32 @@ protected List<RaftPeerId> getIds(String[] optionValues,
BiConsumer<RaftPeerId,
}
return ids;
}
+
+ protected List<RaftPeer> getClusterPeers(RaftPeerRole role) {
Review Comment:
We may return `Stream<RaftPeer>` and simply the code as below:
```java
protected Stream<RaftPeer> getPeerStream(RaftPeerRole role) {
final RaftConfigurationProto conf =
groupInfoReply.getConf().orElse(null);
if (conf == null) {
// Assume all peers are followers in order preserve the pre-listener
behaviors.
return role == RaftPeerRole.FOLLOWER?
getRaftGroup().getPeers().stream() : Stream.empty();
}
final Set<RaftPeer> targets = (role == RaftPeerRole.LISTENER ?
conf.getListenersList() : conf.getPeersList())
.stream()
.map(ProtoUtils::toRaftPeer)
.collect(Collectors.toSet());
return getRaftGroup()
.getPeers()
.stream()
.filter(targets::contains);
}
```
##########
ratis-shell/src/main/java/org/apache/ratis/shell/cli/sh/election/TransferCommand.java:
##########
@@ -21,6 +21,7 @@
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.ratis.client.RaftClient;
+import org.apache.ratis.proto.RaftProtos;
Review Comment:
Let's import `RaftProtos.RaftPeerRole`. It will make the code shorter.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]