Skip to content

Commit

Permalink
Modified by review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
idellzheng committed Aug 16, 2023
1 parent 24b7d1f commit 74ca5ae
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.ratis.proto.RaftProtos;
import org.apache.ratis.shell.cli.RaftUtils;
import org.apache.ratis.shell.cli.sh.command.AbstractRatisCommand;
import org.apache.ratis.shell.cli.sh.command.Context;
import org.apache.ratis.thirdparty.com.google.protobuf.ByteString;
Expand Down Expand Up @@ -60,12 +61,15 @@ public String getCommandName() {
public int run(CommandLine cl) throws IOException {
String peersStr = cl.getOptionValue(PEER_OPTION_NAME);
String path = cl.getOptionValue(PATH_OPTION_NAME);
if (peersStr == null || path == null || peersStr.isEmpty() || path.isEmpty()) {
System.out.println("peers or path can't be empty.");
return -1;
}
List<RaftProtos.RaftPeerProto> raftPeerProtos = new ArrayList<>();
for (String peer : peersStr.split(",")) {
String[] peerInfos = peer.split(":");
String peerId = peerInfos[0] + "_" + peerInfos[1];
for (String address : peersStr.split(",")) {
String peerId = RaftUtils.getPeerId(parseInetSocketAddress(address)).toString();
raftPeerProtos.add(RaftProtos.RaftPeerProto.newBuilder()
.setId(ByteString.copyFrom(peerId.getBytes(StandardCharsets.UTF_8))).setAddress(peer)
.setId(ByteString.copyFrom(peerId.getBytes(StandardCharsets.UTF_8))).setAddress(address)
.setStartupRole(RaftProtos.RaftPeerRole.FOLLOWER).build());
}
try (InputStream in = new FileInputStream(new File(path, RAFT_META_CONF));
Expand Down

0 comments on commit 74ca5ae

Please sign in to comment.