szetszwo commented on code in PR #945:
URL: https://github.com/apache/ratis/pull/945#discussion_r1367314944
##########
ratis-client/src/main/java/org/apache/ratis/client/impl/DataStreamClientImpl.java:
##########
@@ -230,6 +231,14 @@ public DataStreamOutputRpc stream(ByteBuffer
headerMessage) {
@Override
public DataStreamOutputRpc stream(ByteBuffer headerMessage, RoutingTable
routingTable) {
+ if (routingTable != null && routingTable.getPrimary() != null) {
+ // Validate that the primary peer is equal to the primary peer passed
+ // by the RoutingTable
+ Preconditions.assertTrue(
+ dataStreamServer.getId().equals(routingTable.getPrimary()),
+ "The primary peer in the routing table is not the same " +
+ "with the one specified in the client");
Review Comment:
Let's include the peer Ids in the message.
##########
ratis-common/src/main/java/org/apache/ratis/protocol/RoutingTable.java:
##########
@@ -159,7 +164,7 @@ public String toString() {
/** @return a new {@link RoutingTable} represented by the given map. */
static RoutingTable newRoutingTable(Map<RaftPeerId, Set<RaftPeerId>> map){
- Builder.validate(map);
+ RaftPeerId primary = Builder.validate(map);
Review Comment:
Let's return null when `map == null || map.isEmpty()`. Then, we can assume
the map is non-empty from here.
##########
ratis-client/src/main/java/org/apache/ratis/client/impl/DataStreamClientImpl.java:
##########
@@ -230,6 +231,14 @@ public DataStreamOutputRpc stream(ByteBuffer
headerMessage) {
@Override
public DataStreamOutputRpc stream(ByteBuffer headerMessage, RoutingTable
routingTable) {
+ if (routingTable != null && routingTable.getPrimary() != null) {
Review Comment:
Let's require `routingTable.getPrimary()` must be non-null.
--
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]