Skip to content

Commit

Permalink
Update code to resolve review comments
Browse files Browse the repository at this point in the history
Thank you @cbono!!!!
  • Loading branch information
cppwfs committed Feb 1, 2024
1 parent 089dadb commit 1ba1048
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 27 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<module>spring-cloud-starter-dataflow-server</module>
<module>spring-cloud-starter-dataflow-ui</module>
<module>spring-cloud-dataflow-server</module>
<!-- TODO: Boot3x followup -->
<!-- <module>spring-cloud-dataflow-tasklauncher</module>-->
<!-- <module>spring-cloud-dataflow-single-step-batch-job</module>-->
<!-- <module>spring-cloud-dataflow-composed-task-runner</module>-->
Expand Down
9 changes: 5 additions & 4 deletions spring-cloud-dataflow-server-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-micrometer</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-ant</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dataflow-schema</artifactId>
Expand Down Expand Up @@ -257,6 +253,11 @@
<artifactId>postgresql</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-ant</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.springframework.cloud.dataflow.server.batch;

//TODO: Boot3x followup
public class JobRestartRuntimeException extends RuntimeException {

public JobRestartRuntimeException(Long jobExecutionId, Exception cause) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.springframework.cloud.dataflow.server.batch;

//TODO: Boot3x followup
public class JobStartRuntimeException extends RuntimeException {

public JobStartRuntimeException(String jobName, Exception cause) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.springframework.cloud.dataflow.server.batch;

//TODO: Boot3x followup
public class JobStopException extends RuntimeException {

public JobStopException(Long jobExecutionId, Exception cause) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ public SimpleJobService(SearchableJobInstanceDao jobInstanceDao, SearchableJobEx
this.executionContextDao = executionContextDao;
this.aggregateJobQueryDao = aggregateJobQueryDao;
this.schemaVersionTarget = schemaVersionTarget;
Assert.notNull(this.jobOperator = jobOperator, "jobOperator must not be null");
Objects.requireNonNull(jobOperator, "jobOperator must not be null");
this.jobOperator = jobOperator;
}

/**
Expand Down Expand Up @@ -165,8 +166,7 @@ public JobExecution restart(Long jobExecutionId, JobParameters params) throws No
try {
jobExecution = new JobExecution(jobOperator.restart(jobExecutionId.longValue()));
}
catch (JobParametersInvalidException | JobRestartException | NoSuchJobExecutionException |
JobInstanceAlreadyCompleteException e) {
catch (Exception e) {
throw new JobRestartRuntimeException(jobExecutionId, e);
}

Expand All @@ -178,14 +178,14 @@ public JobExecution launch(String jobName, JobParameters jobParameters) throws N
JobExecution jobExecution;

if (jobOperator != null) {
try {
jobExecution = new JobExecution(jobOperator.start(jobName, jobParameters.toProperties()));
} catch (JobInstanceAlreadyExistsException | JobParametersInvalidException e) {
throw new JobStartRuntimeException(jobName, e);
}
} else {
try {
jobExecution = new JobExecution(jobOperator.start(jobName, jobParameters.toProperties()));
} catch (JobInstanceAlreadyExistsException | JobParametersInvalidException e) {
throw new JobStartRuntimeException(jobName, e);
}
} else {
throw new NoSuchJobException(String.format("Unable to find job %s to launch",
String.valueOf(jobName)));
jobName));
}

return jobExecution;
Expand Down Expand Up @@ -257,19 +257,18 @@ public int countJobs() {
@Override
public int stopAll() {
Collection<JobExecution> result = jobExecutionDao.getRunningJobExecutions();
Collection<String> jsrJobNames = getJobNames();
Collection<String> jobNames = getJobNames();

for (JobExecution jobExecution : result) {
if (jsrJobNames.contains(jobExecution.getJobInstance().getJobName())) {
try {
jobOperator.stop(jobExecution.getId());
} catch (NoSuchJobExecutionException e) {
throw new JobStopException(jobExecution.getId(), e);
} catch (JobExecutionNotRunningException e) {
throw new JobStopException(jobExecution.getId(), e);
}
} else {
throw new JobStopException(jobExecution.getId());
try {
if (jobNames.contains(jobExecution.getJobInstance().getJobName())) {
jobOperator.stop(jobExecution.getId());

} else {
throw new JobStopException(jobExecution.getId());
}
} catch (Exception e) {
throw new IllegalArgumentException("The following JobExecutionId was not found: " + jobExecution.getId(), e);
}
}

Expand Down Expand Up @@ -309,10 +308,10 @@ public JobExecution abandon(Long jobExecutionId) throws NoSuchJobExecutionExcept

logger.info("Aborting job execution: " + jobExecution);

Collection<String> jsrJobNames = getJobNames();
Collection<String> jobNames = getJobNames();

JobInstance jobInstance = jobExecution.getJobInstance();
if (jobOperator != null && jsrJobNames.contains(jobInstance.getJobName())) {
if (jobOperator != null && jobNames.contains(jobInstance.getJobName())) {
jobOperator.abandon(jobExecutionId);
jobExecution = getJobExecution(jobExecutionId);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ public void restartJobExecution(long jobExecutionId, String schemaTarget) throws

}

//TODO: Boot3x followup Remove boot2 check in this method once boot2 suuport code has been removed.
/**
* Apply identifying job parameters to arguments. There are cases (incrementers)
* that add parameters to a job and thus must be added for each restart so that the
Expand Down

0 comments on commit 1ba1048

Please sign in to comment.