Class BaseDurableOperation<T>
java.lang.Object
software.amazon.lambda.durable.operation.BaseDurableOperation<T>
- All Implemented Interfaces:
DurableFuture<T>
- Direct Known Subclasses:
CallbackOperation,ChildContextOperation,InvokeOperation,StepOperation,WaitOperation
Base class for all durable operations (STEP, WAIT, etc.).
Key methods:
execute()starts the operation (returns immediately)get()blocks until complete and returns the result
The separation allows:
- Starting multiple async operations quickly
- Blocking on results later when needed
- Proper thread coordination via future
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseDurableOperation(String operationId, String name, software.amazon.awssdk.services.lambda.model.OperationType operationType, TypeToken<T> resultTypeToken, SerDes resultSerDes, DurableContext durableContext) -
Method Summary
Modifier and TypeMethodDescriptionprotected ThrowabledeserializeException(software.amazon.awssdk.services.lambda.model.ErrorObject errorObject) protected TdeserializeResult(String result) voidexecute()Starts the operation, processes the operation updates from backend.protected List<software.amazon.awssdk.services.lambda.model.Operation>getChildOperations(String operationId) Gets the direct child Operations of a give context operation.protected DurableContextGets the parent context.protected ThreadContextgetName()Gets the operation name (maybe null).protected software.amazon.awssdk.services.lambda.model.OperationGets the Operation from ExecutionManager and update the replay state from REPLAY to EXECUTE if operation is not found.Gets the unique identifier for this operation.software.amazon.awssdk.services.lambda.model.OperationTypegetType()Gets the operation typeprotected booleanChecks if this operation is completedprotected voidMarks the operation as already completed (in replay).voidonCheckpointComplete(software.amazon.awssdk.services.lambda.model.Operation operation) Receives operation updates from ExecutionManager and updates the internal state of the operationprotected CompletableFuture<software.amazon.awssdk.services.lambda.model.Operation>protected CompletableFuture<software.amazon.awssdk.services.lambda.model.Operation>pollForOperationUpdates(Duration delay) protected voidregisterActiveThread(String threadId) protected abstract voidreplay(software.amazon.awssdk.services.lambda.model.Operation existing) Replays the operation.protected voidsendOperationUpdate(software.amazon.awssdk.services.lambda.model.OperationUpdate.Builder builder) protected CompletableFuture<Void>sendOperationUpdateAsync(software.amazon.awssdk.services.lambda.model.OperationUpdate.Builder builder) protected software.amazon.awssdk.services.lambda.model.ErrorObjectserializeException(Throwable throwable) protected StringserializeResult(T result) protected abstract voidstart()Starts the operation.protected Tprotected Tprotected voidvalidateReplay(software.amazon.awssdk.services.lambda.model.Operation checkpointed) Validates that current operation matches checkpointed operation during replay.protected software.amazon.awssdk.services.lambda.model.OperationWaits for the operation to complete and suspends the execution if no active thread is runningMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface software.amazon.lambda.durable.DurableFuture
get
-
Field Details
-
completionFuture
-
-
Constructor Details
-
BaseDurableOperation
-
-
Method Details
-
getOperationId
Gets the unique identifier for this operation. -
getName
Gets the operation name (maybe null). -
getContext
Gets the parent context. -
getType
public software.amazon.awssdk.services.lambda.model.OperationType getType()Gets the operation type -
execute
public void execute()Starts the operation, processes the operation updates from backend. Does not block. -
start
protected abstract void start()Starts the operation. -
replay
protected abstract void replay(software.amazon.awssdk.services.lambda.model.Operation existing) Replays the operation. -
getOperation
protected software.amazon.awssdk.services.lambda.model.Operation getOperation()Gets the Operation from ExecutionManager and update the replay state from REPLAY to EXECUTE if operation is not found. Operation IDs are globally unique (prefixed for child contexts), so no parentId is needed for lookups.- Returns:
- the operation if found, otherwise null
-
getChildOperations
protected List<software.amazon.awssdk.services.lambda.model.Operation> getChildOperations(String operationId) Gets the direct child Operations of a give context operation.- Parameters:
operationId- the operation id of the context- Returns:
- list of the child Operations
-
isOperationCompleted
protected boolean isOperationCompleted()Checks if this operation is completed -
waitForOperationCompletion
protected software.amazon.awssdk.services.lambda.model.Operation waitForOperationCompletion()Waits for the operation to complete and suspends the execution if no active thread is running -
onCheckpointComplete
public void onCheckpointComplete(software.amazon.awssdk.services.lambda.model.Operation operation) Receives operation updates from ExecutionManager and updates the internal state of the operation -
markAlreadyCompleted
protected void markAlreadyCompleted()Marks the operation as already completed (in replay). -
terminateExecution
-
terminateExecutionWithIllegalDurableOperationException
-
registerActiveThread
-
getCurrentThreadContext
-
pollForOperationUpdates
protected CompletableFuture<software.amazon.awssdk.services.lambda.model.Operation> pollForOperationUpdates() -
pollForOperationUpdates
protected CompletableFuture<software.amazon.awssdk.services.lambda.model.Operation> pollForOperationUpdates(Duration delay) -
sendOperationUpdate
protected void sendOperationUpdate(software.amazon.awssdk.services.lambda.model.OperationUpdate.Builder builder) -
sendOperationUpdateAsync
protected CompletableFuture<Void> sendOperationUpdateAsync(software.amazon.awssdk.services.lambda.model.OperationUpdate.Builder builder) -
deserializeResult
-
serializeResult
-
serializeException
protected software.amazon.awssdk.services.lambda.model.ErrorObject serializeException(Throwable throwable) -
deserializeException
protected Throwable deserializeException(software.amazon.awssdk.services.lambda.model.ErrorObject errorObject) -
validateReplay
protected void validateReplay(software.amazon.awssdk.services.lambda.model.Operation checkpointed) Validates that current operation matches checkpointed operation during replay.
-