Package org.apache.ignite.internal.processors.metric.impl

## Class MetricUtils

- java.lang.Object
- - org.apache.ignite.internal.processors.metric.impl.MetricUtils

    public class MetricUtils
    extends Object

Utility class to build or parse metric name in dot notation.

See Also:
  `GridMetricManager`, `MetricRegistry`

### Field Summary

Fields
`static char` `HISTOGRAM_NAME_DIVIDER` Histogram name divider.
`static String` `INF` Histogram metric last interval high bound.
`static String` `SEPARATOR` Metric name part separator.

### Constructor Summary

Constructors
`MetricUtils()`

### Method Summary

All Methods Static Methods Concrete Methods
`static String` `cacheGroupMetricsRegistryName​(String cacheOrGroupName)`
`static String` `cacheMetricsRegistryName​(String cacheName, boolean isNear)`
`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.
`static boolean` `customMetric​(String name)`
`static String` `customName​(String name)` Adds `GridMetricManager.CUSTOM_METRICS` to `name`.
`static T2<String,​String>` `fromFullName​(String name)` Splits full metric name to registry name and metric name.
`static String[]` `histogramBucketNames​(HistogramMetric metric)` Generates histogram bucket names.
`static String` `metricName​(String... names)` Chechs and builds metric name.
`static void` `setIfGreater​(AtomicLongMetric m, long update)` Update metrics value only if current value if greater then `update`.
`static void` `setIfLess​(AtomicLongMetric m, long update)` Update metrics value only if current value if less then `update`.
`static Map<String,​Class<?>>` `systemViewAttributes​(SystemView<?> sysView)` Extract attributes for system view.
`static String` `toSqlName​(String name)` Build SQL-like name from Java code style name.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### SEPARATOR

    public static final String SEPARATOR

Metric name part separator.

See Also:
  Constant Field Values

#### INF

    public static final String INF

Histogram metric last interval high bound.

See Also:
  Constant Field Values

#### HISTOGRAM_NAME_DIVIDER

    public static final char HISTOGRAM_NAME_DIVIDER

Histogram name divider.

See Also:
  Constant Field Values

### 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.

#### customName

    public static String customName​(String name)

Adds `GridMetricManager.CUSTOM_METRICS` to `name`.

#### 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.