From 0d94cb12af3cdf9bf4307632415aec59b356148a Mon Sep 17 00:00:00 2001 From: HuaizhiDai Date: Thu, 9 Jul 2026 14:39:05 +1000 Subject: [PATCH] decouple aws batch resource --- .../server/core/configuration/AwsConfig.java | 8 ++++++- .../enumeration/DatasetDownloadEnums.java | 22 ------------------- .../ogcapi/server/processes/RestServices.java | 12 ++++++---- server/src/main/resources/application.yaml | 4 ++++ 4 files changed, 19 insertions(+), 27 deletions(-) diff --git a/server/src/main/java/au/org/aodn/ogcapi/server/core/configuration/AwsConfig.java b/server/src/main/java/au/org/aodn/ogcapi/server/core/configuration/AwsConfig.java index a4749831..a540fb39 100644 --- a/server/src/main/java/au/org/aodn/ogcapi/server/core/configuration/AwsConfig.java +++ b/server/src/main/java/au/org/aodn/ogcapi/server/core/configuration/AwsConfig.java @@ -15,6 +15,12 @@ public class AwsConfig { @Value("${aws.region}") private String awsRegion; + @Value("${aws.batch.job.definition}") + private String batchJobDefinition; + + @Value("${aws.batch.job.queue}") + private String batchJobQueue; + @Bean public BatchClient batchClient() { return BatchClient @@ -26,6 +32,6 @@ public BatchClient batchClient() { @Bean public RestServices awsBatchService(BatchClient batchClient, ObjectMapper objectMapper) { - return new RestServices(batchClient, objectMapper); + return new RestServices(batchClient, objectMapper, batchJobDefinition, batchJobQueue); } } diff --git a/server/src/main/java/au/org/aodn/ogcapi/server/core/model/enumeration/DatasetDownloadEnums.java b/server/src/main/java/au/org/aodn/ogcapi/server/core/model/enumeration/DatasetDownloadEnums.java index a4ba184c..e272fd62 100644 --- a/server/src/main/java/au/org/aodn/ogcapi/server/core/model/enumeration/DatasetDownloadEnums.java +++ b/server/src/main/java/au/org/aodn/ogcapi/server/core/model/enumeration/DatasetDownloadEnums.java @@ -61,26 +61,4 @@ public enum Type { this.value = value; } } - - @Getter - public enum JobDefinition { - GENERATE_CSV_DATA_FILE("data-access-service-batch-job-definition"); - - private final String value; - - JobDefinition(String value) { - this.value = value; - } - } - - @Getter - public enum JobQueue { - GENERATING_CSV_DATA_FILE("data-access-service-batch-job-queue"); - - private final String value; - - JobQueue(String value) { - this.value = value; - } - } } diff --git a/server/src/main/java/au/org/aodn/ogcapi/server/processes/RestServices.java b/server/src/main/java/au/org/aodn/ogcapi/server/processes/RestServices.java index 69e552b7..ce593461 100644 --- a/server/src/main/java/au/org/aodn/ogcapi/server/processes/RestServices.java +++ b/server/src/main/java/au/org/aodn/ogcapi/server/processes/RestServices.java @@ -32,13 +32,17 @@ public class RestServices { private final BatchClient batchClient; private final ObjectMapper objectMapper; + private final String batchJobDefinition; + private final String batchJobQueue; @Autowired private DownloadWfsDataService downloadWfsDataService; - public RestServices(BatchClient batchClient, ObjectMapper objectMapper) { + public RestServices(BatchClient batchClient, ObjectMapper objectMapper, String batchJobDefinition, String batchJobQueue) { this.batchClient = batchClient; this.objectMapper = objectMapper; + this.batchJobDefinition = batchJobDefinition; + this.batchJobQueue = batchJobQueue; } public void notifyUser(String recipient, String uuid, String startDate, String endDate, Object multiPolygon, String collectionTitle, @@ -113,10 +117,10 @@ public ResponseEntity downloadData( String jobId = submitJob( "generating-data-file-for-" + recipient.replaceAll("[^a-zA-Z0-9-_]", "-"), - DatasetDownloadEnums.JobQueue.GENERATING_CSV_DATA_FILE.getValue(), - DatasetDownloadEnums.JobDefinition.GENERATE_CSV_DATA_FILE.getValue(), + this.batchJobQueue, + this.batchJobDefinition, parameters); - log.info("Job submitted with ID: " + jobId); + log.info("Job submitted with ID: {}", jobId); return ResponseEntity.ok("Job submitted with ID: " + jobId); } diff --git a/server/src/main/resources/application.yaml b/server/src/main/resources/application.yaml index 8b40984a..ce92eec6 100644 --- a/server/src/main/resources/application.yaml +++ b/server/src/main/resources/application.yaml @@ -25,6 +25,10 @@ elasticsearch: aws: region: ap-southeast-2 + batch: + job: + queue: data-access-service-batch-job-queueb + definition: data-access-service-batch-job-definition wfs-default-param: fields: