aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorramverma <ram.krishna.verma@est.tech>2019-02-05 15:34:35 +0000
committerramverma <ram.krishna.verma@est.tech>2019-02-05 15:34:35 +0000
commitb5f4934afdc2601c925e83458d0e3d136c36cf1c (patch)
tree1217188ee7f3b6194362c5f9fea1acbc8c515a95
parent9255568baf91af0065a5fea1963d19ecfcf90f7a (diff)
Change policy/distribution logging to slf4j
1) Changed logging from FlexLogger to SLF4J with logback 2) Fixed test cases of distribution REST endpoints having infinite while loop Change-Id: I1551873b3d348f9a7d2b4f8dfc3ae5dd6462bdb8 Issue-ID: POLICY-1346 Signed-off-by: ramverma <ram.krishna.verma@est.tech>
-rw-r--r--forwarding/pom.xml5
-rw-r--r--forwarding/src/main/java/org/onap/policy/distribution/forwarding/parameters/PolicyForwarderParameters.java7
-rw-r--r--main/pom.xml5
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.java7
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/parameters/PolicyForwarderConfigurationParametersJsonAdapter.java19
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestServer.java7
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java9
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/startstop/Main.java9
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java59
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionStatistics.java70
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java61
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsStatisticDistributionRestServer.java64
-rw-r--r--packages/policy-distribution-docker/src/main/docker/Dockerfile2
-rw-r--r--packages/policy-distribution-tarball/src/main/resources/etc/logback.xml327
-rw-r--r--packages/policy-distribution-tarball/src/main/resources/policyLogger.properties44
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java80
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java17
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.java7
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileClientHandler.java8
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java18
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java33
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandler.java14
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java19
-rw-r--r--pom.xml26
-rw-r--r--reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java7
-rw-r--r--reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java7
-rw-r--r--reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderConfigurationParametersJsonAdapter.java8
-rw-r--r--reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderParameters.java9
-rw-r--r--reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParametersJsonAdapter.java19
-rw-r--r--reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerParameters.java13
30 files changed, 419 insertions, 561 deletions
diff --git a/forwarding/pom.xml b/forwarding/pom.xml
index 276cca82..46508a02 100644
--- a/forwarding/pom.xml
+++ b/forwarding/pom.xml
@@ -41,10 +41,5 @@
<artifactId>common-parameters</artifactId>
<version>${policy.common.version}</version>
</dependency>
- <dependency>
- <groupId>org.onap.policy.common</groupId>
- <artifactId>ONAP-Logging</artifactId>
- <version>${policy.common.version}</version>
- </dependency>
</dependencies>
</project>
diff --git a/forwarding/src/main/java/org/onap/policy/distribution/forwarding/parameters/PolicyForwarderParameters.java b/forwarding/src/main/java/org/onap/policy/distribution/forwarding/parameters/PolicyForwarderParameters.java
index 1334b3dd..e5c757b1 100644
--- a/forwarding/src/main/java/org/onap/policy/distribution/forwarding/parameters/PolicyForwarderParameters.java
+++ b/forwarding/src/main/java/org/onap/policy/distribution/forwarding/parameters/PolicyForwarderParameters.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,11 +21,11 @@
package org.onap.policy.distribution.forwarding.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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class to hold all the policy forwarder parameters.
@@ -33,7 +34,7 @@ import org.onap.policy.common.parameters.ValidationStatus;
*/
public class PolicyForwarderParameters implements ParameterGroup {
- private static final Logger LOGGER = FlexLogger.getLogger(PolicyForwarderParameters.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(PolicyForwarderParameters.class);
private String forwarderType;
private String forwarderClassName;
diff --git a/main/pom.xml b/main/pom.xml
index 34467aea..cc471bd4 100644
--- a/main/pom.xml
+++ b/main/pom.xml
@@ -42,11 +42,6 @@
<version>${policy.common.version}</version>
</dependency>
<dependency>
- <groupId>org.onap.policy.common</groupId>
- <artifactId>policy-endpoints</artifactId>
- <version>${policy.common.version}</version>
- </dependency>
- <dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>
diff --git a/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.java b/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.java
index 603c9869..7ef5fd75 100644
--- a/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.java
+++ b/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,8 +26,6 @@ import com.google.gson.GsonBuilder;
import java.io.FileReader;
-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.distribution.main.PolicyDistributionException;
import org.onap.policy.distribution.main.startstop.DistributionCommandLineArguments;
@@ -34,12 +33,14 @@ import org.onap.policy.distribution.reception.parameters.PolicyDecoderConfigurat
import org.onap.policy.distribution.reception.parameters.PolicyDecoderConfigurationParametersJsonAdapter;
import org.onap.policy.distribution.reception.parameters.ReceptionHandlerConfigurationParameterGroup;
import org.onap.policy.distribution.reception.parameters.ReceptionHandlerConfigurationParametersJsonAdapter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This class handles reading, parsing and validating of policy distribution parameters from JSON files.
*/
public class DistributionParameterHandler {
- private static final Logger LOGGER = FlexLogger.getLogger(DistributionParameterHandler.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(DistributionParameterHandler.class);
/**
* Read the parameters from the parameter file.
diff --git a/main/src/main/java/org/onap/policy/distribution/main/parameters/PolicyForwarderConfigurationParametersJsonAdapter.java b/main/src/main/java/org/onap/policy/distribution/main/parameters/PolicyForwarderConfigurationParametersJsonAdapter.java
index 5ce15a28..687970dc 100644
--- a/main/src/main/java/org/onap/policy/distribution/main/parameters/PolicyForwarderConfigurationParametersJsonAdapter.java
+++ b/main/src/main/java/org/onap/policy/distribution/main/parameters/PolicyForwarderConfigurationParametersJsonAdapter.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -25,17 +26,19 @@ import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
+
import java.lang.reflect.Type;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This class deserialises policy forwarder parameters from JSON.
*/
public class PolicyForwarderConfigurationParametersJsonAdapter
implements JsonDeserializer<PolicyForwarderConfigurationParameterGroup> {
- private static final XLogger LOGGER =
- XLoggerFactory.getXLogger(PolicyForwarderConfigurationParametersJsonAdapter.class);
+ private static final Logger LOGGER =
+ LoggerFactory.getLogger(PolicyForwarderConfigurationParametersJsonAdapter.class);
private static final String PARAMETER_CLASS_NAME = "parameterClassName";
private static final String POLICY_FORWARDER_PARAMETERS = "parameters";
@@ -46,7 +49,7 @@ public class PolicyForwarderConfigurationParametersJsonAdapter
final JsonObject jsonObject = json.getAsJsonObject();
final String policyForwarderParameterClassName = getParameterGroupClassName(jsonObject);
- Class<?> policyForwarderParameterClass = getParameterGroupClass(policyForwarderParameterClassName);
+ final Class<?> policyForwarderParameterClass = getParameterGroupClass(policyForwarderParameterClassName);
return context.deserialize(jsonObject.get(POLICY_FORWARDER_PARAMETERS), policyForwarderParameterClass);
}
diff --git a/main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestServer.java b/main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestServer.java
index 748d516d..8f7652b8 100644
--- a/main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestServer.java
+++ b/main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestServer.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,9 +27,9 @@ import java.util.Properties;
import org.onap.policy.common.capabilities.Startable;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.distribution.main.parameters.RestServerParameters;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class to manage life cycle of distribution rest server.
@@ -37,9 +38,9 @@ import org.onap.policy.distribution.main.parameters.RestServerParameters;
*/
public class DistributionRestServer implements Startable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(DistributionRestServer.class);
private static final String SEPARATOR = ".";
private static final String HTTP_SERVER_SERVICES = "http.server.services";
- private static final Logger LOGGER = FlexLogger.getLogger(DistributionRestServer.class);
private List<HttpServletServer> servers = new ArrayList<>();
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 1395b283..8db118a8 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
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,8 +25,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
-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.main.PolicyDistributionException;
import org.onap.policy.distribution.main.parameters.DistributionParameterGroup;
@@ -36,14 +35,16 @@ import org.onap.policy.distribution.reception.handling.AbstractReceptionHandler;
import org.onap.policy.distribution.reception.parameters.PolicyDecoderConfigurationParameterGroup;
import org.onap.policy.distribution.reception.parameters.ReceptionHandlerConfigurationParameterGroup;
import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters;
+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 distribution
* and forwarding handlers.
*/
public class DistributionActivator {
- // The logger for this class
- private static final Logger LOGGER = FlexLogger.getLogger(DistributionActivator.class);
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(DistributionActivator.class);
// The parameters of this policy distribution activator
private final DistributionParameterGroup distributionParameterGroup;
diff --git a/main/src/main/java/org/onap/policy/distribution/main/startstop/Main.java b/main/src/main/java/org/onap/policy/distribution/main/startstop/Main.java
index 3ff85b8e..13da2169 100644
--- a/main/src/main/java/org/onap/policy/distribution/main/startstop/Main.java
+++ b/main/src/main/java/org/onap/policy/distribution/main/startstop/Main.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,11 +23,11 @@ package org.onap.policy.distribution.main.startstop;
import java.util.Arrays;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.distribution.main.PolicyDistributionException;
import org.onap.policy.distribution.main.parameters.DistributionParameterGroup;
import org.onap.policy.distribution.main.parameters.DistributionParameterHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This class initiates ONAP Policy Framework policy distribution.
@@ -34,7 +35,7 @@ import org.onap.policy.distribution.main.parameters.DistributionParameterHandler
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class Main {
- private static final Logger LOGGER = FlexLogger.getLogger(Main.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);
// The policy distribution Activator that activates the policy distribution service
private DistributionActivator activator;
@@ -49,7 +50,7 @@ public class Main {
*/
public Main(final String[] args) {
final String argumentString = Arrays.toString(args);
- LOGGER.info("Starting policy distribution service with arguments - " + argumentString);
+ LOGGER.info("Starting policy distribution service with arguments - {}", argumentString);
// Check the arguments
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java
index d02139f2..356a5861 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +23,9 @@ package org.onap.policy.distribution.main.rest;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
@@ -33,12 +37,13 @@ import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.junit.Test;
import org.onap.policy.common.endpoints.report.HealthCheckReport;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.distribution.main.PolicyDistributionException;
import org.onap.policy.distribution.main.parameters.CommonTestData;
import org.onap.policy.distribution.main.parameters.RestServerParameters;
import org.onap.policy.distribution.main.startstop.Main;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class to perform unit test of HealthCheckMonitor.
@@ -47,33 +52,43 @@ import org.onap.policy.distribution.main.startstop.Main;
*/
public class TestDistributionRestServer {
- private static final Logger LOGGER = FlexLogger.getLogger(TestDistributionRestServer.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestDistributionRestServer.class);
private static final String NOT_ALIVE = "not alive";
private static final String ALIVE = "alive";
private static final String SELF = "self";
private static final String NAME = "Policy SSD";
@Test
- public void testHealthCheckSuccess() throws PolicyDistributionException, InterruptedException {
+ public void testHealthCheckSuccess() {
final String reportString = "Report [name=Policy SSD, url=self, healthy=true, code=200, message=alive]";
- final Main main = startDistributionService();
- final HealthCheckReport report = performHealthCheck();
- validateReport(NAME, SELF, true, 200, ALIVE, reportString, report);
- stopDistributionService(main);
+ try {
+ final Main main = startDistributionService();
+ final HealthCheckReport report = performHealthCheck();
+ validateReport(NAME, SELF, true, 200, ALIVE, reportString, report);
+ stopDistributionService(main);
+ } catch (final Exception exp) {
+ LOGGER.error("testHealthCheckSuccess failed", exp);
+ fail("Test should not throw an exception");
+ }
}
@Test
- public void testHealthCheckFailure() throws InterruptedException {
+ public void testHealthCheckFailure() {
final String reportString = "Report [name=Policy SSD, url=self, healthy=false, code=500, message=not alive]";
final RestServerParameters restServerParams = new CommonTestData().getRestServerParameters(false);
restServerParams.setName(CommonTestData.DISTRIBUTION_GROUP_NAME);
final DistributionRestServer restServer = new DistributionRestServer(restServerParams);
- restServer.start();
- final HealthCheckReport report = performHealthCheck();
- validateReport(NAME, SELF, false, 500, NOT_ALIVE, reportString, report);
- assertTrue(restServer.isAlive());
- assertTrue(restServer.toString().startsWith("DistributionRestServer [servers="));
- restServer.shutdown();
+ try {
+ restServer.start();
+ final HealthCheckReport report = performHealthCheck();
+ validateReport(NAME, SELF, false, 500, NOT_ALIVE, reportString, report);
+ assertTrue(restServer.isAlive());
+ assertTrue(restServer.toString().startsWith("DistributionRestServer [servers="));
+ restServer.shutdown();
+ } catch (final Exception exp) {
+ LOGGER.error("testHealthCheckFailure failed", exp);
+ fail("Test should not throw an exception");
+ }
}
private Main startDistributionService() {
@@ -85,8 +100,7 @@ public class TestDistributionRestServer {
main.shutdown();
}
- private HealthCheckReport performHealthCheck() throws InterruptedException {
- HealthCheckReport response = null;
+ private HealthCheckReport performHealthCheck() throws InterruptedException, IOException {
final ClientConfig clientConfig = new ClientConfig();
final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
@@ -96,14 +110,11 @@ public class TestDistributionRestServer {
final WebTarget webTarget = client.target("http://localhost:6969/healthcheck");
final Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
- while (response == null) {
- try {
- response = invocationBuilder.get(HealthCheckReport.class);
- } catch (final Exception exp) {
- LOGGER.info("the server is not started yet. We will retry again");
- }
+
+ if (!NetworkUtil.isTcpPortOpen("localhost", 6969, 6, 10000L)) {
+ throw new IllegalStateException("cannot connect to port 6969");
}
- return response;
+ return invocationBuilder.get(HealthCheckReport.class);
}
private void validateReport(final String name, final String url, final boolean healthy, final int code,
diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionStatistics.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionStatistics.java
index 92ae14a8..6c95a2a8 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionStatistics.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionStatistics.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +22,9 @@
package org.onap.policy.distribution.main.rest;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
@@ -31,13 +35,14 @@ import javax.ws.rs.core.MediaType;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.junit.Test;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.distribution.main.PolicyDistributionException;
import org.onap.policy.distribution.main.parameters.CommonTestData;
import org.onap.policy.distribution.main.parameters.RestServerParameters;
import org.onap.policy.distribution.main.startstop.Main;
import org.onap.policy.distribution.reception.statistics.DistributionStatisticsManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class to perform unit test of {@link DistributionRestController}.
@@ -46,40 +51,45 @@ import org.onap.policy.distribution.reception.statistics.DistributionStatisticsM
*/
public class TestDistributionStatistics {
- private static final Logger LOGGER = FlexLogger.getLogger(TestDistributionStatistics.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestDistributionStatistics.class);
@Test
- public void testDistributionStatistics_200() throws PolicyDistributionException, InterruptedException {
- final Main main = startDistributionService();
- StatisticsReport report = getDistributionStatistics();
-
- validateReport(report, 0, 200);
- updateDistributionStatistics();
- report = getDistributionStatistics();
- validateReport(report, 1, 200);
- stopDistributionService(main);
- DistributionStatisticsManager.resetAllStatistics();
+ public void testDistributionStatistics_200() {
+ try {
+ final Main main = startDistributionService();
+ StatisticsReport report = getDistributionStatistics();
+ validateReport(report, 0, 200);
+ updateDistributionStatistics();
+ report = getDistributionStatistics();
+ validateReport(report, 1, 200);
+ stopDistributionService(main);
+ DistributionStatisticsManager.resetAllStatistics();
+ } catch (final Exception exp) {
+ LOGGER.error("testDistributionStatistics_200 failed", exp);
+ fail("Test should not throw an exception");
+ }
}
@Test
public void testDistributionStatistics_500() throws InterruptedException {
final RestServerParameters restServerParams = new CommonTestData().getRestServerParameters(false);
restServerParams.setName(CommonTestData.DISTRIBUTION_GROUP_NAME);
-
final DistributionRestServer restServer = new DistributionRestServer(restServerParams);
- restServer.start();
- final StatisticsReport report = getDistributionStatistics();
-
- validateReport(report, 0, 500);
- restServer.shutdown();
- DistributionStatisticsManager.resetAllStatistics();
+ try {
+ restServer.start();
+ final StatisticsReport report = getDistributionStatistics();
+ validateReport(report, 0, 500);
+ restServer.shutdown();
+ DistributionStatisticsManager.resetAllStatistics();
+ } catch (final Exception exp) {
+ LOGGER.error("testDistributionStatistics_500 failed", exp);
+ fail("Test should not throw an exception");
+ }
}
-
private Main startDistributionService() {
- final String[] distributionConfigParameters =
- { "-c", "parameters/DistributionConfigParameters.json" };
+ final String[] distributionConfigParameters = { "-c", "parameters/DistributionConfigParameters.json" };
return new Main(distributionConfigParameters);
}
@@ -87,8 +97,7 @@ public class TestDistributionStatistics {
main.shutdown();
}
- private StatisticsReport getDistributionStatistics() throws InterruptedException {
- StatisticsReport response = null;
+ private StatisticsReport getDistributionStatistics() throws InterruptedException, IOException {
final ClientConfig clientConfig = new ClientConfig();
final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
@@ -98,14 +107,11 @@ public class TestDistributionStatistics {
final WebTarget webTarget = client.target("http://localhost:6969/statistics");
final Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
- while (response == null) {
- try {
- response = invocationBuilder.get(StatisticsReport.class);
- } catch (final Exception exp) {
- LOGGER.info("the server is not started yet. We will retry again");
- }
+
+ if (!NetworkUtil.isTcpPortOpen("localhost", 6969, 6, 10000L)) {
+ throw new IllegalStateException("cannot connect to port 6969");
}
- return response;
+ return invocationBuilder.get(StatisticsReport.class);
}
private void updateDistributionStatistics() {
diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java
index 6667d7fd..f3046c29 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Intel. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,9 +22,8 @@
package org.onap.policy.distribution.main.rest;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.util.Properties;
@@ -31,7 +31,6 @@ import java.util.Properties;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
-
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Invocation;
@@ -41,10 +40,11 @@ import javax.ws.rs.core.MediaType;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.junit.Test;
import org.onap.policy.common.endpoints.report.HealthCheckReport;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.distribution.main.PolicyDistributionException;
import org.onap.policy.distribution.main.startstop.Main;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class to perform unit test of HealthCheckMonitor.
@@ -53,24 +53,28 @@ import org.onap.policy.distribution.main.startstop.Main;
*/
public class TestHttpsDistributionRestServer {
- private static final Logger LOGGER = FlexLogger.getLogger(TestDistributionRestServer.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestHttpsDistributionRestServer.class);
private static final String ALIVE = "alive";
private static final String SELF = "self";
private static final String NAME = "Policy SSD";
private static String KEYSTORE = System.getProperty("user.dir") + "/src/test/resources/ssl/policy-keystore";
@Test
- public void testHealthCheckSuccess()
- throws PolicyDistributionException, InterruptedException, KeyManagementException, NoSuchAlgorithmException {
+ public void testHttpsHealthCheckSuccess() {
final String reportString = "Report [name=Policy SSD, url=self, healthy=true, code=200, message=alive]";
- final Main main = startDistributionService();
- final HealthCheckReport report = performHealthCheck();
- validateReport(NAME, SELF, true, 200, ALIVE, reportString, report);
- stopDistributionService(main);
+ try {
+ final Main main = startDistributionService();
+ final HealthCheckReport report = performHealthCheck();
+ validateReport(NAME, SELF, true, 200, ALIVE, reportString, report);
+ stopDistributionService(main);
+ } catch (final Exception exp) {
+ LOGGER.error("testHttpsHealthCheckSuccess failed", exp);
+ fail("Test should not throw an exception");
+ }
}
private Main startDistributionService() {
- Properties systemProps = System.getProperties();
+ final Properties systemProps = System.getProperties();
systemProps.put("javax.net.ssl.keyStore", KEYSTORE);
systemProps.put("javax.net.ssl.keyStorePassword", "Pol1cy_0nap");
System.setProperties(systemProps);
@@ -83,11 +87,9 @@ public class TestHttpsDistributionRestServer {
main.shutdown();
}
- private HealthCheckReport performHealthCheck()
- throws InterruptedException, KeyManagementException, NoSuchAlgorithmException {
- HealthCheckReport response = null;
+ private HealthCheckReport performHealthCheck() throws Exception {
- TrustManager[] noopTrustManager = new TrustManager[] { new X509TrustManager() {
+ final TrustManager[] noopTrustManager = new TrustManager[] { new X509TrustManager() {
@Override
public X509Certificate[] getAcceptedIssuers() {
@@ -95,18 +97,16 @@ public class TestHttpsDistributionRestServer {
}
@Override
- public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
- }
+ public void checkClientTrusted(final java.security.cert.X509Certificate[] certs, final String authType) {}
@Override
- public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
- }
+ public void checkServerTrusted(final java.security.cert.X509Certificate[] certs, final String authType) {}
} };
- SSLContext sc = SSLContext.getInstance("TLSv1.2");
+ final SSLContext sc = SSLContext.getInstance("TLSv1.2");
sc.init(null, noopTrustManager, new SecureRandom());
- final ClientBuilder clientBuilder = ClientBuilder.newBuilder().sslContext(sc)
- .hostnameVerifier((host, session) -> true);
+ final ClientBuilder clientBuilder =
+ ClientBuilder.newBuilder().sslContext(sc).hostnameVerifier((host, session) -> true);
final Client client = clientBuilder.build();
final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
client.register(feature);
@@ -114,18 +114,15 @@ public class TestHttpsDistributionRestServer {
final WebTarget webTarget = client.target("https://localhost:6969/healthcheck");
final Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
- while (response == null) {
- try {
- response = invocationBuilder.get(HealthCheckReport.class);
- } catch (final Exception exp) {
- LOGGER.error("the server is not started yet. We will retry again", exp);
- }
+
+ if (!NetworkUtil.isTcpPortOpen("localhost", 6969, 6, 10000L)) {
+ throw new IllegalStateException("cannot connect to port 6969");
}
- return response;
+ return invocationBuilder.get(HealthCheckReport.class);
}
private void validateReport(final String name, final String url, final boolean healthy, final int code,
- final String message, final String reportString, final HealthCheckReport report) {
+ final String message, final String reportString, final HealthCheckReport report) {
assertEquals(name, report.getName());
assertEquals(url, report.getUrl());
assertEquals(healthy, report.isHealthy());
diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsStatisticDistributionRestServer.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsStatisticDistributionRestServer.java
index 5aadb6ed..ba64e550 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsStatisticDistributionRestServer.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsStatisticDistributionRestServer.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Intel. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +22,7 @@
package org.onap.policy.distribution.main.rest;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
@@ -31,7 +33,6 @@ import java.util.Properties;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
-
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Invocation;
@@ -40,10 +41,11 @@ import javax.ws.rs.core.MediaType;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.junit.Test;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.distribution.main.PolicyDistributionException;
import org.onap.policy.distribution.main.startstop.Main;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class to perform unit test of HealthCheckMonitor.
@@ -52,22 +54,25 @@ import org.onap.policy.distribution.main.startstop.Main;
*/
public class TestHttpsStatisticDistributionRestServer {
- private static final Logger LOGGER = FlexLogger.getLogger(TestHttpsStatisticDistributionRestServer.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestHttpsStatisticDistributionRestServer.class);
private static String KEYSTORE = System.getProperty("user.dir") + "/src/test/resources/ssl/policy-keystore";
@Test
- public void testDistributionStatistic()
- throws PolicyDistributionException, InterruptedException, KeyManagementException, NoSuchAlgorithmException {
- final String reportString = "StatisticsReport [code=200, totalDistributionCount=0, distributionSuccessCount=0, "
- + "distributionFailureCount=0, totalDownloadCount=0, " + "downloadSuccessCount=0, downloadFailureCount=0]";
- final Main main = startDistributionService();
- final StatisticsReport report = performStatisticCheck();
- validateReport(200, 0, 0, 0, 0, 0, 0, reportString, report);
- stopDistributionService(main);
+ public void testHttpsDistributionStatistic()
+ throws PolicyDistributionException, InterruptedException, KeyManagementException, NoSuchAlgorithmException {
+ try {
+ final Main main = startDistributionService();
+ final StatisticsReport report = performStatisticCheck();
+ validateReport(200, 0, 0, 0, 0, 0, 0, report);
+ stopDistributionService(main);
+ } catch (final Exception exp) {
+ LOGGER.error("testHttpsDistributionStatistic failed", exp);
+ fail("Test should not throw an exception");
+ }
}
private Main startDistributionService() {
- Properties systemProps = System.getProperties();
+ final Properties systemProps = System.getProperties();
systemProps.put("javax.net.ssl.keyStore", KEYSTORE);
systemProps.put("javax.net.ssl.keyStorePassword", "Pol1cy_0nap");
System.setProperties(systemProps);
@@ -80,11 +85,9 @@ public class TestHttpsStatisticDistributionRestServer {
main.shutdown();
}
- private StatisticsReport performStatisticCheck()
- throws InterruptedException, KeyManagementException, NoSuchAlgorithmException {
- StatisticsReport response = null;
+ private StatisticsReport performStatisticCheck() throws Exception {
- TrustManager[] noopTrustManager = new TrustManager[] { new X509TrustManager() {
+ final TrustManager[] noopTrustManager = new TrustManager[] { new X509TrustManager() {
@Override
public X509Certificate[] getAcceptedIssuers() {
@@ -92,18 +95,16 @@ public class TestHttpsStatisticDistributionRestServer {
}
@Override
- public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
- }
+ public void checkClientTrusted(final java.security.cert.X509Certificate[] certs, final String authType) {}
@Override
- public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
- }
+ public void checkServerTrusted(final java.security.cert.X509Certificate[] certs, final String authType) {}
} };
- SSLContext sc = SSLContext.getInstance("TLSv1.2");
+ final SSLContext sc = SSLContext.getInstance("TLSv1.2");
sc.init(null, noopTrustManager, new SecureRandom());
- final ClientBuilder clientBuilder = ClientBuilder.newBuilder().sslContext(sc)
- .hostnameVerifier((host, session) -> true);
+ final ClientBuilder clientBuilder =
+ ClientBuilder.newBuilder().sslContext(sc).hostnameVerifier((host, session) -> true);
final Client client = clientBuilder.build();
final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
client.register(feature);
@@ -111,19 +112,15 @@ public class TestHttpsStatisticDistributionRestServer {
final WebTarget webTarget = client.target("https://localhost:6969/statistics");
final Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
- while (response == null) {
- try {
- response = invocationBuilder.get(StatisticsReport.class);
- } catch (final Exception exp) {
- LOGGER.error("the server is not started yet. We will retry again", exp);
- }
+
+ if (!NetworkUtil.isTcpPortOpen("localhost", 6969, 6, 10000L)) {
+ throw new IllegalStateException("cannot connect to port 6969");
}
- return response;
+ return invocationBuilder.get(StatisticsReport.class);
}
private void validateReport(final int code, final int total, final int successCount, final int failureCount,
- final int download, final int downloadSuccess, final int downloadFailure, final String reportString,
- final StatisticsReport report) {
+ final int download, final int downloadSuccess, final int downloadFailure, final StatisticsReport report) {
assertEquals(code, report.getCode());
assertEquals(total, report.getTotalDistributionCount());
assertEquals(successCount, report.getDistributionSuccessCount());
@@ -131,6 +128,5 @@ public class TestHttpsStatisticDistributionRestServer {
assertEquals(download, report.getTotalDownloadCount());
assertEquals(downloadSuccess, report.getDownloadSuccessCount());
assertEquals(downloadFailure, report.getDownloadFailureCount());
- assertEquals(reportString, report.toString());
}
}
diff --git a/packages/policy-distribution-docker/src/main/docker/Dockerfile b/packages/policy-distribution-docker/src/main/docker/Dockerfile
index 3168d72b..34061856 100644
--- a/packages/policy-distribution-docker/src/main/docker/Dockerfile
+++ b/packages/policy-distribution-docker/src/main/docker/Dockerfile
@@ -3,7 +3,7 @@ FROM ubuntu:14.04
ARG HTTP_PROXY=${HTTP_PROXY}
ARG HTTPS_PROXY=${HTTPS_PROXY}
ARG BUILD_VERSION=${BUILD_VERSION}
-ARG POLICY_LOGS=/var/log/onap
+ARG POLICY_LOGS=/var/log/onap/policy/distribution
ENV http_proxy $HTTP_PROXY
ENV https_proxy $HTTPS_PROXY
diff --git a/packages/policy-distribution-tarball/src/main/resources/etc/logback.xml b/packages/policy-distribution-tarball/src/main/resources/etc/logback.xml
index ebe06a8f..1c0a8bd4 100644
--- a/packages/policy-distribution-tarball/src/main/resources/etc/logback.xml
+++ b/packages/policy-distribution-tarball/src/main/resources/etc/logback.xml
@@ -18,232 +18,105 @@
============LICENSE_END=========================================================
-->
-<configuration scan="true" scanPeriod="3 seconds" debug="true">
- <!--<jmxConfigurator /> -->
- <!-- directory path for all other type logs -->
- <property name="logDir" value="${POLICY_LOGS}" />
-
- <!-- directory path for debugging type logs -->
- <property name="debugDir" value="${POLICY_LOGS}" />
-
- <!-- specify the component name
- <ONAP-component-name>::= "MSO" | "DCAE" | "ASDC " | "AAI" |"Policy" | "SDNC" | "AC" -->
- <property name="componentName" value="policy"></property>
- <property name="subComponentName" value="distribution"></property>
-
- <!-- log file names -->
- <property name="errorLogName" value="error" />
- <property name="metricsLogName" value="metrics" />
- <property name="auditLogName" value="audit" />
- <property name="debugLogName" value="debug" />
-
-
- <!-- modified time stamp format -->
-
- <!-- A U D I T
- <property name="defaultAuditPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
- <property name="defaultAuditPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{requestId}|%X{serviceInstanceId}|%t|%X{serverName}|%X{serviceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{instanceUuid}|%p|%X{severity}|%X{serverIpAddress}|%X{ElapsedTime}|%X{server}|%X{clientIpAddress}|%c||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
- -->
- <property name="defaultAuditPattern" value="%X{TransactionBeginTimestamp}|%X{TransactionEndTimestamp}|%X{requestId}|%X{serviceInstanceId}|%t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{statusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{instanceUuid}|%p|%X{severity}|%X{serverIpAddress}|%X{TransactionElapsedTime}|%X{server}|%X{clientIpAddress}|%c||%X{ProcessKey}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
-
-
-
- <!-- M E T R I C
- <property name="defaultMetricPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
- -->
- <property name="defaultMetricPattern" value="%X{MetricBeginTimestamp}|%X{MetricEndTimestamp}|%X{requestId}|%X{serviceInstanceId}|%t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%X{statusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%p|%X{severity}|%X{serverIpAddress}|%X{MetricElapsedTime}|%X{server}|%X{clientIpAddress}|%c||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
-
-
-
- <!-- E R R O R
- <property name="defaultErrorPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}|%X{RequestId}|%thread|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{ErrorCategory}|%X{ErrorCode}|%X{ErrorDesciption}|%msg%n" />
- -->
- <property name="defaultErrorPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}|%X{requestId}|%t|%X{serviceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{ErrorCategory}|%X{ErrorCode}|%X{ErrorDesciption}|%msg%n" />
-
-
-
- <!-- D E B U G
- <property name="debugLoggerPatternOld" value="%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{Timer}|[%caller{3}]|%msg%n" />
- <property name="debugLoggerPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}||%X{ProcessKey}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" /> -->
- -->
- <property name="debugLoggerPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}|%X{RequestId}|%msg%n" />
-
-
-
- <!-- D E F A U L T
- <property name="defaultPatternOld" value="%d{MM/dd-HH:mm:ss.SSS}|%logger|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Timer}|%msg%n" />
- <property name="defaultPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
- -->
- <property name="defaultPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX, UTC}|%X{requestId}|%X{serviceInstanceId}|%t|%X{serverName}|%X{serviceName}|%X{instanceUuid}|%p|%X{severity}|%X{serverIpAddress}|%X{server}|%X{clientIpAddress}|%c||%msg%n" />
-
-
-
- <!-- P A T H
- <property name="logDirectory" value="${logDir}/${componentName}/${subComponentName}" />
- <property name="debugLogDirectory" value="${debugDir}/${componentName}/${subComponentName}" />
-
- -->
- <property name="logDirectory" value="${logDir}/${componentName}/${subComponentName}" />
- <property name="debugLogDirectory" value="${debugDir}/${componentName}/${subComponentName}" />
-
-
-
-
- <!-- Example evaluator filter applied against console appender -->
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>${defaultPattern}</pattern>
- </encoder>
- </appender>
-
- <!-- ============================================================================ -->
- <!-- EELF Appenders -->
- <!-- ============================================================================ -->
-
- <!-- The EELFAppender is used to record events to the general application
- log -->
-
- <!-- EELF Audit Appender. This appender is used to record audit engine
- related logging events. The audit logger and appender are specializations
- of the EELF application root logger and appender. This can be used to segregate
- Policy engine events from other components, or it can be eliminated to record
- these events as part of the application root log. -->
-
- <appender name="EELFAudit"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDirectory}/${auditLogName}.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
- <fileNamePattern>${logDirectory}/${auditLogName}.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
-
- <!-- keep 30 days' worth of history capped at 3GB total size -->
- <maxFileSize>50MB</maxFileSize>
- <maxHistory>30</maxHistory>
- <totalSizeCap>10GB</totalSizeCap>
- </rollingPolicy>
-
- <encoder>
- <pattern>${defaultAuditPattern}</pattern>
- </encoder>
- </appender>
-
- <appender name="asyncEELFAudit" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELFAudit" />
- </appender>
-
-
-
-
-<appender name="EELFMetrics"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDirectory}/${metricsLogName}.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
- <fileNamePattern>${logDirectory}/${metricsLogName}.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
-
- <!-- keep 30 days' worth of history capped at 3GB total size -->
- <maxFileSize>50MB</maxFileSize>
- <maxHistory>30</maxHistory>
- <totalSizeCap>10GB</totalSizeCap>
- </rollingPolicy>
-
- <encoder>
- <pattern>${defaultMetricPattern}</pattern>
- </encoder>
- </appender>
-
- <appender name="asyncEELFMetrics" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELFMetrics"/>
- </appender>
-
-
-
-
- <appender name="EELFError"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDirectory}/${errorLogName}.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
- <fileNamePattern>${logDirectory}/${errorLogName}.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
-
- <!-- keep 30 days' worth of history capped at 3GB total size -->
- <maxFileSize>50MB</maxFileSize>
- <maxHistory>30</maxHistory>
- <totalSizeCap>10GB</totalSizeCap>
- </rollingPolicy>
- <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
- <level>ERROR</level>
- </filter>
- <encoder>
- <pattern>${defaultErrorPattern}</pattern>
- </encoder>
- </appender>
-
- <appender name="asyncEELFError" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELFError"/>
- </appender>
-
-
-
- <appender name="EELFDebug"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${debugLogDirectory}/${debugLogName}.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
- <fileNamePattern>${debugLogDirectory}/${debugLogName}.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
-
- <!-- keep 30 days' worth of history capped at 3GB total size -->
- <maxFileSize>50MB</maxFileSize>
- <maxHistory>30</maxHistory>
- <totalSizeCap>10GB</totalSizeCap>
- </rollingPolicy>
- <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
- <level>DEBUG</level>
- </filter>
-
- <encoder>
- <pattern>${debugLoggerPattern}</pattern>
- </encoder>
- </appender>
-
- <appender name="asyncEELFDebug" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELFDebug" />
- <includeCallerData>true</includeCallerData>
- </appender>
-
-
- <!-- ============================================================================ -->
- <!-- EELF loggers -->
- <!-- ============================================================================ -->
-
- <logger name="com.att.eelf.audit" level="info" additivity="false">
- <appender-ref ref="asyncEELFAudit" />
- </logger>
-
- <logger name="com.att.eelf.metrics" level="info" additivity="false">
- <appender-ref ref="asyncEELFMetrics" />
- </logger>
-
- <logger name="com.att.eelf.error" level="error" additivity="false">
- <appender-ref ref="asyncEELFError" />
- </logger>
-
- <logger name="com.att.eelf.debug" level="debug" additivity="false">
- <appender-ref ref="asyncEELFDebug" />
- </logger>
-
- <logger name="org.onap.sdc" level="trace">
- <appender-ref ref="asyncEELFDebug" />
- </logger>
-
-
- <root level="INFO">
- <appender-ref ref="asyncEELFDebug" />
- <appender-ref ref="asyncEELFError" />
- </root>
+<configuration scan="true" scanPeriod="30 seconds" debug="false">
+
+ <property name="logDir" value="${POLICY_LOGS}" />
+
+ <property name="errorLog" value="error" />
+ <property name="debugLog" value="debug" />
+ <property name="networkLog" value="network" />
+
+ <property name="metricLog" value="metric" />
+ <property name="transactionLog" value="audit" />
+
+ <property name="debugPattern"
+ value="[%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}|%level|%logger{0}|%thread] %msg%n" />
+ <property name="errorPattern" value="${debugPattern}" />
+ <property name="networkPattern"
+ value="[%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}|%t]%m%n" />
+
+ <property name="metricPattern"
+ value="%X{RequestID}|%X{InvocationID}|%X{ServiceName}|%X{PartnerName}|%X{BeginTimestamp}|%X{EndTimestamp}|%X{ElapsedTime}|%X{ServiceInstanceID}|%X{VirtualServerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%X{Severity}|%X{TargetEntity}|%X{TargetServiceName}|%X{Server}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{ClientIPAddress}|%X{ProcessKey}|%X{RemoteHost}|%X{AlertSeverity}|%X{TargetVirtualEntity}|%level|%thread| %msg%n" />
+ <property name="transactionPattern" value="${metricPattern}" />
+
+ <appender name="ErrorOut"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDir}/${errorLog}.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <fileNamePattern>${logDir}/${errorLog}.%d{yyyy-MM-dd}.%i.log.zip
+ </fileNamePattern>
+ <maxFileSize>50MB</maxFileSize>
+ <maxHistory>30</maxHistory>
+ <totalSizeCap>10GB</totalSizeCap>
+ </rollingPolicy>
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>WARN</level>
+ </filter>
+ <encoder>
+ <pattern>${errorPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="AsyncErrorOut"
+ class="ch.qos.logback.classic.AsyncAppender">
+ <appender-ref ref="ErrorOut" />
+ </appender>
+
+ <appender name="DebugOut"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDir}/${debugLog}.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <fileNamePattern>${logDir}/${debugLog}.%d{yyyy-MM-dd}.%i.log.zip
+ </fileNamePattern>
+ <maxFileSize>50MB</maxFileSize>
+ <maxHistory>30</maxHistory>
+ <totalSizeCap>10GB</totalSizeCap>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${debugPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="AsyncDebugOut"
+ class="ch.qos.logback.classic.AsyncAppender">
+ <appender-ref ref="DebugOut" />
+ </appender>
+
+ <appender name="NetworkOut"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDir}/${networkLog}.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <fileNamePattern>${logDir}/${networkLog}.%d{yyyy-MM-dd}.%i.log.zip
+ </fileNamePattern>
+ <maxFileSize>50MB</maxFileSize>
+ <maxHistory>30</maxHistory>
+ <totalSizeCap>10GB</totalSizeCap>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${networkPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="AsyncNetworkOut"
+ class="ch.qos.logback.classic.AsyncAppender">
+ <appender-ref ref="NetworkOut" />
+ </appender>
+
+ <logger name="network" level="INFO" additivity="false">
+ <appender-ref ref="AsyncNetworkOut" />
+ </logger>
+
+ <logger name="org.eclipse.jetty.server.RequestLog" level="info"
+ additivity="false">
+ <appender-ref ref="AsyncNetworkOut" />
+ </logger>
+
+ <root level="INFO">
+ <appender-ref ref="AsyncDebugOut" />
+ <appender-ref ref="AsyncErrorOut" />
+ </root>
</configuration>
diff --git a/packages/policy-distribution-tarball/src/main/resources/policyLogger.properties b/packages/policy-distribution-tarball/src/main/resources/policyLogger.properties
deleted file mode 100644
index 0ff9ebe9..00000000
--- a/packages/policy-distribution-tarball/src/main/resources/policyLogger.properties
+++ /dev/null
@@ -1,44 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# Copyright (C) 2018 Ericsson. All rights reserved.
-# ================================================================================
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# SPDX-License-Identifier: Apache-2.0
-# ============LICENSE_END=========================================================
-###
-
-################################## Set concurrentHashMap and timer info #######################
-#Timer initial delay and the delay between in milliseconds before task is to be execute.
-timer.delay.time=1000
-#Timer scheduleAtFixedRate period - time in milliseconds between successive task executions.
-check.interval= 30000
-#Longest time an event info can be stored in the concurrentHashMap for logging - in seconds.
-event.expired.time=86400
-#Size of the concurrentHashMap which stores the event starting time, etc - when its size reaches this limit, the Timer gets executed
-#to remove all expired records from this concurrentHashMap.
-concurrentHashMap.limit=5000
-#Size of the concurrentHashMap - when its size drops to this point, stop the Timer
-stop.check.point=2500
-################################### Set logging format #############################################
-# set EELF for EELF logging format, set LOG4J for using log4j, set SYSTEMOUT for using system.out.println
-logger.type=EELF
-#################################### Set level for EELF or SYSTEMOUT logging ##################################
-# Set level for debug file. Set DEBUG to enable .info, .warn and .debug; set INFO for enable .info and .warn; set OFF to disable all
-debugLogger.level=INFO
-# Set level for metrics file. Set OFF to disable; set ON to enable
-metricsLogger.level=ON
-# Set level for error file. Set OFF to disable; set ON to enable
-error.level=ON
-# Set level for audit file. Set OFF to disable; set ON to enable
-audit.level=ON
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java
index 579454c5..1eac005a 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,8 +33,6 @@ import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.toscaparser.api.CapabilityAssignment;
@@ -42,6 +41,8 @@ import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.RequirementAssignment;
import org.onap.sdc.toscaparser.api.RequirementAssignments;
import org.onap.sdc.toscaparser.api.elements.Metadata;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Extract concerned info from NodeTemplate, currently ONLY HPA Feature.
@@ -50,8 +51,9 @@ import org.onap.sdc.toscaparser.api.elements.Metadata;
*/
public class ExtractFromNode {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ExtractFromNode.class);
+
private static final String CONFIGURATION_VALUE = "configurationValue";
- private static final Logger LOGGER = FlexLogger.getLogger(ExtractFromNode.class);
private static final String VDU_TYPE = "tosca.nodes.nfv.Vdu.Compute";
private static final String VDU_CP_TYPE = "tosca.nodes.nfv.VduCp";
private static final String VIRTUAL_MEM_SIZE_PATH = "virtual_memory#virtual_mem_size";
@@ -60,7 +62,7 @@ public class ExtractFromNode {
private static final String MEMORY_PAGE_SIZE_PATH = "virtual_memory#vdu_memory_requirements#memoryPageSize";
private static final String NETWORK_INTERFACE_TYPE_PATH =
"virtual_network_interface_requirements#network_interface_requirements#interfaceType";
- private static final String NETWORK_PCI_PATH =
+ private static final String NETWORK_PCI_PATH =
"virtual_network_interface_requirements#nic_io_requirements#logical_node_requirements";
private static final String BASIC_CAPABILITIES_HPA_FEATURE = "basicCapabilities";
private static final String HUGE_PAGES_HPA_FEATURE = "hugePages";
@@ -85,10 +87,10 @@ public class ExtractFromNode {
* @throws PolicyDecodingException if extract fails
*/
public Content extractInfo(final NodeTemplate node) throws PolicyDecodingException {
- Metadata metaData = sdcCsarHelper.getNodeTemplateMetadata(node);
- LOGGER.debug("the meta data of this nodetemplate = " + metaData);
+ final Metadata metaData = sdcCsarHelper.getNodeTemplateMetadata(node);
+ LOGGER.debug("the meta data of this nodetemplate = {}", metaData);
final List<NodeTemplate> lnodeChild = sdcCsarHelper.getNodeTemplateChildren(node);
- LOGGER.debug("the size of lnodeChild = " + lnodeChild.size());
+ LOGGER.debug("the size of lnodeChild = {}", lnodeChild.size());
// Store all the VDUs under one VNF
final List<NodeTemplate> lnodeVdu = new ArrayList<>();
@@ -96,16 +98,16 @@ public class ExtractFromNode {
final List<NodeTemplate> lnodeVduCp = new ArrayList<>();
for (final NodeTemplate nodeChild : lnodeChild) {
final String type = sdcCsarHelper.getTypeOfNodeTemplate(nodeChild);
- LOGGER.debug("the type of this nodeChild = " + type);
- LOGGER.debug("the meta data of this nodeChild = " + sdcCsarHelper.getNodeTemplateMetadata(nodeChild));
+ LOGGER.debug("the type of this nodeChild = {}", type);
+ LOGGER.debug("the meta data of this nodeChild = {}", sdcCsarHelper.getNodeTemplateMetadata(nodeChild));
if (type.equalsIgnoreCase(VDU_TYPE)) {
lnodeVdu.add(nodeChild);
} else if (type.equalsIgnoreCase(VDU_CP_TYPE)) {
lnodeVduCp.add(nodeChild);
}
}
- LOGGER.debug("the size of vdu is =" + lnodeVdu.size());
- LOGGER.debug("the size of cp is =" + lnodeVduCp.size());
+ LOGGER.debug("the size of vdu is = {}", lnodeVdu.size());
+ LOGGER.debug("the size of cp is = {}", lnodeVduCp.size());
final Content content = new Content();
content.getResources().add(metaData.getValue("name"));
@@ -137,7 +139,7 @@ public class ExtractFromNode {
flavorDirective.getAttributes().add(flavorAttribute);
final FlavorFeature flavorFeature = new FlavorFeature();
flavorFeature.setId(node.toString());
- LOGGER.debug("the name of node =" + node.toString());
+ LOGGER.debug("the name of node = {}", node);
flavorFeature.getDirectives().add(flavorDirective);
final CapabilityAssignments capabilityAssignments = sdcCsarHelper.getCapabilitiesOf(node);
@@ -164,7 +166,7 @@ public class ExtractFromNode {
final String virtualMemSize =
sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, VIRTUAL_MEM_SIZE_PATH);
if (virtualMemSize != null) {
- LOGGER.debug("the virtualMemSize = " + virtualMemSize);
+ LOGGER.debug("the virtualMemSize = {}", virtualMemSize);
final HpaFeatureAttribute hpaFeatureAttribute =
generateHpaFeatureAttribute("virtualMemSize", virtualMemSize);
final FlavorProperty flavorProperty = new FlavorProperty();
@@ -177,7 +179,7 @@ public class ExtractFromNode {
final String numVirtualCpu =
sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, NUM_VIRTUAL_CPU_PATH);
if (numVirtualCpu != null) {
- LOGGER.debug("the numVirtualCpu = " + numVirtualCpu);
+ LOGGER.debug("the numVirtualCpu = {}", numVirtualCpu);
final HpaFeatureAttribute hpaFeatureAttribute = generateHpaFeatureAttribute("numVirtualCpu", numVirtualCpu);
final String cpuArchitecture =
sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, CPU_ARCHITECTURE_PATH);
@@ -207,15 +209,17 @@ public class ExtractFromNode {
final String modifiedValue = featureValue.replace(" ", "");
final Matcher matcher = PATTERN.matcher(modifiedValue);
if (matcher.find()) {
- LOGGER.debug("operator " + matcher.group(1) + ", value = " + matcher.group(2)
- + ", unit = " + matcher.group(3));
- if ( matcher.group(1).length() == 0 ) {
+ final String matcher1 = matcher.group(1);
+ final String matcher2 = matcher.group(2);
+ final String matcher3 = matcher.group(3);
+ LOGGER.debug("operator {} , value = {} , unit = {}", matcher1, matcher2, matcher3);
+ if (matcher.group(1).length() == 0) {
hpaFeatureAttribute.setOperator("=");
} else {
- hpaFeatureAttribute.setOperator(matcher.group(1));
+ hpaFeatureAttribute.setOperator(matcher1);
}
- hpaFeatureAttribute.setHpaAttributeValue(matcher.group(2));
- hpaFeatureAttribute.setUnit(matcher.group(3));
+ hpaFeatureAttribute.setHpaAttributeValue(matcher2);
+ hpaFeatureAttribute.setUnit(matcher3);
}
return hpaFeatureAttribute;
}
@@ -232,11 +236,11 @@ public class ExtractFromNode {
private void generateHugePages(final CapabilityAssignment capabilityAssignment, final FlavorFeature flavorFeature) {
final String memoryPageSize =
sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, MEMORY_PAGE_SIZE_PATH);
- LOGGER.debug("the memoryPageSize = " + memoryPageSize);
+ LOGGER.debug("the memoryPageSize = {}", memoryPageSize);
if (memoryPageSize != null) {
final Map<String, String> retMap =
gson.fromJson(memoryPageSize, new TypeToken<HashMap<String, String>>() {}.getType());
- LOGGER.debug("the retMap = " + retMap);
+ LOGGER.debug("the retMap = {}", retMap);
final String memoryPageSizeValue = retMap.get(CONFIGURATION_VALUE);
final String mandatory = retMap.get("mandatory");
if (memoryPageSizeValue == null) {
@@ -268,35 +272,47 @@ public class ExtractFromNode {
// each CP will binds to a VDU so need the vdu flavor map info.
final Map<String, FlavorFeature> vduFlavorMap = new HashMap<>();
for (final FlavorFeature flavorFeature : content.getFlavorFeatures()) {
- LOGGER.debug("the id = " + flavorFeature.getId());
+ LOGGER.debug("the id = {}", flavorFeature.getId());
vduFlavorMap.put(flavorFeature.getId(), flavorFeature);
}
+ parseNodeVduCp(lnodeVduCp, vduFlavorMap);
+ }
+
+ /**
+ * Parse the VduCp list.
+ *
+ * @param lnodeVduCp the lnodeVduCp
+ * @param vduFlavorMap the vduFlavorMap
+ * @throws PolicyDecodingException if any error occurs
+ */
+ private void parseNodeVduCp(final List<NodeTemplate> lnodeVduCp, final Map<String, FlavorFeature> vduFlavorMap)
+ throws PolicyDecodingException {
for (final NodeTemplate node : lnodeVduCp) {
final String interfaceType =
sdcCsarHelper.getNodeTemplatePropertyLeafValue(node, NETWORK_INTERFACE_TYPE_PATH);
- LOGGER.debug("the interfaceType = " + interfaceType);
+ LOGGER.debug("the interfaceType = {}", interfaceType);
Map<String, Object> retMap = new HashMap<>();
if (interfaceType != null) {
retMap = gson.fromJson(interfaceType, new TypeToken<HashMap<String, Object>>() {}.getType());
- LOGGER.debug("the retMap = " + retMap);
+ LOGGER.debug("the retMap = {}", retMap);
}
String networkHpaFeature;
if (retMap.containsKey(CONFIGURATION_VALUE)
- && NETWORK_HPA_FEATURE_MAP.containsKey(retMap.get(CONFIGURATION_VALUE).toString())) {
+ && NETWORK_HPA_FEATURE_MAP.containsKey(retMap.get(CONFIGURATION_VALUE).toString())) {
final String interfaceTypeValue = retMap.get(CONFIGURATION_VALUE).toString();
networkHpaFeature = NETWORK_HPA_FEATURE_MAP.get(interfaceTypeValue);
- LOGGER.debug(" the networkHpaFeature is =" + networkHpaFeature);
+ LOGGER.debug(" the networkHpaFeature is = {}", networkHpaFeature);
} else {
LOGGER.debug(" no networkHpaFeature defined in interfaceType");
continue;
}
final RequirementAssignments requriements =
- sdcCsarHelper.getRequirementsOf(node).getRequirementsByName("virtual_binding");
- for (final RequirementAssignment requriement: requriements.getAll()) {
+ sdcCsarHelper.getRequirementsOf(node).getRequirementsByName("virtual_binding");
+ for (final RequirementAssignment requriement : requriements.getAll()) {
final String nodeTemplateName = requriement.getNodeTemplateName();
- LOGGER.debug("getNodeTemplateName =" + nodeTemplateName);
+ LOGGER.debug("getNodeTemplateName = {}", nodeTemplateName);
if (nodeTemplateName == null) {
continue;
}
@@ -323,11 +339,11 @@ public class ExtractFromNode {
flavorProperty.setHpaFeature(networkHpaFeature);
final String[] pciKeys = { "pciVendorId", "pciDeviceId", "pciNumDevices", "physicalNetwork" };
for (final String pciKey : pciKeys) {
- LOGGER.debug("the pciKey = " + pciKey);
+ LOGGER.debug("the pciKey = {}", pciKey);
final String pciKeyPath = NETWORK_PCI_PATH + "#" + pciKey;
final String pciValue = sdcCsarHelper.getNodeTemplatePropertyLeafValue(node, pciKeyPath);
if (pciValue != null) {
- LOGGER.debug("the pciValue = " + pciValue);
+ LOGGER.debug("the pciValue = {}", pciValue);
final Map<String, String> retMap =
gson.fromJson(pciValue, new TypeToken<HashMap<String, String>>() {}.getType());
final String pciConfigValue = retMap.get(CONFIGURATION_VALUE);
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java
index 7a73c831..705968ae 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,12 +23,12 @@ package org.onap.policy.distribution.reception.decoding.pdpx;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-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.model.Csar;
import org.onap.policy.distribution.model.OptimizationPolicy;
@@ -37,13 +38,15 @@ import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Decodes PDP-X policies from a CSAR file.
*/
public class PolicyDecoderCsarPdpx implements PolicyDecoder<Csar, OptimizationPolicy> {
- private static final Logger LOGGER = FlexLogger.getLogger(PolicyDecoderCsarPdpx.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(PolicyDecoderCsarPdpx.class);
private final Gson gson = new GsonBuilder().serializeNulls().disableHtmlEscaping().create();
private PolicyDecoderCsarPdpxConfigurationParameterGroup decoderParameters;
@@ -52,11 +55,11 @@ public class PolicyDecoderCsarPdpx implements PolicyDecoder<Csar, OptimizationPo
final List<OptimizationPolicy> policys = new ArrayList<>();
final ISdcCsarHelper sdcCsarHelper = parseCsar(csar);
final List<NodeTemplate> lnodeVf = sdcCsarHelper.getServiceVfList();
- LOGGER.debug("the size of Vf = " + lnodeVf.size());
+ LOGGER.debug("the size of Vf = {}", lnodeVf.size());
final ExtractFromNode extractFromNode = new ExtractFromNode();
extractFromNode.setSdcCsarHelper(sdcCsarHelper);
final String serviceName = sdcCsarHelper.getServiceMetadata().getValue("name");
- LOGGER.debug("the name of the service = " + serviceName);
+ LOGGER.debug("the name of the service = {}", serviceName);
for (final NodeTemplate node : lnodeVf) {
final Content content = extractFromNode.extractInfo(node);
if (content != null) {
@@ -64,7 +67,7 @@ public class PolicyDecoderCsarPdpx implements PolicyDecoder<Csar, OptimizationPo
final String policyName = decoderParameters.getPolicyNamePrefix() + "." + content.getIdentity();
policy.setOnapName(decoderParameters.getOnapName());
policy.setPolicyName(policyName);
- ConfigBody configBody = new ConfigBody();
+ final ConfigBody configBody = new ConfigBody();
configBody.setService("hpaPolicy");
configBody.setPolicyName(policyName);
configBody.setDescription("OOF Policy");
@@ -101,7 +104,7 @@ public class PolicyDecoderCsarPdpx implements PolicyDecoder<Csar, OptimizationPo
ISdcCsarHelper sdcCsarHelper;
try {
final SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();
- LOGGER.debug("Csar File Path = " + csar.getCsarPath());
+ LOGGER.debug("Csar File Path = {}", csar.getCsarPath());
final File csarFile = new File(csar.getCsarPath());
sdcCsarHelper = factory.getSdcCsarHelper(csarFile.getAbsolutePath());
} catch (final Exception exp) {
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.java
index 482ac80b..22b626f8 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,14 +30,14 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.apache.commons.io.IOUtils;
-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.model.Csar;
import org.onap.policy.distribution.model.PolicyAsString;
import org.onap.policy.distribution.model.PolicyInput;
import org.onap.policy.distribution.reception.decoding.PolicyDecoder;
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This class extracts policy files from a CSAR file.
@@ -45,7 +46,7 @@ import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
*/
public class PolicyDecoderFileInCsarToPolicy implements PolicyDecoder<Csar, PolicyAsString> {
- private static final Logger LOGGER = FlexLogger.getLogger(PolicyDecoderFileInCsarToPolicy.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(PolicyDecoderFileInCsarToPolicy.class);
PolicyDecoderFileInCsarToPolicyParameterGroup decoderParameters;
/**
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileClientHandler.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileClientHandler.java
index f8e57747..fd4f69cc 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileClientHandler.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileClientHandler.java
@@ -22,8 +22,8 @@ package org.onap.policy.distribution.reception.handling.file;
import java.io.IOException;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This class implements Runnable interface for creating new thread which will be used as file watcher.
@@ -32,7 +32,7 @@ import org.onap.policy.common.logging.flexlogger.Logger;
*/
public class FileClientHandler implements Runnable {
- private static final Logger LOGGER = FlexLogger.getLogger(FileClientHandler.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(FileClientHandler.class);
private FileSystemReceptionHandler fileReceptionHandler;
private String watchPath;
@@ -55,7 +55,7 @@ public class FileClientHandler implements Runnable {
try {
fileReceptionHandler.initFileWatcher(watchPath);
} catch (final IOException ex) {
- LOGGER.error(ex);
+ LOGGER.error("Failed initializing file watcher thread", ex);
}
}
}
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java
index 3cb167f3..a3f6fab0 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java
@@ -34,20 +34,20 @@ import java.nio.file.WatchService;
import java.util.concurrent.TimeUnit;
import java.util.zip.ZipFile;
-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.model.Csar;
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
import org.onap.policy.distribution.reception.handling.AbstractReceptionHandler;
import org.onap.policy.distribution.reception.statistics.DistributionStatisticsManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Handles reception of inputs from File System which can be used to decode policies.
*/
public class FileSystemReceptionHandler extends AbstractReceptionHandler {
- private static final Logger LOGGER = FlexLogger.getLogger(FileSystemReceptionHandler.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(FileSystemReceptionHandler.class);
private boolean running = false;
/**
@@ -63,7 +63,7 @@ public class FileSystemReceptionHandler extends AbstractReceptionHandler {
final Thread fileWatcherThread = new Thread(fileClientHandler);
fileWatcherThread.start();
} catch (final Exception ex) {
- LOGGER.error(ex);
+ LOGGER.error("FileSystemReceptionHandler initialization failed", ex);
}
}
@@ -93,10 +93,10 @@ public class FileSystemReceptionHandler extends AbstractReceptionHandler {
try (final WatchService watcher = FileSystems.getDefault().newWatchService()) {
final Path dir = Paths.get(watchPath);
dir.register(watcher, ENTRY_CREATE);
- LOGGER.debug("Watch Service registered for dir: " + dir.getFileName());
+ LOGGER.debug("Watch Service registered for dir: {}", dir.getFileName());
startWatchService(watcher, dir);
} catch (final InterruptedException ex) {
- LOGGER.debug(ex);
+ LOGGER.error("FileWatcher initialization failed", ex);
Thread.currentThread().interrupt();
}
}
@@ -118,12 +118,12 @@ public class FileSystemReceptionHandler extends AbstractReceptionHandler {
for (final WatchEvent<?> event : key.pollEvents()) {
final WatchEvent<Path> ev = (WatchEvent<Path>) event;
final Path fileName = ev.context();
- LOGGER.debug("new CSAR found: " + fileName);
+ LOGGER.debug("new CSAR found: {}", fileName);
DistributionStatisticsManager.updateTotalDistributionCount();
final String fullFilePath = dir.toString() + File.separator + fileName.toString();
waitForFileToBeReady(fullFilePath);
createPolicyInputAndCallHandler(fullFilePath);
- LOGGER.debug("CSAR complete: " + fileName);
+ LOGGER.debug("CSAR complete: {}", fileName);
}
final boolean valid = key.reset();
if (!valid) {
@@ -148,7 +148,7 @@ public class FileSystemReceptionHandler extends AbstractReceptionHandler {
} catch (final PolicyDecodingException ex) {
DistributionStatisticsManager.updateDownloadFailureCount();
DistributionStatisticsManager.updateDistributionFailureCount();
- LOGGER.error(ex);
+ LOGGER.error("Policy creation failed", ex);
}
}
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java
index 0d100f8f..c3d7e43b 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,8 +27,6 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
-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.model.Csar;
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
@@ -46,13 +45,15 @@ import org.onap.sdc.api.results.IDistributionClientResult;
import org.onap.sdc.impl.DistributionClientFactory;
import org.onap.sdc.utils.DistributionActionResultEnum;
import org.onap.sdc.utils.DistributionStatusEnum;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Handles reception of inputs from ONAP Service Design and Creation (SDC) from which policies may be decoded.
*/
public class SdcReceptionHandler extends AbstractReceptionHandler implements INotificationCallback {
- private static final Logger LOGGER = FlexLogger.getLogger(SdcReceptionHandler.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(SdcReceptionHandler.class);
private static final String SECONDS = "Seconds";
private SdcReceptionHandlerStatus sdcReceptionHandlerStatus = SdcReceptionHandlerStatus.STOPPED;
@@ -85,11 +86,11 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
@Override
public void activateCallback(final INotificationData notificationData) {
- LOGGER.debug("Receieved the notification from SDC with ID: " + notificationData.getDistributionID());
+ LOGGER.debug("Receieved the notification from SDC with ID: {}", notificationData.getDistributionID());
changeSdcReceptionHandlerStatus(SdcReceptionHandlerStatus.BUSY);
processCsarServiceArtifacts(notificationData);
changeSdcReceptionHandlerStatus(SdcReceptionHandlerStatus.IDLE);
- LOGGER.debug("Processed the notification from SDC with ID: " + notificationData.getDistributionID());
+ LOGGER.debug("Processed the notification from SDC with ID: {}", notificationData.getDistributionID());
}
/**
@@ -137,8 +138,8 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
}
final IDistributionClientResult clientResult = distributionClient.init(sdcConfig, this);
if (!clientResult.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
- LOGGER.error("SDC client initialization failed with reason:" + clientResult.getDistributionMessageResult()
- + ". Initialization will be retried after " + retryDelay + SECONDS);
+ LOGGER.error("SDC client initialization failed with reason: {}. Initialization will be retried after {} {}",
+ clientResult.getDistributionMessageResult(), retryDelay, SECONDS);
return;
}
LOGGER.debug("SDC Client is initialized successfully");
@@ -158,8 +159,8 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
}
final IDistributionClientResult clientResult = distributionClient.start();
if (!clientResult.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
- LOGGER.error("SDC client start failed with reason:" + clientResult.getDistributionMessageResult()
- + ". Start will be retried after " + retryDelay + SECONDS);
+ LOGGER.error("SDC client start failed with reason: {}. Start will be retried after {} {}",
+ clientResult.getDistributionMessageResult(), retryDelay, SECONDS);
return;
}
LOGGER.debug("SDC Client is started successfully");
@@ -175,8 +176,8 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
LOGGER.debug("Going to stop the SDC Client...");
final IDistributionClientResult clientResult = distributionClient.stop();
if (!clientResult.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
- LOGGER.error("SDC client stop failed with reason:" + clientResult.getDistributionMessageResult()
- + ". Stop will be retried after " + retryDelay + SECONDS);
+ LOGGER.error("SDC client stop failed with reason: {}. Stop will be retried after {} {}",
+ clientResult.getDistributionMessageResult(), retryDelay, SECONDS);
return;
}
LOGGER.debug("SDC Client is stopped successfully");
@@ -324,10 +325,10 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
}
if (!clientResult.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
loggerMessage.insert(0, "Failed sending ");
- LOGGER.debug(loggerMessage);
+ LOGGER.debug("Failed sending {}", loggerMessage);
} else {
loggerMessage.insert(0, "Successfully Sent ");
- LOGGER.debug(loggerMessage);
+ LOGGER.debug("Successfully Sent {}", loggerMessage);
}
}
@@ -358,11 +359,9 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
loggerMessage.append(" ErrorReason: ").append(errorReason);
}
if (!clientResult.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
- loggerMessage.insert(0, "Failed sending ");
- LOGGER.debug(loggerMessage);
+ LOGGER.debug("Failed sending {}", loggerMessage);
} else {
- loggerMessage.insert(0, "Successfully Sent ");
- LOGGER.debug(loggerMessage);
+ LOGGER.debug("Successfully Sent {}", loggerMessage);
}
}
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandler.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandler.java
index 28408700..fdb01007 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandler.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandler.java
@@ -43,11 +43,11 @@ import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
-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.reception.decoding.PolicyDecodingException;
import org.onap.policy.distribution.reception.statistics.DistributionStatisticsManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class to perform unit test of {@link FileSystemReceptionHandler}.
@@ -55,7 +55,7 @@ import org.onap.policy.distribution.reception.statistics.DistributionStatisticsM
@RunWith(MockitoJUnitRunner.class)
public class TestFileSystemReceptionHandler {
- private static final Logger LOGGER = FlexLogger.getLogger(TestFileSystemReceptionHandler.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestFileSystemReceptionHandler.class);
@Rule
public TemporaryFolder tempFolder = new TemporaryFolder();
@@ -97,7 +97,7 @@ public class TestFileSystemReceptionHandler {
try {
sypHandler.initializeReception(pssdConfigParameters.getName());
} catch (final Exception exp) {
- LOGGER.error(exp);
+ LOGGER.error("testInit failed", exp);
fail("Test should not throw any exception");
}
}
@@ -110,7 +110,7 @@ public class TestFileSystemReceptionHandler {
sypHandler.initializeReception(pssdConfigParameters.getName());
sypHandler.destroy();
} catch (final Exception exp) {
- LOGGER.error(exp);
+ LOGGER.error("testDestroy failed", exp);
fail("Test should not throw any exception");
}
@@ -143,7 +143,7 @@ public class TestFileSystemReceptionHandler {
try {
sypHandler.initFileWatcher(watchPath);
} catch (final IOException ex) {
- LOGGER.error(ex);
+ LOGGER.error("testMain failed", ex);
}
});
@@ -170,7 +170,7 @@ public class TestFileSystemReceptionHandler {
th.interrupt();
th.join();
} catch (final InterruptedException ex) {
- LOGGER.error(ex);
+ LOGGER.error("testMain failed", ex);
}
Mockito.verify(sypHandler, Mockito.times(1)).createPolicyInputAndCallHandler(Mockito.isA(String.class));
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java
index 557a7683..3118f95d 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Intel. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,8 +45,6 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
-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.parameters.PolicyForwarderParameters;
@@ -63,6 +62,8 @@ import org.onap.sdc.api.results.IDistributionClientDownloadResult;
import org.onap.sdc.api.results.IDistributionClientResult;
import org.onap.sdc.impl.mock.DistributionClientStubImpl;
import org.onap.sdc.utils.DistributionActionResultEnum;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class to perform unit test of {@link SdcReceptionHandler}.
@@ -72,7 +73,7 @@ import org.onap.sdc.utils.DistributionActionResultEnum;
@RunWith(MockitoJUnitRunner.class)
public class TestSdcReceptionHandler {
- private static final Logger LOGGER = FlexLogger.getLogger(TestSdcReceptionHandler.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestSdcReceptionHandler.class);
private static final String DUMMY_SERVICE_CSAR = "dummyService.csar";
@Mock
@@ -145,7 +146,7 @@ public class TestSdcReceptionHandler {
try {
sypHandler.initializeReception(pssdConfigParameters.getName());
} catch (final Exception exp) {
- LOGGER.error(exp);
+ LOGGER.error("testInitializeSdcClient failed", exp);
fail("Test should not throw any exception");
}
}
@@ -158,7 +159,7 @@ public class TestSdcReceptionHandler {
try {
sypHandler.initializeReception(pssdConfigParameters.getName());
} catch (final Exception exp) {
- LOGGER.error(exp);
+ LOGGER.error("testInitializeSdcClient_Failure failed", exp);
fail("Test should not throw any exception");
}
}
@@ -170,7 +171,7 @@ public class TestSdcReceptionHandler {
.thenReturn(successfulClientInitResult);
sypHandler.initializeReception(pssdConfigParameters.getName());
} catch (final Exception exp) {
- LOGGER.error(exp);
+ LOGGER.error("testStartSdcClient_Failure failed", exp);
fail("Test should not throw any exception");
}
}
@@ -181,7 +182,7 @@ public class TestSdcReceptionHandler {
sypHandler.initializeReception(pssdConfigParameters.getName());
sypHandler.destroy();
} catch (final Exception exp) {
- LOGGER.error(exp);
+ LOGGER.error("testStopSdcClient failed", exp);
fail("Test should not throw any exception");
}
@@ -196,7 +197,7 @@ public class TestSdcReceptionHandler {
try {
sypHandler.destroy();
} catch (final Exception exp) {
- LOGGER.error(exp);
+ LOGGER.error("testStopSdcClient_Failure failed", exp);
fail("Test should not throw any exception");
}
}
@@ -206,7 +207,7 @@ public class TestSdcReceptionHandler {
try {
sypHandler.destroy();
} catch (final Exception exp) {
- LOGGER.error(exp);
+ LOGGER.error("testStopSdcClientWithoutStart", exp);
fail("Test should not throw any exception");
}
diff --git a/pom.xml b/pom.xml
index a1480e56..acd73378 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,6 +3,7 @@
ONAP Policy SDC Service Distribution
================================================================================
Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ Copyright (C) 2019 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -18,7 +19,8 @@
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -56,7 +58,7 @@
<module>reception</module>
<module>forwarding</module>
<module>plugins</module>
- <module>packages</module>
+ <module>packages</module>
</modules>
<dependencies>
@@ -66,21 +68,15 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-ext</artifactId>
- <version>1.8.0-beta2</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-core</artifactId>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
</dependency>
+
<dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>policy-endpoints</artifactId>
+ <version>${policy.common.version}</version>
</dependency>
</dependencies>
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 7f3d80b5..5b2d1671 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
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,8 +24,6 @@ package org.onap.policy.distribution.reception.handling;
import java.util.ArrayList;
import java.util.Collection;
-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;
@@ -34,6 +33,8 @@ import org.onap.policy.distribution.reception.decoding.PluginInitializationExcep
import org.onap.policy.distribution.reception.decoding.PolicyDecoder;
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Base implementation of {@link ReceptionHandler}. All reception handlers should extend this base class by implementing
@@ -42,7 +43,7 @@ import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParamet
*/
public abstract class AbstractReceptionHandler implements ReceptionHandler {
- private static final Logger LOGGER = FlexLogger.getLogger(AbstractReceptionHandler.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(AbstractReceptionHandler.class);
private PluginHandler pluginHandler;
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 74b8eb16..afa703ab 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
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,8 +25,6 @@ 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.parameters.PolicyForwarderParameters;
@@ -35,13 +34,15 @@ import org.onap.policy.distribution.reception.decoding.PluginInitializationExcep
import org.onap.policy.distribution.reception.decoding.PolicyDecoder;
import org.onap.policy.distribution.reception.parameters.PluginHandlerParameters;
import org.onap.policy.distribution.reception.parameters.PolicyDecoderParameters;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Handles the plugins to policy distribution.
*/
public class PluginHandler {
- private static final Logger LOGGER = FlexLogger.getLogger(PluginHandler.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(PluginHandler.class);
private Collection<PolicyDecoder<PolicyInput, Policy>> policyDecoders;
private Collection<PolicyForwarder> policyForwarders;
diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderConfigurationParametersJsonAdapter.java b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderConfigurationParametersJsonAdapter.java
index 64eb4ed7..c30d3d3d 100644
--- a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderConfigurationParametersJsonAdapter.java
+++ b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderConfigurationParametersJsonAdapter.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,8 +29,8 @@ import com.google.gson.JsonPrimitive;
import java.lang.reflect.Type;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This class deserialises policy decoder parameters from JSON.
@@ -38,8 +39,7 @@ import org.slf4j.ext.XLoggerFactory;
*/
public class PolicyDecoderConfigurationParametersJsonAdapter
implements JsonDeserializer<PolicyDecoderConfigurationParameterGroup> {
- private static final XLogger LOGGER =
- XLoggerFactory.getXLogger(PolicyDecoderConfigurationParametersJsonAdapter.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(PolicyDecoderConfigurationParametersJsonAdapter.class);
private static final String PARAMETER_CLASS_NAME = "parameterClassName";
private static final String POLICY_DECODER_PARAMETERS = "parameters";
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 f56f8b64..f8ede1a9 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
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,11 +21,11 @@
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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class to hold all the policy decoder parameters.
@@ -33,7 +34,7 @@ import org.onap.policy.common.parameters.ValidationStatus;
*/
public class PolicyDecoderParameters implements ParameterGroup {
- private static final Logger LOGGER = FlexLogger.getLogger(PolicyDecoderParameters.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(PolicyDecoderParameters.class);
private String decoderType;
private String decoderClassName;
@@ -85,7 +86,7 @@ public class PolicyDecoderParameters implements ParameterGroup {
*/
@Override
public String getName() {
- return decoderType;
+ return getDecoderType();
}
/**
diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParametersJsonAdapter.java b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParametersJsonAdapter.java
index 0890a2ab..9b3a4d2b 100644
--- a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParametersJsonAdapter.java
+++ b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParametersJsonAdapter.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -25,17 +26,19 @@ import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
+
import java.lang.reflect.Type;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This class deserialises reception handler parameters from JSON.
*/
public class ReceptionHandlerConfigurationParametersJsonAdapter
implements JsonDeserializer<ReceptionHandlerConfigurationParameterGroup> {
- private static final XLogger LOGGER =
- XLoggerFactory.getXLogger(ReceptionHandlerConfigurationParametersJsonAdapter.class);
+ private static final Logger LOGGER =
+ LoggerFactory.getLogger(ReceptionHandlerConfigurationParametersJsonAdapter.class);
private static final String PARAMETER_CLASS_NAME = "parameterClassName";
private static final String RECEPTION_HANDLER_PARAMETERS = "parameters";
@@ -46,7 +49,7 @@ public class ReceptionHandlerConfigurationParametersJsonAdapter
final JsonObject jsonObject = json.getAsJsonObject();
final String receptionHandlerParameterClassName = getParameterGroupClassName(jsonObject);
- Class<?> receptionHandlerParameterClass = getParameterGroupClass(receptionHandlerParameterClassName);
+ final Class<?> receptionHandlerParameterClass = getParameterGroupClass(receptionHandlerParameterClassName);
return context.deserialize(jsonObject.get(RECEPTION_HANDLER_PARAMETERS), receptionHandlerParameterClass);
}
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 3839c449..ea6d8d86 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
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,11 +21,11 @@
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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class to hold all the reception handler parameters.
@@ -33,7 +34,7 @@ import org.onap.policy.common.parameters.ValidationStatus;
*/
public class ReceptionHandlerParameters implements ParameterGroup {
- private static final Logger LOGGER = FlexLogger.getLogger(ReceptionHandlerParameters.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(ReceptionHandlerParameters.class);
private String name;
private String receptionHandlerType;
@@ -46,8 +47,7 @@ public class ReceptionHandlerParameters implements ParameterGroup {
*
* @param receptionHandlerType the reception handler type
* @param receptionHandlerClassName the reception handler class name
- * @param receptionHandlerConfigurationName the name of the configuration for the reception
- * handler
+ * @param receptionHandlerConfigurationName the name of the configuration for the reception handler
* @param pluginHandlerParameters the plugin handler parameters
*/
public ReceptionHandlerParameters(final String receptionHandlerType, final String receptionHandlerClassName,
@@ -77,8 +77,7 @@ public class ReceptionHandlerParameters implements ParameterGroup {
}
/**
- * Return the name of the reception handler configuration for this ReceptionHandlerParameters
- * instance.
+ * Return the name of the reception handler configuration for this ReceptionHandlerParameters instance.
*
* @return the PssdConfigurationParametersGroup
*/