@@ -102,11 +102,9 @@ WriteBatcher newWriteBatcher(DataMovementManager dataMovementManager) {
102
102
.newWriteBatcher ()
103
103
.withBatchSize (batchSize )
104
104
.withThreadCount (threadCount )
105
- .withTemporalCollection (getStringOption (Options .WRITE_TEMPORAL_COLLECTION ));
105
+ .withTemporalCollection (getStringOption (Options .WRITE_TEMPORAL_COLLECTION ))
106
+ .onBatchSuccess (this ::logBatchOnSuccess );
106
107
107
- if (logger .isDebugEnabled ()) {
108
- writeBatcher .onBatchSuccess (this ::logBatchOnSuccess );
109
- }
110
108
Optional <ServerTransform > transform = makeRestTransform ();
111
109
if (transform .isPresent ()) {
112
110
writeBatcher .withTransform (transform .get ());
@@ -254,23 +252,26 @@ private void logBatchOnSuccess(WriteBatch batch) {
254
252
WriteEvent firstEvent = batch .getItems ()[0 ];
255
253
// If the first event is the item added by DMSDK for the default metadata object, ignore it when showing
256
254
// the count of documents in the batch.
257
- // the count of documents in the batch.
258
255
if (firstEvent .getTargetUri () == null && firstEvent .getMetadata () != null ) {
259
256
docCount --;
260
257
}
261
258
}
262
259
if (this .logProgress > 0 ) {
263
260
logProgressIfNecessary (docCount );
264
261
}
265
- logger .debug ("Wrote batch; length: {}; job batch number: {}" , docCount , batch .getJobBatchNumber ());
262
+ if (logger .isDebugEnabled ()) {
263
+ logger .debug ("Wrote batch; length: {}; job batch number: {}" , docCount , batch .getJobBatchNumber ());
264
+ }
266
265
}
267
266
268
267
private void logProgressIfNecessary (int docCount ) {
269
268
int sum = progressTracker .addAndGet (docCount );
270
- int lowerBound = sum / (this .logProgress );
271
- int upperBound = (lowerBound * this .logProgress ) + this .batchSize ;
272
- if (sum >= lowerBound && sum < upperBound ) {
273
- Util .MAIN_LOGGER .info ("Documents written: {}" , sum );
269
+ if (sum >= logProgress ) {
270
+ int lowerBound = sum / (this .logProgress );
271
+ int upperBound = (lowerBound * this .logProgress ) + this .batchSize ;
272
+ if (sum >= lowerBound && sum < upperBound ) {
273
+ Util .MAIN_LOGGER .info ("Documents written: {}" , sum );
274
+ }
274
275
}
275
276
}
276
277
0 commit comments