Class SerializableDurableOperation<T>
java.lang.Object
software.amazon.lambda.durable.operation.BaseDurableOperation
software.amazon.lambda.durable.operation.SerializableDurableOperation<T>
- All Implemented Interfaces:
DurableFuture<T>
- Direct Known Subclasses:
CallbackOperation,ChildContextOperation,ConcurrencyOperation,InvokeOperation,StepOperation,WaitForConditionOperation
public abstract class SerializableDurableOperation<T>
extends BaseDurableOperation
implements DurableFuture<T>
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 inherited from class software.amazon.lambda.durable.operation.BaseDurableOperation
completionFuture, executionManager, parentOperation -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSerializableDurableOperation(OperationIdentifier operationIdentifier, TypeToken<T> resultTypeToken, SerDes resultSerDes, DurableContextImpl durableContext) Constructs a new durable operation.protectedSerializableDurableOperation(OperationIdentifier operationIdentifier, TypeToken<T> resultTypeToken, SerDes resultSerDes, DurableContextImpl durableContext, BaseDurableOperation parentOperation) -
Method Summary
Modifier and TypeMethodDescriptionprotected ThrowabledeserializeException(software.amazon.awssdk.services.lambda.model.ErrorObject errorObject) Deserializes anErrorObjectback into a throwable, reconstructing the original exception type and stack trace when possible.protected TdeserializeResult(String result) Deserializes a result string into the operation's result type.abstract Tget()Blocks until the operation completes and returns the result.protected software.amazon.awssdk.services.lambda.model.ErrorObjectserializeException(Throwable throwable) Serializes a throwable into anErrorObjectfor checkpointing.protected StringserializeResult(T result) Serializes the result to a string.Methods inherited from class software.amazon.lambda.durable.operation.BaseDurableOperation
execute, getChildOperations, getCompletionFuture, getContext, getCurrentThreadContext, getName, getOperation, getOperationId, getSubType, getType, isOperationCompleted, markAlreadyCompleted, onCheckpointComplete, pollForOperationUpdates, pollForOperationUpdates, registerActiveThread, replay, runUserHandler, sendOperationUpdate, sendOperationUpdateAsync, start, terminateExecution, terminateExecutionWithIllegalDurableOperationException, validateReplay, waitForOperationCompletion
-
Constructor Details
-
SerializableDurableOperation
protected SerializableDurableOperation(OperationIdentifier operationIdentifier, TypeToken<T> resultTypeToken, SerDes resultSerDes, DurableContextImpl durableContext) Constructs a new durable operation.- Parameters:
operationIdentifier- the unique identifier for this operationresultTypeToken- the type token for deserializing the resultresultSerDes- the serializer/deserializer for the resultdurableContext- the parent context this operation belongs to
-
SerializableDurableOperation
protected SerializableDurableOperation(OperationIdentifier operationIdentifier, TypeToken<T> resultTypeToken, SerDes resultSerDes, DurableContextImpl durableContext, BaseDurableOperation parentOperation)
-
-
Method Details
-
deserializeResult
Deserializes a result string into the operation's result type.- Parameters:
result- the serialized result string- Returns:
- the deserialized result
- Throws:
SerDesException- if deserialization fails
-
serializeResult
Serializes the result to a string.- Parameters:
result- the result to serialize- Returns:
- the serialized string
-
serializeException
protected software.amazon.awssdk.services.lambda.model.ErrorObject serializeException(Throwable throwable) Serializes a throwable into anErrorObjectfor checkpointing.- Parameters:
throwable- the exception to serialize- Returns:
- the serialized error object
-
deserializeException
protected Throwable deserializeException(software.amazon.awssdk.services.lambda.model.ErrorObject errorObject) Deserializes anErrorObjectback into a throwable, reconstructing the original exception type and stack trace when possible. Falls back to null if the exception class is not found or deserialization fails.- Parameters:
errorObject- the serialized error object- Returns:
- the reconstructed throwable, or null if reconstruction is not possible
-
get
Description copied from interface:DurableFutureBlocks until the operation completes and returns the result.This delegates to operation.get() which handles: - Thread deregistration (allows suspension) - Thread reactivation (resumes execution) - Result retrieval
- Specified by:
getin interfaceDurableFuture<T>- Returns:
- the operation result
-