aboutsummaryrefslogtreecommitdiffstats
path: root/reception/src/main/java/org
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 /reception/src/main/java/org
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 'reception/src/main/java/org')
-rw-r--r--reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java6
-rw-r--r--reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java35
-rw-r--r--reception/src/main/java/org/onap/policy/distribution/reception/handling/ReceptionHandler.java8
-rw-r--r--reception/src/main/java/org/onap/policy/distribution/reception/parameters/PluginHandlerParameters.java4
-rw-r--r--reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderParameters.java8
-rw-r--r--reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerParameters.java10
6 files changed, 47 insertions, 24 deletions
diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java b/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java
index 94bcc65a..eeb1ead1 100644
--- a/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java
+++ b/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java
@@ -34,10 +34,10 @@ import org.onap.policy.distribution.reception.decoding.PolicyDecoder;
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters;
-/***
+/**
* Base implementation of {@link ReceptionHandler}. All reception handlers should extend this base class by implementing
* the {@link #initializeReception(String)} method to perform the specific initialization required to receive inputs and
- * by invoking {@link #inputReceived(PolicyInput)} when the reception handler receives input
+ * by invoking {@link #inputReceived(PolicyInput)} when the reception handler receives input.
*/
public abstract class AbstractReceptionHandler implements ReceptionHandler {
@@ -55,7 +55,7 @@ public abstract class AbstractReceptionHandler implements ReceptionHandler {
/**
* Sub classes must implement this method to perform the specific initialization required to receive inputs, for
- * example setting up subscriptions
+ * example setting up subscriptions.
*
* @param parameterGroupName the parameter group name
*/
diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java b/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java
index 7afc5814..37638b59 100644
--- a/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java
+++ b/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java
@@ -24,6 +24,8 @@ import java.util.ArrayList;
import java.util.Collection;
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;
import org.onap.policy.distribution.forwarding.PolicyForwarder;
import org.onap.policy.distribution.forwarding.PolicyForwardingException;
@@ -40,6 +42,8 @@ import org.onap.policy.distribution.reception.parameters.PolicyDecoderParameters
*/
public class PluginHandler {
+ private static final Logger LOGGER = FlexLogger.getLogger(PluginHandler.class);
+
private Collection<PolicyDecoder<PolicyInput, Policy>> policyDecoders;
private Collection<PolicyForwarder> policyForwarders;
@@ -47,8 +51,8 @@ public class PluginHandler {
* Create an instance to instantiate plugins based on the given parameter group.
*
* @param parameterGroupName the name of the parameter group
- * @throws PolicyDecodingException
- * @throws PolicyForwardingException
+ * @throws PolicyDecodingException exception if it occurs
+ * @throws PolicyForwardingException exception if it occurs
*/
public PluginHandler(final String parameterGroupName) throws PolicyDecodingException, PolicyForwardingException {
final PluginHandlerParameters params = (PluginHandlerParameters) ParameterService.get(parameterGroupName);
@@ -77,41 +81,44 @@ public class PluginHandler {
/**
* Initialize policy decoders.
*
- * @param policyDecoderParameters
- * @throws PolicyDecodingException
+ * @param policyDecoderParameters exception if it occurs
+ * @throws PolicyDecodingException exception if it occurs
*/
@SuppressWarnings("unchecked")
private void initializePolicyDecoders(final Map<String, PolicyDecoderParameters> policyDecoderParameters)
throws PolicyDecodingException {
- policyDecoders = new ArrayList<PolicyDecoder<PolicyInput, Policy>>();
- for (final PolicyDecoderParameters pDParameters : policyDecoderParameters.values()) {
+ policyDecoders = new ArrayList<>();
+ for (final PolicyDecoderParameters decoderParameters : policyDecoderParameters.values()) {
try {
final Class<PolicyDecoder<PolicyInput, Policy>> policyDecoderClass =
- (Class<PolicyDecoder<PolicyInput, Policy>>) Class.forName(pDParameters.getDecoderClassName());
+ (Class<PolicyDecoder<PolicyInput, Policy>>) Class
+ .forName(decoderParameters.getDecoderClassName());
final PolicyDecoder<PolicyInput, Policy> decoder = policyDecoderClass.newInstance();
policyDecoders.add(decoder);
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException exp) {
- throw new PolicyDecodingException(exp.getMessage());
+ LOGGER.error("exception occured while initializing decoders", exp);
+ throw new PolicyDecodingException(exp.getMessage(), exp.getCause());
}
}
}
/**
- * Initialize policy forwarders
+ * Initialize policy forwarders.
*
- * @param policyForwarderParameters
- * @throws PolicyForwardingException
+ * @param policyForwarderParameters exception if it occurs
+ * @throws PolicyForwardingException exception if it occurs
*/
@SuppressWarnings("unchecked")
private void initializePolicyForwarders(final Map<String, PolicyForwarderParameters> policyForwarderParameters)
throws PolicyForwardingException {
- policyForwarders = new ArrayList<PolicyForwarder>();
- for (final PolicyForwarderParameters pFParameters : policyForwarderParameters.values()) {
+ policyForwarders = new ArrayList<>();
+ for (final PolicyForwarderParameters forwarderParameters : policyForwarderParameters.values()) {
try {
final Class<PolicyForwarder> policyForwarderClass =
- (Class<PolicyForwarder>) Class.forName(pFParameters.getForwarderClassName());
+ (Class<PolicyForwarder>) Class.forName(forwarderParameters.getForwarderClassName());
policyForwarders.add(policyForwarderClass.newInstance());
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException exp) {
+ LOGGER.error("exception occured while initializing forwarders", exp);
throw new PolicyForwardingException(exp.getMessage(), exp.getCause());
}
}
diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/handling/ReceptionHandler.java b/reception/src/main/java/org/onap/policy/distribution/reception/handling/ReceptionHandler.java
index c3a7544d..5f2e3716 100644
--- a/reception/src/main/java/org/onap/policy/distribution/reception/handling/ReceptionHandler.java
+++ b/reception/src/main/java/org/onap/policy/distribution/reception/handling/ReceptionHandler.java
@@ -29,16 +29,16 @@ import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
public interface ReceptionHandler {
/**
- * Initialize the reception handler with the given parameters
+ * Initialize the reception handler with the given parameters.
*
* @param parameterGroupName the name of the parameter group containing the configuration for the reception handler
- * @throws PolicyDecodingException
- * @throws PolicyForwardingException
+ * @throws PolicyDecodingException exception if it occurs
+ * @throws PolicyForwardingException exception if it occurs
*/
void initialize(String parameterGroupName) throws PolicyDecodingException, PolicyForwardingException;
/**
- * Destroy the reception handler, removing any subscriptions and releasing all resources
+ * Destroy the reception handler, removing any subscriptions and releasing all resources.
*/
void destroy();
diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PluginHandlerParameters.java b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PluginHandlerParameters.java
index 7e16518b..c752020b 100644
--- a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PluginHandlerParameters.java
+++ b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PluginHandlerParameters.java
@@ -105,7 +105,9 @@ public class PluginHandlerParameters implements ParameterGroup {
}
/**
- * @param name the name to set
+ * Set the name of this group.
+ *
+ * @param name the name to set.
*/
public void setName(final String name) {
this.name = name;
diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderParameters.java b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderParameters.java
index 59c59e16..6157b8b6 100644
--- a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderParameters.java
+++ b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderParameters.java
@@ -20,6 +20,8 @@
package org.onap.policy.distribution.reception.parameters;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.common.parameters.GroupValidationResult;
import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.parameters.ValidationStatus;
@@ -30,6 +32,9 @@ import org.onap.policy.common.parameters.ValidationStatus;
* @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
*/
public class PolicyDecoderParameters implements ParameterGroup {
+
+ private static final Logger LOGGER = FlexLogger.getLogger(PolicyDecoderParameters.class);
+
private String decoderType;
private String decoderClassName;
@@ -89,7 +94,8 @@ public class PolicyDecoderParameters implements ParameterGroup {
private void validatePolicyDecoderClass(final GroupValidationResult validationResult) {
try {
Class.forName(decoderClassName);
- } catch (final ClassNotFoundException e) {
+ } catch (final ClassNotFoundException exp) {
+ LOGGER.error("policy decoder class not found in classpath", exp);
validationResult.setResult("decoderClassName", ValidationStatus.INVALID,
"policy decoder class not found in classpath");
}
diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerParameters.java b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerParameters.java
index 54979ab2..974436aa 100644
--- a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerParameters.java
+++ b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerParameters.java
@@ -20,6 +20,8 @@
package org.onap.policy.distribution.reception.parameters;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.common.parameters.GroupValidationResult;
import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.parameters.ValidationStatus;
@@ -30,6 +32,9 @@ import org.onap.policy.common.parameters.ValidationStatus;
* @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
*/
public class ReceptionHandlerParameters implements ParameterGroup {
+
+ private static final Logger LOGGER = FlexLogger.getLogger(ReceptionHandlerParameters.class);
+
private String name;
private String receptionHandlerType;
private String receptionHandlerClassName;
@@ -109,13 +114,16 @@ public class ReceptionHandlerParameters implements ParameterGroup {
private void validateReceptionHandlerClass(final GroupValidationResult validationResult) {
try {
Class.forName(receptionHandlerClassName);
- } catch (final ClassNotFoundException e) {
+ } catch (final ClassNotFoundException exp) {
+ LOGGER.error("reception handler class not found in classpath", exp);
validationResult.setResult("receptionHandlerClassName", ValidationStatus.INVALID,
"reception handler class not found in classpath");
}
}
/**
+ * Set the name of this group.
+ *
* @param name the name to set
*/
public void setName(final String name) {