ignite-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [ignite] NSAmelchev commented on a change in pull request #6882: IGNITE-12044: Export histogram values as separate JMX attributes.
Date Thu, 19 Sep 2019 13:04:54 GMT
NSAmelchev commented on a change in pull request #6882: IGNITE-12044: Export histogram values
as separate JMX attributes.
URL: https://github.com/apache/ignite/pull/6882#discussion_r326162086
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/spi/metric/jmx/MetricRegistryMBean.java
 ##########
 @@ -146,4 +176,55 @@ else if (metric instanceof ObjectMetric)
 
         throw new UnsupportedOperationException("invoke not supported.");
     }
+
+    /**
+     * Parse attribute name for a histogram and search it's value.
+     *
+     * @param name Attribute name.
+     * @param mreg Metric registry to search histogram in.
+     * @return Specific bucket value or {@code null} if not found.
+     * @see MetricUtils#histogramBucketNames(HistogramMetric, Map)
+     */
+    public static Long searchHistogram(String name, MetricRegistry mreg) {
+        Scanner sc = new Scanner(name).useDelimiter("_");
+
+        if (!sc.hasNext())
+            return null;
+
+        Metric m = mreg.findMetric(sc.next());
+
+        if (!(m instanceof HistogramMetric))
+            return null;
+
+        HistogramMetric h = (HistogramMetric)m;
+
+        long[] bounds = h.bounds();
+        long[] values = h.value();
+
+        if (!sc.hasNextLong())
+            return null;
+
+        long lowBound = sc.nextLong();
+
+        //If `highBound` not presented this can be last interval `[max]_inf`.
+        if (!sc.hasNextLong()) {
+            if (sc.hasNext() && INF.equals(sc.next()) && bounds[bounds.length-1]
== lowBound)
+                return values[values.length-1];
+
+            return null;
+        }
+
+        long highBound = sc.nextLong();
+
+        for (int i=0; i<bounds.length; i++) {
+            if (bounds[i] == highBound) {
 
 Review comment:
   Bounds are sorted so we can use the binary search here instead of a full scan.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message