-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JBERET-483 Implementation and tests for TaskSubmissionListener proposal #119
Open
Zerrossetto
wants to merge
2
commits into
jberet:main
Choose a base branch
from
Zerrossetto:JBERET-483
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
jberet-se/src/main/java/org/jberet/se/TaskSubmissionListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.jberet.se; | ||
|
||
/** | ||
* Invoked around a task submission | ||
* | ||
* @author Formenti Lorenzo | ||
*/ | ||
public interface TaskSubmissionListener { | ||
|
||
void beforeSubmit(); | ||
|
||
void afterSubmit(); | ||
|
||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
jberet-se/src/test/java/org/jberet/se/test/FailTaskSubmissionListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.jberet.se.test; | ||
|
||
import org.jberet.se.TaskSubmissionListener; | ||
|
||
public class FailTaskSubmissionListener implements TaskSubmissionListener { | ||
|
||
@Override | ||
public void beforeSubmit() { | ||
throw new RuntimeException(); | ||
} | ||
|
||
@Override | ||
public void afterSubmit() { | ||
throw new RuntimeException(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what parameters do these 2 methods need? In your application and use case, which info are needed that should be passed in as parameters?
org.jberet.spi.JobTask
seems a good one, and I think implementers will need to know what JobTask it is in order to determine the appropriate action.javax.batch.runtime.context.JobContext
may be another one, to provide more details about the current job execution.Also note that jberet JobExecutor is used for not only job execution, but also Split/Flow/Partition executions. If we attach such a listener this way, it will be called upon submission of a job, a flow, split and step partition. Is this what you intend it to be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to write an answer to your points multiple times, but more I think of it more I think I underestimated the addition of this feature to the library.
Now, below my original answer.
You definitely have a point with your questions, i was eager to submit the proposal that I ended missing the goal I posed to myself for the submission itself.
What I meant was described in the issue JBERET-483: I wanted for the
jberet-se
module a clean way to introspect the task submissions (and only the tasks) and, in my specific case, propagate data that is generated during the costruction of the job instance and the job execution to child threads via the TheadFactory object.Also, by reading your last intervention
By looking the the references in the code now I get what you meant, I don't wish to have a listener for those objects too, and I don't think having it would be useful. One easy way would be to test the type of task submitted, but I don't really like it.
Another I can think of would probably be to split the generation of the jobtask and the submission, leaving the invoker class the task of rollback the transaction if needed, but this impacts more the current mechanics of the
AbstractJobOperator
class, (that is jberet-core, so behavior of the EE component is impacted.On the other hand, it's probably needed to create a new interface on the line of
JobTaskInformation
, that lets the implementing class expose a minimal amount of information without letting the caller edit theJobContext
data.I would really like to think more about this part and come back with a better pull request. For the moment I think I'll close this one.