feat(stepfunctions): dispatch the seven Task service integrations of #2663 (#2686)

* feat(sfn): support the aws-sdk:sfn:startSyncExecution task integration

Calling an Express child workflow from a Standard parent goes through
arn:aws:states:::aws-sdk:sfn:startSyncExecution, which reached the end of the
dispatch chain and failed with "Unsupported resource".

The integration reuses the existing StartSyncExecution service call and differs
from the optimized states:startExecution.sync integration in two observable
ways: the response envelope uses PascalCase field names with Output as a JSON
string, and a child execution that fails is reported through Status instead of
failing the calling task.

* feat(stepfunctions): dispatch the six remaining Task service integrations

events:putEvents, aws-sdk:sfn:startExecution, aws-sdk:sfn:sendTaskSuccess,
aws-sdk:sfn:sendTaskFailure, aws-sdk:scheduler:createSchedule and
aws-sdk:scheduler:updateSchedule reached the end of the dispatch chain in
invokeResource and failed with "Unsupported resource", although Floci already
serves all six APIs. Each branch maps the Task Arguments onto the client the
direct call already goes through: putEvents onto EventBridgeHandler, and the
scheduler pair onto the controller's own parse and SchedulerService.

Two conventions of the aws-sdk: integrations, measured against us-east-1 through
test-state, now hold for the whole family and correct the startSyncExecution
envelope with them. A timestamp is the SDK's ISO-8601 rendering rather than the
epoch seconds the wire response carries, and an error names the SDK exception
class, so it always ends in Exception.

SendTaskSuccess and SendTaskFailure report whether the token resolved a waiting
task, which is what lets the Task integration fail with Sfn.InvalidTokenException
instead of reporting a delivery that never happened. The direct API keeps
tolerating an unknown token.

Closes #2663

* fix(stepfunctions): make scheduler argument validation reachable for Retry and Catch

parseScheduleRequest raises the same AwsException the scheduler service raises,
so a Task whose Target.EventBridgeParameters is incomplete failed the execution
with States.Runtime and skipped the state's Catch. It now runs inside the same
translation as the service call and fails with Scheduler.ValidationException.

* fix(scheduler): answer a malformed EcsParameters list with ValidationException

A CapacityProviderStrategy, PlacementConstraints, PlacementStrategy or Tags list
holding anything but objects made ObjectMapper.convertValue raise
IllegalArgumentException, which CreateSchedule and UpdateSchedule answered with
a server error and the aws-sdk:scheduler Task integration turned into
States.Runtime. The conversion failure is now named per field and carries the
400 the rest of the parser's validations carry.

* fix(scheduler): answer a malformed awsvpcConfiguration list with ValidationException

Subnets and SecurityGroups went through a bare ObjectMapper.convertValue, so an
element that is not a string left the same unhandled IllegalArgumentException the
EcsParameters object lists left. They now read through a stringList sibling of
mapList and carry the parser's 400.

* test(stepfunctions): pass the scheduler and eventbridge dependencies to the executor under test

* fix(scheduler): refuse a scalar in an awsvpcConfiguration list instead of coercing it

* fix(scheduler): refuse a non-list EcsParameters field instead of dropping it

* test(stepfunctions): catch a malformed scheduler list as the SDK exception AWS sends

---------

Co-authored-by: Facundo Paredes <naranjax@MAC-69786.local>
Co-authored-by: Facundo Paredes <25681464+facuparedes@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-08-28 22:21:48 -04:00
1 parent a155e66b15
commit 14112b8ace
21 files changed
+1744 -33

No files matched your search

