szetszwo commented on a change in pull request #364:
URL: https://github.com/apache/incubator-ratis/pull/364#discussion_r546331656



##########
File path: 
ratis-client/src/main/java/org/apache/ratis/client/api/DataStreamApi.java
##########
@@ -44,4 +48,7 @@ default DataStreamOutput stream() {
 
   /** Create a stream by providing a customized header message. */
   DataStreamOutput stream(ByteBuffer headerMessage);
+
+  /** Create a stream by providing a customized header message and route 
table. */
+  DataStreamOutput stream(ByteBuffer headerMessage, Map<RaftPeerId, 
List<RaftPeerId>> routingTable);

Review comment:
       It should use RoutingTable as the type.

##########
File path: 
ratis-netty/src/main/java/org/apache/ratis/netty/server/DataStreamManagement.java
##########
@@ -145,6 +150,22 @@ LocalStream getLocal() {
     public String toString() {
       return JavaUtils.getClassSimpleName(getClass()) + ":" + request;
     }
+
+    @Override
+    public List<RaftPeerId> getSuccessors(RaftPeerId peerId) throws 
IOException {
+      Map<RaftPeerId, List<RaftPeerId>> routingTable = 
request.getRoutingTable();
+      if (routingTable.containsKey(peerId)) {
+        return routingTable.get(peerId);
+      } else if (isPrimary()) {
+        // TODO(runzhiwang): if filestore support route table, we can remove 
this branch

Review comment:
       We should keep this branch as the default for the applications which 
does not support RoutingTable.

##########
File path: 
ratis-netty/src/main/java/org/apache/ratis/netty/server/DataStreamManagement.java
##########
@@ -145,6 +150,22 @@ LocalStream getLocal() {
     public String toString() {
       return JavaUtils.getClassSimpleName(getClass()) + ":" + request;
     }
+
+    @Override
+    public List<RaftPeerId> getSuccessors(RaftPeerId peerId) throws 
IOException {
+      Map<RaftPeerId, List<RaftPeerId>> routingTable = 
request.getRoutingTable();
+      if (routingTable.containsKey(peerId)) {
+        return routingTable.get(peerId);
+      } else if (isPrimary()) {
+        // TODO(runzhiwang): if filestore support route table, we can remove 
this branch
+        final RaftGroupId groupId = request.getRaftGroupId();
+        return 
server.getDivision(groupId).getRaftConf().getCurrentPeers().stream()
+            .filter(p -> 
!p.getId().equals(server.getId())).map(RaftPeer::getId)
+            .collect(Collectors.toList());
+      } else {
+        return new ArrayList<>();

Review comment:
       Use `Collections.emptyList()`.
   




----------------------------------------------------------------
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]


Reply via email to