Add metric with neighbours for each token range - #9
Conversation
| final Stream<NumericMetric> ownershipMetricStream = metadataFactory.keyspaces().stream() | ||
| .filter(keyspace -> !excludedKeyspaces.contains(keyspace)) | ||
| .flatMap(keyspace -> { | ||
| try { |
There was a problem hiding this comment.
In order to increase readability for this method, what do you think about extracting this block into a dedicated method? I imagine it could return a Stream<...>
There was a problem hiding this comment.
I agree, and I'll remember this. But if you look further down (see effectiveOwnership(keyspace)) in the code you'll see that's not how the code is written, so for now I'd keep the same code style.
| // token range example: | ||
| // TokenRange(start_token:5585272669612250202, end_token:5664918566912044362, endpoints:[172.16.28.48, 172.16.28.166], rpc_endpoints:[172.16.28.48, 172.16.28.166], endpoint_details:[EndpointDetails(host:172.16.28.48, datacenter:eu-west_edge-irl1_profiles-bk, rack:1a), EndpointDetails(host:172.16.28.166, datacenter:eu-west_edge-irl1_profiles-bk, rack:1c)]) | ||
| // see https://github.com/apache/cassandra/blob/trunk/src/java/org/apache/cassandra/service/TokenRange.java | ||
| String s = tokenRange.substring(tokenRange.indexOf(", endpoints:") + 13); |
There was a problem hiding this comment.
Are the token ranges always in valid format? If not, should we have a regex to validate them before going ahead with these splits/substrings?
There was a problem hiding this comment.
The format is fixed, and it's very unlikely to change in the future. It seems to have been added just to preserve some backward compatibility, and it's unlikely to ever change. It's used only by a nodetool option, nodedetool describering. Anyway, I'll change it to a regex match and group, it's probably safer anyway.
No description provided.