diff options
Diffstat (limited to 'main/src/main')
-rw-r--r-- | main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java | 23 | ||||
-rw-r--r-- | main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java | 5 |
2 files changed, 23 insertions, 5 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 17995fd6..d1e326f1 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 @@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory; * Current state of this XACML PDP. */ public class XacmlState { + // The logger for this class private static final Logger LOGGER = LoggerFactory.getLogger(XacmlState.class); /** @@ -112,6 +113,9 @@ public class XacmlState { PdpStatus status2 = makeResponse(message, ""); + // start/stop rest controller based on state change + handleXacmlRestController(); + // these fields aren't needed in the response, so clear them out to avoid sending status2.setPolicies(null); @@ -165,4 +169,23 @@ public class XacmlState { status2.setResponse(resp); return status2; } + + /** + * Manages the Xacml-Pdp rest controller based on the Xacml-Pdp State. + * Current supported states: + * ACTIVE - rest service is running and handling requests + * PASSIVE - rest service is not running + */ + private void handleXacmlRestController() { + if (status.getState() == PdpState.ACTIVE) { + LOGGER.info("State change: {} - Starting rest controller", status.getState()); + XacmlPdpActivator.getCurrent().startXacmlRestController(); + } else if (status.getState() == PdpState.PASSIVE) { + LOGGER.info("State change: {} - Stopping rest controller", status.getState()); + XacmlPdpActivator.getCurrent().stopXacmlRestController(); + } else { + // unsupported state + LOGGER.warn("Unsupported state: {}", status.getState()); + } + } } 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 050d8b24..892b3835 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 @@ -152,16 +152,11 @@ public class XacmlPdpActivator extends ServiceManagerContainer { addAction("Terminate PDP", () -> { }, () -> sendTerminateMessage(sinkClient, state)); - // initial heart beats act as registration messages addAction("Heartbeat Publisher", heartbeat::start, heartbeat::terminate); - addAction("REST Server", - restServer::start, - restServer::stop); - // @formatter:on } |