szetszwo commented on pull request #364:
URL: https://github.com/apache/incubator-ratis/pull/364#issuecomment-748587147
RoutingTable is a small interface to encapsulate the getSuccessors(..)
method. We want to use it instead of Map since we don't have to build a Map in
some cases. E.g. the default uses a RaftConfigurable to return the other peer
ids.
BTW, StreamInfo does not have to implement RoutingTable. It may just
provide a getSuccessors method as below.
```
// StreamInfo
private Set<RaftPeer> getSuccessors(RaftPeerId peerId, RaftConfiguration
conf) {
final RoutingTable routingTable = ...;
if (routingTable != null) {
return
routingTable.getSuccessors(peerId).stream().map(conf::getPeer).collect(Collectors.toSet());
} if (isPrimary()) {
return conf.getCurrentPeers().stream()
.filter(p -> !p.getId().equals(server.getId()))
.collect(Collectors.toSet());
} else {
return Collections.emptySet();
}
}
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]