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

## Class HitRateMetric

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

All Implemented Interfaces:
  LongMetric, Metric

    public class HitRateMetric
    extends AbstractMetric
    implements LongMetric

Accumulates approximate hit rate statistics. Calculates number of hits in last `rateTimeInterval` milliseconds. Algorithm is based on circular array of `size` hit counters, each is responsible for last corresponding time interval of `rateTimeInterval`/`size` milliseconds. Resulting number of hits is sum of all counters.

Implementation is nonblocking and protected from hits loss. Maximum relative error is 1/`size`. 2^55 - 1 hits per interval can be accumulated without numeric overflow.

### Field Summary

Fields
`static int` `DFLT_SIZE` Default counters array size.

### Constructor Summary

Constructors
Constructor and Description
`HitRateMetric(String name, @Nullable String desc, long rateTimeInterval, int size)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `add(long x)` Adds x to the metric.
`void` `increment()` Adds 1 to the metric.
`long` `rateTimeInterval()`
`void` `reset()` Resets metric state.
`void` `reset(long rateTimeInterval)` Resets metric with the new parametes.
`void` `reset(long rateTimeInterval, int size)` Resets metric with the new parameters.
`long` `value()`

### Methods inherited from class org.apache.ignite.internal.processors.metric.AbstractMetric

`description, equals, hashCode, name`

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

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

### Methods inherited from interface org.apache.ignite.spi.metric.LongMetric

`getAsString`

### Methods inherited from interface org.apache.ignite.spi.metric.Metric

`description, name`

### Field Detail

#### DFLT_SIZE

    public static final int DFLT_SIZE

Default counters array size.

See Also:
  Constant Field Values

### Constructor Detail

#### HitRateMetric

    public HitRateMetric(String name,
                         @Nullable
                         @Nullable String desc,
                         long rateTimeInterval,
                         int size)

Parameters:
  `name` - Name.
  `desc` - Description.
  `rateTimeInterval` - Rate time interval in milliseconds.
  `size` - Counters array size.

### Method Detail

#### reset

    public void reset()

Resets metric state.

Specified by:
  `reset` in interface `Metric`

#### reset

    public void reset(long rateTimeInterval)

Resets metric with the new parametes.

Parameters:
  `rateTimeInterval` - New rate time interval.

#### reset

    public void reset(long rateTimeInterval,
                      int size)

Resets metric with the new parameters.

Parameters:
  `rateTimeInterval` - New rate time interval.
  `size` - New counters array size.

#### add

    public void add(long x)

Adds x to the metric.

Parameters:
  `x` - Value to be added.

#### increment

    public void increment()

Adds 1 to the metric.

#### value

    public long value()

Specified by:
  `value` in interface `LongMetric`
Returns:
  Value of the metric.

#### rateTimeInterval

    public long rateTimeInterval()

Returns:
  Rate time interval in milliseconds.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.10.0
Release Date | : March 10 2021