Package org.terracotta.statistics
Class StatisticMapper<SOURCE extends Enum<SOURCE>,TARGET extends Enum<TARGET>>
- java.lang.Object
-
- org.terracotta.statistics.StatisticMapper<SOURCE,TARGET>
-
- All Implemented Interfaces:
OperationObserver<TARGET>,OperationStatistic<TARGET>,SourceStatistic<ChainedOperationObserver<? super TARGET>>
public class StatisticMapper<SOURCE extends Enum<SOURCE>,TARGET extends Enum<TARGET>> extends Object implements OperationStatistic<TARGET>
-
-
Constructor Summary
Constructors Constructor Description StatisticMapper(Map<TARGET,Set<SOURCE>> translation, OperationStatistic<SOURCE> statistic)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDerivedStatistic(ChainedOperationObserver<? super TARGET> derived)Register the givenObserverto be called by thisSourceStatisticvoidbegin()Called immediately prior to the operation beginning.longcount(TARGET type)Return the count of operations with the given type.voidend(TARGET result)Called immediately after the operation completes with no interesting parameters, and with the same thread the called {OperationObserver.begin()} before.Collection<ChainedOperationObserver<? super TARGET>>getDerivedStatistics()Retrieve all registered statistics.voidremoveDerivedStatistic(ChainedOperationObserver<? super TARGET> derived)Remove the given registeredObserverfrom thisSourceStatistic.ValueStatistic<Long>statistic(Set<TARGET> results)ValueStatistic<Long>statistic(TARGET result)Return aValueStatisticreturning the count for the given result.longsum()longsum(Set<TARGET> types)Class<TARGET>type()
-
-
-
Method Detail
-
type
public Class<TARGET> type()
- Specified by:
typein interfaceOperationStatistic<SOURCE extends Enum<SOURCE>>
-
statistic
public ValueStatistic<Long> statistic(TARGET result)
Description copied from interface:OperationStatisticReturn aValueStatisticreturning the count for the given result.- Specified by:
statisticin interfaceOperationStatistic<SOURCE extends Enum<SOURCE>>- Parameters:
result- the result of interest- Returns:
- a
ValueStatisticinstance
-
statistic
public ValueStatistic<Long> statistic(Set<TARGET> results)
- Specified by:
statisticin interfaceOperationStatistic<SOURCE extends Enum<SOURCE>>
-
count
public long count(TARGET type)
Description copied from interface:OperationStatisticReturn the count of operations with the given type.- Specified by:
countin interfaceOperationStatistic<SOURCE extends Enum<SOURCE>>- Parameters:
type- the result type- Returns:
- the operation count
-
sum
public long sum(Set<TARGET> types)
- Specified by:
sumin interfaceOperationStatistic<SOURCE extends Enum<SOURCE>>
-
sum
public long sum()
- Specified by:
sumin interfaceOperationStatistic<SOURCE extends Enum<SOURCE>>
-
addDerivedStatistic
public void addDerivedStatistic(ChainedOperationObserver<? super TARGET> derived)
Description copied from interface:SourceStatisticRegister the givenObserverto be called by thisSourceStatistic- Specified by:
addDerivedStatisticin interfaceSourceStatistic<SOURCE extends Enum<SOURCE>>- Parameters:
derived- statistic to be registered
-
removeDerivedStatistic
public void removeDerivedStatistic(ChainedOperationObserver<? super TARGET> derived)
Description copied from interface:SourceStatisticRemove the given registeredObserverfrom thisSourceStatistic.- Specified by:
removeDerivedStatisticin interfaceSourceStatistic<SOURCE extends Enum<SOURCE>>- Parameters:
derived- statistic to be removed
-
getDerivedStatistics
public Collection<ChainedOperationObserver<? super TARGET>> getDerivedStatistics()
Description copied from interface:SourceStatisticRetrieve all registered statistics.- Specified by:
getDerivedStatisticsin interfaceSourceStatistic<SOURCE extends Enum<SOURCE>>- Returns:
- an unmodifiable collection of all derived statistics
-
begin
public void begin()
Description copied from interface:OperationObserverCalled immediately prior to the operation beginning.- Specified by:
beginin interfaceOperationObserver<SOURCE extends Enum<SOURCE>>
-
end
public void end(TARGET result)
Description copied from interface:OperationObserverCalled immediately after the operation completes with no interesting parameters, and with the same thread the called {OperationObserver.begin()} before.- Specified by:
endin interfaceOperationObserver<SOURCE extends Enum<SOURCE>>- Parameters:
result- the operation result
-
-