frankgh commented on code in PR #69:
URL: https://github.com/apache/cassandra-sidecar/pull/69#discussion_r1338970416
##########
adapters/base/src/main/java/org/apache/cassandra/sidecar/adapters/base/CassandraStorageOperations.java:
##########
@@ -55,14 +55,18 @@ public class CassandraStorageOperations implements
StorageOperations
*/
public CassandraStorageOperations(JmxClient jmxClient, DnsResolver
dnsResolver)
{
- this(jmxClient, new RingProvider(jmxClient, dnsResolver));
+ this(jmxClient,
+ new RingProvider(jmxClient, dnsResolver),
+ new TokenRangeReplicaProvider(jmxClient, dnsResolver));
}
- public CassandraStorageOperations(JmxClient jmxClient, RingProvider
ringProvider)
+ public CassandraStorageOperations(JmxClient jmxClient,
Review Comment:
I wonder why we have this constructor. It only seems to be used from the
call in line 58. Should we remove it?
##########
adapters/base/src/main/java/org/apache/cassandra/sidecar/adapters/base/TokenRangeReplicaProvider.java:
##########
@@ -115,22 +122,45 @@ 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(replica -> {
+ try
+ {
+ HostAndPort hap =
HostAndPort.fromString(replica);
+ return new ReplicaMetadata(state.of(replica),
+ status.of(replica),
+
dnsResolver.reverseResolve(hap.getHost()),
+ replica,
Review Comment:
since we already have it split, let's add an address field and a port field.
```suggestion
hap.getHost(),
hap.getPort(),
```
--
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]