Class ParallelOperation
java.lang.Object
software.amazon.lambda.durable.operation.BaseDurableOperation
software.amazon.lambda.durable.operation.SerializableDurableOperation<T>
software.amazon.lambda.durable.operation.ConcurrencyOperation<ParallelResult>
software.amazon.lambda.durable.operation.ParallelOperation
- All Implemented Interfaces:
AutoCloseable,DurableFuture<ParallelResult>,SafeCloseable,ParallelDurableFuture
public class ParallelOperation
extends ConcurrencyOperation<ParallelResult>
implements ParallelDurableFuture
Manages parallel execution of multiple branches as child context operations.
Extends ConcurrencyOperation to provide parallel-specific behavior:
- Creates branches as
ChildContextOperationwithOperationSubType.PARALLEL_BRANCH - Checkpoints SUCCESS on the parallel context when completion criteria are met
- Returns a
ParallelResultsummarising branch outcomes
Context hierarchy:
DurableContext (root)
└── ParallelOperation context (ChildContextOperation with PARALLEL subtype)
├── Branch 1 context (ChildContextOperation with PARALLEL_BRANCH)
├── Branch 2 context (ChildContextOperation with PARALLEL_BRANCH)
└── Branch N context (ChildContextOperation with PARALLEL_BRANCH)
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.lambda.durable.operation.ConcurrencyOperation
ConcurrencyOperation.ExpectedCompletionStatusNested classes/interfaces inherited from class software.amazon.lambda.durable.operation.SerializableDurableOperation
SerializableDurableOperation.SerializedResult<T> -
Field Summary
Fields inherited from class software.amazon.lambda.durable.operation.ConcurrencyOperation
isJoinedFields inherited from class software.amazon.lambda.durable.operation.BaseDurableOperation
completionFuture, executionManager, isVirtual, parentOperation, replayCompletedOperation -
Constructor Summary
ConstructorsConstructorDescriptionParallelOperation(OperationIdentifier operationIdentifier, SerDes resultSerDes, DurableContextImpl durableContext, ParallelConfig config) -
Method Summary
Modifier and TypeMethodDescription<T> DurableFuture<T>branch(String name, TypeToken<T> resultType, Function<DurableContext, T> func, ParallelBranchConfig config) Registers and immediately starts a branch (respects maxConcurrency).voidclose()Callsget()if not already called.get()Blocks until the operation completes and returns the result.protected voidhandleCompletion(CompletionConfig.CompletionDecision completionDecision) Called when the concurrency operation completes.protected voidreplay(software.amazon.awssdk.services.lambda.model.Operation existing) Replays the operation from an existing checkpoint.protected voidstart()Starts the operation on first execution (no existing checkpoint).Methods inherited from class software.amazon.lambda.durable.operation.ConcurrencyOperation
createItem, enqueueItem, executeItems, executeItems, getBranches, joinMethods inherited from class software.amazon.lambda.durable.operation.SerializableDurableOperation
deserializeException, deserializeResult, serDesContext, serializeAndDeserializeResult, serializeExceptionMethods inherited from class software.amazon.lambda.durable.operation.BaseDurableOperation
deregisterActiveThread, execute, extractErrorFromOperation, fireOnOperationEnd, getChildOperations, getCompletionFuture, getContext, getCurrentThreadContext, getErrorObject, getName, getOperation, getOperationId, getRunningUserHandler, getSubType, getType, interruptRunningUserHandler, isOperationCompleted, isRunningUserHandlerOwner, markAlreadyCompleted, onCheckpointComplete, pollForOperationUpdates, pollForOperationUpdates, processCheckpointUpdate, registerActiveThread, runUserFunction, runUserHandler, sendOperationUpdate, sendOperationUpdateAsync, terminateExecution, terminateExecutionWithIllegalDurableOperationException, validateReplay, waitForFirstOperationCompletion, waitForOperationCompletionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface software.amazon.lambda.durable.ParallelDurableFuture
branch, branch, branch
-
Constructor Details
-
ParallelOperation
public ParallelOperation(OperationIdentifier operationIdentifier, SerDes resultSerDes, DurableContextImpl durableContext, ParallelConfig config)
-
-
Method Details
-
handleCompletion
Description copied from class:ConcurrencyOperationCalled when the concurrency operation completes. Subclasses define checkpointing behavior.- Specified by:
handleCompletionin classConcurrencyOperation<ParallelResult>
-
start
protected void start()Description copied from class:BaseDurableOperationStarts the operation on first execution (no existing checkpoint).- Specified by:
startin classBaseDurableOperation
-
replay
protected void replay(software.amazon.awssdk.services.lambda.model.Operation existing) Description copied from class:BaseDurableOperationReplays the operation from an existing checkpoint.- Specified by:
replayin classBaseDurableOperation- Parameters:
existing- the checkpointed operation state
-
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<ParallelResult>- Specified by:
getin classSerializableDurableOperation<ParallelResult>- Returns:
- the operation result
-
close
public void close()Callsget()if not already called. Guarantees that the context is closed.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSafeCloseable
-
branch
public <T> DurableFuture<T> branch(String name, TypeToken<T> resultType, Function<DurableContext, T> func, ParallelBranchConfig config) Description copied from interface:ParallelDurableFutureRegisters and immediately starts a branch (respects maxConcurrency).- Specified by:
branchin interfaceParallelDurableFuture- Type Parameters:
T- the result type- Parameters:
name- the branch nameresultType- the result type token for generic typesfunc- the function to execute in the branch's child context- Returns:
- a
DurableFuturethat will contain the branch result
-