Skip to content

Commit

Permalink
Fix JdbcAggregateJobQueryDao to read AGGREGATE_JOB_EXECUTION.EXIT_COD…
Browse files Browse the repository at this point in the history
…E instead of EXIT_MESSAGE.

Fix test updating EXIT_CODE with incorrect value.

Remove unnecessary commit as part of polishing before merge
  • Loading branch information
corneil authored and cppwfs committed May 15, 2024
1 parent ecd5bdb commit d1ba772
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public class JdbcAggregateJobQueryDao implements AggregateJobQueryDao {
" LEFT OUTER JOIN AGGREGATE_TASK_BATCH TT ON E.JOB_EXECUTION_ID = TT.JOB_EXECUTION_ID AND E.SCHEMA_TARGET = TT.SCHEMA_TARGET" +
" LEFT OUTER JOIN AGGREGATE_TASK_EXECUTION T ON TT.TASK_EXECUTION_ID = T.TASK_EXECUTION_ID AND TT.SCHEMA_TARGET = T.SCHEMA_TARGET";

private static final String FIND_CTR_STATUS = "SELECT T.TASK_EXECUTION_ID as TASK_EXECUTION_ID, J.EXIT_MESSAGE as CTR_STATUS" +
private static final String FIND_CTR_STATUS = "SELECT T.TASK_EXECUTION_ID as TASK_EXECUTION_ID, J.EXIT_CODE as CTR_STATUS" +
" from AGGREGATE_TASK_EXECUTION T" +
" JOIN AGGREGATE_TASK_BATCH TB ON TB.TASK_EXECUTION_ID=T.TASK_EXECUTION_ID AND TB.SCHEMA_TARGET=T.SCHEMA_TARGET" +
" JOIN AGGREGATE_JOB_EXECUTION J ON J.JOB_EXECUTION_ID=TB.JOB_EXECUTION_ID AND J.SCHEMA_TARGET=TB.SCHEMA_TARGET" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,19 +305,26 @@ private Pair<TaskExecution, JobExecution> createSampleJob(
JdbcTemplate template = new JdbcTemplate(this.dataSource);

if (insertTaskExecutionMetadata) {
template.execute(String.format("INSERT INTO " + schemaVersionTarget.getTaskPrefix() + "EXECUTION_METADATA (ID, TASK_EXECUTION_ID, TASK_EXECUTION_MANIFEST) VALUES (%s, %s, '{\"taskDeploymentRequest\":{\"definition\":{\"name\":\"bd0917a\",\"properties\":{\"spring.datasource.username\":\"root\",\"spring.cloud.task.name\":\"bd0917a\",\"spring.datasource.url\":\"jdbc:mariadb://localhost:3306/task\",\"spring.datasource.driverClassName\":\"org.mariadb.jdbc.Driver\",\"spring.datasource.password\":\"password\"}},\"resource\":\"file:/Users/glennrenfro/tmp/batchdemo-0.0.1-SNAPSHOT.jar\",\"deploymentProperties\":{},\"commandlineArguments\":[\"run.id_long=1\",\"--spring.cloud.task.executionid=201\"]},\"platformName\":\"demo\"}')", taskExecution.getExecutionId(), taskExecution.getExecutionId()));
template.execute(String.format("INSERT INTO %sEXECUTION_METADATA (ID, TASK_EXECUTION_ID, TASK_EXECUTION_MANIFEST) VALUES (%s, %s, '{\"taskDeploymentRequest\":{\"definition\":{\"name\":\"bd0917a\",\"properties\":{\"spring.datasource.username\":\"root\",\"spring.cloud.task.name\":\"bd0917a\",\"spring.datasource.url\":\"jdbc:mariadb://localhost:3306/task\",\"spring.datasource.driverClassName\":\"org.mariadb.jdbc.Driver\",\"spring.datasource.password\":\"password\"}},\"resource\":\"file:/Users/glennrenfro/tmp/batchdemo-0.0.1-SNAPSHOT.jar\",\"deploymentProperties\":{},\"commandlineArguments\":[\"run.id_long=1\",\"--spring.cloud.task.executionid=201\"]},\"platformName\":\"demo\"}')", schemaVersionTarget.getTaskPrefix(), taskExecution.getExecutionId(), taskExecution.getExecutionId()));
}
if(AppBootSchemaVersion.BOOT3.equals(schemaVersionTarget.getSchemaVersion())) {
jobExecution = new JobExecution(instance, taskExecution.getExecutionId(), this.jobParameters, "foo");
jobExecution.setCreateTime(new Date());
jobExecution.setVersion(1);

Object[] jobExecutionParameters = new Object[] { jobExecution.getId(), instance.getInstanceId(), new Date(), new Date(),
BatchStatus.COMPLETED, ExitStatus.COMPLETED,
ExitStatus.COMPLETED.getExitDescription(), 1, new Date(), new Date() };
this.jdbcTemplate.update(SAVE_JOB_EXECUTION, jobExecutionParameters,
new int[] { Types.BIGINT, Types.BIGINT, Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.VARCHAR,
Types.VARCHAR, Types.INTEGER, Types.TIMESTAMP, Types.TIMESTAMP });
Object[] jobExecutionParameters = new Object[] {
jobExecution.getId(),
instance.getInstanceId(),
new Date(),
new Date(),
BatchStatus.COMPLETED,
ExitStatus.COMPLETED.getExitCode(),
ExitStatus.COMPLETED.getExitDescription(),
1,
new Date(),
new Date()
};
int[] argTypes = {Types.BIGINT, Types.BIGINT, Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.TIMESTAMP, Types.TIMESTAMP};
this.jdbcTemplate.update(SAVE_JOB_EXECUTION, jobExecutionParameters, argTypes);

Object[] jobExecutionParmParameters = new Object[] { jobExecution.getId(), "identifying.param", "java.lang.String", "testparm", "Y"};
this.jdbcTemplate.update(SAVE_JOB_EXECUTION_PARAM, jobExecutionParmParameters, new int[] { Types.BIGINT,
Expand All @@ -332,7 +339,7 @@ private Pair<TaskExecution, JobExecution> createSampleJob(
taskBatchDao.saveRelationship(taskExecution, jobExecution);
jobExecution.setStatus(status);
jobExecution.setStartTime(new Date());
ExitStatus exitStatus = new ExitStatus(BatchStatus.COMPLETED.equals(status.getBatchStatus()) ? "0" : "1", status.toString());
ExitStatus exitStatus = new ExitStatus(status.getBatchStatus().name(), status.toString());
jobExecution.setExitStatus(exitStatus);
jobRepository.update(jobExecution);
return Pair.of(taskExecution, jobExecution);
Expand Down

0 comments on commit d1ba772

Please sign in to comment.