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 StatisticsgetOverallStatistics()This returns the overall statistics, that is not per thread but for the life of this objectStatisticsgetStatistics()This returns the statistics for this thread.voidincrementBatchLoadCountBy(long delta)Deprecated.<K> voidincrementBatchLoadCountBy(long delta, IncrementBatchLoadCountByStatisticsContext<K> context)Called to increment the number of batch loadsvoidincrementBatchLoadExceptionCount()Deprecated.<K> voidincrementBatchLoadExceptionCount(IncrementBatchLoadExceptionCountStatisticsContext<K> context)Called to increment the number of batch loads exceptionsvoidincrementCacheHitCount()Deprecated.<K> voidincrementCacheHitCount(IncrementCacheHitCountStatisticsContext<K> context)Called to increment the number of cache hitsvoidincrementLoadCount()Deprecated.<K> voidincrementLoadCount(IncrementLoadCountStatisticsContext<K> context)Called to increment the number of loadsvoidincrementLoadErrorCount()Deprecated.<K> voidincrementLoadErrorCount(IncrementLoadErrorCountStatisticsContext<K> context)Called to increment the number of loads that resulted in an object deemed in errorThreadLocalStatisticsCollectorresetThread()Removes the underlying thread local value for this current thread.java.lang.StringtoString()
-
-
-
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> void incrementLoadCount(IncrementLoadCountStatisticsContext<K> context)
Description copied from interface:StatisticsCollectorCalled to increment the number of loads- Specified by:
incrementLoadCountin interfaceStatisticsCollector- Type Parameters:
K- the class of the key in the data loader- Parameters:
context- the context containing metadata of the data loader invocation
-
incrementLoadCount
@Deprecated public void incrementLoadCount()
Deprecated.Description copied from interface:StatisticsCollectorCalled to increment the number of loads- Specified by:
incrementLoadCountin interfaceStatisticsCollector
-
incrementLoadErrorCount
public <K> void incrementLoadErrorCount(IncrementLoadErrorCountStatisticsContext<K> context)
Description copied from interface:StatisticsCollectorCalled to increment the number of loads that resulted in an object deemed in error- Specified by:
incrementLoadErrorCountin interfaceStatisticsCollector- Type Parameters:
K- the class of the key in the data loader- Parameters:
context- the context containing metadata of the data loader invocation
-
incrementLoadErrorCount
@Deprecated public void incrementLoadErrorCount()
Deprecated.Description copied from interface:StatisticsCollectorCalled to increment the number of loads that resulted in an object deemed in error- Specified by:
incrementLoadErrorCountin interfaceStatisticsCollector
-
incrementBatchLoadCountBy
public <K> void incrementBatchLoadCountBy(long delta, IncrementBatchLoadCountByStatisticsContext<K> context)Description copied from interface:StatisticsCollectorCalled to increment the number of batch loads- Specified by:
incrementBatchLoadCountByin 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
-
incrementBatchLoadCountBy
@Deprecated public void incrementBatchLoadCountBy(long delta)
Deprecated.Description copied from interface:StatisticsCollectorCalled to increment the number of batch loads- Specified by:
incrementBatchLoadCountByin interfaceStatisticsCollector- Parameters:
delta- how much to add to the count
-
incrementBatchLoadExceptionCount
public <K> void incrementBatchLoadExceptionCount(IncrementBatchLoadExceptionCountStatisticsContext<K> context)
Description copied from interface:StatisticsCollectorCalled to increment the number of batch loads exceptions- Specified by:
incrementBatchLoadExceptionCountin interfaceStatisticsCollector- Type Parameters:
K- the class of the key in the data loader- Parameters:
context- the context containing metadata of the data loader invocation
-
incrementBatchLoadExceptionCount
@Deprecated public void incrementBatchLoadExceptionCount()
Deprecated.Description copied from interface:StatisticsCollectorCalled to increment the number of batch loads exceptions- Specified by:
incrementBatchLoadExceptionCountin interfaceStatisticsCollector
-
incrementCacheHitCount
public <K> void incrementCacheHitCount(IncrementCacheHitCountStatisticsContext<K> context)
Description copied from interface:StatisticsCollectorCalled to increment the number of cache hits- Specified by:
incrementCacheHitCountin interfaceStatisticsCollector- Type Parameters:
K- the class of the key in the data loader- Parameters:
context- the context containing metadata of the data loader invocation
-
incrementCacheHitCount
@Deprecated public void incrementCacheHitCount()
Deprecated.Description copied from interface:StatisticsCollectorCalled to increment the number of cache hits- Specified by:
incrementCacheHitCountin interfaceStatisticsCollector
-
getStatistics
public Statistics getStatistics()
This returns the statistics for this thread.- Specified by:
getStatisticsin 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:
toStringin classjava.lang.Object
-
-