Eliminate a couple more xxxAsync calls in Actors 49/102349/2
authorJim Hahn <jrh3@att.com>
Tue, 25 Feb 2020 23:33:47 +0000 (18:33 -0500)
committerJim Hahn <jrh3@att.com>
Tue, 25 Feb 2020 23:36:19 +0000 (18:36 -0500)
Eliminated a few more xxxAsync calls in Actors.  Now, the remaining
xxxAsync calls are necessary so that the callbacks are executed using
the executor specified via the "params".

Issue-ID: POLICY-1625
Signed-off-by: Jim Hahn <jrh3@att.com>
Change-Id: Ia4ff758f71f8bbe014ae5b1a58d8439c0d4ea2ed

models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java

index ff1b462..24c7ec8 100644 (file)
@@ -68,6 +68,14 @@ import org.slf4j.LoggerFactory;
  * returned by overridden methods will do the same. Of course, if a class overrides
  * {@link #doOperation(int, OperationOutcome) doOperation()}, then there's little that can
  * be done to cancel that particular operation.
+ * <p/>
+ * In general tasks in a pipeline are executed by the same thread. However, the following
+ * should always be executed via the executor specified in "params":
+ * <ul>
+ * <li>start callback</li>
+ * <li>completion callback</li>
+ * <li>controller completion (i.e., delayedComplete())</li>
+ * </ul>
  */
 public abstract class OperationPartial implements Operation {
     private static final Logger logger = LoggerFactory.getLogger(OperationPartial.class);
@@ -558,8 +566,7 @@ public abstract class OperationPartial implements Operation {
      *         canceled. Similarly, when this future completes, any incomplete futures
      *         will be canceled
      */
-    public CompletableFuture<OperationOutcome> anyOf(
-                    List<Supplier<CompletableFuture<OperationOutcome>>> futureMakers) {
+    public CompletableFuture<OperationOutcome> anyOf(List<Supplier<CompletableFuture<OperationOutcome>>> futureMakers) {
 
         PipelineControllerFuture<OperationOutcome> controller = new PipelineControllerFuture<>();
 
@@ -610,8 +617,7 @@ public abstract class OperationPartial implements Operation {
      *         canceled. Similarly, when this future completes, any incomplete futures
      *         will be canceled
      */
-    public CompletableFuture<OperationOutcome> allOf(
-                    List<Supplier<CompletableFuture<OperationOutcome>>> futureMakers) {
+    public CompletableFuture<OperationOutcome> allOf(List<Supplier<CompletableFuture<OperationOutcome>>> futureMakers) {
         PipelineControllerFuture<OperationOutcome> controller = new PipelineControllerFuture<>();
 
         Queue<OperationOutcome> outcomes = new LinkedList<>();
@@ -809,7 +815,7 @@ public abstract class OperationPartial implements Operation {
 
         // @formatter:off
         controller.wrap(nextTask)
-                    .thenComposeAsync(nextTaskOnSuccess(controller, queue), executor)
+                    .thenCompose(nextTaskOnSuccess(controller, queue))
                     .whenCompleteAsync(controller.delayedComplete(), executor);
         // @formatter:on
 
@@ -843,7 +849,7 @@ public abstract class OperationPartial implements Operation {
             // @formatter:off
             return controller
                         .wrap(nextTask)
-                        .thenComposeAsync(nextTaskOnSuccess(controller, taskQueue), params.getExecutor());
+                        .thenCompose(nextTaskOnSuccess(controller, taskQueue));
             // @formatter:on
         };
     }