From notifications-return-6918-archive-asf-public=cust-asf.ponee.io@ignite.apache.org Thu Sep 19 13:08:04 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id C5BE818062C for ; Thu, 19 Sep 2019 15:08:03 +0200 (CEST) Received: (qmail 33446 invoked by uid 500); 19 Sep 2019 13:08:03 -0000 Mailing-List: contact notifications-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list notifications@ignite.apache.org Received: (qmail 33437 invoked by uid 99); 19 Sep 2019 13:08:03 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Sep 2019 13:08:03 +0000 From: GitBox To: notifications@ignite.apache.org Subject: [GitHub] [ignite] nizhikov commented on a change in pull request #6882: IGNITE-12044: Export histogram values as separate JMX attributes. Message-ID: <156889848311.3030.8833366386485921229.gitbox@gitbox.apache.org> Date: Thu, 19 Sep 2019 13:08:03 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit nizhikov 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_r326163490 ########## 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