use of com.baidu.hugegraph.backend.store.raft.rpc.RaftRequests.ListPeersResponse in project incubator-hugegraph by apache.
the class RaftGroupManagerImpl method listPeers.
@Override
public List<String> listPeers() {
if (this.raftNode.selfIsLeader()) {
List<PeerId> peerIds = this.raftNode.node().listPeers();
return peerIds.stream().map(PeerId::toString).collect(Collectors.toList());
}
// If current node is not leader, forward request to leader
ListPeersRequest request = ListPeersRequest.getDefaultInstance();
try {
RaftClosure<ListPeersResponse> future;
future = this.forwardToLeader(request);
ListPeersResponse response = future.waitFinished();
return response.getEndpointsList();
} catch (Throwable e) {
throw new BackendException("Failed to list peers", e);
}
}
Aggregations