Top Constructors Methods
org.terracotta.statistics

public Class ValueStatistics

extends Object
Class Inheritance
Imports
java.io.Serializable, java.util.concurrent.TimeUnit, java.util.function.Supplier

Author
Mathieu Carbou

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static <T extends Serializable> ConstantValueStatistic<T>
constant(StatisticType type, T value)

public static <T extends Number> ValueStatistic<T>
counter(Supplier<T> supplier)

public static <T extends Number> ValueStatistic<T>
gauge(Supplier<T> supplier)

public static <
The statistic type
T extends Serializable
>
ValueStatistic<T>

Returns:

the memoizing statistic
memoize
(long
The delay
delay
,
TimeUnit
The unit of time
unit
,
ValueStatistic<T>
The delegate statistic that will provide the value
valueStatistic
)

Returns a ValueStatistic that caches the value of a statistic for at least a specific amount of time.

public static <T extends Serializable> ConstantValueStatistic<T>
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 Serializable> ValueStatistic<T>
supply(StatisticType type, Supplier<T> supplier)

public static <T extends Table> ValueStatistic<T>
table(Supplier<T> supplier)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ValueStatisticsback to summary
public ValueStatistics()

Method Detail

constantback to summary
public static <T extends Serializable> ConstantValueStatistic<T> constant(StatisticType type, T value)
counterback to summary
public static <T extends Number> ValueStatistic<T> counter(Supplier<T> supplier)
gaugeback to summary
public static <T extends Number> ValueStatistic<T> gauge(Supplier<T> supplier)
memoizeback to summary
public static <T extends Serializable> ValueStatistic<T> 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.

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.

Parameters
<T>
The statistic type
delay:long

The delay

unit:TimeUnit

The unit of time

valueStatistic:ValueStatistic<T>

The delegate statistic that will provide the value

Returns:ValueStatistic<T>

the memoizing statistic

nullValueback to summary
public static <T extends Serializable> ConstantValueStatistic<T> nullValue(StatisticType type)
rateback to summary
public static <T extends Number> ValueStatistic<T> rate(Supplier<T> supplier)
ratioback to summary
public static <T extends Number> ValueStatistic<T> ratio(Supplier<T> supplier)
supplyback to summary
public static <T extends Serializable> ValueStatistic<T> supply(StatisticType type, Supplier<T> supplier)
tableback to summary
public static <T extends Table> ValueStatistic<T> table(Supplier<T> supplier)