diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java | 10 | ||||
-rw-r--r-- | main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java | 21 |
2 files changed, 29 insertions, 2 deletions
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java b/main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java index 521413c8..f672ccdd 100644 --- a/main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java +++ b/main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java @@ -125,6 +125,16 @@ public class XacmlState { } /** + * Updates the internal state to Terminated. + * + * @return the current PdpStatus with Terminated state + */ + public PdpStatus terminatePdpMessage() { + status.setState(PdpState.TERMINATED); + return status; + } + + /** * Makes a response to the given message, based on the current state. * * @param message message for which the response should be made diff --git a/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java b/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java index 2a881d45..e7633674 100644 --- a/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java +++ b/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java @@ -22,6 +22,7 @@ package org.onap.policy.pdpx.main.startstop; import java.nio.file.Paths; import java.util.Arrays; +import java.util.Collections; import java.util.Properties; import lombok.Getter; import lombok.Setter; @@ -31,9 +32,11 @@ import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient; import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClientException; import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher; import org.onap.policy.common.parameters.ParameterService; +import org.onap.policy.common.utils.network.NetworkUtil; import org.onap.policy.common.utils.services.ServiceManagerContainer; import org.onap.policy.models.pdp.concepts.PdpStatus; import org.onap.policy.models.pdp.enums.PdpMessageType; +import org.onap.policy.models.pdp.enums.PdpState; import org.onap.policy.pdpx.main.PolicyXacmlPdpRuntimeException; import org.onap.policy.pdpx.main.XacmlState; import org.onap.policy.pdpx.main.comm.XacmlPdpHearbeatPublisher; @@ -89,6 +92,8 @@ public class XacmlPdpActivator extends ServiceManagerContainer { TopicEndpoint.manager.addTopicSources(topicProperties); XacmlPdpHearbeatPublisher heartbeat; + TopicSinkClient sinkClient; + final XacmlState state; try { XacmlPdpApplicationManager appmgr = @@ -99,12 +104,12 @@ public class XacmlPdpActivator extends ServiceManagerContainer { XacmlPdpStatisticsManager.setCurrent(stats); stats.setTotalPolicyTypesCount(appmgr.getPolicyTypeCount()); - XacmlState state = new XacmlState(appmgr); + state = new XacmlState(appmgr); this.xacmlPdpParameterGroup = xacmlPdpParameterGroup; this.msgDispatcher = new MessageTypeDispatcher(MSG_TYPE_NAMES); - TopicSinkClient sinkClient = new TopicSinkClient(TOPIC); + sinkClient = new TopicSinkClient(TOPIC); heartbeat = new XacmlPdpHearbeatPublisher(sinkClient, state); /* @@ -135,6 +140,9 @@ public class XacmlPdpActivator extends ServiceManagerContainer { TopicEndpoint.manager::start, TopicEndpoint.manager::shutdown); + addAction("Terminate PDP", + () -> { }, + () -> sendTerminateMessage(sinkClient, state)); // initial heart beats act as registration messages addAction("Heartbeat Publisher", heartbeat::start, @@ -147,9 +155,18 @@ public class XacmlPdpActivator extends ServiceManagerContainer { addAction("REST server", () -> restServer.start(), () -> restServer.stop()); + // @formatter:on } + /* + * Method used to send a terminate message to the PAP. + */ + private void sendTerminateMessage(TopicSinkClient sinkClient, XacmlState state) { + PdpStatus terminateStatus = state.terminatePdpMessage(); + sinkClient.send(terminateStatus); + } + /** * Get the parameters used by the activator. * |