-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added statistics support * added delegating stats collector * Added error counts to stats * Added noop version of collector * Made it doubles and added toMap * javadoc warning * batch load count is now the number of objects loaded via the batch function and batch invoke count the number of invocations of the batch function * readme updates * Made Statistics a class
- Loading branch information
Showing
17 changed files
with
1,096 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/main/java/org/dataloader/stats/DelegatingStatisticsCollector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package org.dataloader.stats; | ||
|
||
import static org.dataloader.impl.Assertions.nonNull; | ||
|
||
/** | ||
* This statistics collector keeps dataloader statistics AND also calls the delegate | ||
* collector at the same time. This allows you to keep a specific set of statistics | ||
* and also delegate the calls onto another collector. | ||
*/ | ||
public class DelegatingStatisticsCollector implements StatisticsCollector { | ||
|
||
private final StatisticsCollector collector = new SimpleStatisticsCollector(); | ||
private final StatisticsCollector delegateCollector; | ||
|
||
/** | ||
* @param delegateCollector a non null delegate collector | ||
*/ | ||
public DelegatingStatisticsCollector(StatisticsCollector delegateCollector) { | ||
this.delegateCollector = nonNull(delegateCollector); | ||
} | ||
|
||
@Override | ||
public long incrementLoadCount() { | ||
delegateCollector.incrementLoadCount(); | ||
return collector.incrementLoadCount(); | ||
} | ||
|
||
@Override | ||
public long incrementBatchLoadCountBy(long delta) { | ||
delegateCollector.incrementBatchLoadCountBy(delta); | ||
return collector.incrementBatchLoadCountBy(delta); | ||
} | ||
|
||
@Override | ||
public long incrementCacheHitCount() { | ||
delegateCollector.incrementCacheHitCount(); | ||
return collector.incrementCacheHitCount(); | ||
} | ||
|
||
@Override | ||
public long incrementLoadErrorCount() { | ||
delegateCollector.incrementLoadErrorCount(); | ||
return collector.incrementLoadErrorCount(); | ||
} | ||
|
||
@Override | ||
public long incrementBatchLoadExceptionCount() { | ||
delegateCollector.incrementBatchLoadExceptionCount(); | ||
return collector.incrementBatchLoadExceptionCount(); | ||
} | ||
|
||
/** | ||
* @return the statistics of the this collector (and not its delegate) | ||
*/ | ||
@Override | ||
public Statistics getStatistics() { | ||
return collector.getStatistics(); | ||
} | ||
|
||
/** | ||
* @return the statistics of the delegate | ||
*/ | ||
public Statistics getDelegateStatistics() { | ||
return delegateCollector.getStatistics(); | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/org/dataloader/stats/NoOpStatisticsCollector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.dataloader.stats; | ||
|
||
/** | ||
* A statistics collector that does nothing | ||
*/ | ||
public class NoOpStatisticsCollector implements StatisticsCollector { | ||
|
||
private static final Statistics ZERO_STATS = new Statistics(); | ||
|
||
@Override | ||
public long incrementLoadCount() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public long incrementLoadErrorCount() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public long incrementBatchLoadCountBy(long delta) { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public long incrementBatchLoadExceptionCount() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public long incrementCacheHitCount() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public Statistics getStatistics() { | ||
return ZERO_STATS; | ||
} | ||
} |
Oops, something went wrong.