Package org.terracotta.statistics
Class ValueStatistics
- java.lang.Object
-
- org.terracotta.statistics.ValueStatistics
-
public class ValueStatistics extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ValueStatistics()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends java.io.Serializable>
ConstantValueStatistic<T>constant(StatisticType type, T value)static <T extends java.lang.Number>
ValueStatistic<T>counter(java.util.function.Supplier<T> supplier)static <T extends java.lang.Number>
ValueStatistic<T>gauge(java.util.function.Supplier<T> supplier)static <T extends java.io.Serializable>
ValueStatistic<T>memoize(long delay, java.util.concurrent.TimeUnit unit, ValueStatistic<T> valueStatistic)Returns aValueStatisticthat caches the value of a statistic for at least a specific amount of time.static <T extends java.io.Serializable>
ConstantValueStatistic<T>nullValue(StatisticType type)static <T extends java.lang.Number>
ValueStatistic<T>rate(java.util.function.Supplier<T> supplier)static <T extends java.lang.Number>
ValueStatistic<T>ratio(java.util.function.Supplier<T> supplier)static <T extends java.io.Serializable>
ValueStatistic<T>supply(StatisticType type, java.util.function.Supplier<T> supplier)static <T extends Table>
ValueStatistic<T>table(java.util.function.Supplier<T> supplier)
-
-
-
Method Detail
-
nullValue
public static <T extends java.io.Serializable> ConstantValueStatistic<T> nullValue(StatisticType type)
-
constant
public static <T extends java.io.Serializable> ConstantValueStatistic<T> constant(StatisticType type, T value)
-
supply
public static <T extends java.io.Serializable> ValueStatistic<T> supply(StatisticType type, java.util.function.Supplier<T> supplier)
-
gauge
public static <T extends java.lang.Number> ValueStatistic<T> gauge(java.util.function.Supplier<T> supplier)
-
counter
public static <T extends java.lang.Number> ValueStatistic<T> counter(java.util.function.Supplier<T> supplier)
-
rate
public static <T extends java.lang.Number> ValueStatistic<T> rate(java.util.function.Supplier<T> supplier)
-
ratio
public static <T extends java.lang.Number> ValueStatistic<T> ratio(java.util.function.Supplier<T> supplier)
-
table
public static <T extends Table> ValueStatistic<T> table(java.util.function.Supplier<T> supplier)
-
memoize
public static <T extends java.io.Serializable> ValueStatistic<T> memoize(long delay, java.util.concurrent.TimeUnit unit, ValueStatistic<T> valueStatistic)
Returns aValueStatisticthat 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.
- Type Parameters:
T- The statistic type- Parameters:
delay- The delayunit- The unit of timevalueStatistic- The delegate statistic that will provide the value- Returns:
- the memoizing statistic
-
-