Skip to content

Commit

Permalink
GRAD2-2505: StepScope reader & writer warnings are resolved.
Browse files Browse the repository at this point in the history
GRAD2-2505: StepScope reader & writer warnings are resolved.
  • Loading branch information
infstar committed Feb 15, 2024
1 parent f771516 commit 0204c0a
Show file tree
Hide file tree
Showing 13 changed files with 164 additions and 173 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -106,14 +104,18 @@ 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;
this.restUtils = restUtils;
this.gradDashboardService = gradDashboardService;
this.gradBatchHistoryService = gradBatchHistoryService;
this.distributionRunStatusUpdateProcessor = distributionRunStatusUpdateProcessor;
this.jsonTransformer = jsonTransformer;
this.gradSchoolOfRecordFilter = gradSchoolOfRecordFilter;
}

@GetMapping(EducGradBatchGraduationApiConstants.EXECUTE_REG_GRAD_BATCH_JOB)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@
public enum BatchStatusEnum {
STARTED,
COMPLETED,
FAILED;
FAILED,
STARTING,
STOPPING,
STOPPED,
ABANDONED,
UNKNOWN;
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
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;
import org.slf4j.LoggerFactory;
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ public abstract class BaseWriter implements ItemWriter<GraduationStudentRecord>
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);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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<? extends GraduationStudentRecord> list) throws Exception {
if(!list.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions api/src/test/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ authorization:
password: abc

batch:
transaction:
chunk-size: 1
partitions:
number: 10
regalg:
Expand Down
4 changes: 2 additions & 2 deletions tools/config/update-configmap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down

0 comments on commit 0204c0a

Please sign in to comment.