aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
diff options
context:
space:
mode:
authorjh7358 <jh7358@att.com>2019-10-16 11:51:46 -0400
committerJim Hahn <jrh3@att.com>2019-10-29 11:09:10 -0400
commit4f3fe21aa98a196ef1ddd62e1ac84a6c2e4c13cf (patch)
tree682a1ce5779a094318a0143aeb993ffb4d3ff59d /main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
parent45c8e61888711a3d6f5913d1d7ddf640ff995b12 (diff)
Generate notifications when policies change
Updated existing PAP code to make use of new notification classes. Change-Id: I4637ad92ac4f432f215cfc837e672c75074d88b5 Issue-ID: POLICY-1841 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java')
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java24
1 files changed, 21 insertions, 3 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java b/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
index d119044f..8d2fd3ea 100644
--- a/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
+++ b/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
@@ -31,6 +31,8 @@ import org.onap.policy.common.endpoints.listeners.RequestIdDispatcher;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.common.utils.services.Registry;
import org.onap.policy.common.utils.services.ServiceManagerContainer;
+import org.onap.policy.models.pap.concepts.PolicyNotification;
+import org.onap.policy.models.pdp.concepts.PdpMessage;
import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.models.pdp.enums.PdpMessageType;
import org.onap.policy.pap.main.PapConstants;
@@ -41,6 +43,7 @@ import org.onap.policy.pap.main.comm.PdpModifyRequestMap;
import org.onap.policy.pap.main.comm.PdpTracker;
import org.onap.policy.pap.main.comm.Publisher;
import org.onap.policy.pap.main.comm.TimerManager;
+import org.onap.policy.pap.main.notification.PolicyNotifier;
import org.onap.policy.pap.main.parameters.PapParameterGroup;
import org.onap.policy.pap.main.parameters.PdpModifyRequestMapParams;
import org.onap.policy.pap.main.parameters.PdpParameters;
@@ -112,13 +115,15 @@ public class PapActivator extends ServiceManagerContainer {
final Object pdpUpdateLock = new Object();
final PdpParameters pdpParams = papParameterGroup.getPdpParameters();
- final AtomicReference<Publisher> pdpPub = new AtomicReference<>();
+ final AtomicReference<Publisher<PdpMessage>> pdpPub = new AtomicReference<>();
+ final AtomicReference<Publisher<PolicyNotification>> notifyPub = new AtomicReference<>();
final AtomicReference<TimerManager> pdpUpdTimers = new AtomicReference<>();
final AtomicReference<TimerManager> pdpStChgTimers = new AtomicReference<>();
final AtomicReference<TimerManager> heartBeatTimers = new AtomicReference<>();
final AtomicReference<PolicyModelsProviderFactoryWrapper> daoFactory = new AtomicReference<>();
final AtomicReference<PdpModifyRequestMap> requestMap = new AtomicReference<>();
final AtomicReference<RestServer> restServer = new AtomicReference<>();
+ final AtomicReference<PolicyNotifier> notifier = new AtomicReference<>();
// @formatter:off
addAction("PAP parameters",
@@ -156,11 +161,23 @@ public class PapActivator extends ServiceManagerContainer {
addAction("PDP publisher",
() -> {
- pdpPub.set(new Publisher(PapConstants.TOPIC_POLICY_PDP_PAP));
+ pdpPub.set(new Publisher<>(PapConstants.TOPIC_POLICY_PDP_PAP));
startThread(pdpPub.get());
},
() -> pdpPub.get().stop());
+ addAction("Policy Notification publisher",
+ () -> {
+ notifyPub.set(new Publisher<>(PapConstants.TOPIC_POLICY_NOTIFICATION));
+ startThread(notifyPub.get());
+ notifier.set(new PolicyNotifier(notifyPub.get()));
+ },
+ () -> notifyPub.get().stop());
+
+ addAction("Policy Notifier",
+ () -> Registry.register(PapConstants.REG_POLICY_NOTIFIER, notifier.get()),
+ () -> Registry.unregister(PapConstants.REG_POLICY_NOTIFIER));
+
addAction("PDP heart beat timers",
() -> {
long maxWaitHeartBeatMs = MAX_MISSED_HEARTBEATS * pdpParams.getHeartBeatMs();
@@ -194,7 +211,8 @@ public class PapActivator extends ServiceManagerContainer {
.setDaoFactory(daoFactory.get())
.setModifyLock(pdpUpdateLock)
.setParams(pdpParams)
- .setPublisher(pdpPub.get())
+ .setPolicyNotifier(notifier.get())
+ .setPdpPublisher(pdpPub.get())
.setResponseDispatcher(reqIdDispatcher)
.setStateChangeTimers(pdpStChgTimers.get())
.setUpdateTimers(pdpUpdTimers.get())));