From a729bcfa6dea2fa50d84093edde454ca3958299e Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Mon, 21 Aug 2023 12:05:33 -0700 Subject: [PATCH] GRAD2-2299: removed the multithread runnings as many as the number of pages to avoid db connection error. GRAD2-2299: removed the multithread runnings as many as the number of pages to avoid db connection error. --- .../api/gradstudent/service/GradStudentReportService.java | 6 +++--- .../api/gradstudent/service/GraduationStatusService.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GradStudentReportService.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GradStudentReportService.java index e960ff0a..6ea9278e 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GradStudentReportService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GradStudentReportService.java @@ -99,17 +99,17 @@ private List createAndExecuteReportGradStudentDataTasks(S tasks.add(pageTask); } - processReportGradStudentDataTasksAsync(tasks, result, totalNumberOfPages); + processReportGradStudentDataTasksAsync(tasks, result); } logger.debug("Completed in {} sec, total objects acquired {}", (System.currentTimeMillis() - startTime) / 1000, result.size()); return result; } @Generated - private void processReportGradStudentDataTasksAsync(List> tasks, List result, int numberOfThreads) { + private void processReportGradStudentDataTasksAsync(List> tasks, List result) { if(tasks.isEmpty()) return; List> executionResult; - ExecutorService executorService = Executors.newFixedThreadPool(numberOfThreads); + ExecutorService executorService = Executors.newWorkStealingPool(); try { executionResult = executorService.invokeAll(tasks); for (Future f : executionResult) { diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java index 786b4141..efe5567a 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java @@ -1022,16 +1022,16 @@ private List processStudentDataList(Page studentGuids) { tasks.add(pageTask); } - processUUIDDataTasksAsync(tasks, result, totalNumberOfPages); + processUUIDDataTasksAsync(tasks, result); } logger.debug("Completed in {} sec, total objects aquared {}", (System.currentTimeMillis() - startTime) / 1000, result.size()); return result; } - private void processUUIDDataTasksAsync(List> tasks, List result, int totalNumberOfPages) { + private void processUUIDDataTasksAsync(List> tasks, List result) { if(tasks.isEmpty()) return; List> executionResult; - ExecutorService executorService = Executors.newFixedThreadPool(totalNumberOfPages); + ExecutorService executorService = Executors.newWorkStealingPool(); try { executionResult = executorService.invokeAll(tasks); for (Future f : executionResult) {