@@ -354,7 +354,12 @@ public class SchedulerController {
return null;
}
private ScheduleRequest parseScheduleRequest(JsonNode node) {
/**
* Reads the PascalCase CreateSchedule / UpdateSchedule body. The Step Functions
* {@code aws-sdk:scheduler:*} Task integrations pass the same shape as {@code Arguments},
* so they parse it here instead of restating the mapping.
*/
public ScheduleRequest parseScheduleRequest(JsonNode node) {
ScheduleRequest req = new ScheduleRequest();
req.setGroupName(textField(node, "GroupName"));
req.setScheduleExpression(textField(node, "ScheduleExpression"));
@@ -471,8 +476,8 @@ public class SchedulerController {
private EcsParameters parseEcsParameters(JsonNode node) {
EcsParameters ecs = new EcsParameters();
if (node.has("CapacityProviderStrategy") && node.get("CapacityProviderStrategy").isArray()) {
ecs.setCapacityProviderStrategy(mapList(node.get("CapacityProviderStrategy")));
if (node.has("CapacityProviderStrategy") && !node.get("CapacityProviderStrategy").isNull()) {
ecs.setCapacityProviderStrategy(mapList("CapacityProviderStrategy", node.get("CapacityProviderStrategy")));
}
if (node.has("EnableECSManagedTags") && !node.get("EnableECSManagedTags").isNull()) {
ecs.setEnableECSManagedTags(node.get("EnableECSManagedTags").asBoolean());
@@ -489,11 +494,11 @@ public class SchedulerController {
if (node.has("LaunchType") && !node.get("LaunchType").isNull()) {
ecs.setLaunchType(node.get("LaunchType").asText());
}
if (node.has("PlacementConstraints") && node.get("PlacementConstraints").isArray()) {
ecs.setPlacementConstraints(mapList(node.get("PlacementConstraints")));
if (node.has("PlacementConstraints") && !node.get("PlacementConstraints").isNull()) {
ecs.setPlacementConstraints(mapList("PlacementConstraints", node.get("PlacementConstraints")));
}
if (node.has("PlacementStrategy") && node.get("PlacementStrategy").isArray()) {
ecs.setPlacementStrategy(mapList(node.get("PlacementStrategy")));
if (node.has("PlacementStrategy") && !node.get("PlacementStrategy").isNull()) {
ecs.setPlacementStrategy(mapList("PlacementStrategy", node.get("PlacementStrategy")));
}
if (node.has("TaskCount") && !node.get("TaskCount").isNull()) {
ecs.setTaskCount(node.get("TaskCount").asInt());
@@ -507,8 +512,8 @@ public class SchedulerController {
if (node.has("ReferenceId") && !node.get("ReferenceId").isNull()) {
ecs.setReferenceId(node.get("ReferenceId").asText());
}
if (node.has("Tags") && node.get("Tags").isArray()) {
ecs.setTags(mapList(node.get("Tags")));
if (node.has("Tags") && !node.get("Tags").isNull()) {
ecs.setTags(mapList("Tags", node.get("Tags")));
}
if (node.has("NetworkConfiguration") && !node.get("NetworkConfiguration").isNull()) {
ecs.setNetworkConfiguration(parseNetworkConfiguration(node.get("NetworkConfiguration")));
@@ -516,10 +521,49 @@ public class SchedulerController {
return ecs;
}
private List<Map<String, Object>> mapList(JsonNode node) {
return objectMapper.convertValue(node,
objectMapper.getTypeFactory().constructCollectionType(List.class,
objectMapper.getTypeFactory().constructMapType(Map.class, String.class, Object.class)));
/**
* Reads one of the {@code EcsParameters} lists of objects. An element that is not an object is a
* malformed body, which AWS answers with 400 {@code SerializationException}, so the conversion
* failure is named here instead of escaping as a server error.
*/
private List<Map<String, Object>> mapList(String field, JsonNode node) {
if (!node.isArray()) {
throw malformedList(field, "objects");
}
try {
return objectMapper.convertValue(node,
objectMapper.getTypeFactory().constructCollectionType(List.class,
objectMapper.getTypeFactory().constructMapType(Map.class, String.class, Object.class)));
} catch (IllegalArgumentException e) {
throw malformedList(field, "objects");
}
}
/**
* {@link #mapList(String, JsonNode)} for the {@code awsvpcConfiguration} lists of strings.
* A number or a boolean is checked before the conversion because Jackson writes it out as a
* string rather than refusing it, which would store a value AWS never accepts.
*/
private List<String> stringList(String field, JsonNode node) {
if (!node.isArray()) {
throw malformedList(field, "strings");
}
for (JsonNode element : node) {
if (!element.isTextual()) {
throw malformedList(field, "strings");
}
}
try {
return objectMapper.convertValue(node,
objectMapper.getTypeFactory().constructCollectionType(List.class, String.class));
} catch (IllegalArgumentException e) {
throw malformedList(field, "strings");
}
}
private AwsException malformedList(String field, String elementType) {
return new AwsException("SerializationException",
"EcsParameters " + field + " must be a list of " + elementType + ".", 400);
}
private NetworkConfiguration parseNetworkConfiguration(JsonNode node) {
@@ -532,11 +576,11 @@ public class SchedulerController {
private AwsVpcConfiguration parseAwsVpcConfiguration(JsonNode node) {
AwsVpcConfiguration vpc = new AwsVpcConfiguration();
if (node.has("Subnets") && node.get("Subnets").isArray()) {
vpc.setSubnets(objectMapper.convertValue(node.get("Subnets"), objectMapper.getTypeFactory().constructCollectionType(List.class, String.class)));
if (node.has("Subnets") && !node.get("Subnets").isNull()) {
vpc.setSubnets(stringList("Subnets", node.get("Subnets")));
}
if (node.has("SecurityGroups") && node.get("SecurityGroups").isArray()) {
vpc.setSecurityGroups(objectMapper.convertValue(node.get("SecurityGroups"), objectMapper.getTypeFactory().constructCollectionType(List.class, String.class)));
if (node.has("SecurityGroups") && !node.get("SecurityGroups").isNull()) {
vpc.setSecurityGroups(stringList("SecurityGroups", node.get("SecurityGroups")));
}
if (node.has("AssignPublicIp") && !node.get("AssignPublicIp").isNull()) {
vpc.setAssignPublicIp(node.get("AssignPublicIp").asText());
@@ -10,6 +10,7 @@ import io.github.hectorvent.floci.services.cloudformation.CloudFormationQueryHan
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbService;
import io.github.hectorvent.floci.services.ec2.Ec2Service;
import io.github.hectorvent.floci.services.eventbridge.EventBridgeHandler;
import io.github.hectorvent.floci.services.ecs.EcsJsonHandler;
import io.github.hectorvent.floci.services.ecs.EcsService;
import io.github.hectorvent.floci.services.ecs.model.ContainerDefinition;
@@ -19,6 +20,10 @@ import io.github.hectorvent.floci.services.ecs.model.NetworkConfiguration;
import io.github.hectorvent.floci.services.ecs.model.TaskDefinition;
import io.github.hectorvent.floci.services.ecs.model.LaunchType;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.services.scheduler.SchedulerController;
import io.github.hectorvent.floci.services.scheduler.SchedulerService;
import io.github.hectorvent.floci.services.scheduler.model.Schedule;
import io.github.hectorvent.floci.services.scheduler.model.ScheduleRequest;
import io.github.hectorvent.floci.services.lambda.LambdaExecutorService;
import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.lambda.model.InvocationType;
@@ -60,6 +65,9 @@ import org.jboss.logging.Logger;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -106,6 +114,17 @@ public class AslExecutor {
private static final long ECS_SYNC_POLL_INTERVAL_MS = 100;
private static final String QUERY_LANGUAGE_JSONATA = "JSONata";
private static final String AWS_SDK_SFN_PREFIX = "arn:aws:states:::aws-sdk:sfn:";
private static final String AWS_SDK_SCHEDULER_PREFIX = "arn:aws:states:::aws-sdk:scheduler:";
/**
* A timestamp inside an {@code aws-sdk:} Task result is the SDK's ISO-8601 rendering of an
* {@code Instant} — {@code 2026-08-28T20:34:59.712Z} — where the same field on the wire
* response of the underlying API carries epoch seconds.
*/
private static final DateTimeFormatter SDK_TIMESTAMP =
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").withZone(ZoneOffset.UTC);
private static final Set<String> HTTP_ALLOWED_METHODS = Set.of(
"GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD");
private static final Set<String> HTTP_FORBIDDEN_HEADERS = Set.of(
@@ -152,6 +171,9 @@ public class AslExecutor {
private final S3Service s3Service;
private final EcsService ecsService;
private final EcsJsonHandler ecsJsonHandler;
private final EventBridgeHandler eventBridgeHandler;
private final SchedulerService schedulerService;
private final SchedulerController schedulerController;
private final ObjectMapper objectMapper;
private final JsonataEvaluator jsonataEvaluator;
private final Instance<StepFunctionsService> sfnService;
@@ -170,6 +192,8 @@ public class AslExecutor {
SqsJsonHandler sqsJsonHandler, CloudFormationQueryHandler cloudFormationHandler,
Ec2Service ec2Service, S3Service s3Service,
EcsService ecsService, EcsJsonHandler ecsJsonHandler,
EventBridgeHandler eventBridgeHandler, SchedulerService schedulerService,
SchedulerController schedulerController,
ObjectMapper objectMapper, JsonataEvaluator jsonataEvaluator,
Instance<StepFunctionsService> sfnService, EmulatorConfig config, Vertx vertx) {
this.lambdaExecutor = lambdaExecutor;
@@ -182,6 +206,9 @@ public class AslExecutor {
this.s3Service = s3Service;
this.ecsService = ecsService;
this.ecsJsonHandler = ecsJsonHandler;
this.eventBridgeHandler = eventBridgeHandler;
this.schedulerService = schedulerService;
this.schedulerController = schedulerController;
this.objectMapper = objectMapper;
this.jsonataEvaluator = jsonataEvaluator;
this.sfnService = sfnService;
@@ -798,6 +825,26 @@ public class AslExecutor {
return invokeEcsRunTask(mode, input, region);
}
// AWS SDK service integrations: Step Functions
if (resource.startsWith(AWS_SDK_SFN_PREFIX)) {
String action = resource.substring(AWS_SDK_SFN_PREFIX.length());
String region = extractRegionFromArn(sm.getStateMachineArn());
return invokeAwsSdkSfn(action, input, region);
}
// AWS SDK service integrations: EventBridge Scheduler
if (resource.startsWith(AWS_SDK_SCHEDULER_PREFIX)) {
String action = resource.substring(AWS_SDK_SCHEDULER_PREFIX.length());
String region = extractRegionFromArn(sm.getStateMachineArn());
return invokeAwsSdkScheduler(action, input, region);
}
// EventBridge optimized integration
if (resource.equals("arn:aws:states:::events:putEvents")) {
String region = extractRegionFromArn(sm.getStateMachineArn());
return invokeOptimizedPutEvents(input, region);
}
// Nested state machine integration
if (resource.startsWith("arn:aws:states:::states:startExecution")) {
String mode = resource.substring("arn:aws:states:::states:startExecution".length());
@@ -922,6 +969,194 @@ public class AslExecutor {
return s.isEmpty() ? s : Character.toUpperCase(s.charAt(0)) + s.substring(1);
}
/**
* The {@code arn:aws:states:::aws-sdk:sfn:*} family. Every one of these calls Step Functions'
* own API and returns its raw response, which is what separates
* {@code aws-sdk:sfn:startExecution} from the optimized {@code states:startExecution}
* handled by {@link #invokeNestedStateMachine}.
*/
private JsonNode invokeAwsSdkSfn(String action, JsonNode input, String region) throws Exception {
return switch (action) {
case "startExecution" -> invokeAwsSdkSfnStartExecution(input, region);
case "startSyncExecution" -> invokeAwsSdkSfnStartSyncExecution(input, region);
case "sendTaskSuccess" -> invokeAwsSdkSfnSendTaskSuccess(input);
case "sendTaskFailure" -> invokeAwsSdkSfnSendTaskFailure(input);
default -> throw new FailStateException("States.TaskFailed",
"Unsupported resource: " + AWS_SDK_SFN_PREFIX + action);
};
}
/**
* An {@code aws-sdk:} Task failure carries the name of the SDK exception class, which always
* ends in {@code Exception}. AWS answers a missing state machine with
* {@code Sfn.StateMachineDoesNotExistException}, while the StartExecution wire response names
* that same error {@code StateMachineDoesNotExist}.
*/
private static String sdkExceptionName(String service, String errorCode) {
return errorCode.endsWith("Exception")
? service + "." + errorCode
: service + "." + errorCode + "Exception";
}
private static String sdkTimestamp(double epochSeconds) {
return SDK_TIMESTAMP.format(Instant.ofEpochMilli(Math.round(epochSeconds * 1000)));
}
/**
* Reads an SDK payload argument such as {@code Input} or {@code Output}. Its AWS type is a JSON
* string; AWS also accepts the object form and serializes it, and an absent one is an empty
* object.
*/
private String sdkPayload(JsonNode node) throws Exception {
if (node.isMissingNode() || node.isNull()) {
return "{}";
}
return node.isTextual() ? node.asText() : objectMapper.writeValueAsString(node);
}
/**
* AWS SDK integration for {@code sfn:startExecution}. Unlike the optimized
* {@code states:startExecution}, which returns {@code executionArn} and {@code startDate} in
* the casing of the wire response, this one returns the SDK's own {@code ExecutionArn} and an
* ISO-8601 {@code StartDate}. Neither waits for the child.
*/
private JsonNode invokeAwsSdkSfnStartExecution(JsonNode input, String region) throws Exception {
String smArn = input.path("StateMachineArn").asText(null);
if (smArn == null || smArn.isBlank()) {
throw new FailStateException("Sfn.InvalidArnException",
"StateMachineArn is required for StartExecution");
}
io.github.hectorvent.floci.services.stepfunctions.model.Execution exec;
try {
exec = sfnService.get().startExecution(smArn, input.path("Name").asText(null),
sdkPayload(input.path("Input")), region);
} catch (AwsException e) {
throw new FailStateException(sdkExceptionName("Sfn", e.getErrorCode()), e.getMessage());
}
ObjectNode response = objectMapper.createObjectNode();
response.put("ExecutionArn", exec.getExecutionArn());
response.put("StartDate", sdkTimestamp(exec.getStartDate()));
return response;
}
/**
* AWS SDK integration for {@code sfn:sendTaskSuccess}. AWS fails the calling task with
* {@code Sfn.InvalidTokenException} when the token names no waiting task, so a token that
* resolved nothing is never reported as a delivered result.
*/
private JsonNode invokeAwsSdkSfnSendTaskSuccess(JsonNode input) throws Exception {
String taskToken = input.path("TaskToken").asText(null);
if (!sfnService.get().sendTaskSuccess(taskToken, sdkPayload(input.path("Output")))) {
throw new FailStateException("Sfn.InvalidTokenException", "Invalid Token: 'Invalid token'");
}
return objectMapper.createObjectNode();
}
/** AWS SDK integration for {@code sfn:sendTaskFailure}, token semantics as in SendTaskSuccess. */
private JsonNode invokeAwsSdkSfnSendTaskFailure(JsonNode input) {
String taskToken = input.path("TaskToken").asText(null);
if (!sfnService.get().sendTaskFailure(taskToken, input.path("Cause").asText(null),
input.path("Error").asText(null))) {
throw new FailStateException("Sfn.InvalidTokenException", "Invalid Token: 'Invalid token'");
}
return objectMapper.createObjectNode();
}
/**
* AWS SDK integrations for {@code scheduler:createSchedule} and {@code scheduler:updateSchedule}.
* The Task {@code Arguments} are the CreateSchedule body with {@code Name} folded in, so they go
* through the controller's parse, and both actions answer with the schedule ARN alone. The parse
* rejects a malformed {@code Target} with the same {@code AwsException} the service raises, so it
* belongs inside the translation that makes those failures reachable for {@code Retry} and
* {@code Catch}.
*/
private JsonNode invokeAwsSdkScheduler(String action, JsonNode input, String region) {
boolean creating = "createSchedule".equals(action);
if (!creating && !"updateSchedule".equals(action)) {
throw new FailStateException("States.TaskFailed",
"Unsupported resource: " + AWS_SDK_SCHEDULER_PREFIX + action);
}
try {
ScheduleRequest request = schedulerController.parseScheduleRequest(input);
request.setName(input.path("Name").asText(null));
Schedule schedule = creating
? schedulerService.createSchedule(request, region)
: schedulerService.updateSchedule(request, region);
ObjectNode response = objectMapper.createObjectNode();
response.put("ScheduleArn", schedule.getArn());
return response;
} catch (AwsException e) {
throw new FailStateException(sdkExceptionName("Scheduler", e.getErrorCode()), e.getMessage());
}
}
/**
* Optimized EventBridge integration for {@code events:putEvents}. The task result is the
* PutEvents response itself, and one failed entry fails the whole task with
* {@code EventBridge.FailedEntry}, carrying the response as the cause so the caller can see
* which entry it was.
*/
private JsonNode invokeOptimizedPutEvents(JsonNode input, String region) throws Exception {
jakarta.ws.rs.core.Response response;
try {
response = eventBridgeHandler.handle("PutEvents", input, region);
} catch (AwsException e) {
throw new FailStateException(sdkExceptionName("EventBridge", e.getErrorCode()), e.getMessage());
}
if (!(response.getEntity() instanceof JsonNode result)) {
throw new FailStateException("EventBridge.SdkClientException", "PutEvents returned no response body");
}
if (result.path("FailedEntryCount").asInt() > 0) {
throw new FailStateException("EventBridge.FailedEntry", objectMapper.writeValueAsString(result));
}
return result;
}
/**
* AWS SDK integration for {@code sfn:startSyncExecution}, the way an EXPRESS child workflow is
* called. It differs from the optimized {@code states:startExecution.sync} integration in three
* ways: the child must be EXPRESS, the response envelope uses PascalCase field names with
* {@code Output} as a JSON string, and a child execution that fails is reported through
* {@code Status} rather than failing the calling task.
*/
private JsonNode invokeAwsSdkSfnStartSyncExecution(JsonNode input, String region) throws Exception {
String smArn = input.path("StateMachineArn").asText(null);
if (smArn == null || smArn.isBlank()) {
throw new FailStateException("Sfn.InvalidArnException",
"StateMachineArn is required for StartSyncExecution");
}
io.github.hectorvent.floci.services.stepfunctions.model.Execution exec;
try {
exec = sfnService.get().startSyncExecution(smArn, input.path("Name").asText(null),
sdkPayload(input.path("Input")), region);
} catch (AwsException e) {
throw new FailStateException(sdkExceptionName("Sfn", e.getErrorCode()), e.getMessage());
}
ObjectNode envelope = objectMapper.createObjectNode();
envelope.put("ExecutionArn", exec.getExecutionArn());
envelope.put("StateMachineArn", exec.getStateMachineArn());
envelope.put("Name", exec.getName());
envelope.put("Status", exec.getStatus());
envelope.put("StartDate", sdkTimestamp(exec.getStartDate()));
if (exec.getStopDate() != null) {
envelope.put("StopDate", sdkTimestamp(exec.getStopDate()));
}
if (exec.getInput() != null) {
envelope.put("Input", exec.getInput());
}
if (exec.getOutput() != null) {
envelope.put("Output", exec.getOutput());
}
if (exec.getError() != null) {
envelope.put("Error", exec.getError());
}
if (exec.getCause() != null) {
envelope.put("Cause", exec.getCause());
}
return envelope;
}
private JsonNode invokeNestedStateMachine(String mode, JsonNode input, String region) throws Exception {
String smArn = input.path("StateMachineArn").asText(null);
if (smArn == null || smArn.isBlank()) {
@@ -727,26 +727,37 @@ public class StepFunctionsService implements Resettable, ResourceProvider {
// ──────────────────────────── Tasks ────────────────────────────
public void sendTaskSuccess(String taskToken, String output) {
CompletableFuture<JsonNode> future = pendingTaskTokens.remove(taskToken);
if (future != null) {
try {
future.complete(objectMapper.readTree(output));
} catch (Exception e) {
future.completeExceptionally(new RuntimeException("Invalid JSON output: " + e.getMessage()));
}
} else {
/**
* @return whether the token named a task that was waiting for it. The
* {@code aws-sdk:sfn:sendTaskSuccess} Task integration fails the calling state when it
* did not, the way AWS answers an unknown token with {@code InvalidToken}.
*/
public boolean sendTaskSuccess(String taskToken, String output) {
CompletableFuture<JsonNode> future = taskToken != null ? pendingTaskTokens.remove(taskToken) : null;
if (future == null) {
LOG.warnv("SendTaskSuccess: no pending task for token {0}", taskToken);
return false;
}
try {
future.complete(objectMapper.readTree(output));
} catch (Exception e) {
future.completeExceptionally(new RuntimeException("Invalid JSON output: " + e.getMessage()));
}
return true;
}
public void sendTaskFailure(String taskToken, String cause, String error) {
CompletableFuture<JsonNode> future = pendingTaskTokens.remove(taskToken);
if (future != null) {
future.completeExceptionally(new AslExecutor.FailStateException(error, cause));
} else {
/**
* @return whether the token named a task that was waiting for it, as in
* {@link #sendTaskSuccess(String, String)}.
*/
public boolean sendTaskFailure(String taskToken, String cause, String error) {
CompletableFuture<JsonNode> future = taskToken != null ? pendingTaskTokens.remove(taskToken) : null;
if (future == null) {
LOG.warnv("SendTaskFailure: no pending task for token {0}", taskToken);
return false;
}
future.completeExceptionally(new AslExecutor.FailStateException(error, cause));
return true;
}
public void sendTaskHeartbeat(String taskToken) {