Class MetricUtils

    • Constructor Detail

      • MetricUtils

        public MetricUtils()
    • Method Detail

      • metricName

        public static String metricName​(String... names)
        Chechs and builds metric name.
        Parameters:
        names - Metric name parts.
        Returns:
        Metric name.
      • customMetric

        public static boolean customMetric​(String name)
        Returns:
        True if name is or start with the custom metric prefix.
      • fromFullName

        public static T2<String,​String> fromFullName​(String name)
        Splits full metric name to registry name and metric name.
        Parameters:
        name - Full metric name.
        Returns:
        Array consist of registry name and metric name.
      • cacheMetricsRegistryName

        public static String cacheMetricsRegistryName​(String cacheName,
                                                      boolean isNear)
        Parameters:
        cacheName - Cache name.
        isNear - Is near flag.
        Returns:
        Cache metrics registry name.
      • cacheGroupMetricsRegistryName

        public static String cacheGroupMetricsRegistryName​(String cacheOrGroupName)
        Parameters:
        cacheOrGroupName - Cache or group name, depending whether group is implicit or not.
        Returns:
        Cache metrics registry name.
      • compareAndSet

        public static boolean compareAndSet​(AtomicLongMetric m,
                                            long expect,
                                            long update)
        Atomically sets the value to the given updated value if the current value == the expected value.
        Parameters:
        m - Metric.
        expect - The expected value.
        update - The new value.
        Returns:
        true if successful. False return indicates that the actual value was not equal to the expected value.
      • setIfLess

        public static void setIfLess​(AtomicLongMetric m,
                                     long update)
        Update metrics value only if current value if less then update.
        Parameters:
        m - Metric to update.
        update - New value.
      • setIfGreater

        public static void setIfGreater​(AtomicLongMetric m,
                                        long update)
        Update metrics value only if current value if greater then update.
        Parameters:
        m - Metric to update.
        update - New value.
      • histogramBucketNames

        public static String[] histogramBucketNames​(HistogramMetric metric)
        Generates histogram bucket names. Example of metric names if bounds are 10,100: histogram_0_10 (less than 10) histogram_10_100 (between 10 and 100) histogram_100_inf (more than 100)
        Parameters:
        metric - Histogram metric
        Returns:
        Histogram intervals names.
      • toSqlName

        public static String toSqlName​(String name)
        Build SQL-like name from Java code style name. Some examples: cacheName -> CACHE_NAME. affinitiKeyName -> AFFINITY_KEY_NAME.
        Parameters:
        name - Name to convert.
        Returns:
        SQL compatible name.
      • systemViewAttributes

        public static Map<String,​Class<?>> systemViewAttributes​(SystemView<?> sysView)
        Extract attributes for system view.
        Parameters:
        sysView - System view.
        Returns:
        Attributes map.