mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
feat(glue): start, read and stop job runs, and list and batch get jobs (#4382)
A job could be created but never run: StartJobRun and the other run actions answered InvalidAction. Add StartJobRun, GetJobRun, GetJobRuns, BatchStopJobRun, ListJobs and BatchGetJobs. Runs follow Glue's state machine without executing the script. They are settled on read, so floci.services.glue.job-run-duration-seconds (default 0, succeed at once) can keep a run RUNNING long enough to stop it or hit MaxConcurrentRuns. DeleteJob also removes the job's runs. Part of #4380
This commit is contained in:
1 parent
c9c01729f2
commit
14ae1dfbdb
12 files changed
+1309
-4
No files matched your search
@@ -1957,6 +1957,10 @@ public interface EmulatorConfig {
|
||||
interface GlueServiceConfig {
|
||||
@WithDefault("true")
|
||||
boolean enabled();
|
||||
|
||||
/** How long a job run stays RUNNING before it succeeds; 0 = a run succeeds as soon as it starts. */
|
||||
@WithDefault("0")
|
||||
int jobRunDurationSeconds();
|
||||
}
|
||||
|
||||
interface SesServiceConfig {
|
||||
|
||||
@@ -0,0 +1,264 @@
|
||||
package io.github.hectorvent.floci.services.glue;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.services.glue.model.ExecutionProperty;
|
||||
import io.github.hectorvent.floci.services.glue.model.Job;
|
||||
import io.github.hectorvent.floci.services.glue.model.JobRun;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.time.Clock;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Glue job runs. No script executes: a run follows Glue's state machine and its response shape,
|
||||
* and settles lazily when read. With the default {@code job-run-duration-seconds} of 0 a run is
|
||||
* SUCCEEDED as soon as it starts; a positive duration keeps it RUNNING until that much time has
|
||||
* passed, which is what makes BatchStopJobRun and MaxConcurrentRuns observable.
|
||||
*
|
||||
* <p>Every public method is synchronized: the store has no atomic compare and set, so admitting a
|
||||
* run (count the live runs, check the limit, write the run), stopping one, settling one and
|
||||
* removing a deleted job's runs must not interleave.
|
||||
*/
|
||||
@ApplicationScoped
|
||||
public class GlueJobRunService {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(GlueJobRunService.class);
|
||||
|
||||
static final String STATE_RUNNING = "RUNNING";
|
||||
static final String STATE_SUCCEEDED = "SUCCEEDED";
|
||||
static final String STATE_STOPPED = "STOPPED";
|
||||
static final String STATE_TIMEOUT = "TIMEOUT";
|
||||
|
||||
private static final Set<String> TERMINAL_STATES =
|
||||
Set.of(STATE_SUCCEEDED, STATE_STOPPED, "FAILED", STATE_TIMEOUT, "ERROR", "EXPIRED");
|
||||
|
||||
// ExecutionProperty.MaxConcurrentRuns defaults to 1 when a job does not set it.
|
||||
private static final int DEFAULT_MAX_CONCURRENT_RUNS = 1;
|
||||
private static final int MAX_JOB_RUNS_PAGE_SIZE = 200;
|
||||
private static final String LOG_GROUP_NAME = "/aws-glue/jobs";
|
||||
|
||||
private final StorageBackend<String, JobRun> runStore;
|
||||
private final GlueService glueService;
|
||||
private final int runDurationSeconds;
|
||||
private final Clock clock;
|
||||
|
||||
@Inject
|
||||
public GlueJobRunService(StorageFactory storageFactory, GlueService glueService, EmulatorConfig config) {
|
||||
this(storageFactory.create("glue", "job_runs.json", new TypeReference<>() {}),
|
||||
glueService, config.services().glue().jobRunDurationSeconds(), Clock.systemUTC());
|
||||
}
|
||||
|
||||
GlueJobRunService(StorageBackend<String, JobRun> runStore, GlueService glueService,
|
||||
int runDurationSeconds, Clock clock) {
|
||||
if (runDurationSeconds < 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"floci.services.glue.job-run-duration-seconds must not be negative: " + runDurationSeconds);
|
||||
}
|
||||
this.runStore = runStore;
|
||||
this.glueService = glueService;
|
||||
this.runDurationSeconds = runDurationSeconds;
|
||||
this.clock = clock;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a run of {@code jobName}. {@code overrides} carries the per-run request fields
|
||||
* (Arguments, Timeout, WorkerType, NumberOfWorkers, MaxCapacity, AllocatedCapacity,
|
||||
* SecurityConfiguration, NotificationProperty, ExecutionClass, JobRunQueuingEnabled); an
|
||||
* unset field falls back to the job definition.
|
||||
*/
|
||||
public synchronized JobRun startJobRun(String jobName, String previousRunId, JobRun overrides) {
|
||||
Job job = glueService.getJob(jobName);
|
||||
// The job's own Timeout is stored as given by CreateJob/UpdateJob, so check what the run inherits.
|
||||
Integer timeout = firstNonNull(overrides.getTimeout(), job.getTimeout());
|
||||
if (timeout != null && timeout < 1) {
|
||||
throw new AwsException("InvalidInputException", "Timeout must be at least 1 minute.", 400);
|
||||
}
|
||||
if (previousRunId != null) {
|
||||
findRun(jobName, previousRunId);
|
||||
}
|
||||
|
||||
boolean queuingEnabled = Boolean.TRUE.equals(firstNonNull(
|
||||
overrides.getJobRunQueuingEnabled(), job.getJobRunQueuingEnabled()));
|
||||
long active = runsOf(jobName).stream().filter(run -> !isTerminal(settle(run))).count();
|
||||
if (!queuingEnabled && active >= maxConcurrentRuns(job)) {
|
||||
throw new AwsException("ConcurrentRunsExceededException",
|
||||
"Concurrent runs exceeded for " + jobName, 400);
|
||||
}
|
||||
|
||||
Instant now = clock.instant();
|
||||
JobRun run = new JobRun();
|
||||
run.setId(newRunId());
|
||||
run.setAttempt(0);
|
||||
run.setPreviousRunId(previousRunId);
|
||||
run.setJobName(job.getName());
|
||||
run.setJobMode(job.getJobMode());
|
||||
run.setJobRunQueuingEnabled(queuingEnabled);
|
||||
run.setStartedOn(now);
|
||||
run.setLastModifiedOn(now);
|
||||
run.setJobRunState(STATE_RUNNING);
|
||||
run.setArguments(overrides.getArguments());
|
||||
run.setAllocatedCapacity(firstNonNull(overrides.getAllocatedCapacity(), job.getAllocatedCapacity()));
|
||||
run.setTimeout(timeout);
|
||||
run.setMaxCapacity(firstNonNull(overrides.getMaxCapacity(), job.getMaxCapacity()));
|
||||
run.setWorkerType(firstNonNull(overrides.getWorkerType(), job.getWorkerType()));
|
||||
run.setNumberOfWorkers(firstNonNull(overrides.getNumberOfWorkers(), job.getNumberOfWorkers()));
|
||||
run.setSecurityConfiguration(
|
||||
firstNonNull(overrides.getSecurityConfiguration(), job.getSecurityConfiguration()));
|
||||
run.setNotificationProperty(
|
||||
firstNonNull(overrides.getNotificationProperty(), job.getNotificationProperty()));
|
||||
run.setExecutionClass(firstNonNull(overrides.getExecutionClass(), job.getExecutionClass()));
|
||||
run.setGlueVersion(job.getGlueVersion());
|
||||
run.setLogGroupName(LOG_GROUP_NAME);
|
||||
run.setExecutionTime(0);
|
||||
runStore.put(run.getId(), run);
|
||||
LOG.infov("Started Glue job run {0} for job {1}", run.getId(), jobName);
|
||||
return settle(run);
|
||||
}
|
||||
|
||||
public synchronized JobRun getJobRun(String jobName, String runId) {
|
||||
glueService.getJob(jobName);
|
||||
if (runId == null) {
|
||||
throw new AwsException("InvalidInputException", "RunId is required.", 400);
|
||||
}
|
||||
return settle(findRun(jobName, runId));
|
||||
}
|
||||
|
||||
public synchronized GlueService.Page<JobRun> getJobRuns(String jobName, Integer maxResults,
|
||||
String nextToken) {
|
||||
glueService.getJob(jobName);
|
||||
if (maxResults != null && (maxResults < 1 || maxResults > MAX_JOB_RUNS_PAGE_SIZE)) {
|
||||
throw new AwsException("InvalidInputException",
|
||||
"MaxResults must be between 1 and " + MAX_JOB_RUNS_PAGE_SIZE, 400);
|
||||
}
|
||||
List<JobRun> runs = new ArrayList<>();
|
||||
for (JobRun run : runsOf(jobName)) {
|
||||
runs.add(settle(run));
|
||||
}
|
||||
runs.sort(Comparator.comparing(JobRun::getStartedOn).reversed().thenComparing(JobRun::getId));
|
||||
return glueService.paginate(runs, maxResults, nextToken);
|
||||
}
|
||||
|
||||
public synchronized StopResult batchStopJobRun(String jobName, List<String> runIds) {
|
||||
if (jobName == null) {
|
||||
throw new AwsException("InvalidInputException", "JobName is required.", 400);
|
||||
}
|
||||
if (runIds == null || runIds.isEmpty()) {
|
||||
throw new AwsException("InvalidInputException", "JobRunIds is required.", 400);
|
||||
}
|
||||
List<StoppedRun> stopped = new ArrayList<>();
|
||||
List<StopError> errors = new ArrayList<>();
|
||||
for (String runId : runIds) {
|
||||
JobRun run = runStore.get(runId)
|
||||
.filter(candidate -> jobName.equals(candidate.getJobName()))
|
||||
.orElse(null);
|
||||
if (run == null) {
|
||||
errors.add(new StopError(jobName, runId, "EntityNotFoundException",
|
||||
"Job run " + runId + " not found for job " + jobName));
|
||||
continue;
|
||||
}
|
||||
settle(run);
|
||||
if (isTerminal(run)) {
|
||||
errors.add(new StopError(jobName, runId, "InvalidInputException",
|
||||
"Job run " + runId + " is not running; its state is " + run.getJobRunState()));
|
||||
continue;
|
||||
}
|
||||
complete(run, STATE_STOPPED, clock.instant(), null);
|
||||
stopped.add(new StoppedRun(jobName, runId));
|
||||
}
|
||||
return new StopResult(stopped, errors);
|
||||
}
|
||||
|
||||
/** Runs belong to their job: deleting the job removes them, as it does on AWS. */
|
||||
public synchronized void deleteRuns(String jobName) {
|
||||
for (JobRun run : runsOf(jobName)) {
|
||||
runStore.delete(run.getId());
|
||||
}
|
||||
}
|
||||
|
||||
private JobRun settle(JobRun run) {
|
||||
if (isTerminal(run)) {
|
||||
return run;
|
||||
}
|
||||
Instant startedOn = run.getStartedOn();
|
||||
long timeoutSeconds = run.getTimeout() == null ? Long.MAX_VALUE : run.getTimeout() * 60L;
|
||||
if (runDurationSeconds >= timeoutSeconds) {
|
||||
Instant timedOutAt = startedOn.plusSeconds(timeoutSeconds);
|
||||
if (!clock.instant().isBefore(timedOutAt)) {
|
||||
complete(run, STATE_TIMEOUT, timedOutAt,
|
||||
"Job run exceeded the timeout of " + run.getTimeout() + " minutes");
|
||||
}
|
||||
return run;
|
||||
}
|
||||
Instant finishedAt = startedOn.plusSeconds(runDurationSeconds);
|
||||
if (!clock.instant().isBefore(finishedAt)) {
|
||||
complete(run, STATE_SUCCEEDED, finishedAt, null);
|
||||
}
|
||||
return run;
|
||||
}
|
||||
|
||||
private void complete(JobRun run, String state, Instant completedOn, String errorMessage) {
|
||||
run.setJobRunState(state);
|
||||
run.setCompletedOn(completedOn);
|
||||
run.setLastModifiedOn(completedOn);
|
||||
run.setExecutionTime((int) Duration.between(run.getStartedOn(), completedOn).toSeconds());
|
||||
run.setErrorMessage(errorMessage);
|
||||
runStore.put(run.getId(), run);
|
||||
}
|
||||
|
||||
private JobRun findRun(String jobName, String runId) {
|
||||
return runStore.get(runId)
|
||||
.filter(run -> jobName.equals(run.getJobName()))
|
||||
.orElseThrow(() -> new AwsException("EntityNotFoundException",
|
||||
"Job run " + runId + " not found for job " + jobName, 400));
|
||||
}
|
||||
|
||||
private List<JobRun> runsOf(String jobName) {
|
||||
List<JobRun> runs = new ArrayList<>();
|
||||
for (JobRun run : runStore.scan(key -> true)) {
|
||||
if (jobName.equals(run.getJobName())) {
|
||||
runs.add(run);
|
||||
}
|
||||
}
|
||||
return runs;
|
||||
}
|
||||
|
||||
private static boolean isTerminal(JobRun run) {
|
||||
return TERMINAL_STATES.contains(run.getJobRunState());
|
||||
}
|
||||
|
||||
private static int maxConcurrentRuns(Job job) {
|
||||
ExecutionProperty property = job.getExecutionProperty();
|
||||
if (property == null || property.getMaxConcurrentRuns() == null) {
|
||||
return DEFAULT_MAX_CONCURRENT_RUNS;
|
||||
}
|
||||
return property.getMaxConcurrentRuns();
|
||||
}
|
||||
|
||||
// Glue job run ids are "jr_" followed by 64 hex characters.
|
||||
private static String newRunId() {
|
||||
return "jr_" + UUID.randomUUID().toString().replace("-", "")
|
||||
+ UUID.randomUUID().toString().replace("-", "");
|
||||
}
|
||||
|
||||
private static <T> T firstNonNull(T preferred, T fallback) {
|
||||
return preferred != null ? preferred : fallback;
|
||||
}
|
||||
|
||||
public record StoppedRun(String jobName, String jobRunId) {}
|
||||
|
||||
public record StopError(String jobName, String jobRunId, String errorCode, String errorMessage) {}
|
||||
|
||||
public record StopResult(List<StoppedRun> stopped, List<StopError> errors) {}
|
||||
}
|
||||
@@ -31,14 +31,17 @@ public class GlueJsonHandler {
|
||||
private static final TypeReference<List<Partition>> PARTITION_LIST = new TypeReference<>() {};
|
||||
|
||||
private final GlueService glueService;
|
||||
private final GlueJobRunService jobRunService;
|
||||
private final GlueSchemaRegistryService schemaRegistryService;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
public GlueJsonHandler(GlueService glueService,
|
||||
GlueJobRunService jobRunService,
|
||||
GlueSchemaRegistryService schemaRegistryService,
|
||||
ObjectMapper mapper) {
|
||||
this.glueService = glueService;
|
||||
this.jobRunService = jobRunService;
|
||||
this.schemaRegistryService = schemaRegistryService;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
@@ -233,9 +236,43 @@ public class GlueJsonHandler {
|
||||
}
|
||||
case "DeleteJob" -> {
|
||||
DeleteJobRequest req = mapper.treeToValue(request, DeleteJobRequest.class);
|
||||
// Job first, runs second: a StartJobRun that checked the job before it was deleted has
|
||||
// stored its run by the time deleteRuns takes the run service's lock.
|
||||
glueService.deleteJob(req.getJobName(), region);
|
||||
jobRunService.deleteRuns(req.getJobName());
|
||||
yield Response.ok(new DeleteJobResponse(req.getJobName())).build();
|
||||
}
|
||||
case "ListJobs" -> {
|
||||
Map<String, String> tags = request.hasNonNull("Tags")
|
||||
? mapper.convertValue(request.get("Tags"), STRING_MAP)
|
||||
: null;
|
||||
GlueService.Page<String> page = glueService.listJobs(
|
||||
readMaxResults(request), readNextToken(request), tags, region);
|
||||
yield Response.ok(pageResponse("JobNames", page.items(), page.nextToken())).build();
|
||||
}
|
||||
case "BatchGetJobs" -> {
|
||||
List<String> names = request.hasNonNull("JobNames")
|
||||
? mapper.convertValue(request.get("JobNames"), STRING_LIST)
|
||||
: null;
|
||||
GlueService.BatchGetJobsResult result = glueService.batchGetJobs(names);
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
response.put("Jobs", result.jobs());
|
||||
response.put("JobsNotFound", result.jobsNotFound());
|
||||
yield Response.ok(response).build();
|
||||
}
|
||||
case "StartJobRun" -> {
|
||||
JobRun run = jobRunService.startJobRun(request.path("JobName").asText(null),
|
||||
request.path("JobRunId").asText(null), jobRunOverrides(request));
|
||||
yield Response.ok(Map.of("JobRunId", run.getId())).build();
|
||||
}
|
||||
case "GetJobRun" -> Response.ok(Map.of("JobRun", jobRunService.getJobRun(
|
||||
request.path("JobName").asText(null), request.path("RunId").asText(null)))).build();
|
||||
case "GetJobRuns" -> {
|
||||
GlueService.Page<JobRun> page = jobRunService.getJobRuns(
|
||||
request.path("JobName").asText(null), readMaxResults(request), readNextToken(request));
|
||||
yield Response.ok(pageResponse("JobRuns", page.items(), page.nextToken())).build();
|
||||
}
|
||||
case "BatchStopJobRun" -> handleBatchStopJobRun(request);
|
||||
case "CreateClassifier" -> {
|
||||
Classifier classifier = mapper.treeToValue(request, Classifier.class);
|
||||
glueService.createClassifier(classifier);
|
||||
@@ -971,6 +1008,72 @@ public class GlueJsonHandler {
|
||||
return Response.ok(Map.of()).build();
|
||||
}
|
||||
|
||||
private JobRun jobRunOverrides(JsonNode request) throws Exception {
|
||||
JobRun overrides = new JobRun();
|
||||
if (request.hasNonNull("Arguments")) {
|
||||
overrides.setArguments(mapper.convertValue(request.get("Arguments"), STRING_MAP));
|
||||
}
|
||||
if (request.hasNonNull("AllocatedCapacity")) {
|
||||
overrides.setAllocatedCapacity(request.get("AllocatedCapacity").asInt());
|
||||
}
|
||||
if (request.hasNonNull("Timeout")) {
|
||||
overrides.setTimeout(request.get("Timeout").asInt());
|
||||
}
|
||||
if (request.hasNonNull("MaxCapacity")) {
|
||||
overrides.setMaxCapacity(request.get("MaxCapacity").asDouble());
|
||||
}
|
||||
if (request.hasNonNull("WorkerType")) {
|
||||
overrides.setWorkerType(request.get("WorkerType").asText());
|
||||
}
|
||||
if (request.hasNonNull("NumberOfWorkers")) {
|
||||
overrides.setNumberOfWorkers(request.get("NumberOfWorkers").asInt());
|
||||
}
|
||||
if (request.hasNonNull("SecurityConfiguration")) {
|
||||
overrides.setSecurityConfiguration(request.get("SecurityConfiguration").asText());
|
||||
}
|
||||
if (request.hasNonNull("NotificationProperty")) {
|
||||
overrides.setNotificationProperty(
|
||||
mapper.treeToValue(request.get("NotificationProperty"), NotificationProperty.class));
|
||||
}
|
||||
if (request.hasNonNull("ExecutionClass")) {
|
||||
overrides.setExecutionClass(request.get("ExecutionClass").asText());
|
||||
}
|
||||
if (request.hasNonNull("JobRunQueuingEnabled")) {
|
||||
overrides.setJobRunQueuingEnabled(request.get("JobRunQueuingEnabled").asBoolean());
|
||||
}
|
||||
return overrides;
|
||||
}
|
||||
|
||||
private Response handleBatchStopJobRun(JsonNode request) {
|
||||
List<String> runIds = request.hasNonNull("JobRunIds")
|
||||
? mapper.convertValue(request.get("JobRunIds"), STRING_LIST)
|
||||
: null;
|
||||
GlueJobRunService.StopResult result =
|
||||
jobRunService.batchStopJobRun(request.path("JobName").asText(null), runIds);
|
||||
List<Map<String, Object>> submissions = new ArrayList<>();
|
||||
for (GlueJobRunService.StoppedRun stopped : result.stopped()) {
|
||||
Map<String, Object> entry = new LinkedHashMap<>();
|
||||
entry.put("JobName", stopped.jobName());
|
||||
entry.put("JobRunId", stopped.jobRunId());
|
||||
submissions.add(entry);
|
||||
}
|
||||
List<Map<String, Object>> errors = new ArrayList<>();
|
||||
for (GlueJobRunService.StopError error : result.errors()) {
|
||||
Map<String, Object> detail = new LinkedHashMap<>();
|
||||
detail.put("ErrorCode", error.errorCode());
|
||||
detail.put("ErrorMessage", error.errorMessage());
|
||||
Map<String, Object> entry = new LinkedHashMap<>();
|
||||
entry.put("JobName", error.jobName());
|
||||
entry.put("JobRunId", error.jobRunId());
|
||||
entry.put("ErrorDetail", detail);
|
||||
errors.add(entry);
|
||||
}
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
response.put("SuccessfulSubmissions", submissions);
|
||||
response.put("Errors", errors);
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
private Response handleGetTags(JsonNode request, String region) {
|
||||
String arn = request.path("ResourceArn").asText(null);
|
||||
Map<String, String> tags = glueService.getTags(arn, region);
|
||||
|
||||
@@ -54,6 +54,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -1728,6 +1729,46 @@ public class GlueService {
|
||||
return paginate(all, maxResults, nextToken);
|
||||
}
|
||||
|
||||
public Page<String> listJobs(Integer maxResults, String nextToken, Map<String, String> tags, String region) {
|
||||
List<String> names = new ArrayList<>();
|
||||
for (Job job : jobStore.scan(k -> true)) {
|
||||
if (tags == null || tags.isEmpty() || hasTags(jobArn(region, job.getName()), tags, region)) {
|
||||
names.add(job.getName());
|
||||
}
|
||||
}
|
||||
names.sort(Comparator.naturalOrder());
|
||||
return paginate(names, maxResults, nextToken);
|
||||
}
|
||||
|
||||
public BatchGetJobsResult batchGetJobs(List<String> names) {
|
||||
if (names == null || names.isEmpty()) {
|
||||
throw new AwsException("InvalidInputException", "JobNames is required.", 400);
|
||||
}
|
||||
List<Job> jobs = new ArrayList<>();
|
||||
List<String> notFound = new ArrayList<>();
|
||||
for (String name : names) {
|
||||
Optional<Job> job = name == null ? Optional.empty() : jobStore.get(name);
|
||||
if (job.isPresent()) {
|
||||
jobs.add(job.get());
|
||||
} else {
|
||||
notFound.add(name);
|
||||
}
|
||||
}
|
||||
return new BatchGetJobsResult(jobs, notFound);
|
||||
}
|
||||
|
||||
public record BatchGetJobsResult(List<Job> jobs, List<String> jobsNotFound) {}
|
||||
|
||||
private boolean hasTags(String arn, Map<String, String> wanted, String region) {
|
||||
Map<String, String> actual = resourceGroupsTaggingService.getTagsForResource(region, arn);
|
||||
for (Map.Entry<String, String> tag : wanted.entrySet()) {
|
||||
if (!Objects.equals(actual.get(tag.getKey()), tag.getValue())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void updateJob(String name, JobUpdate update) {
|
||||
validateRequired(name, "JobName");
|
||||
validateRequired(update, "JobUpdate");
|
||||
@@ -2476,7 +2517,7 @@ public class GlueService {
|
||||
|
||||
public record Page<T>(List<T> items, String nextToken) {}
|
||||
|
||||
private <T> Page<T> paginate(List<T> all, Integer maxResults, String nextToken) {
|
||||
<T> Page<T> paginate(List<T> all, Integer maxResults, String nextToken) {
|
||||
if (maxResults != null && (maxResults < 1 || maxResults > 1000)) {
|
||||
throw new AwsException("InvalidInputException", "MaxResults must be between 1 and 1000", 400);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
package io.github.hectorvent.floci.services.glue.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class JobRun {
|
||||
@JsonProperty("Id")
|
||||
private String id;
|
||||
|
||||
@JsonProperty("Attempt")
|
||||
private Integer attempt;
|
||||
|
||||
@JsonProperty("PreviousRunId")
|
||||
private String previousRunId;
|
||||
|
||||
@JsonProperty("JobName")
|
||||
private String jobName;
|
||||
|
||||
@JsonProperty("JobMode")
|
||||
private String jobMode;
|
||||
|
||||
@JsonProperty("JobRunQueuingEnabled")
|
||||
private Boolean jobRunQueuingEnabled;
|
||||
|
||||
@JsonProperty("StartedOn")
|
||||
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
|
||||
private Instant startedOn;
|
||||
|
||||
@JsonProperty("LastModifiedOn")
|
||||
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
|
||||
private Instant lastModifiedOn;
|
||||
|
||||
@JsonProperty("CompletedOn")
|
||||
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
|
||||
private Instant completedOn;
|
||||
|
||||
@JsonProperty("JobRunState")
|
||||
private String jobRunState;
|
||||
|
||||
@JsonProperty("Arguments")
|
||||
private Map<String, String> arguments;
|
||||
|
||||
@JsonProperty("ErrorMessage")
|
||||
private String errorMessage;
|
||||
|
||||
@JsonProperty("AllocatedCapacity")
|
||||
private Integer allocatedCapacity;
|
||||
|
||||
@JsonProperty("ExecutionTime")
|
||||
private Integer executionTime;
|
||||
|
||||
@JsonProperty("Timeout")
|
||||
private Integer timeout;
|
||||
|
||||
@JsonProperty("MaxCapacity")
|
||||
private Double maxCapacity;
|
||||
|
||||
@JsonProperty("WorkerType")
|
||||
private String workerType;
|
||||
|
||||
@JsonProperty("NumberOfWorkers")
|
||||
private Integer numberOfWorkers;
|
||||
|
||||
@JsonProperty("SecurityConfiguration")
|
||||
private String securityConfiguration;
|
||||
|
||||
@JsonProperty("LogGroupName")
|
||||
private String logGroupName;
|
||||
|
||||
@JsonProperty("NotificationProperty")
|
||||
private NotificationProperty notificationProperty;
|
||||
|
||||
@JsonProperty("GlueVersion")
|
||||
private String glueVersion;
|
||||
|
||||
@JsonProperty("ExecutionClass")
|
||||
private String executionClass;
|
||||
|
||||
public JobRun() {}
|
||||
|
||||
public String getId() { return id; }
|
||||
public void setId(String id) { this.id = id; }
|
||||
|
||||
public Integer getAttempt() { return attempt; }
|
||||
public void setAttempt(Integer attempt) { this.attempt = attempt; }
|
||||
|
||||
public String getPreviousRunId() { return previousRunId; }
|
||||
public void setPreviousRunId(String previousRunId) { this.previousRunId = previousRunId; }
|
||||
|
||||
public String getJobName() { return jobName; }
|
||||
public void setJobName(String jobName) { this.jobName = jobName; }
|
||||
|
||||
public String getJobMode() { return jobMode; }
|
||||
public void setJobMode(String jobMode) { this.jobMode = jobMode; }
|
||||
|
||||
public Boolean getJobRunQueuingEnabled() { return jobRunQueuingEnabled; }
|
||||
public void setJobRunQueuingEnabled(Boolean jobRunQueuingEnabled) { this.jobRunQueuingEnabled = jobRunQueuingEnabled; }
|
||||
|
||||
public Instant getStartedOn() { return startedOn; }
|
||||
public void setStartedOn(Instant startedOn) { this.startedOn = startedOn; }
|
||||
|
||||
public Instant getLastModifiedOn() { return lastModifiedOn; }
|
||||
public void setLastModifiedOn(Instant lastModifiedOn) { this.lastModifiedOn = lastModifiedOn; }
|
||||
|
||||
public Instant getCompletedOn() { return completedOn; }
|
||||
public void setCompletedOn(Instant completedOn) { this.completedOn = completedOn; }
|
||||
|
||||
public String getJobRunState() { return jobRunState; }
|
||||
public void setJobRunState(String jobRunState) { this.jobRunState = jobRunState; }
|
||||
|
||||
public Map<String, String> getArguments() { return arguments; }
|
||||
public void setArguments(Map<String, String> arguments) { this.arguments = arguments; }
|
||||
|
||||
public String getErrorMessage() { return errorMessage; }
|
||||
public void setErrorMessage(String errorMessage) { this.errorMessage = errorMessage; }
|
||||
|
||||
public Integer getAllocatedCapacity() { return allocatedCapacity; }
|
||||
public void setAllocatedCapacity(Integer allocatedCapacity) { this.allocatedCapacity = allocatedCapacity; }
|
||||
|
||||
public Integer getExecutionTime() { return executionTime; }
|
||||
public void setExecutionTime(Integer executionTime) { this.executionTime = executionTime; }
|
||||
|
||||
public Integer getTimeout() { return timeout; }
|
||||
public void setTimeout(Integer timeout) { this.timeout = timeout; }
|
||||
|
||||
public Double getMaxCapacity() { return maxCapacity; }
|
||||
public void setMaxCapacity(Double maxCapacity) { this.maxCapacity = maxCapacity; }
|
||||
|
||||
public String getWorkerType() { return workerType; }
|
||||
public void setWorkerType(String workerType) { this.workerType = workerType; }
|
||||
|
||||
public Integer getNumberOfWorkers() { return numberOfWorkers; }
|
||||
public void setNumberOfWorkers(Integer numberOfWorkers) { this.numberOfWorkers = numberOfWorkers; }
|
||||
|
||||
public String getSecurityConfiguration() { return securityConfiguration; }
|
||||
public void setSecurityConfiguration(String securityConfiguration) { this.securityConfiguration = securityConfiguration; }
|
||||
|
||||
public String getLogGroupName() { return logGroupName; }
|
||||
public void setLogGroupName(String logGroupName) { this.logGroupName = logGroupName; }
|
||||
|
||||
public NotificationProperty getNotificationProperty() { return notificationProperty; }
|
||||
public void setNotificationProperty(NotificationProperty notificationProperty) { this.notificationProperty = notificationProperty; }
|
||||
|
||||
public String getGlueVersion() { return glueVersion; }
|
||||
public void setGlueVersion(String glueVersion) { this.glueVersion = glueVersion; }
|
||||
|
||||
public String getExecutionClass() { return executionClass; }
|
||||
public void setExecutionClass(String executionClass) { this.executionClass = executionClass; }
|
||||
}
|
||||
Reference in new issue
Block a user