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