Bugzilla – Bug 6288
Consider a beforeStep/afterStep-equivalent that runs on a partition thread.
Last modified: 2016-03-30 15:14:36 UTC
It is a noticeable asymmetry between partitioned and non-partition steps that there is no equivalent to beforeStep/afterStep on the partition thread.
True, the ChunkListener runs on the partition thread, but you don't have a clear way without inventing one to know it's the last chunk. True, the PartitionAnalyzer runs at the end of the partition, but that's back on the main thread.
Would be curious to hear other opinions on whether this would be desirable for a future release.
I agree with your comments. The closest fit, as you say, is the ChunkListener. It requires some extra coding to know that it is the final chunk and overall doesn't feel as clean as a PartitionListener (or extended StepListener) interface would.
That leaves partitioned batchlet steps without any before/after listener options at all. Of course it could be coded/called directly from each batchlet, but I think the listener approach is cleaner.
Let me follow-up and propose adding beforePartition/afterPartition to StepListener.
So beforeStep/afterStep will continue to be called only on the top-level thread, and the new beforePartition/afterPartition will only be called on the partition threads.
(Also relevant to keep in mind, the PartitionReducer#beginPartitionedStep/afterPartitionedStepCompletion methods allow for before/after calls as well, and only from the top-level. Both these and beforeStep/afterStep can continue to be useful in different cases from the top-level.)
Let's deal with any other new listener method proposals separately (e.g. https://java.net/bugzilla/show_bug.cgi?id=7374)