fix race condition
This commit is contained in:
parent
1a1243db34
commit
3e7eec4e9e
|
@ -62,10 +62,11 @@ public class BatchJobHelper {
|
||||||
public List<JobExecution> awaitAllBulkJobCompletions(boolean theFailIfNotJobsFound, String... theJobNames) {
|
public List<JobExecution> awaitAllBulkJobCompletions(boolean theFailIfNotJobsFound, String... theJobNames) {
|
||||||
assert theJobNames.length > 0;
|
assert theJobNames.length > 0;
|
||||||
|
|
||||||
List<JobInstance> matchingJobInstances = new ArrayList<>();
|
if (theFailIfNotJobsFound) {
|
||||||
for (String nextName : theJobNames) {
|
await().until(() -> !getJobInstances(theJobNames).isEmpty());
|
||||||
matchingJobInstances.addAll(myJobExplorer.findJobInstancesByJobName(nextName, 0, 100));
|
|
||||||
}
|
}
|
||||||
|
List<JobInstance> matchingJobInstances = getJobInstances(theJobNames);
|
||||||
|
|
||||||
if (theFailIfNotJobsFound) {
|
if (theFailIfNotJobsFound) {
|
||||||
if (matchingJobInstances.isEmpty()) {
|
if (matchingJobInstances.isEmpty()) {
|
||||||
List<String> wantNames = Arrays.asList(theJobNames);
|
List<String> wantNames = Arrays.asList(theJobNames);
|
||||||
|
@ -81,6 +82,14 @@ public class BatchJobHelper {
|
||||||
return matchingExecutions;
|
return matchingExecutions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<JobInstance> getJobInstances(String[] theJobNames) {
|
||||||
|
List<JobInstance> matchingJobInstances = new ArrayList<>();
|
||||||
|
for (String nextName : theJobNames) {
|
||||||
|
matchingJobInstances.addAll(myJobExplorer.findJobInstancesByJobName(nextName, 0, 100));
|
||||||
|
}
|
||||||
|
return matchingJobInstances;
|
||||||
|
}
|
||||||
|
|
||||||
public JobExecution awaitJobExecution(Long theJobExecutionId) {
|
public JobExecution awaitJobExecution(Long theJobExecutionId) {
|
||||||
JobExecution jobExecution = myJobExplorer.getJobExecution(theJobExecutionId);
|
JobExecution jobExecution = myJobExplorer.getJobExecution(theJobExecutionId);
|
||||||
awaitJobCompletion(jobExecution);
|
awaitJobCompletion(jobExecution);
|
||||||
|
|
Loading…
Reference in New Issue