Bug 6288 - Consider a beforeStep/afterStep-equivalent that runs on a partition thread.
Consider a beforeStep/afterStep-equivalent that runs on a partition thread.
Status: NEW
Product: jbatch
Classification: Unclassified
Component: SPEC
PC Windows
: P5 enhancement
: ---
Assigned To: ScottKurz
Depends on:
  Show dependency treegraph
Reported: 2014-07-30 14:03 UTC by ScottKurz
Modified: 2016-03-30 15:14 UTC (History)
2 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description ScottKurz 2014-07-30 14:03:27 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.
Comment 1 m_edgar 2014-09-19 02:23:58 UTC
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.
Comment 2 ScottKurz 2016-03-30 15:14:36 UTC
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)