|
19 | 19 | import org.slf4j.LoggerFactory; |
20 | 20 | import software.amazon.awssdk.services.lambda.model.ErrorObject; |
21 | 21 | import software.amazon.awssdk.services.lambda.model.Operation; |
22 | | -import software.amazon.awssdk.services.lambda.model.OperationStatus; |
23 | 22 | import software.amazon.awssdk.services.lambda.model.OperationType; |
24 | 23 | import software.amazon.awssdk.services.lambda.model.OperationUpdate; |
25 | 24 |
|
@@ -50,7 +49,7 @@ public abstract class BaseDurableOperation<T> implements DurableFuture<T> { |
50 | 49 | private final ExecutionManager executionManager; |
51 | 50 | private final TypeToken<T> resultTypeToken; |
52 | 51 | private final SerDes resultSerDes; |
53 | | - private final CompletableFuture<Void> completionFuture; |
| 52 | + protected final CompletableFuture<Void> completionFuture; |
54 | 53 |
|
55 | 54 | protected BaseDurableOperation( |
56 | 55 | String operationId, |
@@ -146,7 +145,9 @@ protected Operation waitForOperationCompletion() { |
146 | 145 |
|
147 | 146 | /** Receives operation updates from ExecutionManager and updates the internal state of the operation */ |
148 | 147 | public void onCheckpointComplete(Operation operation) { |
149 | | - if (isTerminalStatus(operation.status())) { |
| 148 | + if (ExecutionManager.isTerminalStatus(operation.status())) { |
| 149 | + // This method handles only terminal status updates. Override this method if a DurableOperation needs to |
| 150 | + // handle other updates. |
150 | 151 | logger.trace("In onCheckpointComplete, completing operation {} ({})", operationId, completionFuture); |
151 | 152 | // It's important that we synchronize access to the future, otherwise the processing could happen |
152 | 153 | // on someone else's thread and cause a race condition. |
@@ -292,12 +293,4 @@ protected void validateReplay(Operation checkpointed) { |
292 | 293 | operationId, checkpointed.name(), getName()))); |
293 | 294 | } |
294 | 295 | } |
295 | | - |
296 | | - private boolean isTerminalStatus(OperationStatus status) { |
297 | | - return status == OperationStatus.SUCCEEDED |
298 | | - || status == OperationStatus.FAILED |
299 | | - || status == OperationStatus.CANCELLED |
300 | | - || status == OperationStatus.TIMED_OUT |
301 | | - || status == OperationStatus.STOPPED; |
302 | | - } |
303 | 296 | } |
0 commit comments