Package org.dataloader.stats
Class ThreadLocalStatisticsCollector
- java.lang.Object
-
- org.dataloader.stats.ThreadLocalStatisticsCollector
-
- All Implemented Interfaces:
StatisticsCollector
public class ThreadLocalStatisticsCollector extends java.lang.Object implements StatisticsCollector
This can collect statistics per thread as well as in an overall sense. This allows you to snapshot stats for a web request say as well as all requests.You will want to call
resetThread()
to clean up the thread local aspects of this object per request thread.ThreadLocals have their place in the Java world but be careful on how you use them. If you don't clean them up on "request boundaries" then you WILL have misleading statistics.
- See Also:
StatisticsCollector
-
-
Constructor Summary
Constructors Constructor Description ThreadLocalStatisticsCollector()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Statistics
getOverallStatistics()
This returns the overall statistics, that is not per thread but for the life of this objectStatistics
getStatistics()
This returns the statistics for this thread.long
incrementBatchLoadCountBy(long delta)
Deprecated.<K> long
incrementBatchLoadCountBy(long delta, IncrementBatchLoadCountByStatisticsContext<K> context)
Called to increment the number of batch loadslong
incrementBatchLoadExceptionCount()
Deprecated.<K> long
incrementBatchLoadExceptionCount(IncrementBatchLoadExceptionCountStatisticsContext<K> context)
Called to increment the number of batch loads exceptionslong
incrementCacheHitCount()
Deprecated.<K> long
incrementCacheHitCount(IncrementCacheHitCountStatisticsContext<K> context)
Called to increment the number of cache hitslong
incrementLoadCount()
Deprecated.<K> long
incrementLoadCount(IncrementLoadCountStatisticsContext<K> context)
Called to increment the number of loadslong
incrementLoadErrorCount()
Deprecated.<K> long
incrementLoadErrorCount(IncrementLoadErrorCountStatisticsContext<K> context)
Called to increment the number of loads that resulted in an object deemed in errorThreadLocalStatisticsCollector
resetThread()
Removes the underlying thread local value for this current thread.java.lang.String
toString()
-
-
-
Method Detail
-
resetThread
public ThreadLocalStatisticsCollector resetThread()
Removes the underlying thread local value for this current thread. This is a way to reset the thread local values for the current thread and start afresh- Returns:
- this collector for fluent coding
-
incrementLoadCount
public <K> long incrementLoadCount(IncrementLoadCountStatisticsContext<K> context)
Description copied from interface:StatisticsCollector
Called to increment the number of loads- Specified by:
incrementLoadCount
in interfaceStatisticsCollector
- Type Parameters:
K
- the class of the key in the data loader- Parameters:
context
- the context containing metadata of the data loader invocation- Returns:
- the current value after increment
-
incrementLoadCount
@Deprecated public long incrementLoadCount()
Deprecated.Description copied from interface:StatisticsCollector
Called to increment the number of loads- Specified by:
incrementLoadCount
in interfaceStatisticsCollector
- Returns:
- the current value after increment
-
incrementLoadErrorCount
public <K> long incrementLoadErrorCount(IncrementLoadErrorCountStatisticsContext<K> context)
Description copied from interface:StatisticsCollector
Called to increment the number of loads that resulted in an object deemed in error- Specified by:
incrementLoadErrorCount
in interfaceStatisticsCollector
- Type Parameters:
K
- the class of the key in the data loader- Parameters:
context
- the context containing metadata of the data loader invocation- Returns:
- the current value after increment
-
incrementLoadErrorCount
@Deprecated public long incrementLoadErrorCount()
Deprecated.Description copied from interface:StatisticsCollector
Called to increment the number of loads that resulted in an object deemed in error- Specified by:
incrementLoadErrorCount
in interfaceStatisticsCollector
- Returns:
- the current value after increment
-
incrementBatchLoadCountBy
public <K> long incrementBatchLoadCountBy(long delta, IncrementBatchLoadCountByStatisticsContext<K> context)
Description copied from interface:StatisticsCollector
Called to increment the number of batch loads- Specified by:
incrementBatchLoadCountBy
in interfaceStatisticsCollector
- Type Parameters:
K
- the class of the key in the data loader- Parameters:
delta
- how much to add to the countcontext
- the context containing metadata of the data loader invocation- Returns:
- the current value after increment
-
incrementBatchLoadCountBy
@Deprecated public long incrementBatchLoadCountBy(long delta)
Deprecated.Description copied from interface:StatisticsCollector
Called to increment the number of batch loads- Specified by:
incrementBatchLoadCountBy
in interfaceStatisticsCollector
- Parameters:
delta
- how much to add to the count- Returns:
- the current value after increment
-
incrementBatchLoadExceptionCount
public <K> long incrementBatchLoadExceptionCount(IncrementBatchLoadExceptionCountStatisticsContext<K> context)
Description copied from interface:StatisticsCollector
Called to increment the number of batch loads exceptions- Specified by:
incrementBatchLoadExceptionCount
in interfaceStatisticsCollector
- Type Parameters:
K
- the class of the key in the data loader- Parameters:
context
- the context containing metadata of the data loader invocation- Returns:
- the current value after increment
-
incrementBatchLoadExceptionCount
@Deprecated public long incrementBatchLoadExceptionCount()
Deprecated.Description copied from interface:StatisticsCollector
Called to increment the number of batch loads exceptions- Specified by:
incrementBatchLoadExceptionCount
in interfaceStatisticsCollector
- Returns:
- the current value after increment
-
incrementCacheHitCount
public <K> long incrementCacheHitCount(IncrementCacheHitCountStatisticsContext<K> context)
Description copied from interface:StatisticsCollector
Called to increment the number of cache hits- Specified by:
incrementCacheHitCount
in interfaceStatisticsCollector
- Type Parameters:
K
- the class of the key in the data loader- Parameters:
context
- the context containing metadata of the data loader invocation- Returns:
- the current value after increment
-
incrementCacheHitCount
@Deprecated public long incrementCacheHitCount()
Deprecated.Description copied from interface:StatisticsCollector
Called to increment the number of cache hits- Specified by:
incrementCacheHitCount
in interfaceStatisticsCollector
- Returns:
- the current value after increment
-
getStatistics
public Statistics getStatistics()
This returns the statistics for this thread.- Specified by:
getStatistics
in interfaceStatisticsCollector
- Returns:
- this thread's statistics
-
getOverallStatistics
public Statistics getOverallStatistics()
This returns the overall statistics, that is not per thread but for the life of this object- Returns:
- overall statistics
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-