You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/08/17 15:11:34 UTC
[GitHub] [ozone] dombizita commented on a diff in pull request #3677: HDDS-7045. Election info is out of date in Recon
dombizita commented on code in PR #3677:
URL: https://github.com/apache/ozone/pull/3677#discussion_r948070379
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/PipelineEndpoint.java:
##########
@@ -130,25 +130,55 @@ public Response getPipelines() {
return Response.ok(pipelinesResponse).build();
}
- private Optional<Long> getMetricValue(String metricName, String groupId) {
+ private Long getElectionCountMetricValue(String groupId) {
+ Long electionCount = 0L;
String metricsQuery = String.format(
- "query=%s{group=\"%s\"}", metricName, groupId);
+ "query=ratis_leader_election_electionCount{group=\"%s\"}", groupId);
try {
List<Metric> metrics = metricsServiceProvider.getMetricsInstant(
- metricsQuery);
+ metricsQuery);
+ if (!metrics.isEmpty()) {
+ for (Metric m : metrics) {
+ TreeMap<Double, Double> values = (TreeMap<Double, Double>)
+ m.getValues();
+ if (!values.isEmpty()) {
+ electionCount += Optional.of(values.firstEntry().getValue()
+ .longValue()).orElse(0L);
Review Comment:
As we discussed offline, the optional is unnecessary as I am checking if the values is empty one line above. With this way there will always be a first entry and also its value. I updated my patch based on this.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org