Announcement Announcement Module
No announcement yet.
Partition Model - Thread safety doubt Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Partition Model - Thread safety doubt


    First of all apologies for the lengthy mail.

    I want use the Partition model for parallel execution of steps.
    All my configurations, I am setting through java.

    So, I have a set of Pre-configured SimpleJobs

    I might run 2 instances of the same job, of course with different parameters.
    My business task would run inside a tasklet.

    I intened to use
    1. TaskExecutorPartitionHandler
    2. SimpleStepExecutionSplitter
    3. SimplePartitioner

    All the above setup is done before I kick of one of more instances of my job.
    I would like my Partitioner to be a bit more sophisticated, by extending the partitioning provided by SimplePartitioner, so that partitioning is done based on the jobExecutionContext. I am ready to define another Partitioner.

    But the problem is SimpleStepExecutionSplitter:split has
    Map<String, ExecutionContext> contexts = partitioner.partition(splitSize);
    so partitioner does not know about the jobExecutionContext.

    Partitioner is a kind of a setup information for a job(meaning different instances of the same job, would have the same partitioner).
    My below lines are based on the above statement.

    Looking at samples for the possibility of passing contextual information to partitioner, I reached MultiResourcePartitioner implementation. It does not looks to be a thread-safe implementation. For a typical job, I would have only partitioner.
    Now, if 2 instances of the same job are running, I might call setResources from one thread, and partition from another thread, which obviously a problem.

    If we could modify SimpleStepExecutionSplitter:split as
    Map<String, ExecutionContext> contexts = partitioner.partition(stepExecution, splitSize);
    it could open up a good possibility of reuse of these classes.