mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
feat(batch): add update and delete job queue endpoints with corresponding service logic (#2807)
This commit is contained in:
1 parent
66d910c613
commit
6f123e83b8
5 files changed
+211
No files matched your search
@@ -56,6 +56,20 @@ public class BatchController {
|
||||
Response.ok(service.createJobQueue(request, region)).build());
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/v1/updatejobqueue")
|
||||
public Response updateJobQueue(@Context HttpHeaders headers, String body) {
|
||||
return handle(headers, body, (request, region) ->
|
||||
Response.ok(service.updateJobQueue(request)).build());
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/v1/deletejobqueue")
|
||||
public Response deleteJobQueue(@Context HttpHeaders headers, String body) {
|
||||
return handle(headers, body, (request, region) ->
|
||||
Response.ok(service.deleteJobQueue(request)).build());
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/v1/describejobqueues")
|
||||
public Response describeJobQueues(@Context HttpHeaders headers, String body) {
|
||||
|
||||
@@ -203,6 +203,46 @@ public class BatchService {
|
||||
return out;
|
||||
}
|
||||
|
||||
public synchronized ObjectNode updateJobQueue(JsonNode request) {
|
||||
BatchJobQueue queue = resolveJobQueue(requiredText(request, "jobQueue"));
|
||||
if (request.hasNonNull("state")) {
|
||||
queue.setState(request.path("state").asText());
|
||||
}
|
||||
if (request.hasNonNull("priority")) {
|
||||
queue.setPriority(request.path("priority").asInt());
|
||||
}
|
||||
if (request.hasNonNull("computeEnvironmentOrder")) {
|
||||
List<BatchComputeEnvironmentOrder> orders =
|
||||
computeEnvironmentOrder(request.path("computeEnvironmentOrder"));
|
||||
for (BatchComputeEnvironmentOrder order : orders) {
|
||||
BatchComputeEnvironment env = resolveComputeEnvironment(order.getComputeEnvironment());
|
||||
if (!"VALID".equals(env.getStatus())) {
|
||||
throw client("Compute environment is not VALID: " + order.getComputeEnvironment());
|
||||
}
|
||||
}
|
||||
queue.setComputeEnvironmentOrder(orders);
|
||||
}
|
||||
jobQueueStore.put(queue.getJobQueueArn(), queue);
|
||||
|
||||
ObjectNode out = objectMapper.createObjectNode();
|
||||
out.put("jobQueueName", queue.getJobQueueName());
|
||||
out.put("jobQueueArn", queue.getJobQueueArn());
|
||||
return out;
|
||||
}
|
||||
|
||||
public synchronized ObjectNode deleteJobQueue(JsonNode request) {
|
||||
String ref = requiredText(request, "jobQueue");
|
||||
Optional<BatchJobQueue> queue = resolveJobQueueOptional(ref);
|
||||
if (queue.isEmpty()) {
|
||||
return objectMapper.createObjectNode();
|
||||
}
|
||||
if ("ENABLED".equals(queue.get().getState())) {
|
||||
throw client("Cannot delete job queue in ENABLED state: " + queue.get().getJobQueueName());
|
||||
}
|
||||
jobQueueStore.delete(queue.get().getJobQueueArn());
|
||||
return objectMapper.createObjectNode();
|
||||
}
|
||||
|
||||
public ObjectNode describeJobQueues(JsonNode request) {
|
||||
List<String> refs = stringList(request.path("jobQueues"));
|
||||
if (refs.size() > DESCRIBE_JOBS_LIMIT) {
|
||||
|
||||
Reference in new issue
Block a user