feat(emr-serverless): keep Spark Connect sessions and answer GetResourceDashboard (#8695)

EMR Serverless's session operations, StartSession, GetSession,
ListSessions, TerminateSession and GetSessionEndpoint, and
GetResourceDashboard, which "Currently, only Session is supported" for,
were not served, and a session's ARN was refused for tagging.

Floci now keeps sessions and their lifecycle, without running a Spark
driver for them. StartSession needs a Spark application on emr-7.13.0 or
later (or the AWS runtime for Apache Spark) with sessionEnabled on, is
admitted like a job run, auto-start included, and is idempotent on its
client token. An application holds at most 25 sessions that have not
ended, as the user guide's default, beyond which the 26th is
ServiceQuotaExceededException. A session is IDLE once started and ends
TERMINATED at its idle timeout (60 minutes by default), at its 24 hour
limit, when terminated, or when its application stops. GetSessionEndpoint
gives an endpoint on Floci's address and a token valid for an hour.
GetResourceDashboard gives a signed link, like GetDashboardForJobRun's, to
a page about the session. Tags work on session ARNs.

ListApplications, ListJobRuns and ListSessions share their validation,
and the latter two their state-grouped paging; StartJobRun and
StartSession share the caller, client-token and retry helpers.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-11-16 22:08:01 -04:00
1 parent 66eb95661e
commit 1d581eb131
23 files changed
+1758 -150

No files matched your search

@@ -12,6 +12,9 @@ import io.floci.aws.services.emrserverless.model.DeleteApplicationResponse;
import io.floci.aws.services.emrserverless.model.GetApplicationResponse;
import io.floci.aws.services.emrserverless.model.GetDashboardForJobRunResponse;
import io.floci.aws.services.emrserverless.model.GetJobRunResponse;
import io.floci.aws.services.emrserverless.model.GetResourceDashboardResponse;
import io.floci.aws.services.emrserverless.model.GetSessionEndpointResponse;
import io.floci.aws.services.emrserverless.model.GetSessionResponse;
import io.floci.aws.services.emrserverless.model.JobRun;
import io.floci.aws.services.emrserverless.model.JobRunAttemptSummary;
import io.floci.aws.services.emrserverless.model.JobRunSummary;
@@ -19,10 +22,16 @@ import io.floci.aws.services.emrserverless.model.ListApplicationsRequest;
import io.floci.aws.services.emrserverless.model.ListApplicationsResponse;
import io.floci.aws.services.emrserverless.model.ListJobRunAttemptsResponse;
import io.floci.aws.services.emrserverless.model.ListJobRunsResponse;
import io.floci.aws.services.emrserverless.model.ListSessionsResponse;
import io.floci.aws.services.emrserverless.model.Session;
import io.floci.aws.services.emrserverless.model.SessionSummary;
import io.floci.aws.services.emrserverless.model.StartApplicationResponse;
import io.floci.aws.services.emrserverless.model.StartJobRunRequest;
import io.floci.aws.services.emrserverless.model.StartJobRunResponse;
import io.floci.aws.services.emrserverless.model.StartSessionRequest;
import io.floci.aws.services.emrserverless.model.StartSessionResponse;
import io.floci.aws.services.emrserverless.model.StopApplicationResponse;
import io.floci.aws.services.emrserverless.model.TerminateSessionResponse;
import io.floci.aws.services.emrserverless.model.UpdateApplicationRequest;
import io.floci.aws.services.emrserverless.model.UpdateApplicationResponse;
import jakarta.enterprise.context.ApplicationScoped;
@@ -48,14 +57,17 @@ public class EmrServerlessController {
private final EmrServerlessService service;
private final EmrServerlessJobRunService jobRuns;
private final EmrServerlessSessionService sessions;
private final EmrServerlessDashboards dashboards;
private final RegionResolver regionResolver;
@Inject
public EmrServerlessController(EmrServerlessService service, EmrServerlessJobRunService jobRuns,
EmrServerlessDashboards dashboards, RegionResolver regionResolver) {
EmrServerlessSessionService sessions, EmrServerlessDashboards dashboards,
RegionResolver regionResolver) {
this.service = service;
this.jobRuns = jobRuns;
this.sessions = sessions;
this.dashboards = dashboards;
this.regionResolver = regionResolver;
}
@@ -127,7 +139,7 @@ public class EmrServerlessController {
@POST
@Path("/{applicationId}/stop")
public StopApplicationResponse stopApplication(@PathParam("applicationId") String applicationId) {
jobRuns.stopApplication(applicationId);
sessions.stopApplication(applicationId);
StopApplicationResponse response = new StopApplicationResponse();
return response;
}
@@ -215,4 +227,84 @@ public class EmrServerlessController {
response.setJobRunId(run.getJobRunId());
return response;
}
@POST
@Path("/{applicationId}/sessions")
public StartSessionResponse startSession(@PathParam("applicationId") String applicationId,
StartSessionRequest request) {
Session session = sessions.startSession(applicationId, request);
StartSessionResponse response = new StartSessionResponse();
response.setApplicationId(session.getApplicationId());
response.setSessionId(session.getSessionId());
response.setArn(session.getArn());
return response;
}
@GET
@Path("/{applicationId}/sessions")
public ListSessionsResponse listSessions(@PathParam("applicationId") String applicationId,
@QueryParam("states") List<String> states,
@QueryParam("createdAtAfter") String createdAtAfter,
@QueryParam("createdAtBefore") String createdAtBefore,
@QueryParam("maxResults") String maxResults,
@QueryParam("nextToken") String nextToken) {
PaginatedResult<SessionSummary> page = sessions.listSessions(applicationId, states,
EmrServerlessJobRunService.parseTimestamp(createdAtAfter, "createdAtAfter"),
EmrServerlessJobRunService.parseTimestamp(createdAtBefore, "createdAtBefore"),
Pagination.parseMaxResults(maxResults, "ValidationException"), nextToken);
ListSessionsResponse response = new ListSessionsResponse();
response.setSessions(page.items());
response.setNextToken(page.nextToken());
return response;
}
@GET
@Path("/{applicationId}/sessions/{sessionId}")
public GetSessionResponse getSession(@PathParam("applicationId") String applicationId,
@PathParam("sessionId") String sessionId) {
GetSessionResponse response = new GetSessionResponse();
response.setSession(sessions.getSession(applicationId, sessionId));
return response;
}
@DELETE
@Path("/{applicationId}/sessions/{sessionId}")
public TerminateSessionResponse terminateSession(@PathParam("applicationId") String applicationId,
@PathParam("sessionId") String sessionId) {
Session session = sessions.terminateSession(applicationId, sessionId);
TerminateSessionResponse response = new TerminateSessionResponse();
response.setApplicationId(session.getApplicationId());
response.setSessionId(session.getSessionId());
return response;
}
@GET
@Path("/{applicationId}/sessions/{sessionId}/endpoint")
public GetSessionEndpointResponse getSessionEndpoint(@PathParam("applicationId") String applicationId,
@PathParam("sessionId") String sessionId) {
EmrServerlessSessionService.Endpoint endpoint = sessions.sessionEndpoint(applicationId, sessionId);
GetSessionEndpointResponse response = new GetSessionEndpointResponse();
response.setApplicationId(applicationId);
response.setSessionId(sessionId);
response.setEndpoint(endpoint.url());
response.setAuthToken(endpoint.authToken());
response.setAuthTokenExpiresAt(endpoint.authTokenExpiresAt());
return response;
}
/**
* The link to a session's application UI ({@link EmrServerlessDashboards}). {@code accessSystemProfileLogs} is for
* sessions on Lake Formation, which Floci runs none of, so it changes nothing.
*/
@GET
@Path("/{applicationId}/dashboard")
public GetResourceDashboardResponse getResourceDashboard(@PathParam("applicationId") String applicationId,
@QueryParam("resourceId") String resourceId,
@QueryParam("resourceType") String resourceType) {
Session session = sessions.dashboardResource(applicationId, resourceId, resourceType);
GetResourceDashboardResponse response = new GetResourceDashboardResponse();
response.setUrl(dashboards.sessionUrl(regionResolver.getAccountId(), regionResolver.getRegion(),
applicationId, session.getSessionId()));
return response;
}
}
@@ -4,6 +4,7 @@ import io.floci.aws.core.common.AwsException;
import io.floci.aws.core.common.Html;
import io.floci.aws.core.common.RequestScopes;
import io.floci.aws.services.emrserverless.model.JobRun;
import io.floci.aws.services.emrserverless.model.Session;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
@@ -12,45 +13,64 @@ import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
/**
* The page a {@code GetDashboardForJobRun} link opens ({@link EmrServerlessDashboards}). EMR Serverless opens the run's
* live Spark or Tez UI while it runs and its Spark History Server or persistent Tez UI once it has ended; Floci keeps
* neither, so the page shows the attempt as GetJobRun gives it and where its driver's logs go, as it was admitted. A
* link that is not one of this process's, or whose hour has passed, opens a refusal instead, and so does one whose run
* has gone. Like the rest of Floci the page takes no AWS credentials: the link is all it asks for.
* The page a {@code GetDashboardForJobRun} or {@code GetResourceDashboard} link opens
* ({@link EmrServerlessDashboards}). EMR Serverless opens the run's live Spark or Tez UI while it runs and its Spark
* History Server or persistent Tez UI once it has ended, and a session's live Spark UI or Spark History Server
* likewise; Floci keeps neither, so the page shows the attempt as GetJobRun gives it and where its driver's logs go, as
* it was admitted, or the session as GetSession gives it. A link that is not one of this process's, or whose hour has
* passed, opens a refusal instead, and so does one whose run or session has gone. Like the rest of Floci the page takes
* no AWS credentials: the link is all it asks for.
*/
@Path(EmrServerlessDashboards.PATH)
public class EmrServerlessDashboardController {
// No source gives AWS's wording for these; they are Floci's.
static final String INVALID = "This dashboard link is not valid, or its hour has passed. Call"
+ " GetDashboardForJobRun for a new one.";
+ " GetDashboardForJobRun or GetResourceDashboard for a new one.";
static final String NO_UI = "Floci keeps no Spark UI, Tez UI or Spark History Server for a job run, so this page"
+ " stands in for the application UI EMR Serverless opens. The driver's output is in its logs.";
static final String NO_SESSION_UI = "Floci keeps no Spark UI or Spark History Server for a session, and runs no"
+ " Spark driver for one, so this page stands in for the application UI EMR Serverless opens.";
private final EmrServerlessDashboards dashboards;
private final EmrServerlessJobRunService jobRuns;
private final EmrServerlessSessionService sessions;
@Inject
public EmrServerlessDashboardController(EmrServerlessDashboards dashboards, EmrServerlessJobRunService jobRuns) {
public EmrServerlessDashboardController(EmrServerlessDashboards dashboards, EmrServerlessJobRunService jobRuns,
EmrServerlessSessionService sessions) {
this.dashboards = dashboards;
this.jobRuns = jobRuns;
this.sessions = sessions;
}
@GET
@Produces(MediaType.TEXT_HTML)
public Response dashboard(@QueryParam("account") String accountId, @QueryParam("region") String region,
@QueryParam("application") String applicationId,
@QueryParam("jobRun") String jobRunId, @QueryParam("attempt") String attempt,
@QueryParam("expires") String expires,
@QueryParam("jobRun") String jobRunId, @QueryParam("session") String sessionId,
@QueryParam("attempt") String attempt, @QueryParam("expires") String expires,
@QueryParam("signature") String signature) {
EmrServerlessDashboards.Link link = dashboards.verified(accountId, region, applicationId, jobRunId, attempt,
expires, signature);
EmrServerlessDashboards.Link link = dashboards.verified(accountId, region, applicationId, jobRunId, sessionId,
attempt, expires, signature);
if (link == null) {
return page(403, "Job run dashboard", List.of("<p>" + Html.escape(INVALID) + "</p>"));
return page(403, sessionId != null ? "Session dashboard" : "Job run dashboard",
List.of("<p>" + Html.escape(INVALID) + "</p>"));
}
if (link.sessionId() != null) {
Session session;
try {
session = RequestScopes.callAs(link.accountId(), link.region(),
() -> sessions.getSession(link.applicationId(), link.sessionId()));
} catch (AwsException e) {
return page(404, "Session " + link.sessionId(), List.of("<p>" + Html.escape(e.getMessage()) + "</p>"));
}
return page(200, "Session " + link.sessionId(), body(session));
}
EmrServerlessJobRunService.DashboardView view;
try {
@@ -84,7 +104,29 @@ public class EmrServerlessDashboardController {
return lines;
}
// A row of the table, left out when the run has no such value.
private static List<String> body(Session session) {
List<String> lines = new ArrayList<>();
lines.add("<table>");
row(lines, "Application", session.getApplicationId());
row(lines, "Session", session.getSessionId());
row(lines, "Name", session.getName());
row(lines, "State", session.getState());
row(lines, "State details", session.getStateDetails());
row(lines, "Release label", session.getReleaseLabel());
row(lines, "Created", text(session.getCreatedAt()));
row(lines, "Started", text(session.getStartedAt()));
row(lines, "Idle since", text(session.getIdleSince()));
row(lines, "Ended", text(session.getEndedAt()));
lines.add("</table>");
lines.add("<p>" + Html.escape(NO_SESSION_UI) + "</p>");
return lines;
}
private static String text(Instant instant) {
return instant != null ? instant.toString() : null;
}
// A row of the table, left out when the run or session has no such value.
private static void row(List<String> lines, String name, String value) {
if (value != null && !value.isEmpty()) {
lines.add("<tr><th>" + Html.escape(name) + "</th><td>" + Html.escape(value) + "</td></tr>");
@@ -16,12 +16,13 @@ import java.time.Duration;
import java.util.HexFormat;
/**
* The links {@code GetDashboardForJobRun} gives: "a URL that you can use to access the application UIs for a job run",
* which "is valid for one hour after you generate it. To access the application UI after that hour elapses, you must
* invoke the API again to generate a new URL." Floci keeps no Spark UI or Spark History Server for a run, so a link
* opens a page of Floci's own about the run ({@link EmrServerlessDashboardController}). It names the run's account,
* Region, application, run and attempt, and when it expires, signed with a key this process makes: a link changed, or
* past its hour, opens nothing, and the links given before a restart open nothing after it.
* The links {@code GetDashboardForJobRun} gives, "a URL that you can use to access the application UIs for a job run",
* and {@code GetResourceDashboard} gives for a session. Each "is valid for one hour after you generate it. To access
* the application UI after that hour elapses, you must invoke the API again to generate a new URL." Floci keeps no
* Spark UI or Spark History Server for a run or a session, so a link opens a page of Floci's own about it
* ({@link EmrServerlessDashboardController}). It names the account, Region, application, the run and its attempt or
* the session, and when it expires, signed with a key this process makes: a link changed, or past its hour, opens
* nothing, and the links given before a restart open nothing after it.
*/
@ApplicationScoped
public class EmrServerlessDashboards {
@@ -47,33 +48,41 @@ public class EmrServerlessDashboards {
this.key = key.clone();
}
/** What a link names: one attempt of a run, and the second, since the epoch, it expires at. */
public record Link(String accountId, String region, String applicationId, String jobRunId, int attempt,
long expires) {
/**
* What a link names: one attempt of a run, or a session, whose {@code attempt} is 0, and the second, since the
* epoch, it expires at.
*/
public record Link(String accountId, String region, String applicationId, String jobRunId, String sessionId,
int attempt, long expires) {
}
/** A link to a run's attempt, valid for {@link #VALIDITY} from now. */
public String url(String accountId, String region, String applicationId, String jobRunId, int attempt) {
Link link = new Link(accountId, region, applicationId, jobRunId, attempt,
clock.instant().plus(VALIDITY).getEpochSecond());
return baseUrl + PATH + "?account=" + encoded(accountId) + "&region=" + encoded(region)
+ "&application=" + encoded(applicationId) + "&jobRun=" + encoded(jobRunId)
+ "&attempt=" + attempt + "&expires=" + link.expires() + "&signature=" + signature(link);
Link link = new Link(accountId, region, applicationId, jobRunId, null, attempt, expiry());
return prefix(link) + "&jobRun=" + encoded(jobRunId) + "&attempt=" + attempt + suffix(link);
}
/** A link to a session, valid for {@link #VALIDITY} from now. */
public String sessionUrl(String accountId, String region, String applicationId, String sessionId) {
Link link = new Link(accountId, region, applicationId, null, sessionId, 0, expiry());
return prefix(link) + "&session=" + encoded(sessionId) + suffix(link);
}
/**
* The link a page request's parameters name, or null when one is missing or malformed, the signature is not this
* process's for them, or the link has expired.
* The link a page request's parameters name, or null when one is missing or malformed, it names both a run and a
* session or neither, the signature is not this process's for them, or the link has expired. A session's link
* carries no attempt.
*/
public Link verified(String accountId, String region, String applicationId, String jobRunId, String attempt,
String expires, String signature) {
if (accountId == null || region == null || applicationId == null || jobRunId == null || signature == null) {
public Link verified(String accountId, String region, String applicationId, String jobRunId, String sessionId,
String attempt, String expires, String signature) {
if (accountId == null || region == null || applicationId == null || signature == null
|| (jobRunId == null) == (sessionId == null) || (sessionId != null && attempt != null)) {
return null;
}
Link link;
try {
link = new Link(accountId, region, applicationId, jobRunId, Integer.parseInt(attempt),
Long.parseLong(expires));
link = new Link(accountId, region, applicationId, jobRunId, sessionId,
sessionId != null ? 0 : Integer.parseInt(attempt), Long.parseLong(expires));
} catch (NumberFormatException e) {
return null;
}
@@ -85,8 +94,24 @@ public class EmrServerlessDashboards {
return link;
}
private long expiry() {
return clock.instant().plus(VALIDITY).getEpochSecond();
}
private String prefix(Link link) {
return baseUrl + PATH + "?account=" + encoded(link.accountId()) + "&region=" + encoded(link.region())
+ "&application=" + encoded(link.applicationId());
}
private String suffix(Link link) {
return "&expires=" + link.expires() + "&signature=" + signature(link);
}
// Over what the link names; a run's link and a session's are told apart, so neither opens as the other.
private String signature(Link link) {
String signed = String.join("\n", link.accountId(), link.region(), link.applicationId(), link.jobRunId(),
String signed = String.join("\n", link.accountId(), link.region(), link.applicationId(),
link.jobRunId() != null ? "jobRun" : "session",
link.jobRunId() != null ? link.jobRunId() : link.sessionId(),
String.valueOf(link.attempt()), String.valueOf(link.expires()));
try {
Mac mac = Mac.getInstance(ALGORITHM);
@@ -1,10 +1,8 @@
package io.floci.aws.services.emrserverless;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.floci.aws.config.EmulatorConfig;
import io.floci.aws.core.common.AwsArnUtils;
import io.floci.aws.core.common.AwsException;
@@ -44,7 +42,6 @@ import java.time.format.DateTimeParseException;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
@@ -134,7 +131,7 @@ public class EmrServerlessJobRunService implements Resettable {
// The EMR Serverless 7.11.0 release notes: for BATCH job runs the maximum "is 7 days from this release
// onwards", and the timeout "can no longer be set to 0".
private static final long MAX_BATCH_EXECUTION_TIMEOUT_MINUTES = 10_080;
private static final Pattern RELEASE_LABEL = Pattern.compile("emr-(\\d{1,6})\\.(\\d{1,6})(?:\\..*)?");
static final Pattern RELEASE_LABEL = Pattern.compile("emr-(\\d{1,6})\\.(\\d{1,6})(?:\\..*)?");
// The AWS runtime for Apache Spark, emr-spark-8.0.0 on (and emr-spark-8.0-preview).
private static final Pattern SPARK_RUNTIME_RELEASE_LABEL =
Pattern.compile("emr-spark-(\\d{1,6})\\.(\\d{1,6})(?:[.-].*)?");
@@ -273,8 +270,9 @@ public class EmrServerlessJobRunService implements Resettable {
StartJobRunRequest body = request != null ? request : new StartJobRunRequest();
validate(body);
applications.getApplication(applicationId);
JsonNode original = requestOf(applicationId, body);
JobRunRecord existing = runWithClientToken(body.getClientToken());
JsonNode original = EmrServerlessService.retriedRequest(objectMapper, applicationId, body);
JobRunRecord existing = EmrServerlessService.startedWithClientToken(store.scan(key -> true),
body.getClientToken(), JobRunRecord::getClientToken, record -> inRequestRegion(record.getJobRun()));
if (existing != null) {
if (!original.equals(existing.getRequest())) {
throw new AwsException("ConflictException", "Request did not match the original", 409);
@@ -285,7 +283,8 @@ public class EmrServerlessJobRunService implements Resettable {
if (body.getTags() != null) {
EmrServerlessService.validateTags(body.getTags());
}
JobRunRecord record = applications.admitJobRun(applicationId, app -> checkBatchTimeout(app, body), app -> {
JobRunRecord record = applications.admit(applicationId, "a job run is submitted",
app -> checkBatchTimeout(app, body), app -> {
JobRunRecord admitted = newRun(app, body, original);
if (sparkRunner != null) {
launch(admitted, app);
@@ -376,14 +375,8 @@ public class EmrServerlessJobRunService implements Resettable {
public synchronized PaginatedResult<JobRunSummary> listJobRuns(String applicationId, List<String> states,
Instant createdAtAfter, Instant createdAtBefore,
String mode, Integer maxResults, String nextToken) {
List<String> violations = new ArrayList<>();
if (maxResults != null) {
String violation = SmithyValidationErrors.outOfRange("maxResults", maxResults, 1, MAX_LIST_RESULTS);
if (violation != null) {
violations.add(violation);
}
}
violations.addAll(EmrServerlessService.statesViolations(states, STATES, MAX_FILTER_STATES));
List<String> violations = EmrServerlessService.listViolations(maxResults, MAX_LIST_RESULTS, states, STATES,
MAX_FILTER_STATES);
if (mode != null && !MODES.contains(mode)) {
violations.add(SmithyValidationErrors.notInEnum(mode, "mode", MODES));
}
@@ -391,7 +384,6 @@ public class EmrServerlessJobRunService implements Resettable {
throw SmithyValidationErrors.validationException(violations);
}
List<JobRunRecord> matching = new ArrayList<>();
Map<String, String> cursors = new HashMap<>();
for (JobRunRecord record : store.scan(key -> true)) {
JobRun run = record.getJobRun();
if (!applicationId.equals(run.getApplicationId()) || !inRequestRegion(run)) {
@@ -404,18 +396,15 @@ public class EmrServerlessJobRunService implements Resettable {
|| (mode != null && !mode.equals(run.getMode() != null ? run.getMode() : MODE_BATCH))) {
continue;
}
int group = states == null || states.isEmpty() ? 0 : states.indexOf(run.getState());
cursors.put(run.getJobRunId(), String.format("%02d%020d%s", group,
Long.MAX_VALUE - run.getCreatedAt().toEpochMilli(), run.getJobRunId()));
matching.add(record);
}
String namespace = String.join("|", "ListJobRuns", applicationId,
String.valueOf(states != null ? states : List.of()), String.valueOf(createdAtAfter),
String.valueOf(createdAtBefore), String.valueOf(mode));
PaginatedResult<JobRunRecord> page = Pagination.paginate(matching,
record -> cursors.get(record.getJobRun().getJobRunId()),
maxResults != null ? maxResults : MAX_LIST_RESULTS, nextToken, namespace,
token -> new AwsException("ValidationException", "Invalid nextToken.", 400));
PaginatedResult<JobRunRecord> page = EmrServerlessService.pageByState(matching,
record -> record.getJobRun().getJobRunId(), record -> record.getJobRun().getState(),
record -> record.getJobRun().getCreatedAt(), states, maxResults, MAX_LIST_RESULTS, nextToken,
namespace);
return new PaginatedResult<>(page.items().stream().map(EmrServerlessJobRunService::toSummary).toList(),
page.nextToken());
}
@@ -522,7 +511,8 @@ public class EmrServerlessJobRunService implements Resettable {
run.setName(request.getName());
run.setArn(AwsArnUtils.Arn.of("emr-serverless", applicationArn.region(), applicationArn.accountId(),
applicationArn.resource() + "/jobruns/" + jobRunId).toString());
run.setCreatedBy(createdBy(applicationArn.accountId()));
run.setCreatedBy(EmrServerlessService.createdBy(iamService, requestContext, regionResolver,
applicationArn.accountId()));
run.setCreatedAt(now);
run.setUpdatedAt(now);
run.setExecutionRole(request.getExecutionRoleArn());
@@ -1258,39 +1248,6 @@ public class EmrServerlessJobRunService implements Resettable {
.orElseThrow(() -> EmrServerlessService.resourceNotFound(resource.arn()));
}
private JobRunRecord runWithClientToken(String clientToken) {
for (JobRunRecord record : store.scan(key -> true)) {
if (clientToken.equals(record.getClientToken()) && inRequestRegion(record.getJobRun())) {
return record;
}
}
return null;
}
/**
* What a retry must repeat: the application and every member of the body but the token itself.
* Read back from its JSON text, so that its numbers compare equal to those of a stored request
* once storage has written and read it.
*/
private JsonNode requestOf(String applicationId, StartJobRunRequest request) {
ObjectNode node;
try {
node = (ObjectNode) objectMapper.readTree(objectMapper.writeValueAsString(request));
} catch (JsonProcessingException e) {
throw new IllegalStateException("Cannot serialize a StartJobRun request", e);
}
node.remove("clientToken");
node.put("applicationId", applicationId);
return node;
}
// The caller, as GetCallerIdentity reports it; the account root for a key IAM does not know.
private String createdBy(String accountId) {
String accessKeyId = requestContext != null ? requestContext.getAccessKeyId() : null;
return iamService.resolveCallerArn(accessKeyId)
.orElseGet(() -> regionResolver.buildGlobalArn("iam", accountId, "root"));
}
private boolean inRequestRegion(JobRun run) {
return regionResolver.getRegion().equals(AwsArnUtils.parse(run.getArn()).region());
}
@@ -1305,11 +1262,9 @@ public class EmrServerlessJobRunService implements Resettable {
if (request.getClientToken() == null) {
violations.add(SmithyValidationErrors.notNull("clientToken"));
}
if (request.getExecutionRoleArn() == null) {
violations.add(SmithyValidationErrors.notNull("executionRoleArn"));
} else if (!ROLE_ARN.matcher(request.getExecutionRoleArn()).matches()) {
violations.add("Value at 'executionRoleArn' failed to satisfy constraint: "
+ "Member must satisfy regular expression pattern: " + ROLE_ARN_PATTERN);
String roleViolation = executionRoleViolation(request.getExecutionRoleArn());
if (roleViolation != null) {
violations.add(roleViolation);
}
if (request.getMode() != null && !MODES.contains(request.getMode())) {
violations.add(SmithyValidationErrors.notInEnum(request.getMode(), "mode", MODES));
@@ -1346,6 +1301,16 @@ public class EmrServerlessJobRunService implements Resettable {
}
}
/** What is wrong with a request's {@code executionRoleArn}, which the model requires: null when nothing is. */
static String executionRoleViolation(String executionRoleArn) {
if (executionRoleArn == null) {
return SmithyValidationErrors.notNull("executionRoleArn");
}
return ROLE_ARN.matcher(executionRoleArn).matches() ? null
: "Value at 'executionRoleArn' failed to satisfy constraint: "
+ "Member must satisfy regular expression pattern: " + ROLE_ARN_PATTERN;
}
/**
* The members of a run's {@code retryPolicy} it gives, each an integer in the model. A restJson1 service
* refuses a body member of another type, a string, a boolean or a fraction where an integer goes, with
@@ -1390,12 +1355,12 @@ public class EmrServerlessJobRunService implements Resettable {
// A release of the AWS runtime for Apache Spark, which starts at emr-spark-8.0-preview and comes after EMR
// Serverless 7.14.0 in the release list.
private static boolean sparkRuntime(String releaseLabel) {
static boolean sparkRuntime(String releaseLabel) {
return releaseAtLeast(SPARK_RUNTIME_RELEASE_LABEL, releaseLabel, 8, 0);
}
// Whether releaseLabel is of the family labelPattern matches, at major.minor or later.
private static boolean releaseAtLeast(Pattern labelPattern, String releaseLabel, int major, int minor) {
static boolean releaseAtLeast(Pattern labelPattern, String releaseLabel, int major, int minor) {
Matcher matcher = labelPattern.matcher(releaseLabel != null ? releaseLabel : "");
if (!matcher.matches()) {
return false;
@@ -1,6 +1,10 @@
package io.floci.aws.services.emrserverless;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.floci.aws.config.EmulatorConfig;
import io.floci.aws.core.common.AwsArnUtils;
import io.floci.aws.core.common.AwsException;
@@ -22,6 +26,7 @@ import io.floci.aws.services.emrserverless.model.ImageConfiguration;
import io.floci.aws.services.emrserverless.model.ListApplicationsRequest;
import io.floci.aws.services.emrserverless.model.UpdateApplicationRequest;
import io.floci.aws.services.emrserverless.model.WorkerTypeSpecification;
import io.floci.aws.services.iam.IamService;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import org.jboss.logging.Logger;
@@ -31,6 +36,7 @@ import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -39,6 +45,7 @@ import java.util.Set;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -82,8 +89,8 @@ public class EmrServerlessService {
private static final int MAX_APPLICATION_STATES = 7;
private static final int MAX_LIST_RESULTS = 50;
/** What an EMR Serverless resource ARN names: an application, or one of its job runs. */
public record ResourceArn(String arn, String applicationId, String jobRunId) {}
/** What an EMR Serverless resource ARN names: an application, or one of its job runs or sessions. */
public record ResourceArn(String arn, String applicationId, String jobRunId, String sessionId) {}
private final EmulatorConfig config;
private final AccountAwareStorageBackend<Application> storage;
@@ -174,15 +181,8 @@ public class EmrServerlessService {
}
public PaginatedResult<ApplicationSummary> listApplications(ListApplicationsRequest request) {
List<String> violations = new ArrayList<>();
if (request.getMaxResults() != null) {
String violation = SmithyValidationErrors.outOfRange("maxResults", request.getMaxResults(), 1,
MAX_LIST_RESULTS);
if (violation != null) {
violations.add(violation);
}
}
violations.addAll(statesViolations(request.getStates(), APPLICATION_STATES, MAX_APPLICATION_STATES));
List<String> violations = listViolations(request.getMaxResults(), MAX_LIST_RESULTS, request.getStates(),
APPLICATION_STATES, MAX_APPLICATION_STATES);
if (!violations.isEmpty()) {
throw SmithyValidationErrors.validationException(violations);
}
@@ -487,15 +487,17 @@ public class EmrServerlessService {
}
/**
* Admits a job run to the application and returns what {@code admit} builds from it. An
* Admits a job run or a session to the application and returns what {@code admit} builds from it. An
* application "only accepts jobs when it's in" STARTED, and auto-start, on unless the
* application turns it off, starts a CREATED or STOPPED one "on job submission" (EMR Serverless
* user guide, "Application states" and "Default application behavior"). {@code check} refuses a
* run against the application before auto-start can change it. This service's lock is held
* throughout, so the application cannot be updated, stopped or deleted while the run is admitted.
* user guide, "Application states" and "Default application behavior"); StartSession's "The application
* must be in the STARTED state or have AutoStart enabled" is the same rule. {@code check} refuses the
* submission against the application before auto-start can change it, and {@code submission} says what it
* is in the refusal of a stopped application. This service's lock is held throughout, so the application
* cannot be updated, stopped or deleted while the submission is admitted.
*/
public synchronized <T> T admitJobRun(String applicationId, Consumer<Application> check,
Function<Application, T> admit) {
public synchronized <T> T admit(String applicationId, String submission, Consumer<Application> check,
Function<Application, T> admit) {
Application app = getApplication(applicationId);
String state = app.getState();
if ("TERMINATED".equals(state)) {
@@ -505,7 +507,7 @@ public class EmrServerlessService {
if (!"STARTED".equals(state)) {
if (!autoStartEnabled(app)) {
throw new AwsException("ValidationException", "Application " + applicationId
+ " must be started before a job run is submitted, as its auto-start is disabled.", 400);
+ " must be started before " + submission + ", as its auto-start is disabled.", 400);
}
startApplication(applicationId);
app = getApplication(applicationId);
@@ -544,8 +546,8 @@ public class EmrServerlessService {
/**
* Parses a tagging ARN: {@code arn:<partition>:emr-serverless:<region>:<account>:/applications/<id>},
* the form CreateApplication returns, with {@code /jobruns/<id>} for a job run. An ARN of another
* Region names nothing here, and neither does a session's, as sessions are not emulated.
* the form CreateApplication returns, with {@code /jobruns/<id>} for a job run and {@code /sessions/<id>} for a
* session. An ARN of another Region names nothing here.
*/
public ResourceArn resourceArn(String arn) {
AwsArnUtils.Arn parsed;
@@ -558,10 +560,12 @@ public class EmrServerlessService {
if (!"emr-serverless".equals(parsed.service()) || !matcher.matches()) {
throw new AwsException("ValidationException", "Invalid resourceArn: " + arn, 400);
}
if (!parsed.region().equals(regionResolver.getRegion()) || "sessions".equals(matcher.group(2))) {
if (!parsed.region().equals(regionResolver.getRegion())) {
throw resourceNotFound(arn);
}
return new ResourceArn(arn, matcher.group(1), matcher.group(3));
boolean session = "sessions".equals(matcher.group(2));
return new ResourceArn(arn, matcher.group(1), session ? null : matcher.group(3),
session ? matcher.group(3) : null);
}
/** Whether the application exists and has not been deleted, which leaves it TERMINATED. */
@@ -571,7 +575,7 @@ public class EmrServerlessService {
/**
* Runs {@code use} on the application when it exists and has not been deleted, under this service's
* lock, so that it cannot be deleted meanwhile, as with {@link #admitJobRun}; returns whether it ran.
* lock, so that it cannot be deleted meanwhile, as with {@link #admit}; returns whether it ran.
*/
public synchronized boolean whileLive(String applicationId, Consumer<Application> use) {
Optional<Application> app = live(applicationId);
@@ -624,11 +628,47 @@ public class EmrServerlessService {
return remaining;
}
/**
* What is wrong with a ListApplications, ListJobRuns or ListSessions request's {@code maxResults} and
* {@code states}.
*/
static List<String> listViolations(Integer maxResults, int maxListResults, List<String> states,
List<String> allowed, int maxStates) {
List<String> violations = new ArrayList<>();
if (maxResults != null) {
String violation = SmithyValidationErrors.outOfRange("maxResults", maxResults, 1, maxListResults);
if (violation != null) {
violations.add(violation);
}
}
violations.addAll(statesViolations(states, allowed, maxStates));
return violations;
}
/**
* A page of ListJobRuns' runs or ListSessions' sessions: {@code matching}, newest first, and, where {@code states}
* names any, "grouped by the state", in the order it names them, as each operation's {@code states} member reads.
* A {@code nextToken} resumes only the listing {@code namespace} names.
*/
static <T> PaginatedResult<T> pageByState(List<T> matching, Function<T, String> id, Function<T, String> state,
Function<T, Instant> createdAt, List<String> states, Integer maxResults,
int defaultMaxResults, String nextToken, String namespace) {
Map<String, String> cursors = new HashMap<>();
for (T item : matching) {
int group = states == null || states.isEmpty() ? 0 : states.indexOf(state.apply(item));
cursors.put(id.apply(item), String.format("%02d%020d%s", group,
Long.MAX_VALUE - createdAt.apply(item).toEpochMilli(), id.apply(item)));
}
return Pagination.paginate(matching, item -> cursors.get(id.apply(item)),
maxResults != null ? maxResults : defaultMaxResults, nextToken, namespace,
token -> new AwsException("ValidationException", "Invalid nextToken.", 400));
}
/**
* The violations of a {@code states} filter: at most {@code max} states, each one of
* {@code allowed}. A typo would otherwise match nothing and list nothing.
*/
static List<String> statesViolations(List<String> states, List<String> allowed, int max) {
private static List<String> statesViolations(List<String> states, List<String> allowed, int max) {
List<String> violations = new ArrayList<>();
if (states == null) {
return violations;
@@ -717,11 +757,51 @@ public class EmrServerlessService {
return text.regionMatches(true, 0, RESERVED_PREFIX, 0, RESERVED_PREFIX.length());
}
/** An application or job run id: 16 lowercase hexadecimal characters, within the model's [0-9a-z]+. */
/** An application, job run or session id: 16 lowercase hexadecimal characters, within the model's [0-9a-z]+. */
static String newId() {
return UUID.randomUUID().toString().replace("-", "").substring(0, 16);
}
/** A job run's or session's {@code createdBy}: the caller, as GetCallerIdentity reports it, or else the root. */
static String createdBy(IamService iamService, RequestContext requestContext, RegionResolver regionResolver,
String accountId) {
String accessKeyId = requestContext != null ? requestContext.getAccessKeyId() : null;
return iamService.resolveCallerArn(accessKeyId)
.orElseGet(() -> regionResolver.buildGlobalArn("iam", accountId, "root"));
}
/**
* The run or session that StartJobRun or StartSession started with {@code clientToken}, which a retry returns, or
* null. A client token is the request's Region's: reused on another application, it finds the run or session it
* started there, whose request then does not match the retry's.
*/
static <T> T startedWithClientToken(List<T> records, String clientToken, Function<T, String> tokenOf,
Predicate<T> inRequestRegion) {
for (T record : records) {
if (clientToken.equals(tokenOf.apply(record)) && inRequestRegion.test(record)) {
return record;
}
}
return null;
}
/**
* What a retry of StartJobRun or StartSession must repeat: the application and every member of the body but
* the client token itself. Read back from its JSON text, so that its numbers compare equal to those of a stored
* request once storage has written and read it.
*/
static JsonNode retriedRequest(ObjectMapper objectMapper, String applicationId, Object request) {
ObjectNode node;
try {
node = (ObjectNode) objectMapper.readTree(objectMapper.writeValueAsString(request));
} catch (JsonProcessingException e) {
throw new IllegalStateException("Cannot serialize a " + request.getClass().getSimpleName(), e);
}
node.remove("clientToken");
node.put("applicationId", applicationId);
return node;
}
private String buildArn(String id) {
String region = regionResolver.getRegion();
String accountId = requestContext != null && requestContext.getAccountId() != null ? requestContext.getAccountId() : config.defaultAccountId();
@@ -0,0 +1,494 @@
package io.floci.aws.services.emrserverless;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.floci.aws.config.EmulatorConfig;
import io.floci.aws.core.common.AwsArnUtils;
import io.floci.aws.core.common.AwsException;
import io.floci.aws.core.common.PaginatedResult;
import io.floci.aws.core.common.RegionResolver;
import io.floci.aws.core.common.RequestContext;
import io.floci.aws.core.common.SmithyValidationErrors;
import io.floci.aws.core.storage.AccountAwareStorageBackend;
import io.floci.aws.core.storage.StorageFactory;
import io.floci.aws.services.emrserverless.model.Application;
import io.floci.aws.services.emrserverless.model.Session;
import io.floci.aws.services.emrserverless.model.SessionRecord;
import io.floci.aws.services.emrserverless.model.SessionSummary;
import io.floci.aws.services.emrserverless.model.StartSessionRequest;
import io.floci.aws.services.iam.IamService;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import org.jboss.logging.Logger;
import java.security.SecureRandom;
import java.time.Clock;
import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.HexFormat;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* EMR Serverless sessions: "a managed connection between your local PySpark client and a Spark driver running on Amazon
* EMR Serverless", through Spark Connect (EMR Serverless user guide, "Run interactive sessions with Amazon EMR
* Serverless through Spark Connect"). Floci keeps each session and its lifecycle but starts no Spark driver for it: a
* session is IDLE once started, nothing answers Spark Connect at its endpoint, and it ends when it is terminated, when
* its idle timeout or its 24 hours pass, or when its application stops.
*/
@ApplicationScoped
public class EmrServerlessSessionService {
private static final Logger LOG = Logger.getLogger(EmrServerlessSessionService.class);
static final String STATE_IDLE = "IDLE";
static final String STATE_TERMINATED = "TERMINATED";
private static final List<String> STATES =
List.of("SUBMITTED", "STARTING", "STARTED", STATE_IDLE, "BUSY", "FAILED", "TERMINATING", STATE_TERMINATED);
private static final Set<String> ENDED = Set.of("FAILED", STATE_TERMINATED);
private static final List<String> RESOURCE_TYPES = List.of("SESSION");
// SessionStateSet holds 1 to 8 states; a ListSessions page holds 1 to 50 sessions.
private static final int MAX_FILTER_STATES = 8;
private static final int MAX_LIST_RESULTS = 50;
// "Each EMR Serverless application supports up to 25 concurrent sessions by default."
static final int MAX_CONCURRENT_SESSIONS = 25;
// "Sessions end after a configurable idle timeout. Default timeout is set to 1 hour."
static final long DEFAULT_IDLE_TIMEOUT_MINUTES = 60;
private static final long MAX_IDLE_TIMEOUT_MINUTES = 1_000_000;
// "Each session has a hard limit of 24 hours by default, after which it auto-terminates even if it is actively
// running a task."
static final Duration HARD_LIMIT = Duration.ofHours(24);
// "Authentication tokens are time-limited to 1 hour."
static final Duration TOKEN_VALIDITY = Duration.ofHours(1);
private static final int TOKEN_BYTES = 32;
// Where GetSessionEndpoint points; nothing answers Spark Connect there, as Floci runs no driver for a session.
static final String ENDPOINT_PATH = "/_aws/emr-serverless/sessions/";
private static final String SPARK_TYPE = "SPARK";
// No source gives AWS's wording for these ends; they are Floci's.
static final String IDLE_TIMED_OUT = "The session was idle for its idle timeout.";
static final String HARD_LIMIT_REACHED = "The session reached its 24 hour limit.";
static final String APPLICATION_STOPPED = "The session's application was stopped.";
private final AccountAwareStorageBackend<SessionRecord> store;
private final EmrServerlessService applications;
private final EmrServerlessJobRunService jobRuns;
private final IamService iamService;
private final RegionResolver regionResolver;
private final RequestContext requestContext;
private final ObjectMapper objectMapper;
private final Clock clock;
private final String baseUrl;
private final SecureRandom random = new SecureRandom();
@Inject
public EmrServerlessSessionService(StorageFactory storageFactory, EmrServerlessService applications,
EmrServerlessJobRunService jobRuns, IamService iamService,
RegionResolver regionResolver, RequestContext requestContext,
ObjectMapper objectMapper, EmulatorConfig config, Clock clock) {
this(storageFactory.create("emrserverless", "emr-serverless-sessions.json", new TypeReference<>() {}),
applications, jobRuns, iamService, regionResolver, requestContext, objectMapper, clock,
config.effectiveBaseUrl());
}
EmrServerlessSessionService(AccountAwareStorageBackend<SessionRecord> store, EmrServerlessService applications,
EmrServerlessJobRunService jobRuns, IamService iamService,
RegionResolver regionResolver, RequestContext requestContext,
ObjectMapper objectMapper, Clock clock, String baseUrl) {
this.store = store;
this.applications = applications;
this.jobRuns = jobRuns;
this.iamService = iamService;
this.regionResolver = regionResolver;
this.requestContext = requestContext;
this.objectMapper = objectMapper;
this.clock = clock;
this.baseUrl = baseUrl.endsWith("/") ? baseUrl.substring(0, baseUrl.length() - 1) : baseUrl;
}
/**
* Starts a session, which "The application must be in the STARTED state or have AutoStart enabled, and have
* interactive sessions enabled" for, on "EMR release 7.13.0 and later", and, as "Spark Connect is supported only
* for the Apache Spark engine", on a Spark application. A retry with the same client token returns the session it
* started, and one whose request differs is refused, as StartJobRun's is. An application holds at most
* {@link #MAX_CONCURRENT_SESSIONS} sessions that have not ended.
*/
public synchronized Session startSession(String applicationId, StartSessionRequest request) {
StartSessionRequest body = request != null ? request : new StartSessionRequest();
validate(body);
applications.getApplication(applicationId);
JsonNode original = EmrServerlessService.retriedRequest(objectMapper, applicationId, body);
SessionRecord existing = EmrServerlessService.startedWithClientToken(store.scan(key -> true),
body.getClientToken(), SessionRecord::getClientToken, record -> inRequestRegion(record.getSession()));
if (existing != null) {
if (!original.equals(existing.getRequest())) {
throw new AwsException("ConflictException", "Request did not match the original", 409);
}
return copy(settle(existing).getSession());
}
// Before admission, which may auto-start the application: a refused session leaves it as it was.
if (body.getTags() != null) {
EmrServerlessService.validateTags(body.getTags());
}
SessionRecord record = applications.admit(applicationId, "a session is started", this::checkAdmissible,
app -> newSession(app, body, original));
LOG.infov("Started EMR Serverless session {0} on application {1}", record.getSession().getSessionId(),
applicationId);
return copy(record.getSession());
}
public synchronized Session getSession(String applicationId, String sessionId) {
applications.getApplication(applicationId);
return copy(settle(findSession(applicationId, sessionId)).getSession());
}
/**
* The application's sessions in the request's Region, newest first, grouped by state as ListJobRuns' runs are.
*/
public synchronized PaginatedResult<SessionSummary> listSessions(String applicationId, List<String> states,
Instant createdAtAfter, Instant createdAtBefore,
Integer maxResults, String nextToken) {
List<String> violations = EmrServerlessService.listViolations(maxResults, MAX_LIST_RESULTS, states, STATES,
MAX_FILTER_STATES);
if (!violations.isEmpty()) {
throw SmithyValidationErrors.validationException(violations);
}
applications.getApplication(applicationId);
List<Session> matching = new ArrayList<>();
for (SessionRecord record : store.scan(key -> true)) {
Session session = record.getSession();
if (!applicationId.equals(session.getApplicationId()) || !inRequestRegion(session)) {
continue;
}
settle(record);
if ((states != null && !states.isEmpty() && !states.contains(session.getState()))
|| (createdAtAfter != null && !session.getCreatedAt().isAfter(createdAtAfter))
|| (createdAtBefore != null && !session.getCreatedAt().isBefore(createdAtBefore))) {
continue;
}
matching.add(session);
}
String namespace = String.join("|", "ListSessions", applicationId,
String.valueOf(states != null ? states : List.of()), String.valueOf(createdAtAfter),
String.valueOf(createdAtBefore));
PaginatedResult<Session> page = EmrServerlessService.pageByState(matching, Session::getSessionId,
Session::getState, Session::getCreatedAt, states, maxResults, MAX_LIST_RESULTS, nextToken, namespace);
return new PaginatedResult<>(page.items().stream().map(SessionSummary::of).toList(), page.nextToken());
}
/**
* Terminates a session that has not ended: "After you terminate a session, it enters the TERMINATING state and
* then the TERMINATED state." With no driver to stop, Floci's is TERMINATED at once. One that has already ended
* is refused; no source gives AWS's answer for it, so the wording is Floci's.
*/
public synchronized Session terminateSession(String applicationId, String sessionId) {
applications.getApplication(applicationId);
SessionRecord record = settle(findSession(applicationId, sessionId));
if (ENDED.contains(record.getSession().getState())) {
throw new AwsException("ValidationException", "Session " + sessionId + " has already ended.", 400);
}
end(record, STATE_TERMINATED, null, now());
LOG.infov("Terminated EMR Serverless session {0} on application {1}", sessionId, applicationId);
return copy(record.getSession());
}
/**
* Where a client connects to a session that has not ended, with an authentication token, which is "time-limited
* to 1 hour". The endpoint is on Floci's own address, where nothing answers Spark Connect, as Floci runs no driver
* for a session. No source gives AWS's answer for a session that has ended, so the refusal's wording is Floci's.
*/
public synchronized Endpoint sessionEndpoint(String applicationId, String sessionId) {
applications.getApplication(applicationId);
Session session = settle(findSession(applicationId, sessionId)).getSession();
if (ENDED.contains(session.getState())) {
throw new AwsException("ValidationException", "Session " + sessionId + " has ended.", 400);
}
byte[] token = new byte[TOKEN_BYTES];
random.nextBytes(token);
return new Endpoint(baseUrl + ENDPOINT_PATH + applicationId + "/" + sessionId,
HexFormat.of().formatHex(token), now().plus(TOKEN_VALIDITY));
}
/** GetSessionEndpoint's endpoint, its token and when the token expires. */
public record Endpoint(String url, String authToken, Instant authTokenExpiresAt) {
}
/**
* Stops the application as StopApplication does once its job runs have ended
* ({@link EmrServerlessJobRunService#stopApplication}), and then terminates its sessions that have not ended. Once
* an application is stopped "no resources are running on the application" (EMR Serverless user guide, "Application
* states"), and while StopApplication requires that "All scheduled and running jobs must be completed or cancelled
* before stopping an application", it names no such requirement for sessions. Under this service's lock, as
* StartSession's admission is, so no session starts between the two.
*/
public synchronized void stopApplication(String applicationId) {
jobRuns.stopApplication(applicationId);
Instant now = now();
for (SessionRecord record : store.scan(key -> true)) {
Session session = record.getSession();
if (applicationId.equals(session.getApplicationId()) && inRequestRegion(session)
&& !ENDED.contains(settle(record).getSession().getState())) {
end(record, STATE_TERMINATED, APPLICATION_STOPPED, now);
}
}
}
/**
* The session GetResourceDashboard links to, in any state: "Currently, only Session is supported" as its
* {@code resourceType}.
*/
public synchronized Session dashboardResource(String applicationId, String resourceId, String resourceType) {
List<String> violations = new ArrayList<>();
if (resourceId == null) {
violations.add(SmithyValidationErrors.notNull("resourceId"));
}
if (resourceType == null) {
violations.add(SmithyValidationErrors.notNull("resourceType"));
} else if (!RESOURCE_TYPES.contains(resourceType)) {
violations.add(SmithyValidationErrors.notInEnum(resourceType, "resourceType", RESOURCE_TYPES));
}
if (!violations.isEmpty()) {
throw SmithyValidationErrors.validationException(violations);
}
return getSession(applicationId, resourceId);
}
public synchronized Map<String, String> listTags(EmrServerlessService.ResourceArn resource) {
Session session = sessionFor(resource).getSession();
return session.getTags() != null ? new LinkedHashMap<>(session.getTags()) : new LinkedHashMap<>();
}
public synchronized void tagResource(EmrServerlessService.ResourceArn resource, Map<String, String> tags) {
SessionRecord record = sessionFor(resource);
record.getSession().setTags(EmrServerlessService.withTags(record.getSession().getTags(), tags));
store.put(record.getSession().getSessionId(), record);
}
public synchronized void untagResource(EmrServerlessService.ResourceArn resource, List<String> tagKeys) {
SessionRecord record = sessionFor(resource);
record.getSession().setTags(EmrServerlessService.withoutTags(record.getSession().getTags(), tagKeys));
store.put(record.getSession().getSessionId(), record);
}
private static void validate(StartSessionRequest request) {
List<String> violations = new ArrayList<>();
if (request.getClientToken() == null) {
violations.add(SmithyValidationErrors.notNull("clientToken"));
}
String roleViolation = EmrServerlessJobRunService.executionRoleViolation(request.getExecutionRoleArn());
if (roleViolation != null) {
violations.add(roleViolation);
}
if (request.getConfigurationOverrides() != null) {
Object configurations = request.getConfigurationOverrides().get("runtimeConfiguration");
if (configurations != null) {
violations.addAll(configurationViolations(configurations,
"configurationOverrides.runtimeConfiguration"));
}
}
if (request.getIdleTimeoutMinutes() != null) {
String violation = SmithyValidationErrors.outOfRange("idleTimeoutMinutes", request.getIdleTimeoutMinutes(),
0, MAX_IDLE_TIMEOUT_MINUTES);
if (violation != null) {
violations.add(violation);
}
}
if (!violations.isEmpty()) {
throw SmithyValidationErrors.validationException(violations);
}
}
/**
* The violations of a ConfigurationList at {@code path}: each configuration needs its {@code classification}.
* One of the wrong JSON type, the list, a configuration, its {@code classification}, its {@code properties}, a
* map of strings, or its nested {@code configurations}, is refused at once with SerializationException, as a
* restJson1 service refuses a body member of another type (Smithy's restJson1 malformed-request tests), in
* Floci's own wording.
*/
private static List<String> configurationViolations(Object configurations, String path) {
if (!(configurations instanceof List<?> list)) {
throw malformed(path + " must be a list of configurations");
}
List<String> violations = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
String member = path + "." + (i + 1) + ".member";
if (!(list.get(i) instanceof Map<?, ?> configuration)) {
throw malformed(member + " must be a configuration");
}
Object classification = configuration.get("classification");
if (classification == null) {
violations.add(SmithyValidationErrors.notNull(member + ".classification"));
} else if (!(classification instanceof String)) {
throw malformed(member + ".classification must be a string");
}
Object properties = configuration.get("properties");
if (properties != null && (!(properties instanceof Map<?, ?> map)
|| !map.values().stream().allMatch(String.class::isInstance))) {
throw malformed(member + ".properties must be a map of strings");
}
Object nested = configuration.get("configurations");
if (nested != null) {
violations.addAll(configurationViolations(nested, member + ".configurations"));
}
}
return violations;
}
private static AwsException malformed(String message) {
return new AwsException("SerializationException", message, 400);
}
/**
* Refuses a session the application cannot hold, before auto-start can change it. No source gives AWS's wording
* for any of these refusals, so it is Floci's; ServiceQuotaExceededException is the model's error for the quota.
*/
private void checkAdmissible(Application app) {
if (!SPARK_TYPE.equalsIgnoreCase(app.getType())) {
throw new AwsException("ValidationException",
"Sessions are supported only on Spark applications.", 400);
}
if (!supportsSessions(app.getReleaseLabel())) {
throw new AwsException("ValidationException",
"Sessions are supported on EMR release 7.13.0 and later.", 400);
}
Object enabled = app.getInteractiveConfiguration() != null
? app.getInteractiveConfiguration().getProperties().get("sessionEnabled") : null;
if (!Boolean.TRUE.equals(enabled)) {
throw new AwsException("ValidationException", "Application " + app.getApplicationId()
+ " does not have interactive sessions enabled.", 400);
}
long open = 0;
for (SessionRecord record : store.scan(key -> true)) {
Session session = record.getSession();
if (app.getApplicationId().equals(session.getApplicationId()) && inRequestRegion(session)
&& !ENDED.contains(settle(record).getSession().getState())) {
open++;
}
}
if (open >= MAX_CONCURRENT_SESSIONS) {
throw new AwsException("ServiceQuotaExceededException", "Application " + app.getApplicationId()
+ " already has " + MAX_CONCURRENT_SESSIONS + " concurrent sessions.", 402);
}
}
/**
* "EMR release 7.13.0 and later": an emr- release from 7.13.0 on, or a release of the AWS runtime for Apache
* Spark, which the release list puts after them.
*/
static boolean supportsSessions(String releaseLabel) {
return EmrServerlessJobRunService.releaseAtLeast(EmrServerlessJobRunService.RELEASE_LABEL, releaseLabel, 7, 13)
|| EmrServerlessJobRunService.sparkRuntime(releaseLabel);
}
private SessionRecord newSession(Application app, StartSessionRequest request, JsonNode original) {
AwsArnUtils.Arn applicationArn = AwsArnUtils.parse(app.getArn());
String sessionId = EmrServerlessService.newId();
Instant now = now();
Session session = new Session();
session.setApplicationId(app.getApplicationId());
session.setSessionId(sessionId);
session.setArn(AwsArnUtils.Arn.of("emr-serverless", applicationArn.region(), applicationArn.accountId(),
applicationArn.resource() + "/sessions/" + sessionId).toString());
session.setName(request.getName());
// With no driver to start, a session is ready, and idle, as it starts.
session.setState(STATE_IDLE);
session.setStateDetails("");
session.setReleaseLabel(app.getReleaseLabel());
session.setExecutionRoleArn(request.getExecutionRoleArn());
session.setCreatedBy(EmrServerlessService.createdBy(iamService, requestContext, regionResolver,
applicationArn.accountId()));
session.setCreatedAt(now);
session.setUpdatedAt(now);
session.setStartedAt(now);
session.setIdleSince(now);
// "Only runtime configuration overrides are supported."
if (request.getConfigurationOverrides() != null
&& request.getConfigurationOverrides().get("runtimeConfiguration") != null) {
session.setConfigurationOverrides(Map.of("runtimeConfiguration",
request.getConfigurationOverrides().get("runtimeConfiguration")));
}
session.setNetworkConfiguration(app.getNetworkConfiguration());
session.setIdleTimeoutMinutes(request.getIdleTimeoutMinutes() != null
? request.getIdleTimeoutMinutes() : DEFAULT_IDLE_TIMEOUT_MINUTES);
session.setTags(request.getTags() != null ? new LinkedHashMap<>(request.getTags()) : new LinkedHashMap<>());
SessionRecord record = new SessionRecord();
record.setSession(session);
record.setClientToken(request.getClientToken());
record.setRequest(original);
store.put(sessionId, record);
return record;
}
/**
* Ends a session whose time has run out by now: an idle one once its idle timeout has passed since it went idle,
* and any once its 24 hours have passed since it started, whichever comes first. An idle timeout of 0 ends
* nothing: no source says what it does, and Floci reads it as a job run's execution timeout of 0 is read, as none.
*/
private SessionRecord settle(SessionRecord record) {
Session session = record.getSession();
if (ENDED.contains(session.getState())) {
return record;
}
Instant hardLimit = session.getStartedAt() != null ? session.getStartedAt().plus(HARD_LIMIT) : null;
Long idleMinutes = session.getIdleTimeoutMinutes();
Instant idleLimit = STATE_IDLE.equals(session.getState()) && session.getIdleSince() != null
&& idleMinutes != null && idleMinutes > 0
? session.getIdleSince().plus(Duration.ofMinutes(idleMinutes)) : null;
Instant now = clock.instant();
if (idleLimit != null && !now.isBefore(idleLimit) && (hardLimit == null || idleLimit.isBefore(hardLimit))) {
end(record, STATE_TERMINATED, IDLE_TIMED_OUT, idleLimit);
} else if (hardLimit != null && !now.isBefore(hardLimit)) {
end(record, STATE_TERMINATED, HARD_LIMIT_REACHED, hardLimit);
}
return record;
}
private void end(SessionRecord record, String state, String details, Instant at) {
Session session = record.getSession();
session.setState(state);
session.setStateDetails(details != null ? details : "");
session.setEndedAt(at);
session.setUpdatedAt(at);
session.setIdleSince(null);
if (session.getStartedAt() != null) {
session.setTotalExecutionDurationSeconds(Duration.between(session.getStartedAt(), at).toSeconds());
}
store.put(session.getSessionId(), record);
}
private SessionRecord findSession(String applicationId, String sessionId) {
return store.get(sessionId)
.filter(record -> applicationId.equals(record.getSession().getApplicationId()))
.filter(record -> inRequestRegion(record.getSession()))
.orElseThrow(() -> new AwsException("ResourceNotFoundException",
"Session " + sessionId + " not found", 404));
}
// The session a tagging ARN names. The ARN must be the session's own, and a deleted application's sessions name
// nothing, as with job runs.
private SessionRecord sessionFor(EmrServerlessService.ResourceArn resource) {
return store.get(resource.sessionId())
.filter(record -> resource.applicationId().equals(record.getSession().getApplicationId()))
.filter(record -> resource.arn().equals(record.getSession().getArn()))
.filter(record -> applications.isLive(resource.applicationId()))
.orElseThrow(() -> EmrServerlessService.resourceNotFound(resource.arn()));
}
private boolean inRequestRegion(Session session) {
return regionResolver.getRegion().equals(AwsArnUtils.parse(session.getArn()).region());
}
private Instant now() {
return clock.instant().truncatedTo(ChronoUnit.MILLIS);
}
private Session copy(Session session) {
return objectMapper.convertValue(session, Session.class);
}
}
@@ -8,7 +8,7 @@ import java.util.List;
import java.util.Map;
/**
* EMR Serverless on the shared {@code /tags/{resourceArn}} path, for applications and job runs. The
* EMR Serverless on the shared {@code /tags/{resourceArn}} path, for applications, job runs and sessions. The
* wire shape is the common one (a lowercase {@code tags} map, a {@code tagKeys} query and
* {@code POST}), except that TagResource and UntagResource answer 200 rather than 204, and payloads
* are validated strictly.
@@ -18,11 +18,14 @@ public class EmrServerlessTagHandler implements TagHandler {
private final EmrServerlessService service;
private final EmrServerlessJobRunService jobRuns;
private final EmrServerlessSessionService sessions;
@Inject
public EmrServerlessTagHandler(EmrServerlessService service, EmrServerlessJobRunService jobRuns) {
public EmrServerlessTagHandler(EmrServerlessService service, EmrServerlessJobRunService jobRuns,
EmrServerlessSessionService sessions) {
this.service = service;
this.jobRuns = jobRuns;
this.sessions = sessions;
}
@Override
@@ -49,7 +52,10 @@ public class EmrServerlessTagHandler implements TagHandler {
@Override
public Map<String, String> listTags(String region, String arn) {
EmrServerlessService.ResourceArn resource = service.resourceArn(arn);
return resource.jobRunId() != null ? jobRuns.listTags(resource) : service.listTags(resource);
if (resource.jobRunId() != null) {
return jobRuns.listTags(resource);
}
return resource.sessionId() != null ? sessions.listTags(resource) : service.listTags(resource);
}
@Override
@@ -57,6 +63,8 @@ public class EmrServerlessTagHandler implements TagHandler {
EmrServerlessService.ResourceArn resource = service.resourceArn(arn);
if (resource.jobRunId() != null) {
jobRuns.tagResource(resource, tags);
} else if (resource.sessionId() != null) {
sessions.tagResource(resource, tags);
} else {
service.tagResource(resource, tags);
}
@@ -67,6 +75,8 @@ public class EmrServerlessTagHandler implements TagHandler {
EmrServerlessService.ResourceArn resource = service.resourceArn(arn);
if (resource.jobRunId() != null) {
jobRuns.untagResource(resource, tagKeys);
} else if (resource.sessionId() != null) {
sessions.untagResource(resource, tagKeys);
} else {
service.untagResource(resource, tagKeys);
}
@@ -0,0 +1,11 @@
package io.floci.aws.services.emrserverless.model;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
public class GetResourceDashboardResponse {
private String url;
public String getUrl() { return url; }
public void setUrl(String url) { this.url = url; }
}
@@ -0,0 +1,27 @@
package io.floci.aws.services.emrserverless.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.time.Instant;
@RegisterForReflection
public class GetSessionEndpointResponse {
private String applicationId;
private String sessionId;
private String endpoint;
private String authToken;
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
private Instant authTokenExpiresAt;
public String getApplicationId() { return applicationId; }
public void setApplicationId(String applicationId) { this.applicationId = applicationId; }
public String getSessionId() { return sessionId; }
public void setSessionId(String sessionId) { this.sessionId = sessionId; }
public String getEndpoint() { return endpoint; }
public void setEndpoint(String endpoint) { this.endpoint = endpoint; }
public String getAuthToken() { return authToken; }
public void setAuthToken(String authToken) { this.authToken = authToken; }
public Instant getAuthTokenExpiresAt() { return authTokenExpiresAt; }
public void setAuthTokenExpiresAt(Instant authTokenExpiresAt) { this.authTokenExpiresAt = authTokenExpiresAt; }
}
@@ -0,0 +1,11 @@
package io.floci.aws.services.emrserverless.model;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
public class GetSessionResponse {
private Session session;
public Session getSession() { return session; }
public void setSession(Session session) { this.session = session; }
}
@@ -0,0 +1,18 @@
package io.floci.aws.services.emrserverless.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.List;
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ListSessionsResponse {
private List<SessionSummary> sessions;
private String nextToken;
public List<SessionSummary> getSessions() { return sessions; }
public void setSessions(List<SessionSummary> sessions) { this.sessions = sessions; }
public String getNextToken() { return nextToken; }
public void setNextToken(String nextToken) { this.nextToken = nextToken; }
}
@@ -0,0 +1,83 @@
package io.floci.aws.services.emrserverless.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.time.Instant;
import java.util.Map;
/** GetSession's session. Timestamps go out as epoch seconds, the restJson1 default. */
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Session {
private String applicationId;
private String sessionId;
private String arn;
private String name;
private String state;
private String stateDetails;
private String releaseLabel;
private String executionRoleArn;
private String createdBy;
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
private Instant createdAt;
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
private Instant updatedAt;
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
private Instant startedAt;
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
private Instant endedAt;
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
private Instant idleSince;
private Map<String, Object> configurationOverrides;
private NetworkConfiguration networkConfiguration;
private Long idleTimeoutMinutes;
private Map<String, String> tags;
private Long totalExecutionDurationSeconds;
public String getApplicationId() { return applicationId; }
public void setApplicationId(String applicationId) { this.applicationId = applicationId; }
public String getSessionId() { return sessionId; }
public void setSessionId(String sessionId) { this.sessionId = sessionId; }
public String getArn() { return arn; }
public void setArn(String arn) { this.arn = arn; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public String getState() { return state; }
public void setState(String state) { this.state = state; }
public String getStateDetails() { return stateDetails; }
public void setStateDetails(String stateDetails) { this.stateDetails = stateDetails; }
public String getReleaseLabel() { return releaseLabel; }
public void setReleaseLabel(String releaseLabel) { this.releaseLabel = releaseLabel; }
public String getExecutionRoleArn() { return executionRoleArn; }
public void setExecutionRoleArn(String executionRoleArn) { this.executionRoleArn = executionRoleArn; }
public String getCreatedBy() { return createdBy; }
public void setCreatedBy(String createdBy) { this.createdBy = createdBy; }
public Instant getCreatedAt() { return createdAt; }
public void setCreatedAt(Instant createdAt) { this.createdAt = createdAt; }
public Instant getUpdatedAt() { return updatedAt; }
public void setUpdatedAt(Instant updatedAt) { this.updatedAt = updatedAt; }
public Instant getStartedAt() { return startedAt; }
public void setStartedAt(Instant startedAt) { this.startedAt = startedAt; }
public Instant getEndedAt() { return endedAt; }
public void setEndedAt(Instant endedAt) { this.endedAt = endedAt; }
public Instant getIdleSince() { return idleSince; }
public void setIdleSince(Instant idleSince) { this.idleSince = idleSince; }
public Map<String, Object> getConfigurationOverrides() { return configurationOverrides; }
public void setConfigurationOverrides(Map<String, Object> configurationOverrides) {
this.configurationOverrides = configurationOverrides;
}
public NetworkConfiguration getNetworkConfiguration() { return networkConfiguration; }
public void setNetworkConfiguration(NetworkConfiguration networkConfiguration) {
this.networkConfiguration = networkConfiguration;
}
public Long getIdleTimeoutMinutes() { return idleTimeoutMinutes; }
public void setIdleTimeoutMinutes(Long idleTimeoutMinutes) { this.idleTimeoutMinutes = idleTimeoutMinutes; }
public Map<String, String> getTags() { return tags; }
public void setTags(Map<String, String> tags) { this.tags = tags; }
public Long getTotalExecutionDurationSeconds() { return totalExecutionDurationSeconds; }
public void setTotalExecutionDurationSeconds(Long totalExecutionDurationSeconds) {
this.totalExecutionDurationSeconds = totalExecutionDurationSeconds;
}
}
@@ -0,0 +1,22 @@
package io.floci.aws.services.emrserverless.model;
import com.fasterxml.jackson.databind.JsonNode;
import io.quarkus.runtime.annotations.RegisterForReflection;
/**
* A stored session: the session as GetSession reports it, plus the client token and the request it came with, which
* decide whether a repeated StartSession is a retry or a conflict.
*/
@RegisterForReflection
public class SessionRecord {
private Session session;
private String clientToken;
private JsonNode request;
public Session getSession() { return session; }
public void setSession(Session session) { this.session = session; }
public String getClientToken() { return clientToken; }
public void setClientToken(String clientToken) { this.clientToken = clientToken; }
public JsonNode getRequest() { return request; }
public void setRequest(JsonNode request) { this.request = request; }
}
@@ -0,0 +1,54 @@
package io.floci.aws.services.emrserverless.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.time.Instant;
/** One of ListSessions' sessions. */
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SessionSummary {
private String applicationId;
private String sessionId;
private String arn;
private String name;
private String state;
private String stateDetails;
private String releaseLabel;
private String executionRoleArn;
private String createdBy;
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
private Instant createdAt;
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
private Instant updatedAt;
public static SessionSummary of(Session session) {
SessionSummary summary = new SessionSummary();
summary.applicationId = session.getApplicationId();
summary.sessionId = session.getSessionId();
summary.arn = session.getArn();
summary.name = session.getName();
summary.state = session.getState();
summary.stateDetails = session.getStateDetails();
summary.releaseLabel = session.getReleaseLabel();
summary.executionRoleArn = session.getExecutionRoleArn();
summary.createdBy = session.getCreatedBy();
summary.createdAt = session.getCreatedAt();
summary.updatedAt = session.getUpdatedAt();
return summary;
}
public String getApplicationId() { return applicationId; }
public String getSessionId() { return sessionId; }
public String getArn() { return arn; }
public String getName() { return name; }
public String getState() { return state; }
public String getStateDetails() { return stateDetails; }
public String getReleaseLabel() { return releaseLabel; }
public String getExecutionRoleArn() { return executionRoleArn; }
public String getCreatedBy() { return createdBy; }
public Instant getCreatedAt() { return createdAt; }
public Instant getUpdatedAt() { return updatedAt; }
}
@@ -0,0 +1,31 @@
package io.floci.aws.services.emrserverless.model;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.Map;
/** StartSession's body. */
@RegisterForReflection
public class StartSessionRequest {
private String clientToken;
private String executionRoleArn;
private Map<String, Object> configurationOverrides;
private Map<String, String> tags;
private Long idleTimeoutMinutes;
private String name;
public String getClientToken() { return clientToken; }
public void setClientToken(String clientToken) { this.clientToken = clientToken; }
public String getExecutionRoleArn() { return executionRoleArn; }
public void setExecutionRoleArn(String executionRoleArn) { this.executionRoleArn = executionRoleArn; }
public Map<String, Object> getConfigurationOverrides() { return configurationOverrides; }
public void setConfigurationOverrides(Map<String, Object> configurationOverrides) {
this.configurationOverrides = configurationOverrides;
}
public Map<String, String> getTags() { return tags; }
public void setTags(Map<String, String> tags) { this.tags = tags; }
public Long getIdleTimeoutMinutes() { return idleTimeoutMinutes; }
public void setIdleTimeoutMinutes(Long idleTimeoutMinutes) { this.idleTimeoutMinutes = idleTimeoutMinutes; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
}
@@ -0,0 +1,17 @@
package io.floci.aws.services.emrserverless.model;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
public class StartSessionResponse {
private String applicationId;
private String sessionId;
private String arn;
public String getApplicationId() { return applicationId; }
public void setApplicationId(String applicationId) { this.applicationId = applicationId; }
public String getSessionId() { return sessionId; }
public void setSessionId(String sessionId) { this.sessionId = sessionId; }
public String getArn() { return arn; }
public void setArn(String arn) { this.arn = arn; }
}
@@ -0,0 +1,14 @@
package io.floci.aws.services.emrserverless.model;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
public class TerminateSessionResponse {
private String applicationId;
private String sessionId;
public String getApplicationId() { return applicationId; }
public void setApplicationId(String applicationId) { this.applicationId = applicationId; }
public String getSessionId() { return sessionId; }
public void setSessionId(String sessionId) { this.sessionId = sessionId; }
}