summaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorramverma <ram.krishna.verma@ericsson.com>2018-08-16 16:43:20 +0100
committerramverma <ram.krishna.verma@ericsson.com>2018-08-16 16:43:58 +0100
commit612196451afe9b16b8914858dd58f3bb0dae8579 (patch)
tree0a3d2c5991fe33594224dbf359db8fcdda588084 /main
parent84beaf8d12f1badc27b4744a4949f8a586370ea9 (diff)
Adding termination code changes for distribution
* Code changes for terminating the handlers started by distribution activator. * More test cases to increase coverage. * Fixes for checkstyle issues. * Fixes for sonar issues. Change-Id: I3299317c83fa643ac1d0ba1105ac1a932c0a83f6 Issue-ID: POLICY-1035 Signed-off-by: ramverma <ram.krishna.verma@ericsson.com>
Diffstat (limited to 'main')
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java19
1 files changed, 17 insertions, 2 deletions
diff --git a/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java b/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java
index 43eb4f80..d360b5dd 100644
--- a/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java
+++ b/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java
@@ -20,6 +20,9 @@
package org.onap.policy.distribution.main.startstop;
+import java.util.HashMap;
+import java.util.Map;
+
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.common.parameters.ParameterService;
@@ -41,6 +44,9 @@ public class DistributionActivator {
// The parameters of this policy distribution activator
private final DistributionParameterGroup distributionParameterGroup;
+ // The map of reception handlers initialized by this distribution activator
+ private final Map<String, AbstractReceptionHandler> receptionHandlersMap = new HashMap<>();
+
/**
* Instantiate the activator for policy distribution as a complete service.
*
@@ -66,6 +72,7 @@ public class DistributionActivator {
(Class<AbstractReceptionHandler>) Class.forName(rHParameters.getReceptionHandlerClassName());
final AbstractReceptionHandler receptionHandler = receptionHandlerClass.newInstance();
receptionHandler.initialize(rHParameters.getName());
+ receptionHandlersMap.put(rHParameters.getName(), receptionHandler);
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException
| PolicyDecodingException | PolicyForwardingException exp) {
throw new PolicyDistributionException(exp.getMessage(), exp);
@@ -80,8 +87,16 @@ public class DistributionActivator {
* @throws PolicyDistributionException on termination errors
*/
public void terminate() throws PolicyDistributionException {
- // Shut down all handlers
- deregisterToParameterService(distributionParameterGroup);
+ try {
+ for (final AbstractReceptionHandler handler : receptionHandlersMap.values()) {
+ handler.destroy();
+ }
+ receptionHandlersMap.clear();
+ deregisterToParameterService(distributionParameterGroup);
+ } catch (final Exception exp) {
+ LOGGER.error("Policy distribution service termination failed", exp);
+ throw new PolicyDistributionException(exp.getMessage(), exp);
+ }
}
/**