Class ConcurrencyOperation<T>
java.lang.Object
software.amazon.lambda.durable.operation.BaseDurableOperation
software.amazon.lambda.durable.operation.SerializableDurableOperation<T>
software.amazon.lambda.durable.operation.ConcurrencyOperation<T>
- Type Parameters:
T- the result type of this operation
- All Implemented Interfaces:
DurableFuture<T>
- Direct Known Subclasses:
MapOperation,ParallelOperation
Abstract base class for concurrent execution of multiple child context operations.
Encapsulates shared concurrency logic: queue-based concurrency control, success/failure counting, and completion
checking. Both ParallelOperation and MapOperation extend this base.
Key design points:
- Does NOT register its own thread — child context threads handle all suspension
- Uses a pending queue + running counter for concurrency control
- Completion is determined by subclass-specific logic via abstract
canComplete()andvalidateItemCount() - When a child suspends, the running count is NOT decremented
-
Field Summary
FieldsFields inherited from class software.amazon.lambda.durable.operation.BaseDurableOperation
completionFuture, executionManager, parentOperation -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConcurrencyOperation(OperationIdentifier operationIdentifier, TypeToken<T> resultTypeToken, SerDes resultSerDes, DurableContextImpl durableContext, int maxConcurrency, Integer minSuccessful, Integer toleratedFailureCount) -
Method Summary
Modifier and TypeMethodDescriptionprotected <R> ChildContextOperation<R>createItem(String operationId, String name, Function<DurableContext, R> function, TypeToken<R> resultType, SerDes serDes, OperationSubType branchSubType, DurableContextImpl parentContext) Creates a child context operation for a single item (branch or iteration).protected <R> ChildContextOperation<R>enqueueItem(String name, Function<DurableContext, R> function, TypeToken<R> resultType, SerDes serDes, OperationSubType branchSubType) Creates and enqueues an item without starting execution.protected voidStarts execution of all enqueued items.protected List<ChildContextOperation<?>>protected abstract voidhandleCompletion(ConcurrencyCompletionStatus concurrencyCompletionStatus) Called when the concurrency operation completes.protected voidjoin()Blocks the calling thread until the concurrency operation reaches a terminal state.Methods inherited from class software.amazon.lambda.durable.operation.SerializableDurableOperation
deserializeException, deserializeResult, get, serializeException, serializeResultMethods 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
-
Field Details
-
isJoined
-
-
Constructor Details
-
ConcurrencyOperation
protected ConcurrencyOperation(OperationIdentifier operationIdentifier, TypeToken<T> resultTypeToken, SerDes resultSerDes, DurableContextImpl durableContext, int maxConcurrency, Integer minSuccessful, Integer toleratedFailureCount)
-
-
Method Details
-
createItem
protected <R> ChildContextOperation<R> createItem(String operationId, String name, Function<DurableContext, R> function, TypeToken<R> resultType, SerDes serDes, OperationSubType branchSubType, DurableContextImpl parentContext) Creates a child context operation for a single item (branch or iteration).- Type Parameters:
R- the result type of the child operation- Parameters:
operationId- the unique operation ID for this itemname- the name of this itemfunction- the user function to executeresultType- the result type tokenbranchSubType- the sub-type of the branch operationparentContext- the parent durable context- Returns:
- a new ChildContextOperation
-
handleCompletion
Called when the concurrency operation completes. Subclasses define checkpointing behavior. -
enqueueItem
protected <R> ChildContextOperation<R> enqueueItem(String name, Function<DurableContext, R> function, TypeToken<R> resultType, SerDes serDes, OperationSubType branchSubType) Creates and enqueues an item without starting execution. UseexecuteItems()to begin execution after all items have been enqueued. This prevents early termination from blocking item creation when all items are known upfront (e.g., map operations). -
executeItems
protected void executeItems()Starts execution of all enqueued items. -
join
protected void join()Blocks the calling thread until the concurrency operation reaches a terminal state. Validates item count, handles zero-branch case, then delegates towaitForOperationCompletion()from BaseDurableOperation. -
getBranches
-