diff options
author | ramverma <ram.krishna.verma@est.tech> | 2019-02-05 10:28:22 +0000 |
---|---|---|
committer | ramverma <ram.krishna.verma@est.tech> | 2019-02-05 10:28:22 +0000 |
commit | 370c227614be2b63c9383d4eb5a6c064d3d49835 (patch) | |
tree | 105047c7ec00b42f4793a99ade2f9d3bae89ef10 /main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java | |
parent | 07b7ba00a053a26a5eef39070bff5297c630c5ce (diff) |
Adding healthcheck endpoint to policy/pap
1) Adding healthcheck REST endpoint to policy/pap using the
policy-endpoints module in policy/common.
2) Added the related unit test cases.
Change-Id: I6a215cceccc9cd42494aef1dfcdd46f0f3fd7d13
Issue-ID: POLICY-1477
Signed-off-by: ramverma <ram.krishna.verma@est.tech>
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.java | 28 |
1 files changed, 22 insertions, 6 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 8aec2adf..b1674efb 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 @@ -23,8 +23,9 @@ package org.onap.policy.pap.main.startstop; import org.onap.policy.common.parameters.ParameterService; import org.onap.policy.pap.main.PolicyPapException; import org.onap.policy.pap.main.parameters.PapParameterGroup; -import org.slf4j.ext.XLogger; -import org.slf4j.ext.XLoggerFactory; +import org.onap.policy.pap.main.rest.PapRestServer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This class wraps a distributor so that it can be activated as a complete service together with all its pap and @@ -33,13 +34,12 @@ import org.slf4j.ext.XLoggerFactory; * @author Ram Krishna Verma (ram.krishna.verma@est.tech) */ public class PapActivator { - // The logger for this class - private static final XLogger LOGGER = XLoggerFactory.getXLogger(PapActivator.class); - // The parameters of this policy pap activator - private final PapParameterGroup papParameterGroup; + private static final Logger LOGGER = LoggerFactory.getLogger(PapActivator.class); + private final PapParameterGroup papParameterGroup; private static boolean alive = false; + private PapRestServer restServer; /** * Instantiate the activator for policy pap as a complete service. @@ -58,6 +58,7 @@ public class PapActivator { public void initialize() throws PolicyPapException { try { LOGGER.debug("Policy pap starting as a service . . ."); + startPapRestServer(); registerToParameterService(papParameterGroup); PapActivator.setAlive(true); LOGGER.debug("Policy pap started as a service"); @@ -77,6 +78,8 @@ public class PapActivator { deregisterToParameterService(papParameterGroup); PapActivator.setAlive(false); + // Stop the pap rest server + restServer.stop(); } catch (final Exception exp) { LOGGER.error("Policy pap service termination failed", exp); throw new PolicyPapException(exp.getMessage(), exp); @@ -127,4 +130,17 @@ public class PapActivator { public static void setAlive(final boolean status) { alive = status; } + + /** + * Starts the pap rest server using configuration parameters. + * + * @throws PolicyPapException if server start fails + */ + private void startPapRestServer() throws PolicyPapException { + papParameterGroup.getRestServerParameters().setName(papParameterGroup.getName()); + restServer = new PapRestServer(papParameterGroup.getRestServerParameters()); + if (!restServer.start()) { + throw new PolicyPapException("Failed to start pap rest server. Check log for more details..."); + } + } } |