public class ValueStatistics extends Object
| Constructor and Description |
|---|
ValueStatistics() |
| Modifier and Type | Method and Description |
|---|---|
static <T extends Serializable> |
constant(StatisticType type,
T value) |
static <T extends Number> |
counter(Supplier<T> supplier) |
static <T extends Number> |
gauge(Supplier<T> supplier) |
static <T extends Serializable> |
memoize(long delay,
TimeUnit unit,
ValueStatistic<T> valueStatistic)
Returns a
ValueStatistic that caches the value of a statistic for at least a specific amount of time. |
static <T extends Serializable> |
nullValue(StatisticType type) |
static <T extends Number> |
rate(Supplier<T> supplier) |
static <T extends Number> |
ratio(Supplier<T> supplier) |
static <T extends Serializable> |
supply(StatisticType type,
Supplier<T> supplier) |
static <T extends Table> |
table(Supplier<T> supplier) |
public static <T extends Serializable> ConstantValueStatistic<T> nullValue(StatisticType type)
public static <T extends Serializable> ConstantValueStatistic<T> constant(StatisticType type, T value)
public static <T extends Serializable> ValueStatistic<T> supply(StatisticType type, Supplier<T> supplier)
public static <T extends Number> ValueStatistic<T> gauge(Supplier<T> supplier)
public static <T extends Number> ValueStatistic<T> counter(Supplier<T> supplier)
public static <T extends Number> ValueStatistic<T> rate(Supplier<T> supplier)
public static <T extends Number> ValueStatistic<T> ratio(Supplier<T> supplier)
public static <T extends Table> ValueStatistic<T> table(Supplier<T> supplier)
public static <T extends Serializable> ValueStatistic<T> memoize(long delay, TimeUnit unit, ValueStatistic<T> valueStatistic)
ValueStatistic that caches the value of a statistic for at least a specific amount of time.
This method does not block.
When the delay expires, if several threads are coming at the same time to read the expired value, then only one will do the update and set a new expiring delay and read the new value. The other threads can continue to read the current expired value for their next call until it gets updated.
If the caching delay is smaller than the time it takes for a statistic value to be computed, then it is possible that a new thread starts asking for a new value before the previous update is completed. In this case, there is no guarantee that the cached value will be updated in order because it depends on the time took to get the new value.
T - The statistic typedelay - The delayunit - The unit of timevalueStatistic - The delegate statistic that will provide the valueCopyright © 2018. All rights reserved.