RESOLVED - BATCH-774: Split item count into read/write/filter
removed itemCount from StepContribution
This commit is contained in:
@@ -16,16 +16,14 @@
|
||||
package org.springframework.batch.core;
|
||||
|
||||
/**
|
||||
* Represents a contribution to a {@link StepExecution}, buffering changes
|
||||
* until they can be applied at a chunk boundary.
|
||||
* Represents a contribution to a {@link StepExecution}, buffering changes until
|
||||
* they can be applied at a chunk boundary.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class StepContribution {
|
||||
|
||||
private volatile int itemCount = 0;
|
||||
|
||||
private volatile int readCount = 0;
|
||||
|
||||
private volatile int writeCount = 0;
|
||||
@@ -51,37 +49,23 @@ public class StepContribution {
|
||||
* Increment the counter for the number of items processed.
|
||||
*/
|
||||
public void incrementFilterCount(int count) {
|
||||
filterCount+=count;
|
||||
filterCount += count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the counter for the number of items processed.
|
||||
*/
|
||||
public void incrementItemCount() {
|
||||
itemCount++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the counter for the number of items processed.
|
||||
*/
|
||||
public void incrementItemCount(int count) {
|
||||
itemCount += count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the counter for the number of items read.
|
||||
*/
|
||||
public void incrementReadCount() {
|
||||
readCount++;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Increment the counter for the number of items read.
|
||||
*/
|
||||
public void incrementReadCount(int count) {
|
||||
readCount += count;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Increment the counter for the number of items written.
|
||||
*/
|
||||
@@ -89,15 +73,6 @@ public class StepContribution {
|
||||
writeCount++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Public access to the item counter.
|
||||
*
|
||||
* @return the item counter.
|
||||
*/
|
||||
public int getItemCount() {
|
||||
return itemCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Public access to the read counter.
|
||||
*
|
||||
@@ -197,8 +172,9 @@ public class StepContribution {
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
public String toString() {
|
||||
return "[StepContribution: items=" + itemCount + ", filtered=" + filterCount + ", readSkips=" + readSkipCount
|
||||
+ ", writeSkips=" + writeSkipCount + ", processSkips=" + processSkipCount + "]";
|
||||
return "[StepContribution: read=" + readCount + ", written=" + writeCount + ", filtered=" + filterCount
|
||||
+ ", readSkips=" + readSkipCount + ", writeSkips=" + writeSkipCount + ", processSkips="
|
||||
+ processSkipCount + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -202,10 +202,9 @@ public class ChunkOrientedTasklet<T, S> implements Tasklet {
|
||||
protected void process(StepContribution contribution, Chunk<ItemWrapper<T>> inputs, Chunk<S> outputs) throws Exception {
|
||||
int filtered = 0;
|
||||
for (ItemWrapper<T> item : inputs) {
|
||||
// TODO: segregate read / write / filter count
|
||||
// (this is read count)
|
||||
contribution.incrementItemCount();
|
||||
|
||||
contribution.incrementReadCount();
|
||||
|
||||
S output = doProcess(item);
|
||||
if (output != null) {
|
||||
outputs.add(output);
|
||||
|
||||
@@ -29,17 +29,7 @@ public class StepContributionTests extends TestCase {
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.StepContribution#incrementItemCount()}.
|
||||
*/
|
||||
public void testIncrementTaskCount() {
|
||||
assertEquals(0, contribution.getItemCount());
|
||||
contribution.incrementItemCount();
|
||||
assertEquals(1, contribution.getItemCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.StepContribution#incrementItemCount()}.
|
||||
* {@link org.springframework.batch.core.StepContribution#incrementFilterCount(int)}.
|
||||
*/
|
||||
public void testIncrementFilterCount() {
|
||||
assertEquals(0, contribution.getFilterCount());
|
||||
|
||||
@@ -84,7 +84,7 @@ public class ChunkOrientedTaskletTests {
|
||||
// expected
|
||||
}
|
||||
assertEquals(2, itemReader.count);
|
||||
assertEquals(2, contribution.getItemCount());
|
||||
assertEquals(2, contribution.getReadCount());
|
||||
assertEquals(0, contribution.getFilterCount());
|
||||
assertEquals("", itemWriter.values);
|
||||
}
|
||||
@@ -97,7 +97,6 @@ public class ChunkOrientedTaskletTests {
|
||||
123L, new JobParameters(), "job"))));
|
||||
handler.execute(contribution, context);
|
||||
assertEquals(2, itemReader.count);
|
||||
assertEquals(2, contribution.getItemCount());
|
||||
assertEquals(2, contribution.getReadCount());
|
||||
assertEquals(1, contribution.getFilterCount());
|
||||
assertEquals(1, contribution.getWriteCount());
|
||||
|
||||
@@ -135,7 +135,7 @@ public class StatefulRetryTaskletTests {
|
||||
catch (SkipLimitExceededException e) {
|
||||
// expected
|
||||
}
|
||||
assertEquals(0, contribution.getItemCount());
|
||||
assertEquals(0, contribution.getReadCount());
|
||||
assertEquals(2, contribution.getReadSkipCount());
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ public class StatefulRetryTaskletTests {
|
||||
// expected
|
||||
}
|
||||
assertTrue(attributes.hasAttribute("INPUT_BUFFER_KEY"));
|
||||
assertEquals(0, contribution.getItemCount());
|
||||
assertEquals(0, contribution.getReadCount());
|
||||
assertEquals(2, contribution.getProcessSkipCount());
|
||||
// Just before the skip at the end we process once more
|
||||
assertEquals(3, processed.size());
|
||||
|
||||
Reference in New Issue
Block a user