mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
feat(batch): add AWS Batch service support (#1332)
This commit is contained in:
1 parent
234af69bd2
commit
022436eaae
39 files changed
+4516
-4
No files matched your search
@@ -172,6 +172,7 @@ public interface EmulatorConfig {
|
||||
BackupStorageConfig backup();
|
||||
CloudFrontStorageConfig cloudfront();
|
||||
AppSyncStorageConfig appsync();
|
||||
BatchStorageConfig batch();
|
||||
}
|
||||
|
||||
interface SsmStorageConfig {
|
||||
@@ -292,6 +293,13 @@ public interface EmulatorConfig {
|
||||
long flushIntervalMs();
|
||||
}
|
||||
|
||||
interface BatchStorageConfig {
|
||||
Optional<String> mode();
|
||||
|
||||
@WithDefault("5000")
|
||||
long flushIntervalMs();
|
||||
}
|
||||
|
||||
interface WalConfig {
|
||||
@WithDefault("30000")
|
||||
long compactionIntervalMs();
|
||||
@@ -370,6 +378,7 @@ public interface EmulatorConfig {
|
||||
CloudTrailServiceConfig cloudtrail();
|
||||
CloudFrontServiceConfig cloudfront();
|
||||
AppSyncServiceConfig appsync();
|
||||
BatchServiceConfig batch();
|
||||
}
|
||||
|
||||
interface CloudTrailServiceConfig {
|
||||
@@ -424,6 +433,16 @@ public interface EmulatorConfig {
|
||||
Optional<String> dockerNetwork();
|
||||
}
|
||||
|
||||
interface BatchServiceConfig {
|
||||
@WithDefault("true")
|
||||
boolean enabled();
|
||||
|
||||
@WithDefault("immediate")
|
||||
String runnerMode();
|
||||
|
||||
Optional<String> dockerNetwork();
|
||||
}
|
||||
|
||||
interface CodeDeployServiceConfig {
|
||||
@WithDefault("true")
|
||||
boolean enabled();
|
||||
|
||||
@@ -4,6 +4,7 @@ import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.services.appconfig.AppConfigController;
|
||||
import io.github.hectorvent.floci.services.backup.BackupController;
|
||||
import io.github.hectorvent.floci.services.appconfig.AppConfigDataController;
|
||||
import io.github.hectorvent.floci.services.batch.BatchController;
|
||||
import io.github.hectorvent.floci.services.bedrockruntime.BedrockRuntimeController;
|
||||
import io.github.hectorvent.floci.services.cognito.CognitoOAuthController;
|
||||
import io.github.hectorvent.floci.services.cognito.CognitoWellKnownController;
|
||||
@@ -240,6 +241,11 @@ public class ResolvedServiceCatalog {
|
||||
null, null, 5000L, null, ServiceProtocol.JSON,
|
||||
protocols(ServiceProtocol.JSON),
|
||||
Set.of("CodeBuild_20161006."), Set.of("codebuild"), Set.of(), Set.of()),
|
||||
descriptor("batch", "batch", config.services().batch().enabled(), true,
|
||||
"batch", storageMode(config.storage().services().batch().mode(), config.storage().mode()),
|
||||
config.storage().services().batch().flushIntervalMs(), null, ServiceProtocol.REST_JSON,
|
||||
protocols(ServiceProtocol.REST_JSON),
|
||||
Set.of(), Set.of("batch"), Set.of(), Set.of(BatchController.class)),
|
||||
descriptor("codedeploy", "codedeploy", config.services().codedeploy().enabled(), true,
|
||||
null, null, 5000L, null, ServiceProtocol.JSON,
|
||||
protocols(ServiceProtocol.JSON),
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
package io.github.hectorvent.floci.services.batch;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.core.common.AwsErrorResponse;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.HttpHeaders;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
@Path("/")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.WILDCARD)
|
||||
public class BatchController {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(BatchController.class);
|
||||
|
||||
private final BatchService service;
|
||||
private final RegionResolver regionResolver;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
@Inject
|
||||
public BatchController(BatchService service, RegionResolver regionResolver, ObjectMapper objectMapper) {
|
||||
this.service = service;
|
||||
this.regionResolver = regionResolver;
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/v1/createcomputeenvironment")
|
||||
public Response createComputeEnvironment(@Context HttpHeaders headers, String body) {
|
||||
return handle(headers, body, (request, region) ->
|
||||
Response.ok(service.createComputeEnvironment(request, region)).build());
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/v1/describecomputeenvironments")
|
||||
public Response describeComputeEnvironments(@Context HttpHeaders headers, String body) {
|
||||
return handle(headers, body, (request, region) ->
|
||||
Response.ok(service.describeComputeEnvironments(request)).build());
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/v1/createjobqueue")
|
||||
public Response createJobQueue(@Context HttpHeaders headers, String body) {
|
||||
return handle(headers, body, (request, region) ->
|
||||
Response.ok(service.createJobQueue(request, region)).build());
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/v1/describejobqueues")
|
||||
public Response describeJobQueues(@Context HttpHeaders headers, String body) {
|
||||
return handle(headers, body, (request, region) ->
|
||||
Response.ok(service.describeJobQueues(request)).build());
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/v1/registerjobdefinition")
|
||||
public Response registerJobDefinition(@Context HttpHeaders headers, String body) {
|
||||
return handle(headers, body, (request, region) ->
|
||||
Response.ok(service.registerJobDefinition(request, region)).build());
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/v1/deregisterjobdefinition")
|
||||
public Response deregisterJobDefinition(@Context HttpHeaders headers, String body) {
|
||||
return handle(headers, body, (request, region) ->
|
||||
Response.ok(service.deregisterJobDefinition(request)).build());
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/v1/describejobdefinitions")
|
||||
public Response describeJobDefinitions(@Context HttpHeaders headers, String body) {
|
||||
return handle(headers, body, (request, region) ->
|
||||
Response.ok(service.describeJobDefinitions(request)).build());
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/v1/submitjob")
|
||||
public Response submitJob(@Context HttpHeaders headers, String body) {
|
||||
return handle(headers, body, (request, region) ->
|
||||
Response.ok(service.submitJob(request, region)).build());
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/v1/describejobs")
|
||||
public Response describeJobs(@Context HttpHeaders headers, String body) {
|
||||
return handle(headers, body, (request, region) ->
|
||||
Response.ok(service.describeJobs(request)).build());
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/v1/listjobs")
|
||||
public Response listJobs(@Context HttpHeaders headers, String body) {
|
||||
return handle(headers, body, (request, region) ->
|
||||
Response.ok(service.listJobs(request)).build());
|
||||
}
|
||||
|
||||
private Response handle(HttpHeaders headers, String body, Handler handler) {
|
||||
try {
|
||||
JsonNode request = body == null || body.isBlank()
|
||||
? objectMapper.createObjectNode()
|
||||
: objectMapper.readTree(body);
|
||||
return handler.handle(request, regionResolver.resolveRegion(headers));
|
||||
} catch (AwsException e) {
|
||||
return error(e.getHttpStatus(), e.getErrorCode(), e.getMessage());
|
||||
} catch (JsonProcessingException e) {
|
||||
return error(400, "ClientException", "Malformed JSON request body.");
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error processing AWS Batch request", e);
|
||||
return error(500, "ServerException", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static Response error(int status, String code, String message) {
|
||||
return Response.status(status)
|
||||
.type(MediaType.APPLICATION_JSON)
|
||||
.header("X-Amzn-Errortype", code)
|
||||
.entity(new AwsErrorResponse(code, message))
|
||||
.build();
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
private interface Handler {
|
||||
Response handle(JsonNode request, String region);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
package io.github.hectorvent.floci.services.batch;
|
||||
|
||||
import com.github.dockerjava.api.command.InspectContainerResponse;
|
||||
import com.github.dockerjava.api.exception.NotFoundException;
|
||||
import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.core.common.dns.EmbeddedDnsServer;
|
||||
import io.github.hectorvent.floci.core.common.docker.ContainerBuilder;
|
||||
import io.github.hectorvent.floci.core.common.docker.ContainerDetector;
|
||||
import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager;
|
||||
import io.github.hectorvent.floci.core.common.docker.ContainerLogStreamer;
|
||||
import io.github.hectorvent.floci.core.common.docker.ContainerSpec;
|
||||
import io.github.hectorvent.floci.services.batch.model.BatchJob;
|
||||
import io.github.hectorvent.floci.services.batch.model.BatchKeyValue;
|
||||
import io.github.hectorvent.floci.services.batch.model.BatchResourceRequirement;
|
||||
import io.github.hectorvent.floci.services.batch.model.BatchRunResult;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ApplicationScoped
|
||||
public class BatchDockerRunner {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(BatchDockerRunner.class);
|
||||
private static final String LOG_GROUP = "/aws/batch/job";
|
||||
|
||||
private final ContainerBuilder containerBuilder;
|
||||
private final ContainerLifecycleManager lifecycleManager;
|
||||
private final ContainerLogStreamer logStreamer;
|
||||
private final EmulatorConfig config;
|
||||
private final ContainerDetector containerDetector;
|
||||
|
||||
@Inject
|
||||
public BatchDockerRunner(ContainerBuilder containerBuilder,
|
||||
ContainerLifecycleManager lifecycleManager,
|
||||
ContainerLogStreamer logStreamer,
|
||||
EmulatorConfig config,
|
||||
ContainerDetector containerDetector) {
|
||||
this.containerBuilder = containerBuilder;
|
||||
this.lifecycleManager = lifecycleManager;
|
||||
this.logStreamer = logStreamer;
|
||||
this.config = config;
|
||||
this.containerDetector = containerDetector;
|
||||
}
|
||||
|
||||
public BatchRunResult run(BatchJob job, int attemptNumber) {
|
||||
long startedAt = System.currentTimeMillis();
|
||||
String logStreamName = logStreamer.generateLogStreamName(
|
||||
job.getJobDefinitionName() + "/default/" + job.getJobId());
|
||||
String containerName = "floci-batch-" + job.getJobId() + "-" + attemptNumber;
|
||||
Closeable logHandle = null;
|
||||
String containerId = null;
|
||||
|
||||
try {
|
||||
if (job.getContainerImage() == null || job.getContainerImage().isBlank()) {
|
||||
return failed(startedAt, logStreamName, "Job definition container image is missing");
|
||||
}
|
||||
|
||||
ContainerBuilder.Builder builder = containerBuilder.newContainer(job.getContainerImage())
|
||||
.withName(containerName)
|
||||
.withEnv(buildEnvironment(job, attemptNumber))
|
||||
.withDockerNetwork(config.services().batch().dockerNetwork())
|
||||
.withHostDockerInternalOnLinux()
|
||||
.withEmbeddedDns()
|
||||
.withLogRotation();
|
||||
|
||||
if (job.getResolvedCommand() != null && !job.getResolvedCommand().isEmpty()) {
|
||||
builder.withCmd(job.getResolvedCommand());
|
||||
}
|
||||
applyResourceRequirements(builder, job);
|
||||
|
||||
ContainerSpec spec = builder.build();
|
||||
containerId = lifecycleManager.createAndStart(spec).containerId();
|
||||
logHandle = logStreamer.attach(containerId, LOG_GROUP, logStreamName, job.getRegion(),
|
||||
"batch:" + job.getJobName() + ":" + job.getJobId());
|
||||
|
||||
Integer exitCode = waitForExit(containerId, timeout(job));
|
||||
long stoppedAt = System.currentTimeMillis();
|
||||
if (exitCode == null) {
|
||||
lifecycleManager.stopAndRemove(containerId, logHandle);
|
||||
return new BatchRunResult(137, "Job timed out", logStreamName, startedAt, stoppedAt, true);
|
||||
}
|
||||
lifecycleManager.stopAndRemove(containerId, logHandle);
|
||||
return new BatchRunResult(exitCode, exitCode == 0 ? null : "Container exited with code " + exitCode,
|
||||
logStreamName, startedAt, stoppedAt, false);
|
||||
} catch (Exception e) {
|
||||
LOG.warnv("Batch Docker job {0} failed: {1}", job.getJobId(), e.getMessage());
|
||||
if (containerId != null) {
|
||||
lifecycleManager.stopAndRemove(containerId, logHandle);
|
||||
}
|
||||
return failed(startedAt, logStreamName, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private BatchRunResult failed(long startedAt, String logStreamName, String reason) {
|
||||
return new BatchRunResult(1, reason, logStreamName, startedAt, System.currentTimeMillis(), false);
|
||||
}
|
||||
|
||||
private List<String> buildEnvironment(BatchJob job, int attemptNumber) {
|
||||
List<String> env = new ArrayList<>();
|
||||
env.add("AWS_REGION=" + job.getRegion());
|
||||
env.add("AWS_DEFAULT_REGION=" + job.getRegion());
|
||||
env.add("AWS_ACCESS_KEY_ID=test");
|
||||
env.add("AWS_SECRET_ACCESS_KEY=test");
|
||||
env.add("AWS_SESSION_TOKEN=test");
|
||||
String hostname = resolveEndpointHostname();
|
||||
String endpoint = "http://" + hostname + ":" + config.port();
|
||||
env.add("FLOCI_ENDPOINT=" + endpoint);
|
||||
env.add("AWS_ENDPOINT_URL=" + endpoint);
|
||||
env.add("FLOCI_HOSTNAME=" + hostname);
|
||||
env.add("AWS_BATCH_JOB_ID=" + job.getJobId());
|
||||
env.add("AWS_BATCH_JOB_ATTEMPT=" + attemptNumber);
|
||||
env.add("AWS_BATCH_JQ_NAME=" + job.getJobQueueName());
|
||||
env.add("AWS_BATCH_CE_NAME=local");
|
||||
if (job.getResolvedEnvironment() != null) {
|
||||
for (BatchKeyValue kv : job.getResolvedEnvironment()) {
|
||||
env.add(kv.getName() + "=" + (kv.getValue() != null ? kv.getValue() : ""));
|
||||
}
|
||||
}
|
||||
return env;
|
||||
}
|
||||
|
||||
String resolveEndpointHostname() {
|
||||
if (containerDetector.isRunningInContainer()) {
|
||||
return config.hostname().orElse(EmbeddedDnsServer.DEFAULT_SUFFIX);
|
||||
}
|
||||
return "host.docker.internal";
|
||||
}
|
||||
|
||||
private void applyResourceRequirements(ContainerBuilder.Builder builder, BatchJob job) {
|
||||
if (job.getResourceRequirements() == null) {
|
||||
return;
|
||||
}
|
||||
for (BatchResourceRequirement requirement : job.getResourceRequirements()) {
|
||||
if (!"MEMORY".equalsIgnoreCase(requirement.getType()) || requirement.getValue() == null) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
builder.withMemoryMb(Integer.parseInt(requirement.getValue()));
|
||||
} catch (NumberFormatException e) {
|
||||
LOG.warnv("Ignoring invalid Batch MEMORY resource value for job {0}: {1}",
|
||||
job.getJobId(), requirement.getValue());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private Duration timeout(BatchJob job) {
|
||||
if (job.getTimeout() == null || job.getTimeout().getAttemptDurationSeconds() == null) {
|
||||
return Duration.ZERO;
|
||||
}
|
||||
return Duration.ofSeconds(job.getTimeout().getAttemptDurationSeconds());
|
||||
}
|
||||
|
||||
private Integer waitForExit(String containerId, Duration timeout) throws InterruptedException {
|
||||
long deadline = timeout.isZero() ? Long.MAX_VALUE : System.currentTimeMillis() + timeout.toMillis();
|
||||
while (System.currentTimeMillis() <= deadline) {
|
||||
Integer exitCode = getExitCodeIfStopped(containerId);
|
||||
if (exitCode != null) {
|
||||
return exitCode;
|
||||
}
|
||||
Thread.sleep(250);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Integer getExitCodeIfStopped(String containerId) {
|
||||
try {
|
||||
InspectContainerResponse inspect = lifecycleManager.getDockerClient().inspectContainerCmd(containerId).exec();
|
||||
if (Boolean.TRUE.equals(inspect.getState().getRunning())) {
|
||||
return null;
|
||||
}
|
||||
Long exitCode = inspect.getState().getExitCodeLong();
|
||||
return exitCode != null ? exitCode.intValue() : 0;
|
||||
} catch (NotFoundException e) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,47 @@
|
||||
package io.github.hectorvent.floci.services.batch.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public class BatchAttempt {
|
||||
private Long startedAt;
|
||||
private Long stoppedAt;
|
||||
private String statusReason;
|
||||
private BatchAttemptContainer container;
|
||||
|
||||
public Long getStartedAt() {
|
||||
return startedAt;
|
||||
}
|
||||
|
||||
public void setStartedAt(Long startedAt) {
|
||||
this.startedAt = startedAt;
|
||||
}
|
||||
|
||||
public Long getStoppedAt() {
|
||||
return stoppedAt;
|
||||
}
|
||||
|
||||
public void setStoppedAt(Long stoppedAt) {
|
||||
this.stoppedAt = stoppedAt;
|
||||
}
|
||||
|
||||
public String getStatusReason() {
|
||||
return statusReason;
|
||||
}
|
||||
|
||||
public void setStatusReason(String statusReason) {
|
||||
this.statusReason = statusReason;
|
||||
}
|
||||
|
||||
public BatchAttemptContainer getContainer() {
|
||||
return container;
|
||||
}
|
||||
|
||||
public void setContainer(BatchAttemptContainer container) {
|
||||
this.container = container;
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package io.github.hectorvent.floci.services.batch.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class BatchAttemptContainer {
|
||||
private Integer exitCode;
|
||||
private String reason;
|
||||
private String logStreamName;
|
||||
private String taskArn;
|
||||
private String containerInstanceArn;
|
||||
|
||||
public Integer getExitCode() {
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
public void setExitCode(Integer exitCode) {
|
||||
this.exitCode = exitCode;
|
||||
}
|
||||
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
public String getLogStreamName() {
|
||||
return logStreamName;
|
||||
}
|
||||
|
||||
public void setLogStreamName(String logStreamName) {
|
||||
this.logStreamName = logStreamName;
|
||||
}
|
||||
|
||||
public String getTaskArn() {
|
||||
return taskArn;
|
||||
}
|
||||
|
||||
public void setTaskArn(String taskArn) {
|
||||
this.taskArn = taskArn;
|
||||
}
|
||||
|
||||
public String getContainerInstanceArn() {
|
||||
return containerInstanceArn;
|
||||
}
|
||||
|
||||
public void setContainerInstanceArn(String containerInstanceArn) {
|
||||
this.containerInstanceArn = containerInstanceArn;
|
||||
}
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
package io.github.hectorvent.floci.services.batch.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public class BatchComputeEnvironment {
|
||||
private String computeEnvironmentName;
|
||||
private String computeEnvironmentArn;
|
||||
private String type;
|
||||
private String state;
|
||||
private String status;
|
||||
private String statusReason;
|
||||
private Map<String, Object> computeResources = new HashMap<>();
|
||||
private String serviceRole;
|
||||
private Map<String, String> tags = new HashMap<>();
|
||||
private long createdAt;
|
||||
private String region;
|
||||
private String accountId;
|
||||
|
||||
public String getComputeEnvironmentName() {
|
||||
return computeEnvironmentName;
|
||||
}
|
||||
|
||||
public void setComputeEnvironmentName(String computeEnvironmentName) {
|
||||
this.computeEnvironmentName = computeEnvironmentName;
|
||||
}
|
||||
|
||||
public String getComputeEnvironmentArn() {
|
||||
return computeEnvironmentArn;
|
||||
}
|
||||
|
||||
public void setComputeEnvironmentArn(String computeEnvironmentArn) {
|
||||
this.computeEnvironmentArn = computeEnvironmentArn;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getStatusReason() {
|
||||
return statusReason;
|
||||
}
|
||||
|
||||
public void setStatusReason(String statusReason) {
|
||||
this.statusReason = statusReason;
|
||||
}
|
||||
|
||||
public Map<String, Object> getComputeResources() {
|
||||
return computeResources;
|
||||
}
|
||||
|
||||
public void setComputeResources(Map<String, Object> computeResources) {
|
||||
this.computeResources = computeResources != null ? computeResources : new HashMap<>();
|
||||
}
|
||||
|
||||
public String getServiceRole() {
|
||||
return serviceRole;
|
||||
}
|
||||
|
||||
public void setServiceRole(String serviceRole) {
|
||||
this.serviceRole = serviceRole;
|
||||
}
|
||||
|
||||
public Map<String, String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(Map<String, String> tags) {
|
||||
this.tags = tags != null ? tags : new HashMap<>();
|
||||
}
|
||||
|
||||
public long getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(long createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
public void setRegion(String region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
public String getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(String accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package io.github.hectorvent.floci.services.batch.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public class BatchComputeEnvironmentOrder {
|
||||
private int order;
|
||||
private String computeEnvironment;
|
||||
|
||||
public int getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public void setOrder(int order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public String getComputeEnvironment() {
|
||||
return computeEnvironment;
|
||||
}
|
||||
|
||||
public void setComputeEnvironment(String computeEnvironment) {
|
||||
this.computeEnvironment = computeEnvironment;
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package io.github.hectorvent.floci.services.batch.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public class BatchContainerOverrides {
|
||||
private List<String> command = new ArrayList<>();
|
||||
private List<BatchKeyValue> environment = new ArrayList<>();
|
||||
private List<BatchResourceRequirement> resourceRequirements = new ArrayList<>();
|
||||
|
||||
public List<String> getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public void setCommand(List<String> command) {
|
||||
this.command = command != null ? command : new ArrayList<>();
|
||||
}
|
||||
|
||||
public List<BatchKeyValue> getEnvironment() {
|
||||
return environment;
|
||||
}
|
||||
|
||||
public void setEnvironment(List<BatchKeyValue> environment) {
|
||||
this.environment = environment != null ? environment : new ArrayList<>();
|
||||
}
|
||||
|
||||
public List<BatchResourceRequirement> getResourceRequirements() {
|
||||
return resourceRequirements;
|
||||
}
|
||||
|
||||
public void setResourceRequirements(List<BatchResourceRequirement> resourceRequirements) {
|
||||
this.resourceRequirements = resourceRequirements != null ? resourceRequirements : new ArrayList<>();
|
||||
}
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
package io.github.hectorvent.floci.services.batch.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public class BatchContainerProperties {
|
||||
private String image;
|
||||
private List<String> command = new ArrayList<>();
|
||||
private List<BatchKeyValue> environment = new ArrayList<>();
|
||||
private List<BatchResourceRequirement> resourceRequirements = new ArrayList<>();
|
||||
private String jobRoleArn;
|
||||
private String executionRoleArn;
|
||||
private Map<String, Object> logConfiguration;
|
||||
private Map<String, Object> networkConfiguration;
|
||||
private Map<String, Object> ephemeralStorage;
|
||||
|
||||
public String getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public void setImage(String image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public List<String> getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public void setCommand(List<String> command) {
|
||||
this.command = command != null ? command : new ArrayList<>();
|
||||
}
|
||||
|
||||
public List<BatchKeyValue> getEnvironment() {
|
||||
return environment;
|
||||
}
|
||||
|
||||
public void setEnvironment(List<BatchKeyValue> environment) {
|
||||
this.environment = environment != null ? environment : new ArrayList<>();
|
||||
}
|
||||
|
||||
public List<BatchResourceRequirement> getResourceRequirements() {
|
||||
return resourceRequirements;
|
||||
}
|
||||
|
||||
public void setResourceRequirements(List<BatchResourceRequirement> resourceRequirements) {
|
||||
this.resourceRequirements = resourceRequirements != null ? resourceRequirements : new ArrayList<>();
|
||||
}
|
||||
|
||||
public String getJobRoleArn() {
|
||||
return jobRoleArn;
|
||||
}
|
||||
|
||||
public void setJobRoleArn(String jobRoleArn) {
|
||||
this.jobRoleArn = jobRoleArn;
|
||||
}
|
||||
|
||||
public String getExecutionRoleArn() {
|
||||
return executionRoleArn;
|
||||
}
|
||||
|
||||
public void setExecutionRoleArn(String executionRoleArn) {
|
||||
this.executionRoleArn = executionRoleArn;
|
||||
}
|
||||
|
||||
public Map<String, Object> getLogConfiguration() {
|
||||
return logConfiguration;
|
||||
}
|
||||
|
||||
public void setLogConfiguration(Map<String, Object> logConfiguration) {
|
||||
this.logConfiguration = logConfiguration;
|
||||
}
|
||||
|
||||
public Map<String, Object> getNetworkConfiguration() {
|
||||
return networkConfiguration;
|
||||
}
|
||||
|
||||
public void setNetworkConfiguration(Map<String, Object> networkConfiguration) {
|
||||
this.networkConfiguration = networkConfiguration;
|
||||
}
|
||||
|
||||
public Map<String, Object> getEphemeralStorage() {
|
||||
return ephemeralStorage;
|
||||
}
|
||||
|
||||
public void setEphemeralStorage(Map<String, Object> ephemeralStorage) {
|
||||
this.ephemeralStorage = ephemeralStorage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
package io.github.hectorvent.floci.services.batch.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public class BatchJob {
|
||||
private String jobId;
|
||||
private String jobArn;
|
||||
private String jobName;
|
||||
private String jobQueue;
|
||||
private String jobQueueName;
|
||||
private String jobDefinition;
|
||||
private String jobDefinitionName;
|
||||
private int jobDefinitionRevision;
|
||||
private String status;
|
||||
private String statusReason;
|
||||
private long createdAt;
|
||||
private Long startedAt;
|
||||
private Long stoppedAt;
|
||||
private Map<String, String> parameters = new HashMap<>();
|
||||
private BatchContainerOverrides containerOverrides;
|
||||
private List<String> resolvedCommand = new ArrayList<>();
|
||||
private List<BatchKeyValue> resolvedEnvironment = new ArrayList<>();
|
||||
private List<BatchResourceRequirement> resourceRequirements = new ArrayList<>();
|
||||
private BatchRetryStrategy retryStrategy;
|
||||
private BatchTimeout timeout;
|
||||
private List<BatchAttempt> attempts = new ArrayList<>();
|
||||
private BatchAttemptContainer container = new BatchAttemptContainer();
|
||||
private Map<String, String> tags = new HashMap<>();
|
||||
private String region;
|
||||
private String accountId;
|
||||
private String containerImage;
|
||||
|
||||
public String getJobId() {
|
||||
return jobId;
|
||||
}
|
||||
|
||||
public void setJobId(String jobId) {
|
||||
this.jobId = jobId;
|
||||
}
|
||||
|
||||
public String getJobArn() {
|
||||
return jobArn;
|
||||
}
|
||||
|
||||
public void setJobArn(String jobArn) {
|
||||
this.jobArn = jobArn;
|
||||
}
|
||||
|
||||
public String getJobName() {
|
||||
return jobName;
|
||||
}
|
||||
|
||||
public void setJobName(String jobName) {
|
||||
this.jobName = jobName;
|
||||
}
|
||||
|
||||
public String getJobQueue() {
|
||||
return jobQueue;
|
||||
}
|
||||
|
||||
public void setJobQueue(String jobQueue) {
|
||||
this.jobQueue = jobQueue;
|
||||
}
|
||||
|
||||
public String getJobQueueName() {
|
||||
return jobQueueName;
|
||||
}
|
||||
|
||||
public void setJobQueueName(String jobQueueName) {
|
||||
this.jobQueueName = jobQueueName;
|
||||
}
|
||||
|
||||
public String getJobDefinition() {
|
||||
return jobDefinition;
|
||||
}
|
||||
|
||||
public void setJobDefinition(String jobDefinition) {
|
||||
this.jobDefinition = jobDefinition;
|
||||
}
|
||||
|
||||
public String getJobDefinitionName() {
|
||||
return jobDefinitionName;
|
||||
}
|
||||
|
||||
public void setJobDefinitionName(String jobDefinitionName) {
|
||||
this.jobDefinitionName = jobDefinitionName;
|
||||
}
|
||||
|
||||
public int getJobDefinitionRevision() {
|
||||
return jobDefinitionRevision;
|
||||
}
|
||||
|
||||
public void setJobDefinitionRevision(int jobDefinitionRevision) {
|
||||
this.jobDefinitionRevision = jobDefinitionRevision;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getStatusReason() {
|
||||
return statusReason;
|
||||
}
|
||||
|
||||
public void setStatusReason(String statusReason) {
|
||||
this.statusReason = statusReason;
|
||||
}
|
||||
|
||||
public long getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(long createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Long getStartedAt() {
|
||||
return startedAt;
|
||||
}
|
||||
|
||||
public void setStartedAt(Long startedAt) {
|
||||
this.startedAt = startedAt;
|
||||
}
|
||||
|
||||
public Long getStoppedAt() {
|
||||
return stoppedAt;
|
||||
}
|
||||
|
||||
public void setStoppedAt(Long stoppedAt) {
|
||||
this.stoppedAt = stoppedAt;
|
||||
}
|
||||
|
||||
public Map<String, String> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void setParameters(Map<String, String> parameters) {
|
||||
this.parameters = parameters != null ? parameters : new HashMap<>();
|
||||
}
|
||||
|
||||
public BatchContainerOverrides getContainerOverrides() {
|
||||
return containerOverrides;
|
||||
}
|
||||
|
||||
public void setContainerOverrides(BatchContainerOverrides containerOverrides) {
|
||||
this.containerOverrides = containerOverrides;
|
||||
}
|
||||
|
||||
public List<String> getResolvedCommand() {
|
||||
return resolvedCommand;
|
||||
}
|
||||
|
||||
public void setResolvedCommand(List<String> resolvedCommand) {
|
||||
this.resolvedCommand = resolvedCommand != null ? resolvedCommand : new ArrayList<>();
|
||||
}
|
||||
|
||||
public List<BatchKeyValue> getResolvedEnvironment() {
|
||||
return resolvedEnvironment;
|
||||
}
|
||||
|
||||
public void setResolvedEnvironment(List<BatchKeyValue> resolvedEnvironment) {
|
||||
this.resolvedEnvironment = resolvedEnvironment != null ? resolvedEnvironment : new ArrayList<>();
|
||||
}
|
||||
|
||||
public List<BatchResourceRequirement> getResourceRequirements() {
|
||||
return resourceRequirements;
|
||||
}
|
||||
|
||||
public void setResourceRequirements(List<BatchResourceRequirement> resourceRequirements) {
|
||||
this.resourceRequirements = resourceRequirements != null ? resourceRequirements : new ArrayList<>();
|
||||
}
|
||||
|
||||
public BatchRetryStrategy getRetryStrategy() {
|
||||
return retryStrategy;
|
||||
}
|
||||
|
||||
public void setRetryStrategy(BatchRetryStrategy retryStrategy) {
|
||||
this.retryStrategy = retryStrategy;
|
||||
}
|
||||
|
||||
public BatchTimeout getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public void setTimeout(BatchTimeout timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public List<BatchAttempt> getAttempts() {
|
||||
return attempts;
|
||||
}
|
||||
|
||||
public void setAttempts(List<BatchAttempt> attempts) {
|
||||
this.attempts = attempts != null ? attempts : new ArrayList<>();
|
||||
}
|
||||
|
||||
public BatchAttemptContainer getContainer() {
|
||||
return container;
|
||||
}
|
||||
|
||||
public void setContainer(BatchAttemptContainer container) {
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
public Map<String, String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(Map<String, String> tags) {
|
||||
this.tags = tags != null ? tags : new HashMap<>();
|
||||
}
|
||||
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
public void setRegion(String region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
public String getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(String accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
public String getContainerImage() {
|
||||
return containerImage;
|
||||
}
|
||||
|
||||
public void setContainerImage(String containerImage) {
|
||||
this.containerImage = containerImage;
|
||||
}
|
||||
}
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
package io.github.hectorvent.floci.services.batch.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public class BatchJobDefinition {
|
||||
private String jobDefinitionName;
|
||||
private String jobDefinitionArn;
|
||||
private int revision;
|
||||
private String status;
|
||||
private String type;
|
||||
private BatchContainerProperties containerProperties;
|
||||
private Map<String, String> parameters = new HashMap<>();
|
||||
private BatchRetryStrategy retryStrategy;
|
||||
private BatchTimeout timeout;
|
||||
private List<String> platformCapabilities = List.of();
|
||||
private Map<String, String> tags = new HashMap<>();
|
||||
private long createdAt;
|
||||
private String region;
|
||||
private String accountId;
|
||||
|
||||
public String getJobDefinitionName() {
|
||||
return jobDefinitionName;
|
||||
}
|
||||
|
||||
public void setJobDefinitionName(String jobDefinitionName) {
|
||||
this.jobDefinitionName = jobDefinitionName;
|
||||
}
|
||||
|
||||
public String getJobDefinitionArn() {
|
||||
return jobDefinitionArn;
|
||||
}
|
||||
|
||||
public void setJobDefinitionArn(String jobDefinitionArn) {
|
||||
this.jobDefinitionArn = jobDefinitionArn;
|
||||
}
|
||||
|
||||
public int getRevision() {
|
||||
return revision;
|
||||
}
|
||||
|
||||
public void setRevision(int revision) {
|
||||
this.revision = revision;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public BatchContainerProperties getContainerProperties() {
|
||||
return containerProperties;
|
||||
}
|
||||
|
||||
public void setContainerProperties(BatchContainerProperties containerProperties) {
|
||||
this.containerProperties = containerProperties;
|
||||
}
|
||||
|
||||
public Map<String, String> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void setParameters(Map<String, String> parameters) {
|
||||
this.parameters = parameters != null ? parameters : new HashMap<>();
|
||||
}
|
||||
|
||||
public BatchRetryStrategy getRetryStrategy() {
|
||||
return retryStrategy;
|
||||
}
|
||||
|
||||
public void setRetryStrategy(BatchRetryStrategy retryStrategy) {
|
||||
this.retryStrategy = retryStrategy;
|
||||
}
|
||||
|
||||
public BatchTimeout getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public void setTimeout(BatchTimeout timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public List<String> getPlatformCapabilities() {
|
||||
return platformCapabilities;
|
||||
}
|
||||
|
||||
public void setPlatformCapabilities(List<String> platformCapabilities) {
|
||||
this.platformCapabilities = platformCapabilities != null ? platformCapabilities : List.of();
|
||||
}
|
||||
|
||||
public Map<String, String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(Map<String, String> tags) {
|
||||
this.tags = tags != null ? tags : new HashMap<>();
|
||||
}
|
||||
|
||||
public long getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(long createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
public void setRegion(String region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
public String getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(String accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package io.github.hectorvent.floci.services.batch.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public class BatchJobQueue {
|
||||
private String jobQueueName;
|
||||
private String jobQueueArn;
|
||||
private String state;
|
||||
private String status;
|
||||
private String statusReason;
|
||||
private int priority;
|
||||
private String jobQueueType;
|
||||
private List<BatchComputeEnvironmentOrder> computeEnvironmentOrder = new ArrayList<>();
|
||||
private Map<String, String> tags = new HashMap<>();
|
||||
private long createdAt;
|
||||
private String region;
|
||||
private String accountId;
|
||||
|
||||
public String getJobQueueName() {
|
||||
return jobQueueName;
|
||||
}
|
||||
|
||||
public void setJobQueueName(String jobQueueName) {
|
||||
this.jobQueueName = jobQueueName;
|
||||
}
|
||||
|
||||
public String getJobQueueArn() {
|
||||
return jobQueueArn;
|
||||
}
|
||||
|
||||
public void setJobQueueArn(String jobQueueArn) {
|
||||
this.jobQueueArn = jobQueueArn;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getStatusReason() {
|
||||
return statusReason;
|
||||
}
|
||||
|
||||
public void setStatusReason(String statusReason) {
|
||||
this.statusReason = statusReason;
|
||||
}
|
||||
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
public void setPriority(int priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
public String getJobQueueType() {
|
||||
return jobQueueType;
|
||||
}
|
||||
|
||||
public void setJobQueueType(String jobQueueType) {
|
||||
this.jobQueueType = jobQueueType;
|
||||
}
|
||||
|
||||
public List<BatchComputeEnvironmentOrder> getComputeEnvironmentOrder() {
|
||||
return computeEnvironmentOrder;
|
||||
}
|
||||
|
||||
public void setComputeEnvironmentOrder(List<BatchComputeEnvironmentOrder> computeEnvironmentOrder) {
|
||||
this.computeEnvironmentOrder = computeEnvironmentOrder != null ? computeEnvironmentOrder : new ArrayList<>();
|
||||
}
|
||||
|
||||
public Map<String, String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(Map<String, String> tags) {
|
||||
this.tags = tags != null ? tags : new HashMap<>();
|
||||
}
|
||||
|
||||
public long getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(long createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
public void setRegion(String region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
public String getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(String accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package io.github.hectorvent.floci.services.batch.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class BatchKeyValue {
|
||||
private String name;
|
||||
private String value;
|
||||
|
||||
public BatchKeyValue() {
|
||||
}
|
||||
|
||||
public BatchKeyValue(String name, String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package io.github.hectorvent.floci.services.batch.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class BatchResourceRequirement {
|
||||
private String type;
|
||||
private String value;
|
||||
|
||||
public BatchResourceRequirement() {
|
||||
}
|
||||
|
||||
public BatchResourceRequirement(String type, String value) {
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package io.github.hectorvent.floci.services.batch.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public class BatchRetryStrategy {
|
||||
private Integer attempts;
|
||||
private List<Map<String, Object>> evaluateOnExit = new ArrayList<>();
|
||||
|
||||
public Integer getAttempts() {
|
||||
return attempts;
|
||||
}
|
||||
|
||||
public void setAttempts(Integer attempts) {
|
||||
this.attempts = attempts;
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getEvaluateOnExit() {
|
||||
return evaluateOnExit;
|
||||
}
|
||||
|
||||
public void setEvaluateOnExit(List<Map<String, Object>> evaluateOnExit) {
|
||||
this.evaluateOnExit = evaluateOnExit != null ? evaluateOnExit : new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package io.github.hectorvent.floci.services.batch.model;
|
||||
|
||||
public record BatchRunResult(
|
||||
int exitCode,
|
||||
String reason,
|
||||
String logStreamName,
|
||||
long startedAt,
|
||||
long stoppedAt,
|
||||
boolean timedOut
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package io.github.hectorvent.floci.services.batch.model;
|
||||
|
||||
public enum BatchStatus {
|
||||
SUBMITTED,
|
||||
PENDING,
|
||||
RUNNABLE,
|
||||
STARTING,
|
||||
RUNNING,
|
||||
SUCCEEDED,
|
||||
FAILED
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package io.github.hectorvent.floci.services.batch.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class BatchTimeout {
|
||||
private Integer attemptDurationSeconds;
|
||||
|
||||
public Integer getAttemptDurationSeconds() {
|
||||
return attemptDurationSeconds;
|
||||
}
|
||||
|
||||
public void setAttemptDurationSeconds(Integer attemptDurationSeconds) {
|
||||
this.attemptDurationSeconds = attemptDurationSeconds;
|
||||
}
|
||||
}
|
||||
+238
-1
@@ -1,9 +1,11 @@
|
||||
package io.github.hectorvent.floci.services.cloudformation;
|
||||
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.services.batch.BatchService;
|
||||
import io.github.hectorvent.floci.services.cloudformation.model.StackResource;
|
||||
import io.github.hectorvent.floci.services.dynamodb.DynamoDbService;
|
||||
import io.github.hectorvent.floci.services.eventbridge.EventBridgeService;
|
||||
import io.github.hectorvent.floci.services.eventbridge.model.BatchParameters;
|
||||
import io.github.hectorvent.floci.services.eventbridge.model.RuleState;
|
||||
import io.github.hectorvent.floci.services.eventbridge.model.SqsParameters;
|
||||
import io.github.hectorvent.floci.services.eventbridge.model.Target;
|
||||
@@ -60,6 +62,8 @@ import io.github.hectorvent.floci.services.lambda.model.InvocationType;
|
||||
import io.github.hectorvent.floci.services.lambda.model.InvokeResult;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
@@ -124,6 +128,7 @@ public class CloudFormationResourceProvisioner {
|
||||
private final EcsService ecsService;
|
||||
private final ElbV2Service elbV2Service;
|
||||
private final StepFunctionsService stepFunctionsService;
|
||||
private final BatchService batchService;
|
||||
|
||||
@Inject
|
||||
public CloudFormationResourceProvisioner(S3Service s3Service, SqsService sqsService,
|
||||
@@ -143,7 +148,8 @@ public class CloudFormationResourceProvisioner {
|
||||
ContainerReachableEndpoint reachableEndpoint,
|
||||
EcsService ecsService,
|
||||
ElbV2Service elbV2Service,
|
||||
StepFunctionsService stepFunctionsService) {
|
||||
StepFunctionsService stepFunctionsService,
|
||||
BatchService batchService) {
|
||||
this.s3Service = s3Service;
|
||||
this.sqsService = sqsService;
|
||||
this.snsService = snsService;
|
||||
@@ -166,6 +172,7 @@ public class CloudFormationResourceProvisioner {
|
||||
this.ecsService = ecsService;
|
||||
this.elbV2Service = elbV2Service;
|
||||
this.stepFunctionsService = stepFunctionsService;
|
||||
this.batchService = batchService;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,6 +263,12 @@ public class CloudFormationResourceProvisioner {
|
||||
provisionListener(resource, properties, engine, region);
|
||||
case "AWS::ElasticLoadBalancingV2::ListenerRule" ->
|
||||
provisionListenerRule(resource, properties, engine, region);
|
||||
case "AWS::Batch::ComputeEnvironment" ->
|
||||
provisionBatchComputeEnvironment(resource, properties, engine, region, stackName);
|
||||
case "AWS::Batch::JobQueue" ->
|
||||
provisionBatchJobQueue(resource, properties, engine, region, stackName);
|
||||
case "AWS::Batch::JobDefinition" ->
|
||||
provisionBatchJobDefinition(resource, properties, engine, region, stackName);
|
||||
default -> {
|
||||
if (resourceType != null && resourceType.startsWith("Custom::")) {
|
||||
provisionCustomResource(resource, properties, engine, region, accountId, stackName);
|
||||
@@ -1333,6 +1346,20 @@ public class CloudFormationResourceProvisioner {
|
||||
target.setSqsParameters(sqsParameters);
|
||||
}
|
||||
}
|
||||
JsonNode batchParamsNode = resolved.path("BatchParameters");
|
||||
if (!batchParamsNode.isMissingNode() && batchParamsNode.isObject()) {
|
||||
JsonNode arrayProperties = batchParamsNode.path("ArrayProperties");
|
||||
BatchParameters batchParameters = new BatchParameters();
|
||||
batchParameters.setJobDefinition(batchParamsNode.path("JobDefinition").asText(null));
|
||||
batchParameters.setJobName(batchParamsNode.path("JobName").asText(null));
|
||||
if (arrayProperties.isObject()) {
|
||||
batchParameters.setArrayProperties(jsonObjectToMap(arrayProperties));
|
||||
}
|
||||
if (batchParamsNode.has("RetryStrategy")) {
|
||||
batchParameters.setRetryStrategy(batchParamsNode.get("RetryStrategy"));
|
||||
}
|
||||
target.setBatchParameters(batchParameters);
|
||||
}
|
||||
targets.add(target);
|
||||
}
|
||||
}
|
||||
@@ -1356,6 +1383,216 @@ public class CloudFormationResourceProvisioner {
|
||||
}
|
||||
}
|
||||
|
||||
// ── Batch ────────────────────────────────────────────────────────────────
|
||||
|
||||
private void provisionBatchComputeEnvironment(StackResource r, JsonNode props,
|
||||
CloudFormationTemplateEngine engine,
|
||||
String region, String stackName) {
|
||||
String name = resolveOptional(props, "ComputeEnvironmentName", engine);
|
||||
if (name == null || name.isBlank()) {
|
||||
name = generatePhysicalName(stackName, r.getLogicalId(), 128, false);
|
||||
}
|
||||
|
||||
ObjectNode req = JsonNodeFactory.instance.objectNode();
|
||||
req.put("computeEnvironmentName", name);
|
||||
putResolvedText(req, "type", props, "Type", engine);
|
||||
putResolvedText(req, "state", props, "State", engine);
|
||||
putResolvedText(req, "serviceRole", props, "ServiceRole", engine);
|
||||
putResolvedObject(req, "computeResources", props, "ComputeResources", engine);
|
||||
putTagsObject(req, props, engine);
|
||||
|
||||
ObjectNode response = batchService.createComputeEnvironment(req, region);
|
||||
String arn = response.path("computeEnvironmentArn").asText();
|
||||
r.setPhysicalId(arn);
|
||||
r.getAttributes().put("Arn", arn);
|
||||
r.getAttributes().put("ComputeEnvironmentArn", arn);
|
||||
r.getAttributes().put("ComputeEnvironmentName", name);
|
||||
}
|
||||
|
||||
private void provisionBatchJobQueue(StackResource r, JsonNode props,
|
||||
CloudFormationTemplateEngine engine,
|
||||
String region, String stackName) {
|
||||
String name = resolveOptional(props, "JobQueueName", engine);
|
||||
if (name == null || name.isBlank()) {
|
||||
name = generatePhysicalName(stackName, r.getLogicalId(), 128, false);
|
||||
}
|
||||
|
||||
ObjectNode req = JsonNodeFactory.instance.objectNode();
|
||||
req.put("jobQueueName", name);
|
||||
String priority = resolveOptional(props, "Priority", engine);
|
||||
req.put("priority", priority != null ? Integer.parseInt(priority) : 1);
|
||||
putResolvedText(req, "state", props, "State", engine);
|
||||
putResolvedText(req, "jobQueueType", props, "JobQueueType", engine);
|
||||
req.set("computeEnvironmentOrder", batchComputeEnvironmentOrder(props, engine));
|
||||
putTagsObject(req, props, engine);
|
||||
|
||||
ObjectNode response = batchService.createJobQueue(req, region);
|
||||
String arn = response.path("jobQueueArn").asText();
|
||||
r.setPhysicalId(arn);
|
||||
r.getAttributes().put("Arn", arn);
|
||||
r.getAttributes().put("JobQueueArn", arn);
|
||||
r.getAttributes().put("JobQueueName", name);
|
||||
}
|
||||
|
||||
private void provisionBatchJobDefinition(StackResource r, JsonNode props,
|
||||
CloudFormationTemplateEngine engine,
|
||||
String region, String stackName) {
|
||||
String name = resolveOptional(props, "JobDefinitionName", engine);
|
||||
if (name == null || name.isBlank()) {
|
||||
name = generatePhysicalName(stackName, r.getLogicalId(), 128, false);
|
||||
}
|
||||
|
||||
ObjectNode req = JsonNodeFactory.instance.objectNode();
|
||||
req.put("jobDefinitionName", name);
|
||||
req.put("type", resolveOrDefault(props, "Type", engine, "container"));
|
||||
putResolvedArray(req, "platformCapabilities", props, "PlatformCapabilities", engine);
|
||||
if (props != null && props.has("ContainerProperties")) {
|
||||
req.set("containerProperties", batchContainerProperties(
|
||||
engine.resolveNode(props.get("ContainerProperties")), engine));
|
||||
}
|
||||
putStringMapFromObject(req, "parameters", props, "Parameters", engine);
|
||||
if (props != null && props.has("RetryStrategy")) {
|
||||
req.set("retryStrategy", batchRetryStrategy(engine.resolveNode(props.get("RetryStrategy"))));
|
||||
}
|
||||
if (props != null && props.has("Timeout")) {
|
||||
ObjectNode timeout = JsonNodeFactory.instance.objectNode();
|
||||
JsonNode resolved = engine.resolveNode(props.get("Timeout"));
|
||||
if (resolved.has("AttemptDurationSeconds")) {
|
||||
timeout.set("attemptDurationSeconds", resolved.get("AttemptDurationSeconds"));
|
||||
}
|
||||
req.set("timeout", timeout);
|
||||
}
|
||||
putTagsObject(req, props, engine);
|
||||
|
||||
ObjectNode response = batchService.registerJobDefinition(req, region);
|
||||
String arn = response.path("jobDefinitionArn").asText();
|
||||
r.setPhysicalId(arn);
|
||||
r.getAttributes().put("Arn", arn);
|
||||
r.getAttributes().put("JobDefinitionArn", arn);
|
||||
r.getAttributes().put("JobDefinitionName", name);
|
||||
r.getAttributes().put("Revision", response.path("revision").asText());
|
||||
}
|
||||
|
||||
private ArrayNode batchComputeEnvironmentOrder(JsonNode props, CloudFormationTemplateEngine engine) {
|
||||
ArrayNode out = JsonNodeFactory.instance.arrayNode();
|
||||
if (props == null || !props.has("ComputeEnvironmentOrder")) {
|
||||
return out;
|
||||
}
|
||||
JsonNode resolved = engine.resolveNode(props.get("ComputeEnvironmentOrder"));
|
||||
if (!resolved.isArray()) {
|
||||
return out;
|
||||
}
|
||||
for (JsonNode item : resolved) {
|
||||
ObjectNode order = out.addObject();
|
||||
order.put("order", item.path("Order").asInt());
|
||||
order.put("computeEnvironment", item.path("ComputeEnvironment").asText(null));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
private ObjectNode batchContainerProperties(JsonNode resolved, CloudFormationTemplateEngine engine) {
|
||||
ObjectNode container = JsonNodeFactory.instance.objectNode();
|
||||
if (resolved == null || !resolved.isObject()) {
|
||||
return container;
|
||||
}
|
||||
copyIfPresent(container, "image", resolved, "Image");
|
||||
copyIfPresent(container, "command", resolved, "Command");
|
||||
copyIfPresent(container, "jobRoleArn", resolved, "JobRoleArn");
|
||||
copyIfPresent(container, "executionRoleArn", resolved, "ExecutionRoleArn");
|
||||
copyIfPresent(container, "logConfiguration", resolved, "LogConfiguration");
|
||||
copyIfPresent(container, "networkConfiguration", resolved, "NetworkConfiguration");
|
||||
copyIfPresent(container, "ephemeralStorage", resolved, "EphemeralStorage");
|
||||
if (resolved.has("ResourceRequirements") && resolved.get("ResourceRequirements").isArray()) {
|
||||
ArrayNode resources = container.putArray("resourceRequirements");
|
||||
for (JsonNode item : resolved.get("ResourceRequirements")) {
|
||||
ObjectNode requirement = resources.addObject();
|
||||
requirement.put("type", item.path("Type").asText(null));
|
||||
requirement.put("value", item.path("Value").asText(null));
|
||||
}
|
||||
}
|
||||
if (resolved.has("Environment") && resolved.get("Environment").isArray()) {
|
||||
ArrayNode env = container.putArray("environment");
|
||||
for (JsonNode item : resolved.get("Environment")) {
|
||||
ObjectNode entry = env.addObject();
|
||||
entry.put("name", item.path("Name").asText(null));
|
||||
entry.put("value", item.path("Value").asText(null));
|
||||
}
|
||||
}
|
||||
return container;
|
||||
}
|
||||
|
||||
private ObjectNode batchRetryStrategy(JsonNode resolved) {
|
||||
ObjectNode retry = JsonNodeFactory.instance.objectNode();
|
||||
if (resolved == null || !resolved.isObject()) {
|
||||
return retry;
|
||||
}
|
||||
if (resolved.has("Attempts")) {
|
||||
retry.set("attempts", resolved.get("Attempts"));
|
||||
}
|
||||
if (resolved.has("EvaluateOnExit")) {
|
||||
retry.set("evaluateOnExit", resolved.get("EvaluateOnExit"));
|
||||
}
|
||||
return retry;
|
||||
}
|
||||
|
||||
private void putResolvedText(ObjectNode req, String target, JsonNode props, String source,
|
||||
CloudFormationTemplateEngine engine) {
|
||||
String value = resolveOptional(props, source, engine);
|
||||
if (value != null) {
|
||||
req.put(target, value);
|
||||
}
|
||||
}
|
||||
|
||||
private void putResolvedObject(ObjectNode req, String target, JsonNode props, String source,
|
||||
CloudFormationTemplateEngine engine) {
|
||||
if (props == null || !props.has(source) || props.get(source).isNull()) {
|
||||
return;
|
||||
}
|
||||
JsonNode resolved = engine.resolveNode(props.get(source));
|
||||
if (resolved != null && resolved.isObject()) {
|
||||
req.set(target, resolved);
|
||||
}
|
||||
}
|
||||
|
||||
private void putResolvedArray(ObjectNode req, String target, JsonNode props, String source,
|
||||
CloudFormationTemplateEngine engine) {
|
||||
if (props == null || !props.has(source) || props.get(source).isNull()) {
|
||||
return;
|
||||
}
|
||||
JsonNode resolved = engine.resolveNode(props.get(source));
|
||||
if (resolved != null && resolved.isArray()) {
|
||||
req.set(target, resolved);
|
||||
}
|
||||
}
|
||||
|
||||
private void putStringMapFromObject(ObjectNode req, String target, JsonNode props, String source,
|
||||
CloudFormationTemplateEngine engine) {
|
||||
if (props == null || !props.has(source) || props.get(source).isNull()) {
|
||||
return;
|
||||
}
|
||||
JsonNode resolved = engine.resolveNode(props.get(source));
|
||||
if (!resolved.isObject()) {
|
||||
return;
|
||||
}
|
||||
ObjectNode out = JsonNodeFactory.instance.objectNode();
|
||||
resolved.fields().forEachRemaining(e -> out.put(e.getKey(), e.getValue().asText()));
|
||||
req.set(target, out);
|
||||
}
|
||||
|
||||
private void putTagsObject(ObjectNode req, JsonNode props, CloudFormationTemplateEngine engine) {
|
||||
Map<String, String> tags = parseCfnTags(props != null ? props.get("Tags") : null, engine);
|
||||
if (!tags.isEmpty()) {
|
||||
ObjectNode tagNode = req.putObject("tags");
|
||||
tags.forEach(tagNode::put);
|
||||
}
|
||||
}
|
||||
|
||||
private void copyIfPresent(ObjectNode target, String targetName, JsonNode source, String sourceName) {
|
||||
if (source.has(sourceName) && !source.get(sourceName).isNull()) {
|
||||
target.set(targetName, source.get(sourceName));
|
||||
}
|
||||
}
|
||||
|
||||
// ── Lambda EventSourceMapping ─────────────────────────────────────────────
|
||||
|
||||
private void provisionLambdaEventSourceMapping(StackResource r, JsonNode props,
|
||||
|
||||
@@ -5,6 +5,7 @@ import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.AwsJson11Controller;
|
||||
import io.github.hectorvent.floci.services.eventbridge.model.Archive;
|
||||
import io.github.hectorvent.floci.services.eventbridge.model.ArchiveState;
|
||||
import io.github.hectorvent.floci.services.eventbridge.model.BatchParameters;
|
||||
import io.github.hectorvent.floci.services.eventbridge.model.EventBus;
|
||||
import io.github.hectorvent.floci.services.eventbridge.model.InputTransformer;
|
||||
import io.github.hectorvent.floci.services.eventbridge.model.Replay;
|
||||
@@ -234,6 +235,10 @@ public class EventBridgeHandler {
|
||||
target.setSqsParameters(sqsParameters);
|
||||
}
|
||||
}
|
||||
JsonNode batchParamsNode = t.path("BatchParameters");
|
||||
if (!batchParamsNode.isMissingNode() && batchParamsNode.isObject()) {
|
||||
target.setBatchParameters(objectMapper.convertValue(batchParamsNode, BatchParameters.class));
|
||||
}
|
||||
targets.add(target);
|
||||
}
|
||||
}
|
||||
@@ -291,6 +296,9 @@ public class EventBridgeHandler {
|
||||
if (t.getSqsParameters() != null && t.getSqsParameters().getMessageGroupId() != null) {
|
||||
node.putObject("SqsParameters").put("MessageGroupId", t.getSqsParameters().getMessageGroupId());
|
||||
}
|
||||
if (t.getBatchParameters() != null) {
|
||||
node.set("BatchParameters", objectMapper.valueToTree(t.getBatchParameters()));
|
||||
}
|
||||
targetsArray.add(node);
|
||||
}
|
||||
return Response.ok(response).build();
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.services.batch.BatchService;
|
||||
import io.github.hectorvent.floci.services.eventbridge.model.InputTransformer;
|
||||
import io.github.hectorvent.floci.services.eventbridge.model.Target;
|
||||
import io.github.hectorvent.floci.services.lambda.LambdaService;
|
||||
@@ -14,6 +15,9 @@ import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ApplicationScoped
|
||||
public class EventBridgeInvoker {
|
||||
|
||||
@@ -22,6 +26,7 @@ public class EventBridgeInvoker {
|
||||
private final LambdaService lambdaService;
|
||||
private final SqsService sqsService;
|
||||
private final SnsService snsService;
|
||||
private final BatchService batchService;
|
||||
private final ObjectMapper objectMapper;
|
||||
private final String baseUrl;
|
||||
|
||||
@@ -29,15 +34,25 @@ public class EventBridgeInvoker {
|
||||
public EventBridgeInvoker(LambdaService lambdaService,
|
||||
SqsService sqsService,
|
||||
SnsService snsService,
|
||||
BatchService batchService,
|
||||
ObjectMapper objectMapper,
|
||||
EmulatorConfig config) {
|
||||
this.lambdaService = lambdaService;
|
||||
this.sqsService = sqsService;
|
||||
this.snsService = snsService;
|
||||
this.batchService = batchService;
|
||||
this.objectMapper = objectMapper;
|
||||
this.baseUrl = config.baseUrl();
|
||||
}
|
||||
|
||||
EventBridgeInvoker(LambdaService lambdaService,
|
||||
SqsService sqsService,
|
||||
SnsService snsService,
|
||||
ObjectMapper objectMapper,
|
||||
EmulatorConfig config) {
|
||||
this(lambdaService, sqsService, snsService, null, objectMapper, config);
|
||||
}
|
||||
|
||||
public void invokeTarget(Target target, String eventJson, String region) {
|
||||
String arn = target.getArn();
|
||||
String payload;
|
||||
@@ -67,6 +82,21 @@ public class EventBridgeInvoker {
|
||||
String topicRegion = extractRegionFromArn(arn, region);
|
||||
snsService.publish(arn, null, payload, "EventBridge", topicRegion);
|
||||
LOG.debugv("EventBridge delivered to SNS: {0}", arn);
|
||||
} else if (arn.contains(":batch:") && arn.contains(":job-queue/")) {
|
||||
if (batchService == null || target.getBatchParameters() == null) {
|
||||
LOG.warnv("EventBridge Batch target missing Batch service or parameters: {0}", arn);
|
||||
return;
|
||||
}
|
||||
String targetRegion = extractRegionFromArn(arn, region);
|
||||
batchService.submitFromEventBridge(
|
||||
arn,
|
||||
target.getBatchParameters().getJobDefinition(),
|
||||
target.getBatchParameters().getJobName(),
|
||||
parametersFromBatchPayload(payload),
|
||||
target.getBatchParameters().getRetryStrategy(),
|
||||
targetRegion
|
||||
);
|
||||
LOG.debugv("EventBridge delivered to Batch: {0}", arn);
|
||||
} else {
|
||||
LOG.warnv("EventBridge: unsupported target ARN type: {0}", arn);
|
||||
}
|
||||
@@ -114,6 +144,26 @@ public class EventBridgeInvoker {
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, String> parametersFromBatchPayload(String payload) {
|
||||
Map<String, String> parameters = new LinkedHashMap<>();
|
||||
if (payload == null || payload.isBlank()) {
|
||||
return parameters;
|
||||
}
|
||||
try {
|
||||
JsonNode node = objectMapper.readTree(payload);
|
||||
JsonNode parametersNode = node.path("Parameters");
|
||||
if (parametersNode.isObject()) {
|
||||
parametersNode.fields().forEachRemaining(entry -> {
|
||||
JsonNode value = entry.getValue();
|
||||
parameters.put(entry.getKey(), value.isTextual() ? value.asText() : value.toString());
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.debugv("EventBridge Batch payload is not a JSON object with Parameters: {0}", e.getMessage());
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
private static String extractRegionFromArn(String arn, String defaultRegion) {
|
||||
String[] parts = arn.split(":");
|
||||
return parts.length >= 4 && !parts[3].isEmpty() ? parts[3] : defaultRegion;
|
||||
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
package io.github.hectorvent.floci.services.eventbridge.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public class BatchParameters {
|
||||
|
||||
private String jobDefinition;
|
||||
private String jobName;
|
||||
private Map<String, Object> arrayProperties;
|
||||
private JsonNode retryStrategy;
|
||||
|
||||
public BatchParameters() {
|
||||
}
|
||||
|
||||
@JsonProperty("JobDefinition")
|
||||
public String getJobDefinition() {
|
||||
return jobDefinition;
|
||||
}
|
||||
|
||||
@JsonProperty("JobDefinition")
|
||||
public void setJobDefinition(String jobDefinition) {
|
||||
this.jobDefinition = jobDefinition;
|
||||
}
|
||||
|
||||
@JsonProperty("JobName")
|
||||
public String getJobName() {
|
||||
return jobName;
|
||||
}
|
||||
|
||||
@JsonProperty("JobName")
|
||||
public void setJobName(String jobName) {
|
||||
this.jobName = jobName;
|
||||
}
|
||||
|
||||
@JsonProperty("ArrayProperties")
|
||||
public Map<String, Object> getArrayProperties() {
|
||||
return arrayProperties;
|
||||
}
|
||||
|
||||
@JsonProperty("ArrayProperties")
|
||||
public void setArrayProperties(Map<String, Object> arrayProperties) {
|
||||
this.arrayProperties = arrayProperties;
|
||||
}
|
||||
|
||||
@JsonProperty("RetryStrategy")
|
||||
public JsonNode getRetryStrategy() {
|
||||
return retryStrategy;
|
||||
}
|
||||
|
||||
@JsonProperty("RetryStrategy")
|
||||
public void setRetryStrategy(JsonNode retryStrategy) {
|
||||
if (retryStrategy == null || retryStrategy.isNull()) {
|
||||
this.retryStrategy = null;
|
||||
return;
|
||||
}
|
||||
ObjectNode allowed = JsonNodeFactory.instance.objectNode();
|
||||
if (retryStrategy.has("Attempts")) {
|
||||
allowed.set("Attempts", retryStrategy.get("Attempts"));
|
||||
}
|
||||
this.retryStrategy = allowed.isEmpty() ? null : allowed;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ public class Target {
|
||||
private String inputPath;
|
||||
private InputTransformer inputTransformer;
|
||||
private SqsParameters sqsParameters;
|
||||
private BatchParameters batchParameters;
|
||||
|
||||
public Target() {}
|
||||
|
||||
@@ -40,4 +41,7 @@ public class Target {
|
||||
|
||||
public SqsParameters getSqsParameters() { return sqsParameters; }
|
||||
public void setSqsParameters(SqsParameters sqsParameters) { this.sqsParameters = sqsParameters; }
|
||||
|
||||
public BatchParameters getBatchParameters() { return batchParameters; }
|
||||
public void setBatchParameters(BatchParameters batchParameters) { this.batchParameters = batchParameters; }
|
||||
}
|
||||
Reference in new issue
Block a user