summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actorServiceProvider
diff options
context:
space:
mode:
Diffstat (limited to 'models-interactions/model-actors/actorServiceProvider')
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java13
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java18
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceProviderTest.java13
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceTest.java13
4 files changed, 19 insertions, 38 deletions
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java
index 22c7d3365..82f744421 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java
@@ -47,10 +47,6 @@ public class ActorService extends StartConfigPartial<Map<String, Map<String, Obj
private final Map<String, Actor> name2actor;
- private static class LazyHolder {
- static final ActorService INSTANCE = new ActorService();
- }
-
/**
* Constructs the object and loads the list of actors.
*/
@@ -85,15 +81,6 @@ public class ActorService extends StartConfigPartial<Map<String, Map<String, Obj
}
/**
- * Get the single instance.
- *
- * @return the instance
- */
- public static ActorService getInstance() {
- return LazyHolder.INSTANCE;
- }
-
- /**
* Gets a particular actor.
*
* @param name name of the actor of interest
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
index ff1b46264..24c7ec866 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
@@ -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
};
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceProviderTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceProviderTest.java
index 139c5179b..cca0694d7 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceProviderTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceProviderTest.java
@@ -23,7 +23,7 @@
package org.onap.policy.controlloop.actorserviceprovider;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
@@ -36,16 +36,11 @@ public class ActorServiceProviderTest {
@Test
public void testActorServiceProvider() {
- ActorService actorService = ActorService.getInstance();
- assertNotNull(actorService);
+ ActorService actorService = new ActorService();
- assertEquals(1, actorService.getActors().size());
+ assertTrue(actorService.getActors().size() >= 1);
- actorService = ActorService.getInstance();
- assertNotNull(actorService);
-
- Actor dummyActor = ActorService.getInstance().getActors().iterator().next();
- assertNotNull(dummyActor);
+ Actor dummyActor = actorService.getActor(DummyActor.class.getSimpleName());
assertEquals("DummyActor", dummyActor.actor());
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceTest.java
index efc7bb830..989fc8d6e 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceTest.java
@@ -215,14 +215,6 @@ public class ActorServiceTest {
}
@Test
- public void testGetInstance() {
- service = ActorService.getInstance();
- assertNotNull(service);
-
- assertSame(service, ActorService.getInstance());
- }
-
- @Test
public void testGetActor() {
assertSame(actor1, service.getActor(ACTOR1));
assertSame(actor3, service.getActor(ACTOR3));
@@ -360,8 +352,9 @@ public class ActorServiceTest {
@Test
public void testLoadActors() {
- assertFalse(ActorService.getInstance().getActors().isEmpty());
- assertNotNull(ActorService.getInstance().getActor("DummyActor"));
+ ActorService service = new ActorService();
+ assertFalse(service.getActors().isEmpty());
+ assertNotNull(service.getActor(DummyActor.class.getSimpleName()));
}
/**