From f771516fdc43a59cb084b33729a788178931c327 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Mon, 5 Feb 2024 17:44:21 -0800 Subject: [PATCH 1/2] GRAD2-2505: task is complete. GRAD2-2505: task is complete. --- .../batchgraduation/config/BatchDbConfig.java | 118 ----- .../config/BatchJobConfig.java | 416 ++++++++---------- ...tionRunCompletionNotificationListener.java | 4 +- ...BaseRunCompletionNotificationListener.java | 4 +- ...napshotCompletionNotificationListener.java | 4 +- ...CertRunCompletionNotificationListener.java | 4 +- ...heduledCompletionNotificationListener.java | 20 +- .../RunRegularGradAlgorithmProcessor.java | 1 + .../EducGradBatchGraduationApiConstants.java | 4 + .../RegGradAlgBatchPerformanceWriter.java | 3 +- .../writer/TvrRunBatchPerformanceWriter.java | 3 +- api/src/main/resources/application.yaml | 11 +- .../batchgraduation/config/AsyncConfig.java | 1 - tools/config/update-configmap.sh | 4 +- 14 files changed, 215 insertions(+), 382 deletions(-) delete mode 100644 api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchDbConfig.java diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchDbConfig.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchDbConfig.java deleted file mode 100644 index b28c7c11..00000000 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchDbConfig.java +++ /dev/null @@ -1,118 +0,0 @@ -package ca.bc.gov.educ.api.batchgraduation.config; - -import com.zaxxer.hikari.HikariConfig; -import com.zaxxer.hikari.HikariDataSource; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.context.annotation.Profile; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -import javax.sql.DataSource; -import java.util.HashMap; - -@Configuration -@Profile("!test") -@EnableJpaRepositories( - basePackages = { - "ca.bc.gov.educ.api.batchgraduation.repository" - }, - entityManagerFactoryRef = "batchEntityManager", - transactionManagerRef = "batchTransactionManager" -) -@EnableTransactionManagement -public class BatchDbConfig { - // Hikari Pool - @Value("${spring.db-connection.hikari.maximum-pool-size}") - private int maxPoolSize; - - @Value("${spring.db-connection.hikari.connection-timeout}") - private int connectionTimeout; - - @Value("${spring.db-connection.hikari.max-lifetime}") - private int maxLifetime; - - @Value("${spring.db-connection.hikari.keepalive-time}") - private int keepAliveTime; - - @Value("${spring.db-connection.hikari.idle-timeout}") - private int idleTimeout; - - @Value("${spring.db-connection.driver-class}") - private String driverClassName; - - @Value("${spring.db-connection.hikari.pool-name}") - private String batchPoolName; - - // Connection String - @Value("${spring.db-connection.url}") - private String jdbcUrl; - - @Value("${spring.db-connection.username}") - private String batchUsername; - - @Value("${spring.db-connection.password}") - private String batchPassword; - - @Primary - @Bean - @Qualifier("datasource") - public DataSource dataSource() { - HikariConfig config = new HikariConfig(); - - config.setDriverClassName(driverClassName); - config.setJdbcUrl(jdbcUrl); - config.setUsername(batchUsername); - config.setPassword(batchPassword); - config.setPoolName(batchPoolName); - - config.setMinimumIdle(2); - config.setMaximumPoolSize(maxPoolSize); - config.setMaxLifetime(maxLifetime); - config.setConnectionTimeout(connectionTimeout); - config.setKeepaliveTime(keepAliveTime); - config.setIdleTimeout(idleTimeout); - config.addDataSourceProperty("socketTimeout", 36000000); - config.addDataSourceProperty("oracle.jdbc.javaNetNio", "false"); - - return new HikariDataSource(config); - } - - @Primary - @Bean - public LocalContainerEntityManagerFactoryBean batchEntityManager() { - LocalContainerEntityManagerFactoryBean em - = new LocalContainerEntityManagerFactoryBean(); - em.setDataSource(dataSource()); - em.setPackagesToScan("ca.bc.gov.educ.api.batchgraduation.entity"); - - HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); - em.setJpaVendorAdapter(vendorAdapter); - HashMap properties = new HashMap<>(); - properties.put("hibernate.hbm2ddl.auto", "none"); - properties.put("hibernate.dialect", "org.hibernate.dialect.OracleDialect"); - properties.put("hibernate.format_sql", "true"); - properties.put("hibernate.show_sql", "false"); - em.setJpaPropertyMap(properties); - - em.setPersistenceUnitName("batchPU"); - - return em; - } - - @Primary - @Bean - @Qualifier("batchTransactionManager") - public PlatformTransactionManager transactionManager() { - JpaTransactionManager transactionManager = new JpaTransactionManager(); - transactionManager.setEntityManagerFactory(batchEntityManager().getObject()); - return transactionManager; - } -} \ No newline at end of file diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchJobConfig.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchJobConfig.java index 2c5cce72..7b65a30e 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchJobConfig.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchJobConfig.java @@ -20,15 +20,12 @@ import org.springframework.batch.item.ItemProcessor; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.task.SimpleAsyncTaskExecutor; import org.springframework.core.task.TaskExecutor; import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.TransactionException; -import java.sql.SQLException; import java.util.List; import java.util.UUID; @@ -38,11 +35,8 @@ public class BatchJobConfig { // Partitioning for Regular Grad Run updates - @Autowired - JobRegistry jobRegistry; - - @Autowired - private PlatformTransactionManager batchTransactionManager; +// @Autowired +// JobRegistry jobRegistry; /** * Regular Grad Algorithm Run @@ -82,30 +76,30 @@ public ItemWriter itemWriterRegGrad() { } @Bean - public Step masterStepRegGrad(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepRegGrad(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { return new StepBuilder("masterStepRegGrad", jobRepository) - .partitioner(graduationJobStep(jobRepository, skipListener).getName(), partitionerRegGrad()) - .step(graduationJobStep(jobRepository, skipListener)) + .partitioner(graduationJobStep(jobRepository, transactionManager, skipListener, constants).getName(), partitionerRegGrad()) + .step(graduationJobStep(jobRepository, transactionManager, skipListener, constants)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean - public Step masterStepRegGradError(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepRegGradError(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { return new StepBuilder("masterStepRegGradError", jobRepository) - .partitioner(graduationJobErrorStep(jobRepository, skipListener).getName(), partitionerRegGradRetry()) - .step(graduationJobErrorStep(jobRepository, skipListener)) + .partitioner(graduationJobErrorStep(jobRepository, transactionManager, skipListener, constants).getName(), partitionerRegGradRetry()) + .step(graduationJobErrorStep(jobRepository, transactionManager, skipListener, constants)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean - public Step masterStepRegGradErrorRetry(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepRegGradErrorRetry(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { return new StepBuilder("masterStepRegGradErrorRetry", jobRepository) - .partitioner(graduationJobErrorRetryStep(jobRepository, skipListener).getName(), partitionerRegGradRetry()) - .step(graduationJobErrorRetryStep(jobRepository, skipListener)) + .partitioner(graduationJobErrorRetryStep(jobRepository, transactionManager, skipListener, constants).getName(), partitionerRegGradRetry()) + .step(graduationJobErrorRetryStep(jobRepository, transactionManager, skipListener, constants)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); @@ -125,63 +119,54 @@ public RegGradAlgPartitionerRetry partitionerRegGradRetry() { } @Bean - public Step graduationJobErrorStep(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + public Step graduationJobErrorStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("graduationJobErrorStep", jobRepository) - .chunk(1) - .transactionManager(batchTransactionManager) - .faultTolerant() - .skip(SQLException.class) - .skip(TransactionException.class) + .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderRegErrorGrad()) .processor(itemProcessorRegGrad()) .writer(itemWriterRegGrad()) - .transactionManager(batchTransactionManager) + .faultTolerant() .listener(skipListener) + .skip(Exception.class) .build(); } @Bean - public Step graduationJobErrorRetryStep(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + public Step graduationJobErrorRetryStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("graduationJobErrorRetryStep", jobRepository) - .chunk(1) - .transactionManager(batchTransactionManager) - .faultTolerant() - .skip(SQLException.class) - .skip(TransactionException.class) + .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderRegErrorRetryGrad()) .processor(itemProcessorRegGrad()) .writer(itemWriterRegGrad()) - .transactionManager(batchTransactionManager) + .faultTolerant() .listener(skipListener) + .skip(Exception.class) .build(); } @Bean - public Step graduationJobStep(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + public Step graduationJobStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("graduationJobStep", jobRepository) - .chunk(1) - .transactionManager(batchTransactionManager) - .faultTolerant() - .skip(SQLException.class) - .skip(TransactionException.class) + .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderRegGrad()) .processor(itemProcessorRegGrad()) .writer(itemWriterRegGrad()) - .transactionManager(batchTransactionManager) + .faultTolerant() .listener(skipListener) + .skip(Exception.class) .build(); } @Bean(name="GraduationBatchJob") - public Job graduationBatchJob(JobRepository jobRepository, GradRunCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constants) { + public Job graduationBatchJob(JobRepository jobRepository, PlatformTransactionManager transactionManager, GradRunCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constants) { return new JobBuilder("GraduationBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .start(masterStepRegGrad(jobRepository, constants, skipListener)) + .start(masterStepRegGrad(jobRepository, transactionManager, constants, skipListener)) .on("*") - .to(masterStepRegGradError(jobRepository,constants, skipListener)) + .to(masterStepRegGradError(jobRepository, transactionManager,constants, skipListener)) .on("*") - .to(masterStepRegGradErrorRetry(jobRepository,constants, skipListener)) + .to(masterStepRegGradErrorRetry(jobRepository, transactionManager,constants, skipListener)) .on("*") .end().build() .build(); @@ -225,30 +210,30 @@ public ItemWriter itemWriterTvrRun() { } @Bean - public Step masterStepTvrRun(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepTvrRun(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { return new StepBuilder("masterStepTvrRun", jobRepository) - .partitioner(tvrJobStep(jobRepository,skipListener).getName(), partitionerTvrRun()) - .step(tvrJobStep(jobRepository,skipListener)) + .partitioner(tvrJobStep(jobRepository, transactionManager,skipListener, constants).getName(), partitionerTvrRun()) + .step(tvrJobStep(jobRepository, transactionManager,skipListener, constants)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean - public Step masterStepTvrRunError(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepTvrRunError(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { return new StepBuilder("masterStepTvrRunError", jobRepository) - .partitioner(tvrJobErrorStep(jobRepository,skipListener).getName(), partitionerTvrRunRetry()) - .step(tvrJobErrorStep(jobRepository,skipListener)) + .partitioner(tvrJobErrorStep(jobRepository, transactionManager,skipListener, constants).getName(), partitionerTvrRunRetry()) + .step(tvrJobErrorStep(jobRepository, transactionManager,skipListener, constants)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean - public Step masterStepTvrRunErrorRetry(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepTvrRunErrorRetry(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { return new StepBuilder("masterStepTvrRunErrorRetry", jobRepository) - .partitioner(tvrJobErrorRetryStep(jobRepository,skipListener).getName(), partitionerTvrRunRetry()) - .step(tvrJobErrorRetryStep(jobRepository,skipListener)) + .partitioner(tvrJobErrorRetryStep(jobRepository, transactionManager,skipListener, constants).getName(), partitionerTvrRunRetry()) + .step(tvrJobErrorRetryStep(jobRepository, transactionManager,skipListener, constants)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); @@ -268,63 +253,54 @@ public TvrRunPartitionerRetry partitionerTvrRunRetry() { @Bean - public Step tvrJobStep(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + public Step tvrJobStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("tvrJobStep", jobRepository) - .chunk(1) - .transactionManager(batchTransactionManager) - .faultTolerant() - .skip(SQLException.class) - .skip(TransactionException.class) + .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderTvrRun()) .processor(itemProcessorTvrRun()) .writer(itemWriterTvrRun()) - .transactionManager(batchTransactionManager) + .faultTolerant() .listener(skipListener) + .skip(Exception.class) .build(); } @Bean - public Step tvrJobErrorStep(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + public Step tvrJobErrorStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("tvrJobErrorStep", jobRepository) - .chunk(1) - .transactionManager(batchTransactionManager) - .faultTolerant() - .skip(SQLException.class) - .skip(TransactionException.class) + .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderTvrErrorRun()) .processor(itemProcessorTvrRun()) .writer(itemWriterTvrRun()) - .transactionManager(batchTransactionManager) + .faultTolerant() .listener(skipListener) + .skip(Exception.class) .build(); } @Bean - public Step tvrJobErrorRetryStep(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + public Step tvrJobErrorRetryStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("tvrJobErrorRetryStep", jobRepository) - .chunk(1) - .transactionManager(batchTransactionManager) - .faultTolerant() - .skip(SQLException.class) - .skip(TransactionException.class) + .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderTvrErrorRetryRun()) .processor(itemProcessorTvrRun()) .writer(itemWriterTvrRun()) - .transactionManager(batchTransactionManager) + .faultTolerant() .listener(skipListener) + .skip(Exception.class) .build(); } @Bean(name="tvrBatchJob") - public Job tvrBatchJob(JobRepository jobRepository, TvrRunJobCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constants) { + public Job tvrBatchJob(JobRepository jobRepository, PlatformTransactionManager transactionManager, TvrRunJobCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constants) { return new JobBuilder("tvrBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .start(masterStepTvrRun(jobRepository,constants,skipListener)) + .start(masterStepTvrRun(jobRepository, transactionManager,constants,skipListener)) .on("*") - .to(masterStepTvrRunError(jobRepository,constants,skipListener)) + .to(masterStepTvrRunError(jobRepository, transactionManager,constants,skipListener)) .on("*") - .to(masterStepTvrRunErrorRetry(jobRepository,constants,skipListener)) + .to(masterStepTvrRunErrorRetry(jobRepository, transactionManager,constants,skipListener)) .on("*") .end().build() .build(); @@ -357,30 +333,30 @@ public ItemWriter itemWriterSpcRegGrad() { @Bean - public Step masterStepSpcRegGrad(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepSpcRegGrad(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { return new StepBuilder("masterStepSpcRegGrad", jobRepository) - .partitioner(slaveSpcRegGradStep(jobRepository,skipListener).getName(), partitionerSpcRegGrad()) - .step(slaveSpcRegGradStep(jobRepository,skipListener)) + .partitioner(slaveSpcRegGradStep(jobRepository, transactionManager,skipListener, constants).getName(), partitionerSpcRegGrad()) + .step(slaveSpcRegGradStep(jobRepository, transactionManager,skipListener, constants)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean - public Step masterStepSpcRegGradError(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepSpcRegGradError(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { return new StepBuilder("masterStepSpcRegGradError", jobRepository) - .partitioner(slaveSpcRegGradErrorStep(jobRepository,skipListener).getName(), partitionerSpcRegGradRetry()) - .step(slaveSpcRegGradErrorStep(jobRepository,skipListener)) + .partitioner(slaveSpcRegGradErrorStep(jobRepository, transactionManager,skipListener, constants).getName(), partitionerSpcRegGradRetry()) + .step(slaveSpcRegGradErrorStep(jobRepository, transactionManager,skipListener, constants)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean - public Step masterStepSpcRegGradErrorRetry(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepSpcRegGradErrorRetry(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { return new StepBuilder("masterStepSpcRegGradErrorRetry", jobRepository) - .partitioner(slaveSpcRegGradErrorRetryStep(jobRepository,skipListener).getName(), partitionerSpcRegGradRetry()) - .step(slaveSpcRegGradErrorRetryStep(jobRepository,skipListener)) + .partitioner(slaveSpcRegGradErrorRetryStep(jobRepository, transactionManager,skipListener, constants).getName(), partitionerSpcRegGradRetry()) + .step(slaveSpcRegGradErrorRetryStep(jobRepository, transactionManager,skipListener, constants)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); @@ -399,63 +375,54 @@ public SpcRegGradAlgPartitionerRetry partitionerSpcRegGradRetry() { } @Bean - public Step slaveSpcRegGradStep(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + public Step slaveSpcRegGradStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("slaveStepSpcRegGrad", jobRepository) - .chunk(1) - .transactionManager(batchTransactionManager) - .faultTolerant() - .skip(SQLException.class) - .skip(TransactionException.class) + .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderSpcRegGrad()) .processor(itemProcessorSpcRegGrad()) .writer(itemWriterSpcRegGrad()) - .transactionManager(batchTransactionManager) + .faultTolerant() .listener(skipListener) + .skip(Exception.class) .build(); } @Bean - public Step slaveSpcRegGradErrorStep(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + public Step slaveSpcRegGradErrorStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("slaveSpcRegGradErrorStep", jobRepository) - .chunk(1) - .transactionManager(batchTransactionManager) - .faultTolerant() - .skip(SQLException.class) - .skip(TransactionException.class) + .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderSpcRegGrad()) .processor(itemProcessorSpcRegGrad()) .writer(itemWriterSpcRegGrad()) - .transactionManager(batchTransactionManager) + .faultTolerant() .listener(skipListener) + .skip(Exception.class) .build(); } @Bean - public Step slaveSpcRegGradErrorRetryStep(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + public Step slaveSpcRegGradErrorRetryStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("slaveSpcRegGradErrorRetryStep", jobRepository) - .chunk(1) - .transactionManager(batchTransactionManager) - .faultTolerant() - .skip(SQLException.class) - .skip(TransactionException.class) + .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderSpcRegGrad()) .processor(itemProcessorSpcRegGrad()) .writer(itemWriterSpcRegGrad()) - .transactionManager(batchTransactionManager) + .faultTolerant() .listener(skipListener) + .skip(Exception.class) .build(); } @Bean(name="SpecialGraduationBatchJob") - public Job specialGraduationBatchJob(JobRepository jobRepository, SpecialRunCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constants) { + public Job specialGraduationBatchJob(JobRepository jobRepository, PlatformTransactionManager transactionManager, SpecialRunCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constants) { return new JobBuilder("SpecialGraduationBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .start(masterStepSpcRegGrad(jobRepository,constants,skipListener)) + .start(masterStepSpcRegGrad(jobRepository, transactionManager,constants,skipListener)) .on("*") - .to(masterStepSpcRegGradError(jobRepository,constants,skipListener)) + .to(masterStepSpcRegGradError(jobRepository, transactionManager,constants,skipListener)) .on("*") - .to(masterStepSpcRegGradErrorRetry(jobRepository,constants,skipListener)) + .to(masterStepSpcRegGradErrorRetry(jobRepository, transactionManager,constants,skipListener)) .on("*") .end().build() .build(); @@ -486,93 +453,84 @@ public ItemWriter itemWriterSpcTvrRun() { } @Bean - public Step masterStepSpcTvrRun(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepSpcTvrRun(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { return new StepBuilder("masterStepSpcTvrRun", jobRepository) - .partitioner(slaveStepSpcTvrRun(jobRepository,skipListener).getName(), partitionerSpcRegGrad()) - .step(slaveStepSpcTvrRun(jobRepository,skipListener)) + .partitioner(slaveStepSpcTvrRun(jobRepository, transactionManager,skipListener, constants).getName(), partitionerSpcRegGrad()) + .step(slaveStepSpcTvrRun(jobRepository, transactionManager,skipListener, constants)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean - public Step masterStepSpcTvrRunError(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepSpcTvrRunError(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { return new StepBuilder("masterStepSpcTvrRunError", jobRepository) - .partitioner(slaveStepSpcTvrRunError(jobRepository,skipListener).getName(), partitionerSpcRegGradRetry()) - .step(slaveStepSpcTvrRunError(jobRepository,skipListener)) + .partitioner(slaveStepSpcTvrRunError(jobRepository, transactionManager,skipListener, constants).getName(), partitionerSpcRegGradRetry()) + .step(slaveStepSpcTvrRunError(jobRepository, transactionManager,skipListener, constants)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean - public Step masterStepSpcTvrRunErrorRetry(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepSpcTvrRunErrorRetry(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { return new StepBuilder("masterStepSpcTvrRunErrorRetry", jobRepository) - .partitioner(slaveStepSpcTvrRunErrorRetry(jobRepository,skipListener).getName(), partitionerSpcRegGradRetry()) - .step(slaveStepSpcTvrRunErrorRetry(jobRepository,skipListener)) + .partitioner(slaveStepSpcTvrRunErrorRetry(jobRepository, transactionManager,skipListener, constants).getName(), partitionerSpcRegGradRetry()) + .step(slaveStepSpcTvrRunErrorRetry(jobRepository, transactionManager,skipListener, constants)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean - public Step slaveStepSpcTvrRun(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + public Step slaveStepSpcTvrRun(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("slaveStepSpcTvrRun", jobRepository) - .chunk(1) - .transactionManager(batchTransactionManager) - .faultTolerant() - .skip(SQLException.class) - .skip(TransactionException.class) + .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderSpcTvrRun()) .processor(itemProcessorSpcTvrRun()) .writer(itemWriterSpcTvrRun()) - .transactionManager(batchTransactionManager) + .faultTolerant() .listener(skipListener) + .skip(Exception.class) .build(); } @Bean - public Step slaveStepSpcTvrRunError(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + public Step slaveStepSpcTvrRunError(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("slaveStepSpcTvrRunError", jobRepository) - .chunk(1) - .transactionManager(batchTransactionManager) - .faultTolerant() - .skip(SQLException.class) - .skip(TransactionException.class) + .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderSpcTvrRun()) .processor(itemProcessorSpcTvrRun()) .writer(itemWriterSpcTvrRun()) - .transactionManager(batchTransactionManager) + .faultTolerant() .listener(skipListener) + .skip(Exception.class) .build(); } @Bean - public Step slaveStepSpcTvrRunErrorRetry(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + public Step slaveStepSpcTvrRunErrorRetry(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("slaveStepSpcTvrRunErrorRetry", jobRepository) - .chunk(1) - .transactionManager(batchTransactionManager) - .faultTolerant() - .skip(SQLException.class) - .skip(TransactionException.class) + .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderSpcTvrRun()) .processor(itemProcessorSpcTvrRun()) .writer(itemWriterSpcTvrRun()) - .transactionManager(batchTransactionManager) + .faultTolerant() .listener(skipListener) + .skip(Exception.class) .build(); } @Bean(name="SpecialTvrRunBatchJob") - public Job specialTvrRunBatchJob(JobRepository jobRepository, SpecialRunCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constants) { + public Job specialTvrRunBatchJob(JobRepository jobRepository, PlatformTransactionManager transactionManager, SpecialRunCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constants) { return new JobBuilder("SpecialTvrRunBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .start(masterStepSpcTvrRun(jobRepository,constants,skipListener)) + .start(masterStepSpcTvrRun(jobRepository, transactionManager,constants,skipListener)) .on("*") - .to(masterStepSpcTvrRunError(jobRepository,constants,skipListener)) + .to(masterStepSpcTvrRunError(jobRepository, transactionManager,constants,skipListener)) .on("*") - .to(masterStepSpcTvrRunErrorRetry(jobRepository,constants,skipListener)) + .to(masterStepSpcTvrRunErrorRetry(jobRepository, transactionManager,constants,skipListener)) .on("*") .end().build() .build(); @@ -628,57 +586,51 @@ public DistributionRunPartitioner partitionerDisRun() { @Bean - public Step slaveStepDisRun(JobRepository jobRepository) { + public Step slaveStepDisRun(JobRepository jobRepository, PlatformTransactionManager transactionManager) { return new StepBuilder("slaveStepDisRun", jobRepository) - .chunk(1) - .transactionManager(batchTransactionManager) + .chunk(1, transactionManager) .reader(itemReaderDisRun()) .processor(itemProcessorDisRun()) .writer(itemWriterDisRun()) - .transactionManager(batchTransactionManager) .build(); } @Bean - public Step slaveStepDisRunYearly(JobRepository jobRepository) { + public Step slaveStepDisRunYearly(JobRepository jobRepository, PlatformTransactionManager transactionManager) { return new StepBuilder("slaveStepDisRun", jobRepository) - .chunk(1) - .transactionManager(batchTransactionManager) + .chunk(1, transactionManager) .reader(itemReaderDisRun()) .processor(itemProcessorDisRun()) .writer(itemWriterDisRun()) - .transactionManager(batchTransactionManager) .build(); } @Bean - public Step slaveStepDisRunYearlyNonGradByMincode(JobRepository jobRepository) { + public Step slaveStepDisRunYearlyNonGradByMincode(JobRepository jobRepository, PlatformTransactionManager transactionManager) { return new StepBuilder("slaveStepDisRunYearlyNonGrad", jobRepository) - .>chunk(1) - .transactionManager(batchTransactionManager) + .>chunk(1, transactionManager) .reader(itemReaderDisRunYearlyNonGrad()) .processor(itemProcessorDisRunYearlyNonGradByMincode()) .writer(itemWriterDisRunYearlyNonGrad()) - .transactionManager(batchTransactionManager) .build(); } @Bean - public Step masterStepDisRun(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants) { + public Step masterStepDisRun(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants) { return new StepBuilder("masterStepDisRun", jobRepository) - .partitioner(slaveStepDisRun(jobRepository).getName(), partitionerDisRun()) - .step(slaveStepDisRun(jobRepository)) + .partitioner(slaveStepDisRun(jobRepository, transactionManager).getName(), partitionerDisRun()) + .step(slaveStepDisRun(jobRepository, transactionManager)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean(name="DistributionBatchJob") - public Job distributionBatchJob(JobRepository jobRepository, DistributionRunCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { + public Job distributionBatchJob(JobRepository jobRepository, PlatformTransactionManager transactionManager, DistributionRunCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { return new JobBuilder("DistributionBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .flow(masterStepDisRun(jobRepository,constants)) + .flow(masterStepDisRun(jobRepository,transactionManager, constants)) .end() .build(); } @@ -696,21 +648,21 @@ public DistributionRunYearlyPartitioner partitionerDisRunYearly() { } @Bean - public Step masterStepDisRunYearly(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants) { + public Step masterStepDisRunYearly(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants) { return new StepBuilder("masterStepDisRunYearly", jobRepository) - .partitioner(slaveStepDisRun(jobRepository).getName(), partitionerDisRunYearly()) - .step(slaveStepDisRunYearly(jobRepository)) + .partitioner(slaveStepDisRun(jobRepository, transactionManager).getName(), partitionerDisRunYearly()) + .step(slaveStepDisRunYearly(jobRepository, transactionManager)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean(name="YearlyDistributionBatchJob") - public Job distributionBatchJobYearly(JobRepository jobRepository, DistributionRunYearlyCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { + public Job distributionBatchJobYearly(JobRepository jobRepository, PlatformTransactionManager transactionManager, DistributionRunYearlyCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { return new JobBuilder("YearlyDistributionBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .flow(masterStepDisRunYearly(jobRepository,constants)) + .flow(masterStepDisRunYearly(jobRepository, transactionManager,constants)) .end() .build(); } @@ -722,21 +674,21 @@ public DistributionRunYearlyNonGradPartitioner partitionerDisRunYearlyNonGrad() } @Bean - public Step masterStepDisRunYearlyNonGrad(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants) { + public Step masterStepDisRunYearlyNonGrad(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants) { return new StepBuilder("masterStepDisRunYearlyNonGrad", jobRepository) - .partitioner(slaveStepDisRunYearlyNonGradByMincode(jobRepository).getName(), partitionerDisRunYearlyNonGrad()) - .step(slaveStepDisRunYearlyNonGradByMincode(jobRepository)) + .partitioner(slaveStepDisRunYearlyNonGradByMincode(jobRepository, transactionManager).getName(), partitionerDisRunYearlyNonGrad()) + .step(slaveStepDisRunYearlyNonGradByMincode(jobRepository, transactionManager)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean(name="YearlyNonGradDistributionBatchJob") - public Job distributionBatchJobYearlyNonGrad(JobRepository jobRepository, DistributionRunYearlyNonGradCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { + public Job distributionBatchJobYearlyNonGrad(JobRepository jobRepository, PlatformTransactionManager transactionManager, DistributionRunYearlyNonGradCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { return new JobBuilder("YearlyNonGradDistributionBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .flow(masterStepDisRunYearlyNonGrad(jobRepository,constants)) + .flow(masterStepDisRunYearlyNonGrad(jobRepository, transactionManager,constants)) .end() .build(); } @@ -748,21 +700,21 @@ public DistributionRunSupplementalPartitioner partitionerDisRunSupplemental() { } @Bean - public Step masterStepDisRunSupplemental(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants) { + public Step masterStepDisRunSupplemental(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants) { return new StepBuilder("masterStepDisRunSupplemental", jobRepository) - .partitioner(slaveStepDisRun(jobRepository).getName(), partitionerDisRunSupplemental()) - .step(slaveStepDisRun(jobRepository)) + .partitioner(slaveStepDisRun(jobRepository, transactionManager).getName(), partitionerDisRunSupplemental()) + .step(slaveStepDisRun(jobRepository, transactionManager)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean(name="SupplementalDistributionBatchJob") - public Job distributionBatchJobSupplemental(JobRepository jobRepository, DistributionRunCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { + public Job distributionBatchJobSupplemental(JobRepository jobRepository, PlatformTransactionManager transactionManager, DistributionRunCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { return new JobBuilder("SupplementalDistributionBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .flow(masterStepDisRunSupplemental(jobRepository,constants)) + .flow(masterStepDisRunSupplemental(jobRepository, transactionManager,constants)) .end() .build(); } @@ -780,21 +732,21 @@ public DistributionRunPartitionerUserReq partitionerDisRunUserReq() { } @Bean - public Step masterStepUserReqDisRun(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants) { + public Step masterStepUserReqDisRun(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants) { return new StepBuilder("masterStepUserReqDisRun", jobRepository) - .partitioner(slaveStepDisRun(jobRepository).getName(), partitionerDisRunUserReq()) - .step(slaveStepDisRun(jobRepository)) + .partitioner(slaveStepDisRun(jobRepository, transactionManager).getName(), partitionerDisRunUserReq()) + .step(slaveStepDisRun(jobRepository, transactionManager)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean(name="UserReqDistributionBatchJob") - public Job distributionBatchJobUserReq(JobRepository jobRepository, UserReqDistributionRunCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { + public Job distributionBatchJobUserReq(JobRepository jobRepository, PlatformTransactionManager transactionManager, UserReqDistributionRunCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { return new JobBuilder("UserReqDistributionBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .flow(masterStepUserReqDisRun(jobRepository,constants)) + .flow(masterStepUserReqDisRun(jobRepository, transactionManager,constants)) .end() .build(); } @@ -831,10 +783,9 @@ public DistributionRunPartitionerBlankUserReq partitionerDisRunBlankUserReq() { } @Bean - public Step slaveStepBlankDisRun(JobRepository jobRepository) { + public Step slaveStepBlankDisRun(JobRepository jobRepository, PlatformTransactionManager transactionManager) { return new StepBuilder("slaveStepBlankDisRun", jobRepository) - .chunk(1) - .transactionManager(batchTransactionManager) + .chunk(1, transactionManager) .reader(itemReaderBlankDisRun()) .processor(itemProcessorBlankDisRun()) .writer(itemWriterBlankDisRun()) @@ -842,10 +793,10 @@ public Step slaveStepBlankDisRun(JobRepository jobRepository) { } @Bean - public Step masterStepBlankUserReqDisRun(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants) { + public Step masterStepBlankUserReqDisRun(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants) { return new StepBuilder("masterStepBlankUserReqDisRun", jobRepository) - .partitioner(slaveStepBlankDisRun(jobRepository).getName(), partitionerDisRunBlankUserReq()) - .step(slaveStepBlankDisRun(jobRepository)) + .partitioner(slaveStepBlankDisRun(jobRepository, transactionManager).getName(), partitionerDisRunBlankUserReq()) + .step(slaveStepBlankDisRun(jobRepository, transactionManager)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); @@ -853,11 +804,11 @@ public Step masterStepBlankUserReqDisRun(JobRepository jobRepository, EducGradBa @Bean(name="blankDistributionBatchJob") - public Job blankDistributionBatchJobUserReq(JobRepository jobRepository, UserReqBlankDistributionRunCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { + public Job blankDistributionBatchJobUserReq(JobRepository jobRepository, PlatformTransactionManager transactionManager, UserReqBlankDistributionRunCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { return new JobBuilder("blankDistributionBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .flow(masterStepBlankUserReqDisRun(jobRepository,constants)) + .flow(masterStepBlankUserReqDisRun(jobRepository, transactionManager,constants)) .end() .build(); } @@ -894,10 +845,9 @@ public DistributionRunPartitionerPsiUserReq partitionerDisRunPsiUserReq() { } @Bean - public Step slaveStepPsiDisRun(JobRepository jobRepository) { + public Step slaveStepPsiDisRun(JobRepository jobRepository, PlatformTransactionManager transactionManager) { return new StepBuilder("slaveStepPsiDisRun", jobRepository) - .chunk(1) - .transactionManager(batchTransactionManager) + .chunk(1, transactionManager) .reader(itemReaderPsiDisRun()) .processor(itemProcessorPsiDisRun()) .writer(itemWriterPsiDisRun()) @@ -905,10 +855,10 @@ public Step slaveStepPsiDisRun(JobRepository jobRepository) { } @Bean - public Step masterStepPsiUserReqDisRun(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants) { + public Step masterStepPsiUserReqDisRun(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants) { return new StepBuilder("masterStepPsiUserReqDisRun", jobRepository) - .partitioner(slaveStepPsiDisRun(jobRepository).getName(), partitionerDisRunPsiUserReq()) - .step(slaveStepPsiDisRun(jobRepository)) + .partitioner(slaveStepPsiDisRun(jobRepository, transactionManager).getName(), partitionerDisRunPsiUserReq()) + .step(slaveStepPsiDisRun(jobRepository, transactionManager)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); @@ -916,11 +866,11 @@ public Step masterStepPsiUserReqDisRun(JobRepository jobRepository, EducGradBatc @Bean(name="psiDistributionBatchJob") - public Job psiDistributionBatchJobUserReq(JobRepository jobRepository, UserReqPsiDistributionRunCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { + public Job psiDistributionBatchJobUserReq(JobRepository jobRepository, PlatformTransactionManager transactionManager, UserReqPsiDistributionRunCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { return new JobBuilder("psiDistributionBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .flow(masterStepPsiUserReqDisRun(jobRepository,constants)) + .flow(masterStepPsiUserReqDisRun(jobRepository, transactionManager,constants)) .end() .build(); } @@ -953,37 +903,34 @@ public ItemProcessor itemProcessorCertRegen() { } @Bean - public Step masterStepCertRegen(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepCertRegen(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { return new StepBuilder("masterStepCertRegen", jobRepository) - .partitioner(certRegenJobStep(jobRepository, skipListener).getName(), partitionerCertRegen()) - .step(certRegenJobStep(jobRepository, skipListener)) + .partitioner(certRegenJobStep(jobRepository, transactionManager, skipListener).getName(), partitionerCertRegen()) + .step(certRegenJobStep(jobRepository, transactionManager, skipListener)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean - public Step certRegenJobStep(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + public Step certRegenJobStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener) { return new StepBuilder("certRegenJobStep", jobRepository) - .chunk(1) - .transactionManager(batchTransactionManager) - .faultTolerant() - .skip(SQLException.class) - .skip(TransactionException.class) + .chunk(1, transactionManager) .reader(itemReaderCertRegen()) .processor(itemProcessorCertRegen()) .writer(itemWriterCertRegen()) - .transactionManager(batchTransactionManager) + .faultTolerant() .listener(skipListener) + .skip(Exception.class) .build(); } @Bean(name="certRegenBatchJob") - public Job certRegenBatchJob(JobRepository jobRepository, RegenCertRunCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constants) { + public Job certRegenBatchJob(JobRepository jobRepository, PlatformTransactionManager transactionManager, RegenCertRunCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constants) { return new JobBuilder("certRegenBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .start(masterStepCertRegen(jobRepository,constants, skipListener)) + .start(masterStepCertRegen(jobRepository, transactionManager,constants, skipListener)) .on("*") .end().build() .build(); @@ -1017,28 +964,25 @@ public ItemProcessor>>> itemProc } @Bean - public Step masterStepEdwSnapshotSchool(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepEdwSnapshotSchool(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { return new StepBuilder("masterStepEdwSnapshotSchool", jobRepository) - .partitioner(edwSnapshotSchoolJobStep(jobRepository, skipListener).getName(), partitionerEDWSnapshotSchool()) - .step(edwSnapshotSchoolJobStep(jobRepository, skipListener)) + .partitioner(edwSnapshotSchoolJobStep(jobRepository, transactionManager, skipListener).getName(), partitionerEDWSnapshotSchool()) + .step(edwSnapshotSchoolJobStep(jobRepository, transactionManager, skipListener)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean - public Step edwSnapshotSchoolJobStep(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + public Step edwSnapshotSchoolJobStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener) { return new StepBuilder("edwSnapshotSchoolJobStep", jobRepository) - .>>>chunk(1) - .transactionManager(batchTransactionManager) - .faultTolerant() - .skip(SQLException.class) - .skip(TransactionException.class) + .>>>chunk(1, transactionManager) .reader(itemReaderEDWSnapshotSchool()) .processor(itemProcessorEDWSnapshotSchool()) .writer(itemWriterEDWSnapshotSchool()) - .transactionManager(batchTransactionManager) + .faultTolerant() .listener(skipListener) + .skip(Exception.class) .build(); } @@ -1067,39 +1011,36 @@ public ItemProcessor itemProcessorEDWSna } @Bean - public Step masterStepEdwSnapshot(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepEdwSnapshot(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { return new StepBuilder("masterStepEdwSnapshot", jobRepository) - .partitioner(edwSnapshotJobStep(jobRepository, skipListener).getName(), partitionerEDWSnapshot()) - .step(edwSnapshotJobStep(jobRepository, skipListener)) + .partitioner(edwSnapshotJobStep(jobRepository, transactionManager, skipListener).getName(), partitionerEDWSnapshot()) + .step(edwSnapshotJobStep(jobRepository, transactionManager, skipListener)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean - public Step edwSnapshotJobStep(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + public Step edwSnapshotJobStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener) { return new StepBuilder("edwSnapshotJobStep", jobRepository) - .chunk(1) - .transactionManager(batchTransactionManager) - .faultTolerant() - .skip(SQLException.class) - .skip(TransactionException.class) + .chunk(1, transactionManager) .reader(itemReaderEDWSnapshot()) .processor(itemProcessorEDWSnapshot()) .writer(itemWriterEDWSnapshot()) - .transactionManager(batchTransactionManager) + .faultTolerant() .listener(skipListener) + .skip(Exception.class) .build(); } @Bean(name="edwSnapshotBatchJob") - public Job edwSnapshotBatchJob(JobRepository jobRepository, EdwSnapshotCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constants) { + public Job edwSnapshotBatchJob(JobRepository jobRepository, PlatformTransactionManager transactionManager, EdwSnapshotCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constants) { return new JobBuilder("edwSnapshotBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .start(masterStepEdwSnapshotSchool(jobRepository,constants, skipListener)) + .start(masterStepEdwSnapshotSchool(jobRepository, transactionManager,constants, skipListener)) .on("*") - .to(masterStepEdwSnapshot(jobRepository,constants, skipListener)) + .to(masterStepEdwSnapshot(jobRepository, transactionManager,constants, skipListener)) .on("*") .end().build() .build(); @@ -1127,10 +1068,9 @@ public ItemWriter itemWriterUserScheduled() { } @Bean - public Step slaveStepUserScheduled(JobRepository jobRepository) { + public Step slaveStepUserScheduled(JobRepository jobRepository, PlatformTransactionManager transactionManager) { return new StepBuilder("slaveStepUserScheduled", jobRepository) - .chunk(1) - .transactionManager(batchTransactionManager) + .chunk(1, transactionManager) .reader(itemReaderUserScheduled()) .processor(itemProcessorUserScheduled()) .writer(itemWriterUserScheduled()) @@ -1138,17 +1078,17 @@ public Step slaveStepUserScheduled(JobRepository jobRepository) { } @Bean(name="userScheduledBatchJobRefresher") - public Job userScheduledBatchJobQueueRefresher(JobRepository jobRepository, UserScheduledCompletionNotificationListener listener) { + public Job userScheduledBatchJobQueueRefresher(JobRepository jobRepository, PlatformTransactionManager transactionManager, UserScheduledCompletionNotificationListener listener) { return new JobBuilder("userScheduledBatchJobRefresher", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .flow(slaveStepUserScheduled(jobRepository)) + .flow(slaveStepUserScheduled(jobRepository, transactionManager)) .end() .build(); } @Bean - public JobRegistryBeanPostProcessor jobRegistryBeanPostProcessor() { + public JobRegistryBeanPostProcessor jobRegistryBeanPostProcessor(JobRegistry jobRegistry) { JobRegistryBeanPostProcessor postProcessor = new JobRegistryBeanPostProcessor(); postProcessor.setJobRegistry(jobRegistry); return postProcessor; diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseDistributionRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseDistributionRunCompletionNotificationListener.java index 1cc31181..6d4d980b 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseDistributionRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseDistributionRunCompletionNotificationListener.java @@ -12,14 +12,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.listener.JobExecutionListenerSupport; +import org.springframework.batch.core.JobExecutionListener; import org.springframework.beans.factory.annotation.Autowired; import java.time.ZoneId; import java.util.Date; import java.util.List; -public abstract class BaseDistributionRunCompletionNotificationListener extends JobExecutionListenerSupport { +public abstract class BaseDistributionRunCompletionNotificationListener implements JobExecutionListener { private static final Logger LOGGER = LoggerFactory.getLogger(BaseDistributionRunCompletionNotificationListener.class); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java index d8466496..56a94395 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java @@ -11,14 +11,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.batch.core.JobExecution; +import org.springframework.batch.core.JobExecutionListener; import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.listener.JobExecutionListenerSupport; import org.springframework.batch.item.ExecutionContext; import org.springframework.beans.factory.annotation.Autowired; import java.util.*; -public abstract class BaseRunCompletionNotificationListener extends JobExecutionListenerSupport { +public abstract class BaseRunCompletionNotificationListener implements JobExecutionListener { private static final Logger LOGGER = LoggerFactory.getLogger(BaseRunCompletionNotificationListener.class); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/EdwSnapshotCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/EdwSnapshotCompletionNotificationListener.java index a89f59b9..caa9184b 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/EdwSnapshotCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/EdwSnapshotCompletionNotificationListener.java @@ -9,7 +9,7 @@ import org.slf4j.LoggerFactory; import org.springframework.batch.core.BatchStatus; import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.listener.JobExecutionListenerSupport; +import org.springframework.batch.core.JobExecutionListener; import org.springframework.batch.item.ExecutionContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -18,7 +18,7 @@ import java.util.Date; @Component -public class EdwSnapshotCompletionNotificationListener extends JobExecutionListenerSupport { +public class EdwSnapshotCompletionNotificationListener implements JobExecutionListener { private static final Logger LOGGER = LoggerFactory.getLogger(EdwSnapshotCompletionNotificationListener.class); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/RegenCertRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/RegenCertRunCompletionNotificationListener.java index 2763b488..3e349baf 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/RegenCertRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/RegenCertRunCompletionNotificationListener.java @@ -8,7 +8,7 @@ import org.slf4j.LoggerFactory; import org.springframework.batch.core.BatchStatus; import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.listener.JobExecutionListenerSupport; +import org.springframework.batch.core.JobExecutionListener; import org.springframework.batch.item.ExecutionContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -17,7 +17,7 @@ import java.util.Date; @Component -public class RegenCertRunCompletionNotificationListener extends JobExecutionListenerSupport { +public class RegenCertRunCompletionNotificationListener implements JobExecutionListener { private static final Logger LOGGER = LoggerFactory.getLogger(RegenCertRunCompletionNotificationListener.class); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserScheduledCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserScheduledCompletionNotificationListener.java index fe9710d7..98825c38 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserScheduledCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserScheduledCompletionNotificationListener.java @@ -7,25 +7,33 @@ import org.slf4j.LoggerFactory; import org.springframework.batch.core.BatchStatus; import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.listener.JobExecutionListenerSupport; -import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.batch.core.JobExecutionListener; import org.springframework.stereotype.Component; import java.time.ZoneId; import java.util.Date; @Component -public class UserScheduledCompletionNotificationListener extends JobExecutionListenerSupport { +public class UserScheduledCompletionNotificationListener implements JobExecutionListener { private static final Logger LOGGER = LoggerFactory.getLogger(UserScheduledCompletionNotificationListener.class); private static final String LOG_SEPARATION = "======================================================================================="; - @Autowired +// @Autowired private GradBatchHistoryService gradBatchHistoryService; - @Autowired +// @Autowired private TaskSchedulingService taskSchedulingService; - @Autowired RestUtils restUtils; +// @Autowired + private RestUtils restUtils; + + public UserScheduledCompletionNotificationListener(GradBatchHistoryService gradBatchHistoryService, + TaskSchedulingService taskSchedulingService, + RestUtils restUtils) { + this.gradBatchHistoryService = gradBatchHistoryService; + this.taskSchedulingService = taskSchedulingService; + this.restUtils = restUtils; + } @Override public void afterJob(JobExecution jobExecution) { diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunRegularGradAlgorithmProcessor.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunRegularGradAlgorithmProcessor.java index 725c5be9..41d6fc0a 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunRegularGradAlgorithmProcessor.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunRegularGradAlgorithmProcessor.java @@ -13,6 +13,7 @@ public class RunRegularGradAlgorithmProcessor extends BaseProcessor { @Override public GraduationStudentRecord process(UUID key) throws Exception { GraduationStudentRecord item = getItem(key); +// Thread.sleep(60000); if (item != null) { LOGGER.info("Processing partitionData = {}", item.getProgram()); summaryDTO.setBatchId(batchId); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/EducGradBatchGraduationApiConstants.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/EducGradBatchGraduationApiConstants.java index 247e620a..cde6a5cb 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/EducGradBatchGraduationApiConstants.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/EducGradBatchGraduationApiConstants.java @@ -139,6 +139,10 @@ public class EducGradBatchGraduationApiConstants { @Value("${batch.partitions.number}") private int numberOfPartitions; + // Spring Batch Transaction Chunk Size + @Value("${batch.transaction.chunk-size}") + private int transactionChunkSize; + // Token expiry offset (seconds) @Value("${batch.token-expiry.offset}") private int tokenExpiryOffset; diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/RegGradAlgBatchPerformanceWriter.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/RegGradAlgBatchPerformanceWriter.java index e614d5d4..bebfec65 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/RegGradAlgBatchPerformanceWriter.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/RegGradAlgBatchPerformanceWriter.java @@ -12,8 +12,7 @@ public class RegGradAlgBatchPerformanceWriter extends BaseWriter { @Override public void write(Chunk list) { if(!list.isEmpty()) { - GraduationStudentRecord gradStatus = list.getItems().get(0); - saveBatchStatus(gradStatus); + list.forEach(this::saveBatchStatus); LOGGER.debug("Left:{}\n",summaryDTO.getReadCount()-summaryDTO.getProcessedCount()); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/TvrRunBatchPerformanceWriter.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/TvrRunBatchPerformanceWriter.java index fe4a717b..1ddc8f9a 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/TvrRunBatchPerformanceWriter.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/TvrRunBatchPerformanceWriter.java @@ -18,8 +18,7 @@ public class TvrRunBatchPerformanceWriter extends BaseWriter { @Override public void write(Chunk list) throws Exception { if(!list.isEmpty()) { - GraduationStudentRecord gradStatus = list.getItems().get(0); - saveBatchStatus(gradStatus); + list.forEach(this::saveBatchStatus); LOGGER.debug("Left:{}\n",summaryDTO.getReadCount()-summaryDTO.getProcessedCount()); } } diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml index 5e9b4cd4..39be3638 100644 --- a/api/src/main/resources/application.yaml +++ b/api/src/main/resources/application.yaml @@ -2,19 +2,18 @@ spring: jmx: enabled: false - db-connection: + datasource: hikari: pool-name: educ-grad-batch-graduation-api-cp maximum-pool-size: ${MAXIMUM_POOL_SIZE} connection-timeout: ${CONNECTION_TIMEOUT} max-lifetime: ${MAX_LIFETIME} minimum-idle: ${MIN_IDLE} - keepalive-time: ${KEEP_ALIVE_TIME} idle-timeout: ${IDLE_TIMEOUT} url: ${CONNECTION_STRING} username: ${USERNAME} password: ${PASSWORD} - driver-class: oracle.jdbc.driver.OracleDriver + driver-class-name: oracle.jdbc.driver.OracleDriver jpa: show-sql: true database-platform: org.hibernate.dialect.OracleDialect @@ -138,6 +137,8 @@ authorization: password: ${GRAD_CLIENT_SECRET} batch: + transaction: + chunk-size: ${TRANSACTION_CHUNK_SIZE} partitions: number: ${NUMBER_OF_PARTITIONS} regalg: @@ -167,9 +168,9 @@ endpoint: keycloak: getToken: ${KEYCLOAK_TOKEN_URL}auth/realms/master/protocol/openid-connect/token grad-graduation-api: - graduatestudent: + graduatestudent: url: ${GRAD_GRADUATION_API}api/v1/graduate/studentid/%s/run/GS?batchId=%s - reportonlyrun: + reportonlyrun: url: ${GRAD_GRADUATION_API}api/v1/graduate/studentid/%s/run/FMR?batchId=%s tvrrun: url: ${GRAD_GRADUATION_API}api/v1/graduate/studentid/%s/run/REGFM?batchId=%s diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/config/AsyncConfig.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/config/AsyncConfig.java index ea8deeab..f5446982 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/config/AsyncConfig.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/config/AsyncConfig.java @@ -5,7 +5,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; import org.springframework.core.task.TaskExecutor; -import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; @Configuration diff --git a/tools/config/update-configmap.sh b/tools/config/update-configmap.sh index f5a6154d..5a425f78 100644 --- a/tools/config/update-configmap.sh +++ b/tools/config/update-configmap.sh @@ -53,7 +53,7 @@ echo Creating config map "$APP_NAME"-config-map oc create -n "$OPENSHIFT_NAMESPACE"-"$envValue" configmap "$APP_NAME"-config-map \ --from-literal=CONNECTION_TIMEOUT="60000" \ --from-literal=GRAD_TRAX_API="http://educ-grad-trax-api.$OPENSHIFT_NAMESPACE-$envValue.svc.cluster.local:8080/" \ - --from-literal=MAX_LIFETIME="600000" \ + --from-literal=MAX_LIFETIME="590000" \ --from-literal=GRAD_STUDENT_API="http://educ-grad-student-api.$OPENSHIFT_NAMESPACE-$envValue.svc.cluster.local:8080/" \ --from-literal=MAXIMUM_POOL_SIZE="25" \ --from-literal=APP_LOG_LEVEL="$APP_LOG_LEVEL" \ @@ -64,10 +64,10 @@ oc create -n "$OPENSHIFT_NAMESPACE"-"$envValue" configmap "$APP_NAME"-config-map --from-literal=IDLE_TIMEOUT="300000" \ --from-literal=MAX_RETRY_ATTEMPTS="5" \ --from-literal=ENABLE_FLYWAY="true" \ - --from-literal=KEEP_ALIVE_TIME="150000" \ --from-literal=TOKEN_EXPIRY_OFFSET="30" \ --from-literal=GRAD_GRADUATION_API="http://educ-grad-graduation-api.$OPENSHIFT_NAMESPACE-$envValue.svc.cluster.local:8080/" \ --from-literal=DIST_RUN_CRON="0 0 02 1 * *" \ + --from-literal=TRANSACTION_CHUNK_SIZE="1" \ --from-literal=NUMBER_OF_PARTITIONS="10" \ --from-literal=KEYCLOAK_TOKEN_URL="https://soam-$envValue.apps.silver.devops.gov.bc.ca/" \ --from-literal=REG_ALG_CRON="0 30 18 * * *" \ From 0204c0a3620de60e421cf401ffb775555f37ae26 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Thu, 15 Feb 2024 10:52:51 -0800 Subject: [PATCH 2/2] GRAD2-2505: StepScope reader & writer warnings are resolved. GRAD2-2505: StepScope reader & writer warnings are resolved. --- .../config/BatchJobConfig.java | 255 ++++++++---------- .../controller/JobLauncherController.java | 12 +- .../entity/BatchStatusEnum.java | 7 +- ...cialRunCompletionNotificationListener.java | 6 - .../RunProjectedGradAlgorithmProcessor.java | 5 +- .../RunRegularGradAlgorithmProcessor.java | 6 +- .../RunSpecialGradAlgorithmProcessor.java | 5 +- ...pecialProjectedGradAlgorithmProcessor.java | 5 +- .../batchgraduation/writer/BaseWriter.java | 14 +- .../writer/TvrRunBatchPerformanceWriter.java | 6 - .../batchgraduation/config/BatchConfig.java | 10 + api/src/test/resources/application.yaml | 2 + tools/config/update-configmap.sh | 4 +- 13 files changed, 164 insertions(+), 173 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchJobConfig.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchJobConfig.java index 7b65a30e..ac7ba394 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchJobConfig.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchJobConfig.java @@ -33,11 +33,6 @@ @EnableBatchProcessing(isolationLevelForCreate = "ISOLATION_READ_COMMITTED") public class BatchJobConfig { - // Partitioning for Regular Grad Run updates - -// @Autowired -// JobRegistry jobRegistry; - /** * Regular Grad Algorithm Run * ItemProcessor,ItemReader and ItemWriter @@ -46,60 +41,63 @@ public class BatchJobConfig { @Bean @StepScope - public ItemProcessor itemProcessorRegGrad() { + public RunRegularGradAlgorithmProcessor itemProcessorRegGrad() { return new RunRegularGradAlgorithmProcessor(); } @Bean @StepScope - public ItemReader itemReaderRegGrad() { + public RecalculateStudentReader itemReaderRegGrad() { return new RecalculateStudentReader(); } @Bean @StepScope - public ItemReader itemReaderRegErrorGrad() { + public RecalculateStudentErrorReader itemReaderRegErrorGrad() { return new RecalculateStudentErrorReader(); } @Bean @StepScope - public ItemReader itemReaderRegErrorRetryGrad() { + public RecalculateStudentErrorRetryReader itemReaderRegErrorRetryGrad() { return new RecalculateStudentErrorRetryReader(); } @Bean @StepScope - public ItemWriter itemWriterRegGrad() { + public RegGradAlgBatchPerformanceWriter itemWriterRegGrad() { return new RegGradAlgBatchPerformanceWriter(); } @Bean - public Step masterStepRegGrad(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepRegGrad(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants) { + Step step = graduationJobStep(jobRepository, transactionManager, constants); return new StepBuilder("masterStepRegGrad", jobRepository) - .partitioner(graduationJobStep(jobRepository, transactionManager, skipListener, constants).getName(), partitionerRegGrad()) - .step(graduationJobStep(jobRepository, transactionManager, skipListener, constants)) + .partitioner(step.getName(), partitionerRegGrad()) + .step(step) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean - public Step masterStepRegGradError(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepRegGradError(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants) { + Step step = graduationJobErrorStep(jobRepository, transactionManager, constants); return new StepBuilder("masterStepRegGradError", jobRepository) - .partitioner(graduationJobErrorStep(jobRepository, transactionManager, skipListener, constants).getName(), partitionerRegGradRetry()) - .step(graduationJobErrorStep(jobRepository, transactionManager, skipListener, constants)) + .partitioner(step.getName(), partitionerRegGradRetry()) + .step(step) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean - public Step masterStepRegGradErrorRetry(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepRegGradErrorRetry(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants) { + Step step = graduationJobErrorRetryStep(jobRepository, transactionManager, constants); return new StepBuilder("masterStepRegGradErrorRetry", jobRepository) - .partitioner(graduationJobErrorRetryStep(jobRepository, transactionManager, skipListener, constants).getName(), partitionerRegGradRetry()) - .step(graduationJobErrorRetryStep(jobRepository, transactionManager, skipListener, constants)) + .partitioner(step.getName(), partitionerRegGradRetry()) + .step(step) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); @@ -119,54 +117,45 @@ public RegGradAlgPartitionerRetry partitionerRegGradRetry() { } @Bean - public Step graduationJobErrorStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { + public Step graduationJobErrorStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("graduationJobErrorStep", jobRepository) .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderRegErrorGrad()) .processor(itemProcessorRegGrad()) .writer(itemWriterRegGrad()) - .faultTolerant() - .listener(skipListener) - .skip(Exception.class) .build(); } @Bean - public Step graduationJobErrorRetryStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { + public Step graduationJobErrorRetryStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("graduationJobErrorRetryStep", jobRepository) .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderRegErrorRetryGrad()) .processor(itemProcessorRegGrad()) .writer(itemWriterRegGrad()) - .faultTolerant() - .listener(skipListener) - .skip(Exception.class) .build(); } @Bean - public Step graduationJobStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { + public Step graduationJobStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("graduationJobStep", jobRepository) .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderRegGrad()) .processor(itemProcessorRegGrad()) .writer(itemWriterRegGrad()) - .faultTolerant() - .listener(skipListener) - .skip(Exception.class) .build(); } @Bean(name="GraduationBatchJob") - public Job graduationBatchJob(JobRepository jobRepository, PlatformTransactionManager transactionManager, GradRunCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constants) { + public Job graduationBatchJob(JobRepository jobRepository, PlatformTransactionManager transactionManager, GradRunCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { return new JobBuilder("GraduationBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .start(masterStepRegGrad(jobRepository, transactionManager, constants, skipListener)) + .start(masterStepRegGrad(jobRepository, transactionManager, constants)) .on("*") - .to(masterStepRegGradError(jobRepository, transactionManager,constants, skipListener)) + .to(masterStepRegGradError(jobRepository, transactionManager,constants)) .on("*") - .to(masterStepRegGradErrorRetry(jobRepository, transactionManager,constants, skipListener)) + .to(masterStepRegGradErrorRetry(jobRepository, transactionManager,constants)) .on("*") .end().build() .build(); @@ -181,59 +170,62 @@ public Job graduationBatchJob(JobRepository jobRepository, PlatformTransactionMa @Bean @StepScope - public ItemProcessor itemProcessorTvrRun() { + public RunProjectedGradAlgorithmProcessor itemProcessorTvrRun() { return new RunProjectedGradAlgorithmProcessor(); } @Bean @StepScope - public ItemReader itemReaderTvrRun() { + public RecalculateProjectedGradRunReader itemReaderTvrRun() { return new RecalculateProjectedGradRunReader(); } @Bean @StepScope - public ItemReader itemReaderTvrErrorRun() { + public RecalculateProjectedGradRunErrorReader itemReaderTvrErrorRun() { return new RecalculateProjectedGradRunErrorReader(); } @Bean @StepScope - public ItemReader itemReaderTvrErrorRetryRun() { + public RecalculateProjectedGradRunErrorRetryReader itemReaderTvrErrorRetryRun() { return new RecalculateProjectedGradRunErrorRetryReader(); } @Bean @StepScope - public ItemWriter itemWriterTvrRun() { + public TvrRunBatchPerformanceWriter itemWriterTvrRun() { return new TvrRunBatchPerformanceWriter(); } @Bean - public Step masterStepTvrRun(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepTvrRun(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants) { + Step step = tvrJobStep(jobRepository, transactionManager, constants); return new StepBuilder("masterStepTvrRun", jobRepository) - .partitioner(tvrJobStep(jobRepository, transactionManager,skipListener, constants).getName(), partitionerTvrRun()) - .step(tvrJobStep(jobRepository, transactionManager,skipListener, constants)) + .partitioner(step.getName(), partitionerTvrRun()) + .step(step) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean - public Step masterStepTvrRunError(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepTvrRunError(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants) { + Step step = tvrJobErrorStep(jobRepository, transactionManager, constants); return new StepBuilder("masterStepTvrRunError", jobRepository) - .partitioner(tvrJobErrorStep(jobRepository, transactionManager,skipListener, constants).getName(), partitionerTvrRunRetry()) - .step(tvrJobErrorStep(jobRepository, transactionManager,skipListener, constants)) + .partitioner(step.getName(), partitionerTvrRunRetry()) + .step(step) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean - public Step masterStepTvrRunErrorRetry(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepTvrRunErrorRetry(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants) { + Step step = tvrJobErrorRetryStep(jobRepository, transactionManager, constants); return new StepBuilder("masterStepTvrRunErrorRetry", jobRepository) - .partitioner(tvrJobErrorRetryStep(jobRepository, transactionManager,skipListener, constants).getName(), partitionerTvrRunRetry()) - .step(tvrJobErrorRetryStep(jobRepository, transactionManager,skipListener, constants)) + .partitioner(step.getName(), partitionerTvrRunRetry()) + .step(step) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); @@ -253,54 +245,45 @@ public TvrRunPartitionerRetry partitionerTvrRunRetry() { @Bean - public Step tvrJobStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { + public Step tvrJobStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("tvrJobStep", jobRepository) .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderTvrRun()) .processor(itemProcessorTvrRun()) .writer(itemWriterTvrRun()) - .faultTolerant() - .listener(skipListener) - .skip(Exception.class) .build(); } @Bean - public Step tvrJobErrorStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { + public Step tvrJobErrorStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("tvrJobErrorStep", jobRepository) .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderTvrErrorRun()) .processor(itemProcessorTvrRun()) .writer(itemWriterTvrRun()) - .faultTolerant() - .listener(skipListener) - .skip(Exception.class) .build(); } @Bean - public Step tvrJobErrorRetryStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { + public Step tvrJobErrorRetryStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("tvrJobErrorRetryStep", jobRepository) .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderTvrErrorRetryRun()) .processor(itemProcessorTvrRun()) .writer(itemWriterTvrRun()) - .faultTolerant() - .listener(skipListener) - .skip(Exception.class) .build(); } @Bean(name="tvrBatchJob") - public Job tvrBatchJob(JobRepository jobRepository, PlatformTransactionManager transactionManager, TvrRunJobCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constants) { + public Job tvrBatchJob(JobRepository jobRepository, PlatformTransactionManager transactionManager, TvrRunJobCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { return new JobBuilder("tvrBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .start(masterStepTvrRun(jobRepository, transactionManager,constants,skipListener)) + .start(masterStepTvrRun(jobRepository, transactionManager,constants)) .on("*") - .to(masterStepTvrRunError(jobRepository, transactionManager,constants,skipListener)) + .to(masterStepTvrRunError(jobRepository, transactionManager,constants)) .on("*") - .to(masterStepTvrRunErrorRetry(jobRepository, transactionManager,constants,skipListener)) + .to(masterStepTvrRunErrorRetry(jobRepository, transactionManager,constants)) .on("*") .end().build() .build(); @@ -314,49 +297,52 @@ public Job tvrBatchJob(JobRepository jobRepository, PlatformTransactionManager t @Bean @StepScope - public ItemProcessor itemProcessorSpcRegGrad() { + public RunSpecialGradAlgorithmProcessor itemProcessorSpcRegGrad() { return new RunSpecialGradAlgorithmProcessor(); } @Bean @StepScope - public ItemReader itemReaderSpcRegGrad() { + public SpecialGradRunStudentReader itemReaderSpcRegGrad() { return new SpecialGradRunStudentReader(); } @Bean @StepScope - public ItemWriter itemWriterSpcRegGrad() { + public RegGradAlgBatchPerformanceWriter itemWriterSpcRegGrad() { return new RegGradAlgBatchPerformanceWriter(); } @Bean - public Step masterStepSpcRegGrad(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepSpcRegGrad(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants) { + Step step = slaveSpcRegGradStep(jobRepository, transactionManager, constants); return new StepBuilder("masterStepSpcRegGrad", jobRepository) - .partitioner(slaveSpcRegGradStep(jobRepository, transactionManager,skipListener, constants).getName(), partitionerSpcRegGrad()) - .step(slaveSpcRegGradStep(jobRepository, transactionManager,skipListener, constants)) + .partitioner(step.getName(), partitionerSpcRegGrad()) + .step(step) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean - public Step masterStepSpcRegGradError(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepSpcRegGradError(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants) { + Step step = slaveSpcRegGradErrorStep(jobRepository, transactionManager, constants); return new StepBuilder("masterStepSpcRegGradError", jobRepository) - .partitioner(slaveSpcRegGradErrorStep(jobRepository, transactionManager,skipListener, constants).getName(), partitionerSpcRegGradRetry()) - .step(slaveSpcRegGradErrorStep(jobRepository, transactionManager,skipListener, constants)) + .partitioner(step.getName(), partitionerSpcRegGradRetry()) + .step(step) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean - public Step masterStepSpcRegGradErrorRetry(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepSpcRegGradErrorRetry(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants) { + Step step = slaveSpcRegGradErrorRetryStep(jobRepository, transactionManager, constants); return new StepBuilder("masterStepSpcRegGradErrorRetry", jobRepository) - .partitioner(slaveSpcRegGradErrorRetryStep(jobRepository, transactionManager,skipListener, constants).getName(), partitionerSpcRegGradRetry()) - .step(slaveSpcRegGradErrorRetryStep(jobRepository, transactionManager,skipListener, constants)) + .partitioner(step.getName(), partitionerSpcRegGradRetry()) + .step(step) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); @@ -375,54 +361,45 @@ public SpcRegGradAlgPartitionerRetry partitionerSpcRegGradRetry() { } @Bean - public Step slaveSpcRegGradStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { + public Step slaveSpcRegGradStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("slaveStepSpcRegGrad", jobRepository) .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderSpcRegGrad()) .processor(itemProcessorSpcRegGrad()) .writer(itemWriterSpcRegGrad()) - .faultTolerant() - .listener(skipListener) - .skip(Exception.class) .build(); } @Bean - public Step slaveSpcRegGradErrorStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { + public Step slaveSpcRegGradErrorStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("slaveSpcRegGradErrorStep", jobRepository) .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderSpcRegGrad()) .processor(itemProcessorSpcRegGrad()) .writer(itemWriterSpcRegGrad()) - .faultTolerant() - .listener(skipListener) - .skip(Exception.class) .build(); } @Bean - public Step slaveSpcRegGradErrorRetryStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { + public Step slaveSpcRegGradErrorRetryStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("slaveSpcRegGradErrorRetryStep", jobRepository) .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderSpcRegGrad()) .processor(itemProcessorSpcRegGrad()) .writer(itemWriterSpcRegGrad()) - .faultTolerant() - .listener(skipListener) - .skip(Exception.class) .build(); } @Bean(name="SpecialGraduationBatchJob") - public Job specialGraduationBatchJob(JobRepository jobRepository, PlatformTransactionManager transactionManager, SpecialRunCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constants) { + public Job specialGraduationBatchJob(JobRepository jobRepository, PlatformTransactionManager transactionManager, SpecialRunCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { return new JobBuilder("SpecialGraduationBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .start(masterStepSpcRegGrad(jobRepository, transactionManager,constants,skipListener)) + .start(masterStepSpcRegGrad(jobRepository, transactionManager,constants)) .on("*") - .to(masterStepSpcRegGradError(jobRepository, transactionManager,constants,skipListener)) + .to(masterStepSpcRegGradError(jobRepository, transactionManager,constants)) .on("*") - .to(masterStepSpcRegGradErrorRetry(jobRepository, transactionManager,constants,skipListener)) + .to(masterStepSpcRegGradErrorRetry(jobRepository, transactionManager,constants)) .on("*") .end().build() .build(); @@ -436,101 +413,95 @@ public Job specialGraduationBatchJob(JobRepository jobRepository, PlatformTransa @Bean @StepScope - public ItemProcessor itemProcessorSpcTvrRun() { + public RunSpecialProjectedGradAlgorithmProcessor itemProcessorSpcTvrRun() { return new RunSpecialProjectedGradAlgorithmProcessor(); } @Bean @StepScope - public ItemReader itemReaderSpcTvrRun() { + public SpecialProjectedGradRunReader itemReaderSpcTvrRun() { return new SpecialProjectedGradRunReader(); } @Bean @StepScope - public ItemWriter itemWriterSpcTvrRun() { + public TvrRunBatchPerformanceWriter itemWriterSpcTvrRun() { return new TvrRunBatchPerformanceWriter(); } @Bean - public Step masterStepSpcTvrRun(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepSpcTvrRun(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants) { + Step step = slaveStepSpcTvrRun(jobRepository, transactionManager, constants); return new StepBuilder("masterStepSpcTvrRun", jobRepository) - .partitioner(slaveStepSpcTvrRun(jobRepository, transactionManager,skipListener, constants).getName(), partitionerSpcRegGrad()) - .step(slaveStepSpcTvrRun(jobRepository, transactionManager,skipListener, constants)) + .partitioner(step.getName(), partitionerSpcRegGrad()) + .step(step) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean - public Step masterStepSpcTvrRunError(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepSpcTvrRunError(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants) { + Step step = slaveStepSpcTvrRunError(jobRepository, transactionManager, constants); return new StepBuilder("masterStepSpcTvrRunError", jobRepository) - .partitioner(slaveStepSpcTvrRunError(jobRepository, transactionManager,skipListener, constants).getName(), partitionerSpcRegGradRetry()) - .step(slaveStepSpcTvrRunError(jobRepository, transactionManager,skipListener, constants)) + .partitioner(step.getName(), partitionerSpcRegGradRetry()) + .step(step) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean - public Step masterStepSpcTvrRunErrorRetry(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + public Step masterStepSpcTvrRunErrorRetry(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constants) { + Step step = slaveStepSpcTvrRunErrorRetry(jobRepository, transactionManager, constants); return new StepBuilder("masterStepSpcTvrRunErrorRetry", jobRepository) - .partitioner(slaveStepSpcTvrRunErrorRetry(jobRepository, transactionManager,skipListener, constants).getName(), partitionerSpcRegGradRetry()) - .step(slaveStepSpcTvrRunErrorRetry(jobRepository, transactionManager,skipListener, constants)) + .partitioner(step.getName(), partitionerSpcRegGradRetry()) + .step(step) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor()) .build(); } @Bean - public Step slaveStepSpcTvrRun(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { + public Step slaveStepSpcTvrRun(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("slaveStepSpcTvrRun", jobRepository) .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderSpcTvrRun()) .processor(itemProcessorSpcTvrRun()) .writer(itemWriterSpcTvrRun()) - .faultTolerant() - .listener(skipListener) - .skip(Exception.class) .build(); } @Bean - public Step slaveStepSpcTvrRunError(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { + public Step slaveStepSpcTvrRunError(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("slaveStepSpcTvrRunError", jobRepository) .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderSpcTvrRun()) .processor(itemProcessorSpcTvrRun()) .writer(itemWriterSpcTvrRun()) - .faultTolerant() - .listener(skipListener) - .skip(Exception.class) .build(); } @Bean - public Step slaveStepSpcTvrRunErrorRetry(JobRepository jobRepository, PlatformTransactionManager transactionManager, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constant) { + public Step slaveStepSpcTvrRunErrorRetry(JobRepository jobRepository, PlatformTransactionManager transactionManager, EducGradBatchGraduationApiConstants constant) { return new StepBuilder("slaveStepSpcTvrRunErrorRetry", jobRepository) .chunk(constant.getTransactionChunkSize(), transactionManager) .reader(itemReaderSpcTvrRun()) .processor(itemProcessorSpcTvrRun()) .writer(itemWriterSpcTvrRun()) - .faultTolerant() - .listener(skipListener) - .skip(Exception.class) .build(); } @Bean(name="SpecialTvrRunBatchJob") - public Job specialTvrRunBatchJob(JobRepository jobRepository, PlatformTransactionManager transactionManager, SpecialRunCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constants) { + public Job specialTvrRunBatchJob(JobRepository jobRepository, PlatformTransactionManager transactionManager, SpecialRunCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { return new JobBuilder("SpecialTvrRunBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .start(masterStepSpcTvrRun(jobRepository, transactionManager,constants,skipListener)) + .start(masterStepSpcTvrRun(jobRepository, transactionManager,constants)) .on("*") - .to(masterStepSpcTvrRunError(jobRepository, transactionManager,constants,skipListener)) + .to(masterStepSpcTvrRunError(jobRepository, transactionManager,constants)) .on("*") - .to(masterStepSpcTvrRunErrorRetry(jobRepository, transactionManager,constants,skipListener)) + .to(masterStepSpcTvrRunErrorRetry(jobRepository, transactionManager,constants)) .on("*") .end().build() .build(); @@ -544,37 +515,37 @@ public Job specialTvrRunBatchJob(JobRepository jobRepository, PlatformTransactio @Bean @StepScope - public ItemProcessor itemProcessorDisRun() { + public DistributionRunProcessor itemProcessorDisRun() { return new DistributionRunProcessor(); } @Bean @StepScope - public ItemProcessor> itemProcessorDisRunYearlyNonGradByMincode() { + public DistributionRunYearlyNonGradProcessor itemProcessorDisRunYearlyNonGradByMincode() { return new DistributionRunYearlyNonGradProcessor(); } @Bean @StepScope - public ItemReader itemReaderDisRun() { + public DistributionRunStudentCredentialsReader itemReaderDisRun() { return new DistributionRunStudentCredentialsReader(); } @Bean @StepScope - public ItemReader itemReaderDisRunYearlyNonGrad() { + public DistributionRunYearlyNonGradReader itemReaderDisRunYearlyNonGrad() { return new DistributionRunYearlyNonGradReader(); } @Bean @StepScope - public ItemWriter itemWriterDisRun() { + public DistributionRunWriter itemWriterDisRun() { return new DistributionRunWriter(); } @Bean @StepScope - public ItemWriter> itemWriterDisRunYearlyNonGrad() { + public DistributionRunYearlyNonGradWriter itemWriterDisRunYearlyNonGrad() { return new DistributionRunYearlyNonGradWriter(); } @@ -759,19 +730,19 @@ public Job distributionBatchJobUserReq(JobRepository jobRepository, PlatformTran @Bean @StepScope - public ItemProcessor itemProcessorBlankDisRun() { + public BlankDistributionRunProcessor itemProcessorBlankDisRun() { return new BlankDistributionRunProcessor(); } @Bean @StepScope - public ItemReader itemReaderBlankDisRun() { + public BlankDistributionRunReader itemReaderBlankDisRun() { return new BlankDistributionRunReader(); } @Bean @StepScope - public ItemWriter itemWriterBlankDisRun() { + public BlankDistributionRunWriter itemWriterBlankDisRun() { return new BlankDistributionRunWriter(); } @@ -821,19 +792,19 @@ public Job blankDistributionBatchJobUserReq(JobRepository jobRepository, Platfor @Bean @StepScope - public ItemProcessor itemProcessorPsiDisRun() { + public PsiDistributionRunProcessor itemProcessorPsiDisRun() { return new PsiDistributionRunProcessor(); } @Bean @StepScope - public ItemReader itemReaderPsiDisRun() { + public PsiDistributionRunReader itemReaderPsiDisRun() { return new PsiDistributionRunReader(); } @Bean @StepScope - public ItemWriter itemWriterPsiDisRun() { + public PsiDistributionRunWriter itemWriterPsiDisRun() { return new PsiDistributionRunWriter(); } @@ -886,19 +857,19 @@ public RegenerateCertificatePartitioner partitionerCertRegen() { @Bean @StepScope - public ItemReader itemReaderCertRegen() { + public RegenerateCertificateReader itemReaderCertRegen() { return new RegenerateCertificateReader(); } @Bean @StepScope - public ItemWriter itemWriterCertRegen() { + public RegenerateCertificateRunWriter itemWriterCertRegen() { return new RegenerateCertificateRunWriter(); } @Bean @StepScope - public ItemProcessor itemProcessorCertRegen() { + public RunCertificateRegenerationProcessor itemProcessorCertRegen() { return new RunCertificateRegenerationProcessor(); } @@ -947,19 +918,19 @@ public EDWSnapshotSchoolPartitioner partitionerEDWSnapshotSchool() { @Bean @StepScope - public ItemReader itemReaderEDWSnapshotSchool() { + public EDWSnapshotSchoolReader itemReaderEDWSnapshotSchool() { return new EDWSnapshotSchoolReader(); } @Bean @StepScope - public ItemWriter>>> itemWriterEDWSnapshotSchool() { + public EDWSnapshotSchoolWriter itemWriterEDWSnapshotSchool() { return new EDWSnapshotSchoolWriter(); } @Bean @StepScope - public ItemProcessor>>> itemProcessorEDWSnapshotSchool() { + public EDWSnapshotSchoolProcessor itemProcessorEDWSnapshotSchool() { return new EDWSnapshotSchoolProcessor(); } @@ -994,19 +965,19 @@ public EDWSnapshotPartitioner partitionerEDWSnapshot() { @Bean @StepScope - public ItemReader itemReaderEDWSnapshot() { + public EDWSnapshotReader itemReaderEDWSnapshot() { return new EDWSnapshotReader(); } @Bean @StepScope - public ItemWriter itemWriterEDWSnapshot() { + public EDWSnapshotWriter itemWriterEDWSnapshot() { return new EDWSnapshotWriter(); } @Bean @StepScope - public ItemProcessor itemProcessorEDWSnapshot() { + public EDWSnapshotProcessor itemProcessorEDWSnapshot() { return new EDWSnapshotProcessor(); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherController.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherController.java index 1b72e427..ca96c610 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherController.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherController.java @@ -91,11 +91,9 @@ public class JobLauncherController { private final GradBatchHistoryService gradBatchHistoryService; private final DistributionRunStatusUpdateProcessor distributionRunStatusUpdateProcessor; - @Autowired - JsonTransformer jsonTransformer; + private final JsonTransformer jsonTransformer; - @Autowired - GradSchoolOfRecordFilter gradSchoolOfRecordFilter; + private final GradSchoolOfRecordFilter gradSchoolOfRecordFilter; @Autowired public JobLauncherController( @@ -106,7 +104,9 @@ public JobLauncherController( RestUtils restUtils, GradDashboardService gradDashboardService, GradBatchHistoryService gradBatchHistoryService, - DistributionRunStatusUpdateProcessor distributionRunStatusUpdateProcessor) { + DistributionRunStatusUpdateProcessor distributionRunStatusUpdateProcessor, + JsonTransformer jsonTransformer, + GradSchoolOfRecordFilter gradSchoolOfRecordFilter) { this.jobLauncher = jobLauncher; this.asyncJobLauncher = asyncJobLauncher; this.jobRegistry = jobRegistry; @@ -114,6 +114,8 @@ public JobLauncherController( this.gradDashboardService = gradDashboardService; this.gradBatchHistoryService = gradBatchHistoryService; this.distributionRunStatusUpdateProcessor = distributionRunStatusUpdateProcessor; + this.jsonTransformer = jsonTransformer; + this.gradSchoolOfRecordFilter = gradSchoolOfRecordFilter; } @GetMapping(EducGradBatchGraduationApiConstants.EXECUTE_REG_GRAD_BATCH_JOB) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchStatusEnum.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchStatusEnum.java index 70501446..70d5f48b 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchStatusEnum.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchStatusEnum.java @@ -3,5 +3,10 @@ public enum BatchStatusEnum { STARTED, COMPLETED, - FAILED; + FAILED, + STARTING, + STOPPING, + STOPPED, + ABANDONED, + UNKNOWN; } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/SpecialRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/SpecialRunCompletionNotificationListener.java index 9fbd7282..d87767e1 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/SpecialRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/SpecialRunCompletionNotificationListener.java @@ -1,6 +1,5 @@ package ca.bc.gov.educ.api.batchgraduation.listener; -import ca.bc.gov.educ.api.batchgraduation.model.StudentSearchRequest; import ca.bc.gov.educ.api.batchgraduation.rest.RestUtils; import ca.bc.gov.educ.api.batchgraduation.util.JsonTransformer; import org.slf4j.Logger; @@ -8,16 +7,11 @@ import org.springframework.batch.core.BatchStatus; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.time.ZoneId; import java.util.Date; -import java.util.List; -import java.util.UUID; - -import static ca.bc.gov.educ.api.batchgraduation.util.EducGradBatchGraduationApiConstants.SEARCH_REQUEST; @Component public class SpecialRunCompletionNotificationListener extends BaseRunCompletionNotificationListener { diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunProjectedGradAlgorithmProcessor.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunProjectedGradAlgorithmProcessor.java index f8e2b2ae..3da79a0c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunProjectedGradAlgorithmProcessor.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunProjectedGradAlgorithmProcessor.java @@ -3,6 +3,8 @@ import ca.bc.gov.educ.api.batchgraduation.model.GraduationStudentRecord; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.lang.NonNull; +import org.springframework.lang.Nullable; import java.util.UUID; @@ -11,7 +13,8 @@ public class RunProjectedGradAlgorithmProcessor extends BaseProcessor { private static final Logger LOGGER = LoggerFactory.getLogger(RunProjectedGradAlgorithmProcessor.class); @Override - public GraduationStudentRecord process(UUID key) throws Exception { + @Nullable + public GraduationStudentRecord process(@NonNull UUID key) throws Exception { GraduationStudentRecord item = getItem(key); if (item != null) { LOGGER.info("Processing partitionData = {}", item.getProgram()); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunRegularGradAlgorithmProcessor.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunRegularGradAlgorithmProcessor.java index 41d6fc0a..65c78312 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunRegularGradAlgorithmProcessor.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunRegularGradAlgorithmProcessor.java @@ -3,6 +3,8 @@ import ca.bc.gov.educ.api.batchgraduation.model.GraduationStudentRecord; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.lang.NonNull; +import org.springframework.lang.Nullable; import java.util.UUID; @@ -11,9 +13,9 @@ public class RunRegularGradAlgorithmProcessor extends BaseProcessor { private static final Logger LOGGER = LoggerFactory.getLogger(RunRegularGradAlgorithmProcessor.class); @Override - public GraduationStudentRecord process(UUID key) throws Exception { + @Nullable + public GraduationStudentRecord process(@NonNull UUID key) throws Exception { GraduationStudentRecord item = getItem(key); -// Thread.sleep(60000); if (item != null) { LOGGER.info("Processing partitionData = {}", item.getProgram()); summaryDTO.setBatchId(batchId); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunSpecialGradAlgorithmProcessor.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunSpecialGradAlgorithmProcessor.java index a4567e0d..20dc93ed 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunSpecialGradAlgorithmProcessor.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunSpecialGradAlgorithmProcessor.java @@ -3,6 +3,8 @@ import ca.bc.gov.educ.api.batchgraduation.model.GraduationStudentRecord; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.lang.NonNull; +import org.springframework.lang.Nullable; import java.util.UUID; @@ -11,7 +13,8 @@ public class RunSpecialGradAlgorithmProcessor extends BaseProcessor { private static final Logger LOGGER = LoggerFactory.getLogger(RunSpecialGradAlgorithmProcessor.class); @Override - public GraduationStudentRecord process(UUID key) throws Exception { + @Nullable + public GraduationStudentRecord process(@NonNull UUID key) throws Exception { GraduationStudentRecord item = getItem(key); if (item != null) { LOGGER.info("Processing partitionData = {}", item.getProgram()); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunSpecialProjectedGradAlgorithmProcessor.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunSpecialProjectedGradAlgorithmProcessor.java index b4dddbc5..49047f8c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunSpecialProjectedGradAlgorithmProcessor.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunSpecialProjectedGradAlgorithmProcessor.java @@ -3,6 +3,8 @@ import ca.bc.gov.educ.api.batchgraduation.model.GraduationStudentRecord; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.lang.NonNull; +import org.springframework.lang.Nullable; import java.util.UUID; @@ -11,7 +13,8 @@ public class RunSpecialProjectedGradAlgorithmProcessor extends BaseProcessor { private static final Logger LOGGER = LoggerFactory.getLogger(RunSpecialProjectedGradAlgorithmProcessor.class); @Override - public GraduationStudentRecord process(UUID key) throws Exception { + @Nullable + public GraduationStudentRecord process(@NonNull UUID key) throws Exception { GraduationStudentRecord item = getItem(key); if (item != null) { LOGGER.info("Processing partitionData = {}", item.getProgram()); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/BaseWriter.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/BaseWriter.java index af035a04..f5f0fb6b 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/BaseWriter.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/BaseWriter.java @@ -22,12 +22,14 @@ public abstract class BaseWriter implements ItemWriter AlgorithmSummaryDTO summaryDTO; protected void saveBatchStatus(GraduationStudentRecord item) { - if (summaryDTO.getErrors().containsKey(item.getStudentID())) { - ProcessError v = summaryDTO.getErrors().get(item.getStudentID()); - gradBatchHistoryService.updateBatchStatusForStudent(batchId, item.getStudentID(), BatchStatusEnum.FAILED, v.getReason() + "-" + v.getDetail()); - summaryDTO.getErrors().remove(item.getStudentID()); - } else { - gradBatchHistoryService.updateBatchStatusForStudent(batchId, item.getStudentID(), BatchStatusEnum.COMPLETED, null); + if (item != null) { + if (summaryDTO.getErrors().containsKey(item.getStudentID())) { + ProcessError v = summaryDTO.getErrors().get(item.getStudentID()); + gradBatchHistoryService.updateBatchStatusForStudent(batchId, item.getStudentID(), BatchStatusEnum.FAILED, v.getReason() + "-" + v.getDetail()); + summaryDTO.getErrors().remove(item.getStudentID()); + } else { + gradBatchHistoryService.updateBatchStatusForStudent(batchId, item.getStudentID(), BatchStatusEnum.COMPLETED, null); + } } } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/TvrRunBatchPerformanceWriter.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/TvrRunBatchPerformanceWriter.java index 1ddc8f9a..e811b08c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/TvrRunBatchPerformanceWriter.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/TvrRunBatchPerformanceWriter.java @@ -1,20 +1,14 @@ package ca.bc.gov.educ.api.batchgraduation.writer; import ca.bc.gov.educ.api.batchgraduation.model.GraduationStudentRecord; -import ca.bc.gov.educ.api.batchgraduation.service.GradBatchHistoryService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.batch.item.Chunk; -import org.springframework.beans.factory.annotation.Autowired; public class TvrRunBatchPerformanceWriter extends BaseWriter { private static final Logger LOGGER = LoggerFactory.getLogger(TvrRunBatchPerformanceWriter.class); - @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") - @Autowired - GradBatchHistoryService gradBatchHistoryService; - @Override public void write(Chunk list) throws Exception { if(!list.isEmpty()) { diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/config/BatchConfig.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/config/BatchConfig.java index 5535e910..2980e601 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/config/BatchConfig.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/config/BatchConfig.java @@ -7,6 +7,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; import org.springframework.core.task.SimpleAsyncTaskExecutor; +import org.springframework.core.task.SyncTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.stereotype.Component; @@ -24,6 +25,15 @@ public JobLauncher asyncJobLauncher(JobRepository jobRepository) throws Exceptio return jobLauncher; } + @Bean(name = "jobLauncher") + public JobLauncher jobLauncher(JobRepository jobRepository) throws Exception { + TaskExecutorJobLauncher jobLauncher = new TaskExecutorJobLauncher(); + jobLauncher.setJobRepository(jobRepository); + jobLauncher.setTaskExecutor(new SyncTaskExecutor()); + jobLauncher.afterPropertiesSet(); + return jobLauncher; + } + @Bean public ThreadPoolTaskScheduler threadPoolTaskScheduler(){ ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler(); diff --git a/api/src/test/resources/application.yaml b/api/src/test/resources/application.yaml index d8ed2070..add51811 100644 --- a/api/src/test/resources/application.yaml +++ b/api/src/test/resources/application.yaml @@ -67,6 +67,8 @@ authorization: password: abc batch: + transaction: + chunk-size: 1 partitions: number: 10 regalg: diff --git a/tools/config/update-configmap.sh b/tools/config/update-configmap.sh index 5a425f78..c82e11b0 100644 --- a/tools/config/update-configmap.sh +++ b/tools/config/update-configmap.sh @@ -51,9 +51,9 @@ PARSER_CONFIG=" ########################################################### echo Creating config map "$APP_NAME"-config-map oc create -n "$OPENSHIFT_NAMESPACE"-"$envValue" configmap "$APP_NAME"-config-map \ - --from-literal=CONNECTION_TIMEOUT="60000" \ + --from-literal=CONNECTION_TIMEOUT="30000" \ --from-literal=GRAD_TRAX_API="http://educ-grad-trax-api.$OPENSHIFT_NAMESPACE-$envValue.svc.cluster.local:8080/" \ - --from-literal=MAX_LIFETIME="590000" \ + --from-literal=MAX_LIFETIME="420000" \ --from-literal=GRAD_STUDENT_API="http://educ-grad-student-api.$OPENSHIFT_NAMESPACE-$envValue.svc.cluster.local:8080/" \ --from-literal=MAXIMUM_POOL_SIZE="25" \ --from-literal=APP_LOG_LEVEL="$APP_LOG_LEVEL" \