frankgh commented on code in PR #69:
URL: https://github.com/apache/cassandra-sidecar/pull/69#discussion_r1331967226


##########
adapters/base/src/main/java/org/apache/cassandra/sidecar/adapters/base/TokenRangeReplicaProvider.java:
##########
@@ -115,22 +121,51 @@ private List<TokenRangeReplicas> 
transformRangeMappings(Map<List<String>, List<S
                               .collect(toList());
     }
 
-    private Map<String, String> replicaToStateMap(List<TokenRangeReplicas> 
replicaSet, StorageJmxOperations storage)
+    private List<ReplicaMetadata> getReplicaMetadata(List<TokenRangeReplicas> 
replicaSet,
+                                                     StorageJmxOperations 
storage,
+                                                     Map<String, String> 
hostToDatacenter)
     {
         List<String> joiningNodes = storage.getJoiningNodesWithPort();
         List<String> leavingNodes = storage.getLeavingNodesWithPort();
         List<String> movingNodes = storage.getMovingNodesWithPort();
 
+        List<String> liveNodes = storage.getLiveNodesWithPort();
+        List<String> deadNodes = storage.getUnreachableNodesWithPort();
+
+
         String rawGossipInfo = getRawGossipInfo();
         GossipInfoResponse gossipInfo = GossipInfoParser.parse(rawGossipInfo);
 
         StateWithReplacement state = new StateWithReplacement(joiningNodes, 
leavingNodes, movingNodes, gossipInfo);
+        RingProvider.Status status = new RingProvider.Status(liveNodes, 
deadNodes);
 
         return replicaSet.stream()
                          .map(TokenRangeReplicas::replicaSet)
                          .flatMap(Collection::stream)
                          .distinct()
-                         .collect(Collectors.toMap(Function.identity(), 
state::of));
+                         .map(r -> new ReplicaMetadata(state.of(r),
+                                                       status.of(r),
+                                                       resolveReplica(r),
+                                                       r,
+                                                       
hostToDatacenter.get(r)))
+                         .collect(Collectors.toList());
+
+    }
+
+    private String resolveReplica(String r)
+    {
+        String hostName;
+        try
+        {
+            hostName = dnsResolver.reverseResolve(r.split(":")[0]);

Review Comment:
   We have some class that will get the host and port for use, just use the 
class. Splitting and getting an index is prone to errors. I believe the library 
is HostAndPort
   ```suggestion
               hostName = dnsResolver.reverseResolve(r.split(":")[0]);
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to