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
ConstructorsModifierConstructorDescriptionBaseDurableOperation(String operationId, String name, software.amazon.awssdk.services.lambda.model.OperationType operationType, TypeToken<T> resultTypeToken, SerDes resultSerDes, ExecutionManager executionManager) Convenience constructor for root-context operations where parentId is null.protectedBaseDurableOperation(String operationId, String name, software.amazon.awssdk.services.lambda.model.OperationType operationType, TypeToken<T> resultTypeToken, SerDes resultSerDes, ExecutionManager executionManager, String parentId) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidderegisterActiveThread(String threadId) protected ThrowabledeserializeException(software.amazon.awssdk.services.lambda.model.ErrorObject errorObject) protected TdeserializeResult(String result) abstract voidexecute()Starts the operation.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.protected StringGets the parent context ID.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 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 voidsetCurrentThreadContext(ThreadContext threadContext) 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
-
BaseDurableOperation
public BaseDurableOperation(String operationId, String name, software.amazon.awssdk.services.lambda.model.OperationType operationType, TypeToken<T> resultTypeToken, SerDes resultSerDes, ExecutionManager executionManager) Convenience constructor for root-context operations where parentId is null.
-
-
Method Details
-
getOperationId
Gets the unique identifier for this operation. -
getName
Gets the operation name (maybe null). -
getParentId
Gets the parent context ID. Null for root-context operations, set for child context operations. -
getType
public software.amazon.awssdk.services.lambda.model.OperationType getType()Gets the operation type -
execute
public abstract void execute()Starts the operation. Returns immediately after starting background work or checkpointing. Does not block. -
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
-
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
-
deregisterActiveThread
-
registerActiveThread
-
getCurrentThreadContext
-
setCurrentThreadContext
-
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.
-