summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Hernandez <jh1730@att.com>2017-06-22 17:17:28 -0500
committerJorge Hernandez <jh1730@att.com>2017-06-22 17:17:28 -0500
commit8f61e18ef0457745719f05bd5c186992a7155416 (patch)
tree884f4653f957a88a65ea981727dfe26494fb7c55
parent3cc1a85a832771cb70ed9cbaab9031bc4a114308 (diff)
[POLICY-30] remove problematic layers
add configurability through telemetry API Change-Id: I77ebde12a417d421b98646c32dc74824f4494c2e Signed-off-by: Jorge Hernandez <jh1730@att.com>
-rw-r--r--policy-core/pom.xml11
-rw-r--r--policy-core/src/main/java/org/openecomp/policy/drools/core/PolicyContainer.java62
-rw-r--r--policy-core/src/main/java/org/openecomp/policy/drools/core/PolicySession.java12
-rw-r--r--policy-core/src/main/java/org/openecomp/policy/drools/core/jmx/PdpJmxListener.java15
-rw-r--r--policy-endpoints/pom.xml9
-rw-r--r--policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/Topic.java2
-rw-r--r--policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/TopicEndpoint.java23
-rw-r--r--policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/DmaapTopicSinkFactory.java21
-rw-r--r--policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/DmaapTopicSourceFactory.java29
-rw-r--r--policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/UebTopicSinkFactory.java23
-rw-r--r--policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/UebTopicSourceFactory.java28
-rw-r--r--policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/BusConsumer.java47
-rw-r--r--policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/BusPublisher.java62
-rw-r--r--policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/InlineBusTopicSink.java49
-rw-r--r--policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/InlineDmaapTopicSink.java10
-rw-r--r--policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/InlineUebTopicSink.java9
-rw-r--r--policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/SingleThreadedBusTopicSource.java70
-rw-r--r--policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java57
-rw-r--r--policy-endpoints/src/main/java/org/openecomp/policy/drools/http/client/HttpClientFactory.java13
-rw-r--r--policy-endpoints/src/main/java/org/openecomp/policy/drools/http/client/internal/JerseyClient.java10
-rw-r--r--policy-endpoints/src/main/java/org/openecomp/policy/drools/http/server/HttpServletServerFactory.java12
-rw-r--r--policy-endpoints/src/main/java/org/openecomp/policy/drools/http/server/internal/JettyJerseyServer.java18
-rw-r--r--policy-endpoints/src/main/java/org/openecomp/policy/drools/http/server/internal/JettyServletServer.java45
-rw-r--r--policy-endpoints/src/test/java/org/openecomp/policy/drools/http/server/test/HttpClientTest.java14
-rw-r--r--policy-endpoints/src/test/java/org/openecomp/policy/drools/http/server/test/HttpServerTest.java30
-rw-r--r--policy-endpoints/src/test/resources/logback-test.xml15
-rw-r--r--policy-healthcheck/pom.xml4
-rw-r--r--policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/HealthCheck.java19
-rw-r--r--policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/HealthCheckFeature.java13
-rw-r--r--policy-management/config/policyLogger.properties44
-rw-r--r--policy-management/pom.xml6
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/controller/DroolsControllerFactory.java22
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/MavenDroolsController.java44
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/persistence/SystemPersistence.java23
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/protocol/coders/EventProtocolCoder.java271
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/protocol/coders/JsonProtocolFilter.java14
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/protocol/coders/ProtocolCoderToolset.java118
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/server/restful/RestManager.java139
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/system/Main.java82
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyControllerFactory.java6
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyEngine.java169
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/system/internal/AggregatedPolicyController.java102
-rw-r--r--policy-management/src/main/resources/schemas/pdpd-configuration.jsonschema (renamed from policy-endpoints/src/main/resources/schema/pdpd-configuration.jsonschema)0
-rw-r--r--policy-management/src/main/server/config/controller.properties.README172
-rw-r--r--policy-management/src/main/server/config/log4j.properties48
-rw-r--r--policy-management/src/main/server/config/logback.xml316
-rw-r--r--policy-management/src/main/server/config/makefile9
-rw-r--r--policy-management/src/main/server/config/policyLogger.properties49
-rw-r--r--policy-management/src/main/server/config/system.properties14
-rw-r--r--policy-utils/pom.xml37
-rw-r--r--policy-utils/src/main/java/org/openecomp/policy/drools/utils/OrderedServiceImpl.java8
-rw-r--r--policy-utils/src/main/java/org/openecomp/policy/drools/utils/PropertyUtil.java18
-rw-r--r--policy-utils/src/main/java/org/openecomp/policy/drools/utils/ReflectionUtil.java22
-rw-r--r--policy-utils/src/test/java/org/openecomp/policy/drools/utils/PropertyUtilTest.java26
-rw-r--r--policy-utils/src/test/resources/log4j.properties26
-rw-r--r--pom.xml17
56 files changed, 1079 insertions, 1455 deletions
diff --git a/policy-core/pom.xml b/policy-core/pom.xml
index 4d504a69..22ce98ea 100644
--- a/policy-core/pom.xml
+++ b/policy-core/pom.xml
@@ -58,17 +58,6 @@
<artifactId>policy-utils</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>org.openecomp.policy.common</groupId>
- <artifactId>ECOMP-Logging</artifactId>
- <version>${common-modules.version}</version>
- </dependency>
- <dependency>
- <groupId>org.mariadb.jdbc</groupId>
- <artifactId>mariadb-java-client</artifactId>
- <version>1.2.3</version>
- <scope>runtime</scope>
- </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
diff --git a/policy-core/src/main/java/org/openecomp/policy/drools/core/PolicyContainer.java b/policy-core/src/main/java/org/openecomp/policy/drools/core/PolicyContainer.java
index 26a80558..1b7941db 100644
--- a/policy-core/src/main/java/org/openecomp/policy/drools/core/PolicyContainer.java
+++ b/policy-core/src/main/java/org/openecomp/policy/drools/core/PolicyContainer.java
@@ -20,12 +20,10 @@
package org.openecomp.policy.drools.core;
-import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import org.kie.api.KieBase;
@@ -36,12 +34,9 @@ import org.kie.api.builder.ReleaseId;
import org.kie.api.builder.Results;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
-import org.openecomp.policy.common.logging.eelf.MessageCodes;
-import org.openecomp.policy.common.logging.eelf.PolicyLogger;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
-import org.openecomp.policy.common.logging.flexlogger.PropertyUtil;
import org.openecomp.policy.drools.properties.Startable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This class is a wrapper around 'KieContainer', which adds the ability
@@ -50,7 +45,7 @@ import org.openecomp.policy.drools.properties.Startable;
public class PolicyContainer implements Startable
{
// get an instance of logger
- private static Logger logger = FlexLogger.getLogger(PolicyContainer.class);
+ private static Logger logger = LoggerFactory.getLogger(PolicyContainer.class);
// 'KieServices' singleton
static private KieServices kieServices = KieServices.Factory.get();
@@ -80,9 +75,6 @@ public class PolicyContainer implements Startable
// (it can block for a long time)
private boolean scannerStarted = false;
- // Used to set relative pathing to config files for unit test environment
- public static boolean isUnitTesting = false;
-
/**
* uses 'groupId', 'artifactId' and 'version', and fetches the associated
* artifact and remaining dependencies from the Maven repository to create
@@ -528,7 +520,7 @@ public class PolicyContainer implements Startable
catch (Exception e)
{
// sometimes the scanner initialization fails for some reason
- logger.error(MessageCodes.EXCEPTION_ERROR, e, "main", "startServer");
+ logger.error("startScanner error", e);
}
}
}
@@ -752,10 +744,7 @@ public class PolicyContainer implements Startable
}
catch (Exception e)
{
- e.printStackTrace();
- logger.error(MessageCodes.EXCEPTION_ERROR, e,
- "activate",
- "PolicyContainer.start()");
+ logger.error("PolicyContainer.start() error in activate", e);
}
}
}
@@ -774,10 +763,7 @@ public class PolicyContainer implements Startable
}
catch (Exception e)
{
- e.printStackTrace();
- logger.error(MessageCodes.EXCEPTION_ERROR, e,
- "deactivate",
- "PolicyContainer.stop()");
+ logger.error("PolicyContainer.start() error in deactivate", e);
}
}
}
@@ -796,23 +782,8 @@ public class PolicyContainer implements Startable
*/
public static void globalInit(String args[])
{
-
- /*
- * When JUnit testing, working directory should be
- * "../policy-management". In test environment, command line argument
- * should specify the relative path from this directory to the config
- * directory ("src/test/server/config")
- */
String configDir = "config";
- if (isUnitTesting) {
- configDir = "src/test/server/config";
- }
- System.out.println("PolicyContainer.main: configDir=" + configDir);
-
- logger.info("Calling initlogger");
-
- initlogger(configDir);
- logger.info("initlogger returned");
+ logger.info("PolicyContainer.main: configDir=" + configDir);
// invoke 'globalInit' on all of the features
for (PolicySessionFeatureAPI feature :
@@ -829,25 +800,6 @@ public class PolicyContainer implements Startable
}
}
}
-
- /**
- * Read in the logger properties
- */
- private static void initlogger(String configDir){
- try {
- Properties properties =
- PropertyUtil.getProperties(configDir + "/policyLogger.properties");
- try {
-
- PolicyLogger.init(properties);
-
- } catch (Exception e) {
- logger.error(MessageCodes.MISS_PROPERTY_ERROR, e, "initlogger");
- }
- } catch (IOException e1) {
- logger.error(MessageCodes.MISS_PROPERTY_ERROR, e1, "initlogger");
- }
- }
/**
* Fetch the adjunct object associated with a given feature
diff --git a/policy-core/src/main/java/org/openecomp/policy/drools/core/PolicySession.java b/policy-core/src/main/java/org/openecomp/policy/drools/core/PolicySession.java
index 4d717f5d..ebfcb025 100644
--- a/policy-core/src/main/java/org/openecomp/policy/drools/core/PolicySession.java
+++ b/policy-core/src/main/java/org/openecomp/policy/drools/core/PolicySession.java
@@ -36,10 +36,10 @@ import org.kie.api.event.rule.RuleFlowGroupActivatedEvent;
import org.kie.api.event.rule.RuleFlowGroupDeactivatedEvent;
import org.kie.api.event.rule.RuleRuntimeEventListener;
import org.kie.api.runtime.KieSession;
-import org.openecomp.policy.common.logging.eelf.MessageCodes;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.drools.core.jmx.PdpJmx;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* This class is a wrapper around 'KieSession', which adds the following:
@@ -52,7 +52,7 @@ public class PolicySession
implements AgendaEventListener, RuleRuntimeEventListener
{
// get an instance of logger
- private static Logger logger = FlexLogger.getLogger(PolicySession.class);
+ private static Logger logger = LoggerFactory.getLogger(PolicySession.class);
// name of the 'PolicySession' and associated 'KieSession'
private String name;
@@ -526,7 +526,7 @@ public class PolicySession
}
catch (Exception e)
{
- logger.error(MessageCodes.EXCEPTION_ERROR, e, "stopThread", "thread.join");
+ logger.error("stopThread in thread.join error");
}
}
@@ -567,7 +567,7 @@ public class PolicySession
}
catch (Throwable e)
{
- logger.error(MessageCodes.EXCEPTION_ERROR, e, "startThread", "kieSession.fireUntilHalt");
+ logger.error("startThread error in kieSession.fireUntilHalt", e);
}
}
logger.info("fireUntilHalt() returned");
diff --git a/policy-core/src/main/java/org/openecomp/policy/drools/core/jmx/PdpJmxListener.java b/policy-core/src/main/java/org/openecomp/policy/drools/core/jmx/PdpJmxListener.java
index 4b48da07..87354bf4 100644
--- a/policy-core/src/main/java/org/openecomp/policy/drools/core/jmx/PdpJmxListener.java
+++ b/policy-core/src/main/java/org/openecomp/policy/drools/core/jmx/PdpJmxListener.java
@@ -30,13 +30,12 @@ import javax.management.MalformedObjectNameException;
import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
-import org.openecomp.policy.common.logging.eelf.MessageCodes;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class PdpJmxListener {
- public static final Logger logger = FlexLogger.getLogger(PdpJmxListener.class);
+ public static final Logger logger = LoggerFactory.getLogger(PdpJmxListener.class);
public static void stop() {
final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
@@ -44,7 +43,9 @@ public class PdpJmxListener {
server.unregisterMBean(new ObjectName("PolicyEngine:type=PdpJmx"));
} catch (MBeanRegistrationException | InstanceNotFoundException
| MalformedObjectNameException e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, "PdpJmxListener.stop()", "Could not unregister PolicyEngine:type=PdpJmx MBean with the MBean server");
+ logger.error("PdpJmxListener.stop(): " +
+ "Could not unregister PolicyEngine:type=PdpJmx MBean " +
+ "with the MBean server", e);
}
}
@@ -56,7 +57,9 @@ public class PdpJmxListener {
server.registerMBean(PdpJmx.getInstance(), new ObjectName("PolicyEngine:type=PdpJmx"));
} catch (InstanceAlreadyExistsException | MBeanRegistrationException
| NotCompliantMBeanException | MalformedObjectNameException e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, "PdpJmxListener.start()", "Could not register PolicyEngine:type=PdpJmx MBean with the MBean server");
+ logger.error("PdpJmxListener.start(): " +
+ "Could not unregister PolicyEngine:type=PdpJmx MBean " +
+ "with the MBean server", e);
}
}
diff --git a/policy-endpoints/pom.xml b/policy-endpoints/pom.xml
index de95eb9a..18d338ce 100644
--- a/policy-endpoints/pom.xml
+++ b/policy-endpoints/pom.xml
@@ -67,6 +67,10 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
</exclusions>
</dependency>
@@ -155,6 +159,11 @@
<artifactId>commons-collections4</artifactId>
<version>4.1</version>
</dependency>
+
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ </dependency>
<dependency>
<groupId>org.openecomp.policy.drools-pdp</groupId>
diff --git a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/Topic.java b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/Topic.java
index d38bab5a..54f49fdc 100644
--- a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/Topic.java
+++ b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/Topic.java
@@ -27,7 +27,7 @@ import java.util.List;
*/
public interface Topic {
- public static final String NETWORK_LOGGER = "networkLogger";
+ public static final String NETWORK_LOGGER = "network";
/**
* Underlying Communication infrastructure Types
diff --git a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/TopicEndpoint.java b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/TopicEndpoint.java
index b3f236f7..fa73ecb7 100644
--- a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/TopicEndpoint.java
+++ b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/TopicEndpoint.java
@@ -28,9 +28,8 @@ import org.openecomp.policy.drools.event.comm.bus.DmaapTopicSink;
import org.openecomp.policy.drools.event.comm.bus.DmaapTopicSource;
import org.openecomp.policy.drools.event.comm.bus.UebTopicSink;
import org.openecomp.policy.drools.event.comm.bus.UebTopicSource;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
-import org.openecomp.policy.common.logging.eelf.MessageCodes;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
import org.openecomp.policy.drools.properties.Lockable;
import org.openecomp.policy.drools.properties.Startable;
import com.fasterxml.jackson.annotation.JsonIgnore;
@@ -239,8 +238,10 @@ public interface TopicEndpoint extends Startable, Lockable {
* implementations according to the communication infrastructure that are supported
*/
class ProxyTopicEndpointManager implements TopicEndpoint {
- // get an instance of logger
- private static Logger logger = FlexLogger.getLogger(ProxyTopicEndpointManager.class);
+ /**
+ * Logger
+ */
+ private static Logger logger = LoggerFactory.getLogger(ProxyTopicEndpointManager.class);
/**
* Is this element locked?
*/
@@ -386,7 +387,7 @@ class ProxyTopicEndpointManager implements TopicEndpoint {
success = endpoint.start() && success;
} catch (Exception e) {
success = false;
- logger.error(MessageCodes.EXCEPTION_ERROR, e, endpoint.toString(), this.toString());
+ logger.error("Problem starting endpoint: {}", endpoint, e);
}
}
@@ -417,7 +418,7 @@ class ProxyTopicEndpointManager implements TopicEndpoint {
success = endpoint.stop() && success;
} catch (Exception e) {
success = false;
- logger.error(MessageCodes.EXCEPTION_ERROR, e, endpoint.toString(), this.toString());
+ logger.error("Problem stopping endpoint: {}", endpoint, e);
}
}
@@ -532,7 +533,7 @@ class ProxyTopicEndpointManager implements TopicEndpoint {
if (uebSource != null)
sources.add(uebSource);
} catch (Exception e) {
- logger.info("No UEB source for topic: " + topic);
+ logger.info("No UEB source for topic: {}", topic);
}
try {
@@ -540,7 +541,7 @@ class ProxyTopicEndpointManager implements TopicEndpoint {
if (dmaapSource != null)
sources.add(dmaapSource);
} catch (Exception e) {
- logger.info("No DMAAP source for topic: " + topic);
+ logger.info("No DMAAP source for topic: {}", topic);
}
}
return sources;
@@ -564,7 +565,7 @@ class ProxyTopicEndpointManager implements TopicEndpoint {
if (uebSink != null)
sinks.add(uebSink);
} catch (Exception e) {
- logger.info("No UEB sink for topic: " + topic);
+ logger.info("No UEB sink for topic: {}", topic);
}
try {
@@ -572,7 +573,7 @@ class ProxyTopicEndpointManager implements TopicEndpoint {
if (dmaapSink != null)
sinks.add(dmaapSink);
} catch (Exception e) {
- logger.info("No DMAAP sink for topic: " + topic);
+ logger.info("No DMAAP sink for topic: {}", topic);
}
}
return sinks;
diff --git a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/DmaapTopicSinkFactory.java b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/DmaapTopicSinkFactory.java
index 4c96f9be..8b8ca530 100644
--- a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/DmaapTopicSinkFactory.java
+++ b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/DmaapTopicSinkFactory.java
@@ -27,8 +27,8 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
import org.openecomp.policy.drools.event.comm.bus.internal.InlineDmaapTopicSink;
import org.openecomp.policy.drools.properties.PolicyProperties;
@@ -171,8 +171,10 @@ public interface DmaapTopicSinkFactory {
* Factory of DMAAP Reader Topics indexed by topic name
*/
class IndexedDmaapTopicSinkFactory implements DmaapTopicSinkFactory {
- // get an instance of logger
- private static Logger logger = FlexLogger.getLogger(IndexedDmaapTopicSinkFactory.class);
+ /**
+ * Logger
+ */
+ private static Logger logger = LoggerFactory.getLogger(IndexedDmaapTopicSinkFactory.class);
/**
* DMAAP Topic Name Index
@@ -279,7 +281,7 @@ class IndexedDmaapTopicSinkFactory implements DmaapTopicSinkFactory {
String writeTopics = properties.getProperty(PolicyProperties.PROPERTY_DMAAP_SINK_TOPICS);
if (writeTopics == null || writeTopics.isEmpty()) {
- logger.warn("No topic for DMAAP Sink " + properties);
+ logger.info("{}: no topic for DMaaP Sink", this);
return new ArrayList<DmaapTopicSink>();
}
@@ -377,7 +379,7 @@ class IndexedDmaapTopicSinkFactory implements DmaapTopicSinkFactory {
dme2AdditionalProps.put(DME2_SESSION_STICKINESS_REQUIRED_PROPERTY, dme2SessionStickinessRequired);
if (servers == null || servers.isEmpty()) {
- logger.error("No DMaaP servers or DME2 ServiceName provided");
+ logger.error("{}: no DMaaP servers or DME2 ServiceName provided", this);
continue;
}
@@ -486,5 +488,12 @@ class IndexedDmaapTopicSinkFactory implements DmaapTopicSinkFactory {
new ArrayList<DmaapTopicSink>(this.dmaapTopicWriters.values());
return writers;
}
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("IndexedDmaapTopicSinkFactory []");
+ return builder.toString();
+ }
} \ No newline at end of file
diff --git a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/DmaapTopicSourceFactory.java b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/DmaapTopicSourceFactory.java
index a54cb6f4..89793d28 100644
--- a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/DmaapTopicSourceFactory.java
+++ b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/DmaapTopicSourceFactory.java
@@ -28,8 +28,8 @@ import java.util.Map;
import java.util.Properties;
import org.openecomp.policy.drools.event.comm.bus.internal.SingleThreadedDmaapTopicSource;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
import org.openecomp.policy.drools.properties.PolicyProperties;
/**
@@ -208,10 +208,13 @@ public interface DmaapTopicSourceFactory {
*/
class IndexedDmaapTopicSourceFactory implements DmaapTopicSourceFactory {
- // get an instance of logger
- private static Logger logger = FlexLogger.getLogger(IndexedDmaapTopicSourceFactory.class);
/**
- * UEB Topic Name Index
+ * Logger
+ */
+ private static Logger logger = LoggerFactory.getLogger(IndexedDmaapTopicSourceFactory.class);
+
+ /**
+ * DMaaP Topic Name Index
*/
protected HashMap<String, DmaapTopicSource> dmaapTopicSources =
new HashMap<String, DmaapTopicSource>();
@@ -318,7 +321,7 @@ class IndexedDmaapTopicSourceFactory implements DmaapTopicSourceFactory {
String readTopics = properties.getProperty(PolicyProperties.PROPERTY_DMAAP_SOURCE_TOPICS);
if (readTopics == null || readTopics.isEmpty()) {
- logger.warn("No topic for UEB Source " + properties);
+ logger.info("{}: no topic for DMaaP Source", this);
return new ArrayList<DmaapTopicSource>();
}
List<String> readTopicList = new ArrayList<String>(Arrays.asList(readTopics.split("\\s*,\\s*")));
@@ -426,7 +429,7 @@ class IndexedDmaapTopicSourceFactory implements DmaapTopicSourceFactory {
if (servers == null || servers.isEmpty()) {
- logger.error("No DMaaP servers or DME2 ServiceName provided");
+ logger.error("{}: no DMaaP servers or DME2 ServiceName provided", this);
continue;
}
@@ -435,7 +438,8 @@ class IndexedDmaapTopicSourceFactory implements DmaapTopicSourceFactory {
try {
fetchTimeout = Integer.parseInt(fetchTimeoutString);
} catch (NumberFormatException nfe) {
- logger.warn("Fetch Timeout in invalid format for topic " + topic + ": " + fetchTimeoutString);
+ logger.warn("{}: fetch timeout {} is in invalid format for topic {} ",
+ this, fetchTimeoutString, topic);
}
}
@@ -447,7 +451,8 @@ class IndexedDmaapTopicSourceFactory implements DmaapTopicSourceFactory {
try {
fetchLimit = Integer.parseInt(fetchLimitString);
} catch (NumberFormatException nfe) {
- logger.warn("Fetch Limit in invalid format for topic " + topic + ": " + fetchLimitString);
+ logger.warn("{}: fetch limit {} is in invalid format for topic {} ",
+ this, fetchLimitString, topic);
}
}
@@ -582,6 +587,12 @@ class IndexedDmaapTopicSourceFactory implements DmaapTopicSourceFactory {
this.dmaapTopicSources.clear();
}
}
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("IndexedDmaapTopicSourceFactory []");
+ return builder.toString();
+ }
}
diff --git a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/UebTopicSinkFactory.java b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/UebTopicSinkFactory.java
index 4dc38f18..0469c4a3 100644
--- a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/UebTopicSinkFactory.java
+++ b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/UebTopicSinkFactory.java
@@ -27,8 +27,8 @@ import java.util.List;
import java.util.Properties;
import org.openecomp.policy.drools.event.comm.bus.internal.InlineUebTopicSink;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
import org.openecomp.policy.drools.properties.PolicyProperties;
/**
@@ -120,8 +120,11 @@ public interface UebTopicSinkFactory {
* Factory of UEB Reader Topics indexed by topic name
*/
class IndexedUebTopicSinkFactory implements UebTopicSinkFactory {
- // get an instance of logger
- private static Logger logger = FlexLogger.getLogger(IndexedUebTopicSinkFactory.class);
+ /**
+ * Logger
+ */
+ private static Logger logger = LoggerFactory.getLogger(IndexedUebTopicSinkFactory.class);
+
/**
* UEB Topic Name Index
*/
@@ -184,7 +187,7 @@ class IndexedUebTopicSinkFactory implements UebTopicSinkFactory {
String writeTopics = properties.getProperty(PolicyProperties.PROPERTY_UEB_SINK_TOPICS);
if (writeTopics == null || writeTopics.isEmpty()) {
- logger.warn("No topic for UEB Sink " + properties);
+ logger.info("{}: no topic for UEB Sink", this);
return new ArrayList<UebTopicSink>();
}
@@ -201,7 +204,7 @@ class IndexedUebTopicSinkFactory implements UebTopicSinkFactory {
topic +
PolicyProperties.PROPERTY_TOPIC_SERVERS_SUFFIX);
if (servers == null || servers.isEmpty()) {
- logger.error("No UEB servers provided in " + properties);
+ logger.error("{}: no UEB servers configured for sink {}", this, topic);
continue;
}
@@ -319,5 +322,13 @@ class IndexedUebTopicSinkFactory implements UebTopicSinkFactory {
new ArrayList<UebTopicSink>(this.uebTopicSinks.values());
return writers;
}
+
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("IndexedUebTopicSinkFactory []");
+ return builder.toString();
+ }
}
diff --git a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/UebTopicSourceFactory.java b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/UebTopicSourceFactory.java
index 474d4a80..77b894db 100644
--- a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/UebTopicSourceFactory.java
+++ b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/UebTopicSourceFactory.java
@@ -27,8 +27,8 @@ import java.util.List;
import java.util.Properties;
import org.openecomp.policy.drools.event.comm.bus.internal.SingleThreadedUebTopicSource;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
import org.openecomp.policy.drools.properties.PolicyProperties;
/**
@@ -144,8 +144,11 @@ public interface UebTopicSourceFactory {
* Factory of UEB Source Topics indexed by topic name
*/
class IndexedUebTopicSourceFactory implements UebTopicSourceFactory {
- // get an instance of logger
- private static Logger logger = FlexLogger.getLogger(IndexedUebTopicSourceFactory.class);
+ /**
+ * Logger
+ */
+ private static Logger logger = LoggerFactory.getLogger(IndexedUebTopicSourceFactory.class);
+
/**
* UEB Topic Name Index
*/
@@ -203,7 +206,7 @@ class IndexedUebTopicSourceFactory implements UebTopicSourceFactory {
String readTopics = properties.getProperty(PolicyProperties.PROPERTY_UEB_SOURCE_TOPICS);
if (readTopics == null || readTopics.isEmpty()) {
- logger.warn("No topic for UEB Source " + properties);
+ logger.info("{}: no topic for UEB Source", this);
return new ArrayList<UebTopicSource>();
}
List<String> readTopicList = new ArrayList<String>(Arrays.asList(readTopics.split("\\s*,\\s*")));
@@ -221,7 +224,7 @@ class IndexedUebTopicSourceFactory implements UebTopicSourceFactory {
PolicyProperties.PROPERTY_TOPIC_SERVERS_SUFFIX);
if (servers == null || servers.isEmpty()) {
- logger.error("No UEB servers provided in " + properties);
+ logger.error("{}: no UEB servers configured for sink {}", this, topic);
continue;
}
@@ -251,7 +254,8 @@ class IndexedUebTopicSourceFactory implements UebTopicSourceFactory {
try {
fetchTimeout = Integer.parseInt(fetchTimeoutString);
} catch (NumberFormatException nfe) {
- logger.warn("Fetch Timeout in invalid format for topic " + topic + ": " + fetchTimeoutString);
+ logger.warn("{}: fetch timeout {} is in invalid format for topic {} ",
+ this, fetchTimeoutString, topic);
}
}
@@ -263,7 +267,8 @@ class IndexedUebTopicSourceFactory implements UebTopicSourceFactory {
try {
fetchLimit = Integer.parseInt(fetchLimitString);
} catch (NumberFormatException nfe) {
- logger.warn("Fetch Limit in invalid format for topic " + topic + ": " + fetchLimitString);
+ logger.warn("{}: fetch limit {} is in invalid format for topic {} ",
+ this, fetchLimitString, topic);
}
}
@@ -388,5 +393,12 @@ class IndexedUebTopicSourceFactory implements UebTopicSourceFactory {
this.uebTopicSources.clear();
}
}
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("IndexedUebTopicSourceFactory []");
+ return builder.toString();
+ }
}
diff --git a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/BusConsumer.java b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/BusConsumer.java
index 6ea21575..d8eb80b8 100644
--- a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/BusConsumer.java
+++ b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/BusConsumer.java
@@ -27,9 +27,10 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
-import org.openecomp.policy.common.logging.eelf.PolicyLogger;
import org.openecomp.policy.drools.event.comm.bus.DmaapTopicSinkFactory;
import org.openecomp.policy.drools.properties.PolicyProperties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.att.nsa.cambria.client.CambriaClientBuilders;
import com.att.nsa.cambria.client.CambriaConsumer;
@@ -62,6 +63,7 @@ public interface BusConsumer {
* Cambria based consumer
*/
public static class CambriaConsumerWrapper implements BusConsumer {
+
/**
* Cambria client
*/
@@ -154,7 +156,9 @@ public interface BusConsumer {
/**
* MR based consumer
*/
- public abstract class DmaapConsumerWrapper implements BusConsumer {
+ public abstract class DmaapConsumerWrapper implements BusConsumer {
+
+ private static Logger logger = LoggerFactory.getLogger(DmaapConsumerWrapper.class);
protected int fetchTimeout;
protected Object closeCondition = new Object();
@@ -206,19 +210,30 @@ public interface BusConsumer {
*/
public Iterable<String> fetch() throws Exception {
MRConsumerResponse response = this.consumer.fetchWithReturnConsumerResponse();
-
- if (PolicyLogger.isDebugEnabled() && response != null)
- PolicyLogger.debug(DmaapConsumerWrapper.class.getName(), "DMaaP consumer received " + response.getResponseCode() + ": " + response.getResponseMessage());
-
- if (response.getResponseCode() == null || !response.getResponseCode().equals("200")) {
- if (response.getResponseCode() == null)
- PolicyLogger.error(DmaapConsumerWrapper.class.getName(), "DMaaP consumer received response code null");
- else
- PolicyLogger.error(DmaapConsumerWrapper.class.getName(), "DMaaP consumer received " + response.getResponseCode() + ": " + response.getResponseMessage());
+ if (response == null) {
+ logger.warn("{}: DMaaP NULL response received", this);
synchronized (closeCondition) {
closeCondition.wait(fetchTimeout);
}
+ return new ArrayList<String>();
+ } else {
+ logger.debug("DMaaP consumer received {} : {}" +
+ response.getResponseCode(),
+ response.getResponseMessage());
+
+ if (response.getResponseCode() == null ||
+ !response.getResponseCode().equals("200")) {
+
+ logger.error("DMaaP consumer received: {} : {}",
+ response.getResponseCode(),
+ response.getResponseMessage());
+
+ synchronized (closeCondition) {
+ closeCondition.wait(fetchTimeout);
+ }
+ /* fall through */
+ }
}
if (response.getActualMessages() == null)
@@ -257,6 +272,9 @@ public interface BusConsumer {
* MR based consumer
*/
public static class DmaapAafConsumerWrapper extends DmaapConsumerWrapper {
+
+ private static Logger logger = LoggerFactory.getLogger(DmaapAafConsumerWrapper.class);
+
private Properties props;
/**
@@ -306,7 +324,7 @@ public interface BusConsumer {
}
this.consumer.setProps(props);
- PolicyLogger.info(DmaapConsumerWrapper.class.getName(), "CREATION: " + this);
+ logger.info("{}: CREATION", this);
}
@Override
@@ -327,6 +345,9 @@ public interface BusConsumer {
}
public static class DmaapDmeConsumerWrapper extends DmaapConsumerWrapper {
+
+ private static Logger logger = LoggerFactory.getLogger(DmaapDmeConsumerWrapper.class);
+
private Properties props;
public DmaapDmeConsumerWrapper(List<String> servers, String topic,
@@ -425,7 +446,7 @@ public interface BusConsumer {
MRClientFactory.prop = props;
this.consumer.setProps(props);
- PolicyLogger.info(DmaapConsumerWrapper.class.getName(), "CREATION: " + this);
+ logger.info("{}: CREATION", this);
}
}
}
diff --git a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/BusPublisher.java b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/BusPublisher.java
index b5595b2d..54e0bcb2 100644
--- a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/BusPublisher.java
+++ b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/BusPublisher.java
@@ -28,9 +28,9 @@ import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
-import org.openecomp.policy.common.logging.eelf.PolicyLogger;
import org.openecomp.policy.drools.event.comm.bus.DmaapTopicSinkFactory;
import org.openecomp.policy.drools.properties.PolicyProperties;
+import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.att.nsa.cambria.client.CambriaBatchingPublisher;
@@ -62,6 +62,8 @@ public interface BusPublisher {
* Cambria based library publisher
*/
public static class CambriaPublisherWrapper implements BusPublisher {
+
+ private static Logger logger = LoggerFactory.getLogger(CambriaPublisherWrapper.class);
/**
* The actual Cambria publisher
@@ -111,10 +113,8 @@ public interface BusPublisher {
try {
this.publisher.send(partitionId, message);
} catch (Exception e) {
- PolicyLogger.warn(CambriaPublisherWrapper.class.getName(),
- "SEND of " + message + " IN " +
- this + " cannot be performed because of " +
- e.getMessage());
+ logger.warn("{}: SEND of {} cannot be performed because of {}",
+ this, message, e.getMessage(), e);
return false;
}
return true;
@@ -125,16 +125,13 @@ public interface BusPublisher {
*/
@Override
public void close() {
- if (PolicyLogger.isInfoEnabled())
- PolicyLogger.info(CambriaPublisherWrapper.class.getName(),
- "CREATION: " + this);
+ logger.info("{}: CLOSE", this);
try {
this.publisher.close();
} catch (Exception e) {
- PolicyLogger.warn(CambriaPublisherWrapper.class.getName(),
- "CLOSE on " + this + " FAILED because of " +
- e.getMessage());
+ logger.warn("{}: CLOSE FAILED because of {}",
+ this, e.getMessage(),e);
}
}
@@ -155,6 +152,9 @@ public interface BusPublisher {
* DmaapClient library wrapper
*/
public abstract class DmaapPublisherWrapper implements BusPublisher {
+
+ private static Logger logger = LoggerFactory.getLogger(DmaapPublisherWrapper.class);
+
/**
* MR based Publisher
*/
@@ -175,9 +175,9 @@ public interface BusPublisher {
String password, boolean useHttps) throws IllegalArgumentException {
- if (topic == null || topic.isEmpty()) {
+ if (topic == null || topic.isEmpty())
throw new IllegalArgumentException("No topic for DMaaP");
- }
+
if (protocol == ProtocolTypeConstants.AAF_AUTH) {
if (servers == null || servers.isEmpty())
@@ -215,7 +215,6 @@ public interface BusPublisher {
build();
this.publisher.setProtocolFlag(ProtocolTypeConstants.DME2.getValue());
-
}
this.publisher.logTo(LoggerFactory.getLogger(MRSimplerBatchPublisher.class.getName()));
@@ -225,14 +224,10 @@ public interface BusPublisher {
props = new Properties();
- if(useHttps){
-
+ if (useHttps) {
props.setProperty("Protocol", "https");
- }
- else{
-
+ } else {
props.setProperty("Protocol", "http");
-
}
props.setProperty("contenttype", "application/json");
@@ -246,13 +241,7 @@ public interface BusPublisher {
if (protocol == ProtocolTypeConstants.AAF_AUTH)
this.publisher.setHost(servers.get(0));
- if (PolicyLogger.isInfoEnabled()) {
- PolicyLogger.info(DmaapPublisherWrapper.class.getName(),
- "CREATION: " + this);
- PolicyLogger.info(DmaapPublisherWrapper.class.getName(),
- "BusPublisher.DmaapPublisherWrapper using Protocol: " + protocol.getValue());
- }
-
+ logger.info("{}: CREATION: using protocol {}", this, protocol.getValue());
}
/**
@@ -260,16 +249,13 @@ public interface BusPublisher {
*/
@Override
public void close() {
- if (PolicyLogger.isInfoEnabled())
- PolicyLogger.info(DmaapPublisherWrapper.class.getName(),
- "CREATION: " + this);
+ logger.info("{}: CLOSE", this);
try {
this.publisher.close(1, TimeUnit.SECONDS);
} catch (Exception e) {
- PolicyLogger.warn(DmaapPublisherWrapper.class.getName(),
- "CLOSE: " + this + " because of " +
- e.getMessage());
+ logger.warn("{}: CLOSE FAILED because of {}",
+ this, e.getMessage(), e);
}
}
@@ -285,15 +271,13 @@ public interface BusPublisher {
this.publisher.setPubResponse(new MRPublisherResponse());
this.publisher.send(partitionId, message);
MRPublisherResponse response = this.publisher.sendBatchWithResponse();
- if (PolicyLogger.isDebugEnabled() && response != null) {
- PolicyLogger.debug(DmaapPublisherWrapper.class.getName(),
- "DMaaP publisher received " + response.getResponseCode() + ": "
- + response.getResponseMessage());
-
+ if (response != null) {
+ logger.debug("DMaaP publisher received {} : {}",
+ response.getResponseCode(),
+ response.getResponseMessage());
}
return true;
-
}
@Override
diff --git a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/InlineBusTopicSink.java b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/InlineBusTopicSink.java
index a78de716..64037749 100644
--- a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/InlineBusTopicSink.java
+++ b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/InlineBusTopicSink.java
@@ -23,11 +23,9 @@ package org.openecomp.policy.drools.event.comm.bus.internal;
import java.util.List;
import java.util.UUID;
-import org.apache.log4j.Logger;
-
import org.openecomp.policy.drools.event.comm.bus.BusTopicSink;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.eelf.MessageCodes;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
/**
* Transport Agnostic Bus Topic Sink to carry out the core functionality
@@ -37,16 +35,10 @@ import org.openecomp.policy.common.logging.eelf.MessageCodes;
public abstract class InlineBusTopicSink extends BusTopicBase implements BusTopicSink {
/**
- * logger
+ * loggers
*/
- private static org.openecomp.policy.common.logging.flexlogger.Logger logger =
- FlexLogger.getLogger(InlineBusTopicSink.class);
-
- /**
- * Not to be converted to PolicyLogger.
- * This will contain all in/out traffic and only that in a single file in a concise format.
- */
- protected static final Logger networkLogger = Logger.getLogger(NETWORK_LOGGER);
+ private static Logger logger = LoggerFactory.getLogger(InlineBusTopicSink.class);
+ private static final Logger netLogger = LoggerFactory.getLogger(NETWORK_LOGGER);
/**
* The partition key to publish to
@@ -109,8 +101,7 @@ public abstract class InlineBusTopicSink extends BusTopicBase implements BusTopi
@Override
public boolean start() throws IllegalStateException {
- if (logger.isInfoEnabled())
- logger.info("START: " + this);
+ logger.info("{}: starting", this);
synchronized(this) {
@@ -144,11 +135,11 @@ public abstract class InlineBusTopicSink extends BusTopicBase implements BusTopi
try {
publisherCopy.close();
} catch (Exception e) {
- logger.warn(MessageCodes.EXCEPTION_ERROR, e, "PUBLISHER.CLOSE", this.toString());
- e.printStackTrace();
+ logger.warn("{}: cannot stop publisher because of {}",
+ this, e.getMessage(), e);
}
} else {
- logger.warn("No publisher to close: " + this);
+ logger.warn("{}: there is no publisher", this);
return false;
}
@@ -161,8 +152,7 @@ public abstract class InlineBusTopicSink extends BusTopicBase implements BusTopi
@Override
public boolean lock() {
- if (logger.isInfoEnabled())
- logger.info("LOCK: " + this);
+ logger.info("{}: locking", this);
synchronized (this) {
if (this.locked)
@@ -180,8 +170,7 @@ public abstract class InlineBusTopicSink extends BusTopicBase implements BusTopi
@Override
public boolean unlock() {
- if (logger.isInfoEnabled())
- logger.info("UNLOCK: " + this);
+ logger.info("{}: unlocking", this);
synchronized(this) {
if (!this.locked)
@@ -193,9 +182,8 @@ public abstract class InlineBusTopicSink extends BusTopicBase implements BusTopi
try {
return this.start();
} catch (Exception e) {
- logger.warn("can't start after unlocking " + this +
- " because of " + e.getMessage());
- e.printStackTrace();
+ logger.warn("{}: cannot start after unlocking because of {}",
+ this, e.getMessage(), e);
return false;
}
}
@@ -235,17 +223,12 @@ public abstract class InlineBusTopicSink extends BusTopicBase implements BusTopi
this.recentEvents.add(message);
}
- if (networkLogger.isInfoEnabled()) {
- networkLogger.info("[OUT|" + this.getTopicCommInfrastructure() + "|" +
- this.topic + "]:" +
- message);
- }
+ netLogger.info("[OUT|{}|{}]{}{}", this.getTopicCommInfrastructure(),
+ this.topic, System.lineSeparator(), message);
publisher.send(this.partitionId, message);
} catch (Exception e) {
- logger.error("can't start after unlocking " + this +
- " because of " + e.getMessage());
- e.printStackTrace();
+ logger.warn("{}: cannot send because of {}", this, e.getMessage(), e);
return false;
}
diff --git a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/InlineDmaapTopicSink.java b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/InlineDmaapTopicSink.java
index f5a3dc11..a78dd0fc 100644
--- a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/InlineDmaapTopicSink.java
+++ b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/InlineDmaapTopicSink.java
@@ -23,8 +23,8 @@ package org.openecomp.policy.drools.event.comm.bus.internal;
import java.util.List;
import java.util.Map;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
import org.openecomp.policy.drools.event.comm.Topic;
import org.openecomp.policy.drools.event.comm.bus.DmaapTopicSink;
@@ -35,7 +35,7 @@ import org.openecomp.policy.drools.event.comm.bus.DmaapTopicSink;
public class InlineDmaapTopicSink extends InlineBusTopicSink implements DmaapTopicSink {
protected static Logger logger =
- FlexLogger.getLogger(InlineDmaapTopicSink.class);
+ LoggerFactory.getLogger(InlineDmaapTopicSink.class);
protected final String userName;
protected final String password;
@@ -128,8 +128,8 @@ public class InlineDmaapTopicSink extends InlineBusTopicSink implements DmaapTop
this.partner, this.latitude, this.longitude,
this.additionalProps, this.useHttps);
}
- if (logger.isInfoEnabled())
- logger.info("DMAAP SINK TOPIC created " + this);
+
+ logger.info("{}: DMAAP SINK created", this);
}
/**
diff --git a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/InlineUebTopicSink.java b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/InlineUebTopicSink.java
index c93e0f2b..3b091f5a 100644
--- a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/InlineUebTopicSink.java
+++ b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/InlineUebTopicSink.java
@@ -24,7 +24,7 @@ import java.util.List;
import org.openecomp.policy.drools.event.comm.Topic;
import org.openecomp.policy.drools.event.comm.bus.UebTopicSink;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.slf4j.LoggerFactory;
/**
* This implementation publishes events for the associated UEB topic,
@@ -35,8 +35,8 @@ public class InlineUebTopicSink extends InlineBusTopicSink implements UebTopicSi
/**
* logger
*/
- private static org.openecomp.policy.common.logging.flexlogger.Logger logger =
- FlexLogger.getLogger(InlineUebTopicSink.class);
+ private static org.slf4j.Logger logger =
+ LoggerFactory.getLogger(InlineUebTopicSink.class);
/**
* Argument-based UEB Topic Writer instantiation
@@ -74,8 +74,7 @@ public class InlineUebTopicSink extends InlineBusTopicSink implements UebTopicSi
this.apiKey,
this.apiSecret,
this.useHttps);
- if (logger.isInfoEnabled())
- logger.info("UEB SINK TOPIC created " + this);
+ logger.info("{}: UEB SINK created", this);
}
@Override
diff --git a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/SingleThreadedBusTopicSource.java b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/SingleThreadedBusTopicSource.java
index d3be9163..85da3f01 100644
--- a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/SingleThreadedBusTopicSource.java
+++ b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/SingleThreadedBusTopicSource.java
@@ -24,12 +24,11 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.openecomp.policy.drools.event.comm.TopicListener;
import org.openecomp.policy.drools.event.comm.bus.BusTopicSource;
-import org.openecomp.policy.common.logging.eelf.MessageCodes;
-import org.openecomp.policy.common.logging.eelf.PolicyLogger;
/**
* This topic source implementation specializes in reading messages
@@ -39,12 +38,12 @@ public abstract class SingleThreadedBusTopicSource
extends BusTopicBase
implements Runnable, BusTopicSource {
- private String className = SingleThreadedBusTopicSource.class.getName();
/**
* Not to be converted to PolicyLogger.
* This will contain all instract /out traffic and only that in a single file in a concise format.
*/
- protected static final Logger networkLogger = Logger.getLogger(NETWORK_LOGGER);
+ private static Logger logger = LoggerFactory.getLogger(InlineBusTopicSink.class);
+ private static final Logger netLogger = LoggerFactory.getLogger(NETWORK_LOGGER);
/**
* Bus consumer group
@@ -165,7 +164,7 @@ public abstract class SingleThreadedBusTopicSource
public void register(TopicListener topicListener)
throws IllegalArgumentException {
- PolicyLogger.info(className,"REGISTER: " + topicListener + " INTO " + this);
+ logger.info("{}: registering {}", this, topicListener);
synchronized(this) {
if (topicListener == null)
@@ -185,8 +184,8 @@ public abstract class SingleThreadedBusTopicSource
try {
this.start();
} catch (Exception e) {
- PolicyLogger.info(className, "new registration of " + topicListener +
- ",but can't start source because of " + e.getMessage());
+ logger.warn("{}: cannot start after registration of because of: {}",
+ this, topicListener, e.getMessage(), e);
}
}
@@ -196,7 +195,7 @@ public abstract class SingleThreadedBusTopicSource
@Override
public void unregister(TopicListener topicListener) {
- PolicyLogger.info(className, "UNREGISTER: " + topicListener + " FROM " + this);
+ logger.info("{}: unregistering {}", this, topicListener);
boolean stop = false;
synchronized (this) {
@@ -217,7 +216,8 @@ public abstract class SingleThreadedBusTopicSource
*/
@Override
public boolean lock() {
- PolicyLogger.info(className, "LOCK: " + this);
+
+ logger.info("{}: locking", this);
synchronized (this) {
if (this.locked)
@@ -233,8 +233,8 @@ public abstract class SingleThreadedBusTopicSource
* {@inheritDoc}
*/
@Override
- public boolean unlock() {
- PolicyLogger.info(className, "UNLOCK: " + this);
+ public boolean unlock() {
+ logger.info("{}: unlocking", this);
synchronized(this) {
if (!this.locked)
@@ -246,8 +246,7 @@ public abstract class SingleThreadedBusTopicSource
try {
return this.start();
} catch (Exception e) {
- PolicyLogger.warn("can't start after unlocking " + this +
- " because of " + e.getMessage());
+ logger.warn("{}: cannot after unlocking because of {}", this, e.getMessage(), e);
return false;
}
}
@@ -256,19 +255,16 @@ public abstract class SingleThreadedBusTopicSource
* {@inheritDoc}
*/
@Override
- public boolean start() throws IllegalStateException {
-
- PolicyLogger.info(className, "START: " + this);
+ public boolean start() throws IllegalStateException {
+ logger.info("{}: starting", this);
synchronized(this) {
- if (alive) {
+ if (alive)
return true;
- }
- if (locked) {
+ if (locked)
throw new IllegalStateException(this + " is locked.");
- }
if (this.busPollerThread == null ||
!this.busPollerThread.isAlive() ||
@@ -281,7 +277,7 @@ public abstract class SingleThreadedBusTopicSource
this.busPollerThread.setName(this.getTopicCommInfrastructure() + "-source-" + this.getTopic());
busPollerThread.start();
} catch (Exception e) {
- e.printStackTrace();
+ logger.warn("{}: cannot start because of {}", this, e.getMessage(), e);
throw new IllegalStateException(e);
}
}
@@ -295,7 +291,7 @@ public abstract class SingleThreadedBusTopicSource
*/
@Override
public boolean stop() {
- PolicyLogger.info(className, "STOP: " + this);
+ logger.info("{}: stopping", this);
synchronized(this) {
BusConsumer consumerCopy = this.consumer;
@@ -307,7 +303,7 @@ public abstract class SingleThreadedBusTopicSource
try {
consumerCopy.close();
} catch (Exception e) {
- PolicyLogger.warn(MessageCodes.EXCEPTION_ERROR, e, "CONSUMER.CLOSE", this.toString());
+ logger.warn("{}: stop failed because of {}", this, e.getMessage(), e);
}
}
}
@@ -341,8 +337,8 @@ public abstract class SingleThreadedBusTopicSource
try {
topicListener.onTopicEvent(this.getTopicCommInfrastructure(), this.topic, message);
} catch (Exception e) {
- PolicyLogger.warn(this.className, "ERROR notifying " + topicListener.toString() +
- " because of " + e.getMessage() + " @ " + this.toString());
+ logger.warn("{}: notification error @ {} because of {}",
+ this, topicListener, e.getMessage(), e);
success = false;
}
}
@@ -372,24 +368,21 @@ public abstract class SingleThreadedBusTopicSource
this.recentEvents.add(event);
}
- if (networkLogger.isInfoEnabled()) {
- networkLogger.info("IN[" + this.getTopicCommInfrastructure() + "|" +
- this.topic + "]:" +
- event);
- }
+ netLogger.info("[IN|{}|{}]{}{}",
+ this.getTopicCommInfrastructure(), this.topic,
+ System.lineSeparator(), event);
- PolicyLogger.info(className, this.topic + " <-- " + event);
broadcast(event);
if (!this.alive)
break;
}
} catch (Exception e) {
- PolicyLogger.error( MessageCodes.EXCEPTION_ERROR, className, e, "CONSUMER.FETCH", this.toString());
+ logger.error("{}: cannot fetch because of ", this, e.getMessage(), e);
}
}
- PolicyLogger.warn(this.className, "Exiting: " + this);
+ logger.info("{}: exiting thread", this);
}
/**
@@ -397,8 +390,6 @@ public abstract class SingleThreadedBusTopicSource
*/
@Override
public boolean offer(String event) {
- PolicyLogger.info(className, "OFFER: " + event + " TO " + this);
-
if (!this.alive) {
throw new IllegalStateException(this + " is not alive.");
}
@@ -407,11 +398,8 @@ public abstract class SingleThreadedBusTopicSource
this.recentEvents.add(event);
}
- if (networkLogger.isInfoEnabled()) {
- networkLogger.info("IN[" + this.getTopicCommInfrastructure() + "|" +
- this.topic + "]:" +
- event);
- }
+ netLogger.info("[IN|{}|{}]{}{}",this.getTopicCommInfrastructure(),this.topic,
+ System.lineSeparator(), event);
return broadcast(event);
diff --git a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java
index 2ced5bcb..7e3e3153 100644
--- a/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java
+++ b/policy-endpoints/src/main/java/org/openecomp/policy/drools/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java
@@ -23,22 +23,23 @@ package org.openecomp.policy.drools.event.comm.bus.internal;
import java.util.List;
import java.util.Map;
-import org.openecomp.policy.common.logging.eelf.PolicyLogger;
import org.openecomp.policy.drools.event.comm.Topic;
import org.openecomp.policy.drools.event.comm.bus.DmaapTopicSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This topic reader implementation specializes in reading messages
* over DMAAP topic and notifying its listeners
*/
public class SingleThreadedDmaapTopicSource extends SingleThreadedBusTopicSource
- implements DmaapTopicSource, Runnable {
-
+ implements DmaapTopicSource, Runnable {
+ private static Logger logger = LoggerFactory.getLogger(SingleThreadedDmaapTopicSource.class);
+
protected boolean allowSelfSignedCerts;
protected final String userName;
protected final String password;
- private String className = SingleThreadedDmaapTopicSource.class.getName();
protected String environment = null;
protected String aftEnvironment = null;
@@ -98,7 +99,7 @@ public class SingleThreadedDmaapTopicSource extends SingleThreadedBusTopicSource
try {
this.init();
} catch (Exception e) {
- e.printStackTrace();
+ logger.error("ERROR during init of topic {}", this.topic);
throw new IllegalArgumentException(e);
}
}
@@ -135,7 +136,7 @@ public class SingleThreadedDmaapTopicSource extends SingleThreadedBusTopicSource
try {
this.init();
} catch (Exception e) {
- e.printStackTrace();
+ logger.warn("dmaap-source: cannot create topic {} because of {}", topic, e.getMessage(), e);
throw new IllegalArgumentException(e);
}
}
@@ -154,29 +155,29 @@ public class SingleThreadedDmaapTopicSource extends SingleThreadedBusTopicSource
this.consumerGroup, this.consumerInstance,
this.fetchTimeout, this.fetchLimit,
this.useHttps, this.allowSelfSignedCerts);
- } else if ((this.environment == null || this.environment.isEmpty()) &&
- (this.aftEnvironment == null || this.aftEnvironment.isEmpty()) &&
- (this.latitude == null || this.latitude.isEmpty()) &&
- (this.longitude == null || this.longitude.isEmpty()) &&
- (this.partner == null || this.partner.isEmpty())) {
- this.consumer =
- new BusConsumer.DmaapAafConsumerWrapper(this.servers, this.topic,
- this.apiKey, this.apiSecret,
- this.userName, this.password,
- this.consumerGroup, this.consumerInstance,
- this.fetchTimeout, this.fetchLimit, this.useHttps);
- } else {
- this.consumer =
- new BusConsumer.DmaapDmeConsumerWrapper(this.servers, this.topic,
- this.apiKey, this.apiSecret,
- this.userName, this.password,
- this.consumerGroup, this.consumerInstance,
- this.fetchTimeout, this.fetchLimit,
- this.environment, this.aftEnvironment, this.partner,
- this.latitude, this.longitude, this.additionalProps, this.useHttps);
- }
+ } else if ((this.environment == null || this.environment.isEmpty()) &&
+ (this.aftEnvironment == null || this.aftEnvironment.isEmpty()) &&
+ (this.latitude == null || this.latitude.isEmpty()) &&
+ (this.longitude == null || this.longitude.isEmpty()) &&
+ (this.partner == null || this.partner.isEmpty())) {
+ this.consumer =
+ new BusConsumer.DmaapAafConsumerWrapper(this.servers, this.topic,
+ this.apiKey, this.apiSecret,
+ this.userName, this.password,
+ this.consumerGroup, this.consumerInstance,
+ this.fetchTimeout, this.fetchLimit, this.useHttps);
+ } else {
+ this.consumer =
+ new BusConsumer.DmaapDmeConsumerWrapper(this.servers, this.topic,
+ this.apiKey, this.apiSecret,
+ this.userName, this.password,
+ this.consumerGroup, this.consumerInstance,
+ this.fetchTimeout, this.fetchLimit,
+ this.environment, this.aftEnvironment, this.partner,
+ this.latitude, this.longitude, this.additionalProps, this.useHttps);
+ }
- PolicyLogger.info(className, "CREATION: " + this);
+ logger.info("{}: INITTED", this);
}
/**
diff --git a/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/client/HttpClientFactory.java b/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/client/HttpClientFactory.java
index 53a8c2b2..15586b66 100644
--- a/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/client/HttpClientFactory.java
+++ b/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/client/HttpClientFactory.java
@@ -27,6 +27,8 @@ import java.util.Properties;
import org.openecomp.policy.drools.http.client.internal.JerseyClient;
import org.openecomp.policy.drools.properties.PolicyProperties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public interface HttpClientFactory {
@@ -50,6 +52,11 @@ public interface HttpClientFactory {
class IndexedHttpClientFactory implements HttpClientFactory {
+ /**
+ * Logger
+ */
+ private static Logger logger = LoggerFactory.getLogger(IndexedHttpClientFactory.class);
+
protected HashMap<String, HttpClient> clients = new HashMap<String, HttpClient>();
@Override
@@ -105,7 +112,7 @@ class IndexedHttpClientFactory implements HttpClientFactory {
}
port = Integer.parseInt(servicePortString);
} catch (NumberFormatException nfe) {
- nfe.printStackTrace();
+ logger.error("http-client-factory: cannot parse port {}", servicePortString, nfe);
continue;
}
@@ -135,7 +142,7 @@ class IndexedHttpClientFactory implements HttpClientFactory {
userName, password, managed);
clientList.add(client);
} catch (Exception e) {
- e.printStackTrace();
+ logger.error("http-client-factory: cannot build client {}", clientName, e);
}
}
@@ -166,7 +173,7 @@ class IndexedHttpClientFactory implements HttpClientFactory {
try {
client.shutdown();
} catch (IllegalStateException e) {
- e.printStackTrace();
+ logger.error("http-client-factory: cannot shutdown client {}", client, e);
}
}
diff --git a/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/client/internal/JerseyClient.java b/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/client/internal/JerseyClient.java
index 4fa59dc8..f041b079 100644
--- a/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/client/internal/JerseyClient.java
+++ b/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/client/internal/JerseyClient.java
@@ -35,11 +35,18 @@ import javax.ws.rs.core.Response;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.openecomp.policy.drools.http.client.HttpClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.annotation.JsonIgnore;
public class JerseyClient implements HttpClient {
+ /**
+ * Logger
+ */
+ private static Logger logger = LoggerFactory.getLogger(JerseyClient.class);
+
protected final String name;
protected final boolean https;
protected final boolean selfSignedCerts;
@@ -156,7 +163,8 @@ public class JerseyClient implements HttpClient {
try {
this.client.close();
} catch (Exception e) {
- e.printStackTrace();
+ logger.warn("{}: cannot close because of {}", this,
+ e.getMessage(), e);
}
}
diff --git a/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/server/HttpServletServerFactory.java b/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/server/HttpServletServerFactory.java
index 40f5c9ad..83f4b3d7 100644
--- a/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/server/HttpServletServerFactory.java
+++ b/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/server/HttpServletServerFactory.java
@@ -25,8 +25,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Properties;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
import org.openecomp.policy.drools.http.server.internal.JettyJerseyServer;
import org.openecomp.policy.drools.properties.PolicyProperties;
@@ -95,7 +95,7 @@ class IndexedHttpServletServerFactory implements HttpServletServerFactory {
/**
* logger
*/
- protected static Logger logger = FlexLogger.getLogger(IndexedHttpServletServerFactory.class);
+ protected static Logger logger = LoggerFactory.getLogger(IndexedHttpServletServerFactory.class);
/**
* servers index
@@ -126,7 +126,7 @@ class IndexedHttpServletServerFactory implements HttpServletServerFactory {
String serviceNames = properties.getProperty(PolicyProperties.PROPERTY_HTTP_SERVER_SERVICES);
if (serviceNames == null || serviceNames.isEmpty()) {
- logger.warn("No topic for HTTP Service " + properties);
+ logger.warn("No topic for HTTP Service: {}", properties);
return serviceList;
}
@@ -142,13 +142,13 @@ class IndexedHttpServletServerFactory implements HttpServletServerFactory {
try {
if (servicePortString == null || servicePortString.isEmpty()) {
if (logger.isWarnEnabled())
- logger.warn("No HTTP port for service in " + serviceName);
+ logger.warn("No HTTP port for service in {}", serviceName);
continue;
}
servicePort = Integer.parseInt(servicePortString);
} catch (NumberFormatException nfe) {
if (logger.isWarnEnabled())
- logger.warn("No HTTP port for service in " + serviceName);
+ logger.warn("No HTTP port for service in {}", serviceName);
continue;
}
diff --git a/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/server/internal/JettyJerseyServer.java b/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/server/internal/JettyJerseyServer.java
index 5bc320e5..c60a62ca 100644
--- a/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/server/internal/JettyJerseyServer.java
+++ b/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/server/internal/JettyJerseyServer.java
@@ -24,8 +24,8 @@ import java.net.UnknownHostException;
import java.util.HashMap;
import org.eclipse.jetty.servlet.ServletHolder;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
import io.swagger.jersey.config.JerseyJaxrsConfig;
@@ -67,7 +67,7 @@ public class JettyJerseyServer extends JettyServletServer {
/**
* Logger
*/
- protected static Logger logger = FlexLogger.getLogger(JettyJerseyServer.class);
+ protected static Logger logger = LoggerFactory.getLogger(JettyJerseyServer.class);
/**
* Container for servlets
@@ -112,7 +112,7 @@ public class JettyJerseyServer extends JettyServletServer {
try {
hostname = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
- logger.warn("can't resolve connector's hostname: " + this);
+ logger.warn("{}: can't resolve connector's hostname: ", this);
hostname = "localhost";
}
}
@@ -125,7 +125,7 @@ public class JettyJerseyServer extends JettyServletServer {
swaggerServlet.setInitOrder(2);
if (logger.isDebugEnabled())
- logger.debug(this + "Swagger Servlet has been attached: " + swaggerServlet.dump());
+ logger.debug("{}: Swagger Servlet has been attached: {}", this, swaggerServlet.dump());
}
/**
@@ -165,7 +165,7 @@ public class JettyJerseyServer extends JettyServletServer {
String initClasses =
jerseyServlet.getInitParameter(JERSEY_INIT_CLASSNAMES_PARAM_NAME);
if (initClasses != null && !initClasses.isEmpty())
- logger.warn("Both packages and classes are used in Jetty+Jersey Configuration: " + restPackage);
+ logger.warn("Both packages and classes are used in Jetty+Jersey Configuration: {}", restPackage);
String initPackages =
jerseyServlet.getInitParameter(JERSEY_INIT_PACKAGES_PARAM_NAME);
@@ -188,7 +188,7 @@ public class JettyJerseyServer extends JettyServletServer {
jerseyServlet.setInitParameter(JERSEY_INIT_PACKAGES_PARAM_NAME, initPackages);
if (logger.isDebugEnabled())
- logger.debug(this + "Added REST Package: " + jerseyServlet.dump());
+ logger.debug("{}: added REST package: {}", this, jerseyServlet.dump());
}
@Override
@@ -206,7 +206,7 @@ public class JettyJerseyServer extends JettyServletServer {
String initPackages =
jerseyServlet.getInitParameter(JERSEY_INIT_PACKAGES_PARAM_NAME);
if (initPackages != null && !initPackages.isEmpty())
- logger.warn("Both classes and packages are used in Jetty+Jersey Configuration: " + restClass);
+ logger.warn("Both classes and packages are used in Jetty+Jersey Configuration: {}", restClass);
String initClasses =
jerseyServlet.getInitParameter(JERSEY_INIT_CLASSNAMES_PARAM_NAME);
@@ -228,7 +228,7 @@ public class JettyJerseyServer extends JettyServletServer {
jerseyServlet.setInitParameter(JERSEY_INIT_CLASSNAMES_PARAM_NAME, initClasses);
if (logger.isDebugEnabled())
- logger.debug(this + "Added REST Class: " + jerseyServlet.dump());
+ logger.debug("{}: added REST class: {}", this, jerseyServlet.dump());
}
@Override
diff --git a/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/server/internal/JettyServletServer.java b/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/server/internal/JettyServletServer.java
index 74360e80..009ad303 100644
--- a/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/server/internal/JettyServletServer.java
+++ b/policy-endpoints/src/main/java/org/openecomp/policy/drools/http/server/internal/JettyServletServer.java
@@ -28,11 +28,9 @@ import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.util.security.Credential;
-
-import org.openecomp.policy.common.logging.eelf.MessageCodes;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.drools.http.server.HttpServletServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.annotation.JsonIgnore;
@@ -41,7 +39,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
*/
public abstract class JettyServletServer implements HttpServletServer, Runnable {
- private static Logger logger = FlexLogger.getLogger(JettyServletServer.class);
+ private static Logger logger = LoggerFactory.getLogger(JettyServletServer.class);
protected final String name;
@@ -141,25 +139,27 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable
*/
@Override
public void run() {
- try {
- if (logger.isInfoEnabled())
- logger.info(this + " STARTING " + this.jettyServer.dump());
+ try {
+ logger.info("{}: STARTING", this);
this.jettyServer.start();
+ if (logger.isInfoEnabled())
+ logger.info("{}: STARTED: {}", this, this.jettyServer.dump());
+
synchronized(this.startCondition) {
this.startCondition.notifyAll();
}
this.jettyServer.join();
} catch (Exception e) {
- logger.warn(MessageCodes.EXCEPTION_ERROR, e,
- "Error found while running management server", this.toString());
+ logger.error("{}: error found while bringing up server", this, e);
}
}
@Override
public boolean waitedStart(long maxWaitTime) throws IllegalArgumentException {
+ logger.info("{}: WAITED-START", this);
if (maxWaitTime < 0)
throw new IllegalArgumentException("max-wait-time cannot be negative");
@@ -184,15 +184,13 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable
long endTs = System.currentTimeMillis();
pendingWaitTime = pendingWaitTime - (endTs - startTs);
- if (logger.isInfoEnabled())
- logger.info(this + "Pending time is " + pendingWaitTime +
- " ms.");
+ logger.info("{}: pending time is {} ms.", this, pendingWaitTime);
if (pendingWaitTime <= 0)
return false;
} catch (InterruptedException e) {
- logger.warn("waited-start has been interrupted");
+ logger.warn("{}: waited-start has been interrupted", this);
return false;
}
}
@@ -206,8 +204,7 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable
*/
@Override
public boolean start() throws IllegalStateException {
- if (logger.isDebugEnabled())
- logger.debug(this + "START");
+ logger.info("{}: STARTING", this);
synchronized(this) {
if (jettyThread == null ||
@@ -227,7 +224,7 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable
*/
@Override
public boolean stop() throws IllegalStateException {
- logger.info(this + "STOP");
+ logger.info("{}: STOPPING", this);
synchronized(this) {
if (jettyThread == null) {
@@ -241,16 +238,13 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable
try {
this.connector.stop();
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e,
- "Error while stopping management server", this.toString());
- e.printStackTrace();
+ logger.error("{}: error while stopping management server", this, e);
}
try {
this.jettyServer.stop();
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e,
- "Error while stopping management server", this.toString());
+ logger.error("{}: error while stopping management server", this, e);
return false;
}
@@ -265,7 +259,7 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable
*/
@Override
public void shutdown() throws IllegalStateException {
- logger.info(this + "SHUTDOWN");
+ logger.info("{}: SHUTTING DOWN", this);
this.stop();
@@ -278,15 +272,14 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable
try {
jettyThreadCopy.join(1000L);
} catch (InterruptedException e) {
- logger.warn(MessageCodes.EXCEPTION_ERROR, e,
- "Error while shutting down management server", this.toString());
+ logger.warn("{}: error while shutting down management server", this);
}
if (!jettyThreadCopy.isInterrupted()) {
try {
jettyThreadCopy.interrupt();
} catch(Exception e) {
// do nothing
- logger.warn("exception while shutting down (OK)");
+ logger.warn("{}: exception while shutting down (OK)", this);
}
}
}
diff --git a/policy-endpoints/src/test/java/org/openecomp/policy/drools/http/server/test/HttpClientTest.java b/policy-endpoints/src/test/java/org/openecomp/policy/drools/http/server/test/HttpClientTest.java
index cd149f7a..df57fcfc 100644
--- a/policy-endpoints/src/test/java/org/openecomp/policy/drools/http/server/test/HttpClientTest.java
+++ b/policy-endpoints/src/test/java/org/openecomp/policy/drools/http/server/test/HttpClientTest.java
@@ -31,12 +31,16 @@ import org.junit.Test;
import org.openecomp.policy.drools.http.client.HttpClient;
import org.openecomp.policy.drools.http.server.HttpServletServer;
import org.openecomp.policy.drools.properties.PolicyProperties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class HttpClientTest {
+ private static Logger logger = LoggerFactory.getLogger(HttpClientTest.class);
+
@Test
public void testHttpNoAuthClient() throws Exception {
- System.out.println("-- testHttpNoAuthClient() --");
+ logger.info("-- testHttpNoAuthClient() --");
HttpServletServer server = HttpServletServer.factory.build("echo", "localhost", 6666, "/", false, true);
server.addServletPackage("/*", this.getClass().getPackage().getName());
@@ -57,7 +61,7 @@ public class HttpClientTest {
@Test
public void testHttpAuthClient() throws Exception {
- System.out.println("-- testHttpAuthClient() --");
+ logger.info("-- testHttpAuthClient() --");
HttpServletServer server = HttpServletServer.factory.build("echo", "localhost", 6666, "/", false, true);
server.setBasicAuthentication("x", "y", null);
@@ -79,7 +83,7 @@ public class HttpClientTest {
@Test
public void testHttpAuthClient401() throws Exception {
- System.out.println("-- testHttpAuthClient401() --");
+ logger.info("-- testHttpAuthClient401() --");
HttpServletServer server = HttpServletServer.factory.build("echo", "localhost", 6666, "/", false, true);
server.setBasicAuthentication("x", "y", null);
@@ -98,7 +102,7 @@ public class HttpClientTest {
//@Test
public void testHttpAuthClientHttps() throws Exception {
- System.out.println("-- testHttpAuthClientHttps() --");
+ logger.info("-- testHttpAuthClientHttps() --");
HttpClient client = HttpClient.factory.build("testHttpAuthClientHttps", true, true, "somehost.somewhere.com",
9091, "pap/test", "testpap", "alpha123", true);
@@ -116,7 +120,7 @@ public class HttpClientTest {
//@Test
public void testHttpAuthClientProps() throws Exception {
- System.out.println("-- testHttpAuthClientProps() --");
+ logger.info("-- testHttpAuthClientProps() --");
Properties httpProperties = new Properties();
diff --git a/policy-endpoints/src/test/java/org/openecomp/policy/drools/http/server/test/HttpServerTest.java b/policy-endpoints/src/test/java/org/openecomp/policy/drools/http/server/test/HttpServerTest.java
index 6a369814..931d968b 100644
--- a/policy-endpoints/src/test/java/org/openecomp/policy/drools/http/server/test/HttpServerTest.java
+++ b/policy-endpoints/src/test/java/org/openecomp/policy/drools/http/server/test/HttpServerTest.java
@@ -29,15 +29,19 @@ import java.util.UUID;
import org.junit.Test;
import org.openecomp.policy.drools.http.server.HttpServletServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* HttpServletServer JUNIT tests
*/
public class HttpServerTest {
+
+ private static Logger logger = LoggerFactory.getLogger(HttpServerTest.class);
@Test
public void testSingleServer() throws Exception {
- System.out.println("-- testSingleServer() --");
+ logger.info("-- testSingleServer() --");
HttpServletServer server = HttpServletServer.factory.build("echo", "localhost", 5678, "/", false, true);
server.addServletPackage("/*", this.getClass().getPackage().getName());
@@ -48,7 +52,6 @@ public class HttpServerTest {
String echo = "hello";
URL url = new URL("http://localhost:5678/junit/echo/" + echo);
String response = response(url);
- System.out.println("Received .. " + response);
assertTrue(response.equals(echo));
String responseSwagger = null;
@@ -67,7 +70,7 @@ public class HttpServerTest {
@Test
public void testMultipleServers() throws Exception {
- System.out.println("-- testMultipleServers() --");
+ logger.info("-- testMultipleServers() --");
HttpServletServer server1 = HttpServletServer.factory.build("echo-1", "localhost", 5678, "/", true, true);
server1.addServletPackage("/*", this.getClass().getPackage().getName());
@@ -84,18 +87,14 @@ public class HttpServerTest {
URL url1 = new URL("http://localhost:5678/junit/echo/" + echo);
String response1 = response(url1);
- System.out.println("Received .. " + response1);
assertTrue(response1.equals(echo));
URL urlSwagger = new URL("http://localhost:5678/swagger.json");
- String responseSwagger = response(urlSwagger);
-
- System.out.println("Received .. " + responseSwagger);
+ String responseSwagger = response(urlSwagger);
assertTrue(responseSwagger != null);
URL url2 = new URL("http://localhost:5679/junit/echo/" + echo);
String response2 = response(url2);
- System.out.println("Received .. " + response2);
assertTrue(response2.equals(echo));
String responseSwagger2 = null;
@@ -105,8 +104,6 @@ public class HttpServerTest {
} catch(IOException ioe) {
// Expected
}
-
- System.out.println("Received .. " + responseSwagger2);
assertTrue(responseSwagger2 == null);
HttpServletServer.factory.destroy();
@@ -115,7 +112,7 @@ public class HttpServerTest {
@Test
public void testMultiServicePackage() throws Exception {
- System.out.println("-- testMultiServicePackage() --");
+ logger.info("-- testMultiServicePackage() --");
String randomName = UUID.randomUUID().toString();
@@ -128,12 +125,10 @@ public class HttpServerTest {
String echo = "hello";
URL urlService1 = new URL("http://localhost:5678/junit/echo/" + echo);
String responseService1 = response(urlService1);
- System.out.println("Received .. " + responseService1);
assertTrue(responseService1.equals(echo));
URL urlService2 = new URL("http://localhost:5678/junit/endpoints/http/servers");
String responseService2 = response(urlService2);
- System.out.println("Received .. " + responseService2);
assertTrue(responseService2.contains(randomName));
HttpServletServer.factory.destroy();
@@ -142,7 +137,7 @@ public class HttpServerTest {
@Test
public void testServiceClass() throws Exception {
- System.out.println("-- testServiceClass() --");
+ logger.info("-- testServiceClass() --");
String randomName = UUID.randomUUID().toString();
HttpServletServer server = HttpServletServer.factory.build(randomName, "localhost", 5678, "/", false, true);
@@ -154,7 +149,6 @@ public class HttpServerTest {
String echo = "hello";
URL urlService1 = new URL("http://localhost:5678/junit/echo/" + echo);
String responseService1 = response(urlService1);
- System.out.println("Received .. " + responseService1);
assertTrue(responseService1.equals(echo));
HttpServletServer.factory.destroy();
@@ -163,7 +157,7 @@ public class HttpServerTest {
@Test
public void testMultiServiceClass() throws Exception {
- System.out.println("-- testMultiServiceClass() --");
+ logger.info("-- testMultiServiceClass() --");
String randomName = UUID.randomUUID().toString();
@@ -177,12 +171,10 @@ public class HttpServerTest {
String echo = "hello";
URL urlService1 = new URL("http://localhost:5678/junit/echo/" + echo);
String responseService1 = response(urlService1);
- System.out.println("Received .. " + responseService1);
assertTrue(responseService1.equals(echo));
URL urlService2 = new URL("http://localhost:5678/junit/endpoints/http/servers");
String responseService2 = response(urlService2);
- System.out.println("Received .. " + responseService2);
assertTrue(responseService2.contains(randomName));
HttpServletServer.factory.destroy();
@@ -200,8 +192,6 @@ public class HttpServerTest {
while ((line = ioReader.readLine()) != null) {
response += line;
}
-
- System.out.println("R is " + response);
ioReader.close();
return response;
}
diff --git a/policy-endpoints/src/test/resources/logback-test.xml b/policy-endpoints/src/test/resources/logback-test.xml
new file mode 100644
index 00000000..9e0dd9ba
--- /dev/null
+++ b/policy-endpoints/src/test/resources/logback-test.xml
@@ -0,0 +1,15 @@
+<configuration>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+ <Pattern>
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M\(%line\) - %msg%n
+ </Pattern>
+ </encoder>
+ </appender>
+
+ <root level="warn">
+ <appender-ref ref="STDOUT"/>
+ </root>
+
+</configuration> \ No newline at end of file
diff --git a/policy-healthcheck/pom.xml b/policy-healthcheck/pom.xml
index 913a944c..ab0e02db 100644
--- a/policy-healthcheck/pom.xml
+++ b/policy-healthcheck/pom.xml
@@ -32,7 +32,7 @@
<artifactId>policy-healthcheck</artifactId>
<name>policy-healthcheck</name>
- <description>Separately loadable module to perform healthchecks of the system</description>
+ <description>Loadable module that performs remote system healthchecks</description>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
@@ -96,7 +96,7 @@
<groupId>io.swagger</groupId>
<artifactId>swagger-jersey2-jaxrs</artifactId>
<scope>provided</scope>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.openecomp.policy.drools-pdp</groupId>
<artifactId>policy-core</artifactId>
diff --git a/policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/HealthCheck.java b/policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/HealthCheck.java
index 17627a63..b45065e9 100644
--- a/policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/HealthCheck.java
+++ b/policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/HealthCheck.java
@@ -30,6 +30,8 @@ import org.openecomp.policy.drools.http.server.HttpServletServer;
import org.openecomp.policy.drools.persistence.SystemPersistence;
import org.openecomp.policy.drools.properties.Startable;
import org.openecomp.policy.drools.system.PolicyEngine;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Healthcheck
@@ -120,6 +122,11 @@ public interface HealthCheck extends Startable {
class HealthCheckMonitor implements HealthCheck {
/**
+ * Logger
+ */
+ private static Logger logger = LoggerFactory.getLogger(HealthCheckMonitor.class);
+
+ /**
* attached http servers
*/
protected volatile ArrayList<HttpServletServer> servers = new ArrayList<>();
@@ -137,7 +144,7 @@ class HealthCheckMonitor implements HealthCheck {
/**
* {@inheritDoc}
*/
- public Reports healthCheck() {
+ public Reports healthCheck() {
Reports reports = new Reports();
reports.healthy = PolicyEngine.manager.isAlive();
@@ -165,7 +172,7 @@ class HealthCheckMonitor implements HealthCheck {
try {
report.message = HttpClient.getBody(response, String.class);
} catch (Exception e) {
- e.printStackTrace();
+ logger.warn("{}: cannot get body from http-client {}", this, client, e);
}
} catch (Exception e) {
report.healthy = false;
@@ -181,6 +188,7 @@ class HealthCheckMonitor implements HealthCheck {
*/
@Override
public boolean start() throws IllegalStateException {
+
try {
this.healthCheckProperties = SystemPersistence.manager.getProperties(HealthCheckFeature.CONFIGURATION_PROPERTIES_NAME);
this.servers = HttpServletServer.factory.build(healthCheckProperties);
@@ -190,7 +198,7 @@ class HealthCheckMonitor implements HealthCheck {
try {
server.start();
} catch (Exception e) {
- e.printStackTrace();
+ logger.warn("{}: cannot start http-server {}", this, server, e);
}
}
} catch (Exception e) {
@@ -205,11 +213,12 @@ class HealthCheckMonitor implements HealthCheck {
*/
@Override
public boolean stop() throws IllegalStateException {
+
for (HttpServletServer server : servers) {
try {
server.stop();
} catch (Exception e) {
- e.printStackTrace();
+ logger.warn("{}: cannot stop http-server {}", this, server, e);
}
}
@@ -217,7 +226,7 @@ class HealthCheckMonitor implements HealthCheck {
try {
client.stop();
} catch (Exception e) {
- e.printStackTrace();
+ logger.warn("{}: cannot stop http-client {}", this, client, e);
}
}
diff --git a/policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/HealthCheckFeature.java b/policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/HealthCheckFeature.java
index 63216f6d..0f16d8cf 100644
--- a/policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/HealthCheckFeature.java
+++ b/policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/HealthCheckFeature.java
@@ -22,11 +22,18 @@ package org.openecomp.policy.drools.healthcheck;
import org.openecomp.policy.drools.features.PolicyEngineFeatureAPI;
import org.openecomp.policy.drools.system.PolicyEngine;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This feature provides healthcheck verification of remotely associated RESTful components
*/
-public class HealthCheckFeature implements PolicyEngineFeatureAPI {
+public class HealthCheckFeature implements PolicyEngineFeatureAPI {
+
+ /**
+ * Logger
+ */
+ private static Logger logger = LoggerFactory.getLogger(HealthCheckFeature.class);
/**
* Properties Configuration Name
@@ -43,7 +50,7 @@ public class HealthCheckFeature implements PolicyEngineFeatureAPI {
try {
HealthCheck.monitor.start();
} catch (IllegalStateException e) {
- e.printStackTrace();
+ logger.error("Healthcheck Monitor cannot be started", e);
}
return false;
@@ -54,7 +61,7 @@ public class HealthCheckFeature implements PolicyEngineFeatureAPI {
try {
HealthCheck.monitor.stop();
} catch (IllegalStateException e) {
- e.printStackTrace();
+ logger.error("Healthcheck Monitor cannot be stopped", e);
}
return false;
diff --git a/policy-management/config/policyLogger.properties b/policy-management/config/policyLogger.properties
deleted file mode 100644
index f8f31d8f..00000000
--- a/policy-management/config/policyLogger.properties
+++ /dev/null
@@ -1,44 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# policy-management
-# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. 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.
-# ============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/policy-management/pom.xml b/policy-management/pom.xml
index 7feef7a8..3ca8bc22 100644
--- a/policy-management/pom.xml
+++ b/policy-management/pom.xml
@@ -242,12 +242,6 @@
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
-
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.17</version>
- </dependency>
<dependency>
<groupId>junit</groupId>
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/controller/DroolsControllerFactory.java b/policy-management/src/main/java/org/openecomp/policy/drools/controller/DroolsControllerFactory.java
index d94e773c..276573eb 100644
--- a/policy-management/src/main/java/org/openecomp/policy/drools/controller/DroolsControllerFactory.java
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/controller/DroolsControllerFactory.java
@@ -30,8 +30,8 @@ import org.openecomp.policy.drools.controller.internal.MavenDroolsController;
import org.openecomp.policy.drools.controller.internal.NullDroolsController;
import org.openecomp.policy.drools.event.comm.Topic;
import org.openecomp.policy.drools.event.comm.Topic.CommInfrastructure;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.openecomp.policy.drools.event.comm.TopicSource;
import org.openecomp.policy.drools.event.comm.TopicSink;
import org.openecomp.policy.drools.properties.PolicyProperties;
@@ -140,11 +140,11 @@ public interface DroolsControllerFactory {
* Factory of Drools Controllers indexed by the Maven coordinates
*/
class IndexedDroolsControllerFactory implements DroolsControllerFactory {
-
+
/**
* logger
*/
- private static Logger logger = FlexLogger.getLogger(MavenDroolsController.class);
+ private static Logger logger = LoggerFactory.getLogger(MavenDroolsController.class);
/**
* Policy Controller Name Index
@@ -262,7 +262,8 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory {
try {
customGsonCoder = new CustomGsonCoder(customGson);
} catch (IllegalArgumentException e) {
- e.printStackTrace();
+ logger.warn("{}: cannot create custom-gson-coder {} because of {}",
+ this, customGson, e.getMessage(), e);
}
}
@@ -276,7 +277,8 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory {
try {
customJacksonCoder = new CustomJacksonCoder(customJackson);
} catch (IllegalArgumentException e) {
- e.printStackTrace();
+ logger.warn("{}: cannot create custom-jackson-coder {} because of {}",
+ this, customJackson, e.getMessage(), e);
}
}
@@ -537,4 +539,12 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory {
return controllers;
}
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("IndexedDroolsControllerFactory [#droolsControllers=").append(droolsControllers.size())
+ .append("]");
+ return builder.toString();
+ }
+
}
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/MavenDroolsController.java b/policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/MavenDroolsController.java
index e404a092..06d2aaf7 100644
--- a/policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/MavenDroolsController.java
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/MavenDroolsController.java
@@ -32,9 +32,8 @@ import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.rule.FactHandle;
import org.kie.api.runtime.rule.QueryResults;
import org.kie.api.runtime.rule.QueryResultsRow;
-import org.openecomp.policy.common.logging.eelf.MessageCodes;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.openecomp.policy.drools.controller.DroolsController;
import org.openecomp.policy.drools.core.PolicyContainer;
import org.openecomp.policy.drools.core.PolicySession;
@@ -61,7 +60,7 @@ public class MavenDroolsController implements DroolsController {
/**
* logger
*/
- private static Logger logger = FlexLogger.getLogger(MavenDroolsController.class);
+ private static Logger logger = LoggerFactory.getLogger(MavenDroolsController.class);
/**
* Policy Container, the access object to the policy-core layer
@@ -423,16 +422,14 @@ public class MavenDroolsController implements DroolsController {
* {@inheritDoc}
*/
@Override
- public void shutdown() throws IllegalStateException {
-
- if (logger.isInfoEnabled())
- logger.info(this + "SHUTDOWN");
+ public void shutdown() throws IllegalStateException {
+ logger.info("{}: SHUTDOWN", this);
try {
this.stop();
this.removeCoders();
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, "stop", this.toString());
+ logger.error("{} SHUTDOWN FAILED because of {}", this, e.getMessage(), e);
} finally {
this.policyContainer.shutdown();
}
@@ -445,14 +442,13 @@ public class MavenDroolsController implements DroolsController {
*/
@Override
public void halt() throws IllegalStateException {
- if (logger.isInfoEnabled())
- logger.info(this + "SHUTDOWN");
+ logger.info("{}: HALT", this);
try {
this.stop();
this.removeCoders();
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, "halt", this.toString());
+ logger.error("{} HALT FAILED because of {}", this, e.getMessage(), e);
} finally {
this.policyContainer.destroy();
}
@@ -462,20 +458,18 @@ public class MavenDroolsController implements DroolsController {
* removes this drools controllers and encoders and decoders from operation
*/
protected void removeCoders() {
-
- if (logger.isInfoEnabled())
- logger.info(this + "REMOVE-CODERS");
+ logger.info("{}: REMOVE-CODERS", this);
try {
this.removeDecoders();
} catch (IllegalArgumentException e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, "removeDecoders", this.toString());
+ logger.error("{} REMOVE-DECODERS FAILED because of {}", this, e.getMessage(), e);
}
try {
this.removeEncoders();
} catch (IllegalArgumentException e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, "removeEncoders", this.toString());
+ logger.error("{} REMOVE-ENCODERS FAILED because of {}", this, e.getMessage(), e);
}
}
@@ -492,9 +486,7 @@ public class MavenDroolsController implements DroolsController {
*/
@Override
public boolean offer(String topic, String event) {
-
- if (logger.isInfoEnabled())
- logger.info("OFFER: " + topic + ":" + event + " INTO " + this);
+ logger.debug("{}: OFFER: {} <- {}", this, topic, event);
if (this.locked)
return true;
@@ -515,8 +507,8 @@ public class MavenDroolsController implements DroolsController {
this.getArtifactId(),
topic)) {
- logger.warn("DECODING-UNSUPPORTED: " + ":" + this.getGroupId() +
- ":" + this.getArtifactId() + ":" + topic + " IN " + this);
+ logger.warn("{}: DECODING-UNSUPPORTED {}:{}:{}", this,
+ topic, this.getGroupId(), this.getArtifactId());
return true;
}
@@ -529,12 +521,12 @@ public class MavenDroolsController implements DroolsController {
topic,
event);
} catch (UnsupportedOperationException uoe) {
- if (logger.isInfoEnabled())
- logger.info("DECODE:"+ this + ":" + topic + ":" + event);
+ logger.info("{}: DECODE FAILED: {} <- {} because of {}", this, topic,
+ event, uoe.getMessage(), uoe);
return true;
} catch (Exception e) {
- e.printStackTrace();
- logger.error("DECODE:"+ this + ":" + topic + ":" + event);
+ logger.warn("{}: DECODE FAILED: {} <- {} because of {}", this, topic,
+ event, e.getMessage(), e);
return true;
}
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/persistence/SystemPersistence.java b/policy-management/src/main/java/org/openecomp/policy/drools/persistence/SystemPersistence.java
index 6bb1185d..dda20a08 100644
--- a/policy-management/src/main/java/org/openecomp/policy/drools/persistence/SystemPersistence.java
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/persistence/SystemPersistence.java
@@ -28,10 +28,9 @@ import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.Properties;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
-import org.openecomp.policy.common.logging.eelf.MessageCodes;
import org.openecomp.policy.drools.utils.PropertyUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public interface SystemPersistence {
@@ -119,7 +118,7 @@ class SystemPropertiesPersistence implements SystemPersistence {
/**
* logger
*/
- private static Logger logger = FlexLogger.getLogger(SystemPropertiesPersistence.class);
+ private static Logger logger = LoggerFactory.getLogger(SystemPropertiesPersistence.class);
/**
* backs up the properties-based controller configuration
@@ -142,8 +141,7 @@ class SystemPropertiesPersistence implements SystemPersistence {
Files.copy(controllerPropertiesPath,
controllerPropertiesBakPath, StandardCopyOption.REPLACE_EXISTING);
} catch (Exception e) {
- logger.warn(MessageCodes.EXCEPTION_ERROR, e,
- controllerName, "SystemPersistenceProperties");
+ logger.warn("{}: cannot be backed up", controllerName, e);
return false;
}
}
@@ -178,7 +176,7 @@ class SystemPropertiesPersistence implements SystemPersistence {
this.backupController(controllerName);
}
} catch (Exception e) {
- logger.info("No existing Properties");
+ logger.info("{}: no existing Properties", controllerName);
// continue
}
}
@@ -188,8 +186,7 @@ class SystemPropertiesPersistence implements SystemPersistence {
FileWriter writer = new FileWriter(controllerPropertiesFile);
properties.store(writer, "Machine created Policy Controller Configuration");
} catch (Exception e) {
- logger.warn(MessageCodes.EXCEPTION_ERROR, e,
- controllerName, "SystemPersistenceProperties");
+ logger.warn("{}: cannot be STORED", controllerName, e);
return false;
}
@@ -217,8 +214,7 @@ class SystemPropertiesPersistence implements SystemPersistence {
controllerPropertiesBakPath,
StandardCopyOption.REPLACE_EXISTING);
} catch (Exception e) {
- logger.warn(MessageCodes.EXCEPTION_ERROR, e,
- controllerName, "SystemPersistenceProperties");
+ logger.warn("{}: cannot be DELETED", controllerName, e);
return false;
}
}
@@ -243,10 +239,7 @@ class SystemPropertiesPersistence implements SystemPersistence {
try {
return PropertyUtil.getProperties(propertiesPath.toFile());
} catch (Exception e) {
- logger.warn(MessageCodes.EXCEPTION_ERROR, e,
- name, "SystemPersistenceProperties can't retrieved properties for " +
- propertiesPath);
- e.printStackTrace();
+ logger.warn("{}: can't read properties @ {}", name, propertiesPath);
throw new IllegalArgumentException("can't read properties for " +
name + " @ " +
propertiesPath);
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/protocol/coders/EventProtocolCoder.java b/policy-management/src/main/java/org/openecomp/policy/drools/protocol/coders/EventProtocolCoder.java
index d82b3724..1030186b 100644
--- a/policy-management/src/main/java/org/openecomp/policy/drools/protocol/coders/EventProtocolCoder.java
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/protocol/coders/EventProtocolCoder.java
@@ -26,14 +26,13 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import org.openecomp.policy.common.logging.eelf.MessageCodes;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.drools.controller.DroolsController;
import org.openecomp.policy.drools.protocol.coders.EventProtocolCoder.CoderFilters;
import org.openecomp.policy.drools.protocol.coders.TopicCoderFilterConfiguration.CustomGsonCoder;
import org.openecomp.policy.drools.protocol.coders.TopicCoderFilterConfiguration.CustomJacksonCoder;
import org.openecomp.policy.drools.utils.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Coder (Encoder/Decoder) of Events.
@@ -399,8 +398,11 @@ public interface EventProtocolCoder {
* class and best fitted json parsing tools.
*/
class MultiplexorEventProtocolCoder implements EventProtocolCoder {
- // get an instance of logger
- private static Logger logger = FlexLogger.getLogger(MultiplexorEventProtocolCoder.class);
+ /**
+ * Logger
+ */
+ private static Logger logger = LoggerFactory.getLogger(MultiplexorEventProtocolCoder.class);
+
/**
* Decoders
*/
@@ -423,11 +425,10 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
CustomJacksonCoder customJacksonCoder,
int modelClassLoaderHash)
throws IllegalArgumentException {
- logger.info("ADD-DECODER: " + groupId + ":" + artifactId + ":" +
- topic + ":" + eventClass + ":" +
- protocolFilter + ":" + customGsonCoder +
- ":" + customJacksonCoder + ":" + modelClassLoaderHash +
- " INTO " + this);
+ logger.info("{}: add-decoder {}:{}:{}:{}:{}:{}:{}:{}", this,
+ groupId, artifactId, topic, eventClass,
+ protocolFilter, customGsonCoder, customJacksonCoder,
+ modelClassLoaderHash);
this.decoders.add(groupId, artifactId, topic, eventClass, protocolFilter,
customGsonCoder, customJacksonCoder, modelClassLoaderHash);
}
@@ -443,11 +444,10 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
CustomJacksonCoder customJacksonCoder,
int modelClassLoaderHash)
throws IllegalArgumentException {
- logger.info("ADD-ENCODER: " + groupId + ":" + artifactId + ":" +
- topic + ":" + eventClass + ":" +
- protocolFilter + ":" + customGsonCoder +
- ":" + customJacksonCoder + ":" + modelClassLoaderHash +
- " INTO " + this);
+ logger.info("{}: add-decoder {}:{}:{}:{}:{}:{}:{}:{}", this,
+ groupId, artifactId, topic, eventClass,
+ protocolFilter, customGsonCoder, customJacksonCoder,
+ modelClassLoaderHash);
this.encoders.add(groupId, artifactId, topic, eventClass, protocolFilter,
customGsonCoder, customJacksonCoder, modelClassLoaderHash);
}
@@ -458,8 +458,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
@Override
public void removeDecoders(String groupId, String artifactId, String topic)
throws IllegalArgumentException {
- logger.info("REMOVE-DECODER: " + groupId + ":" + artifactId + ":" +
- topic + " FROM " + this);
+ logger.info("{}: remove-decoder {}:{}:{}", this, groupId, artifactId, topic);
this.decoders.remove(groupId, artifactId, topic);
}
@@ -469,8 +468,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
@Override
public void removeEncoders(String groupId, String artifactId, String topic)
throws IllegalArgumentException {
- logger.info("REMOVE-ENCODER: " + groupId + ":" + artifactId + ":" +
- topic + " FROM " + this);
+ logger.info("{}: remove-encoder {}:{}:{}", this, groupId, artifactId, topic);
this.encoders.remove(groupId, artifactId, topic);
}
@@ -496,8 +494,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
@Override
public Object decode(String groupId, String artifactId, String topic, String json)
throws IllegalArgumentException, UnsupportedOperationException, IllegalStateException {
- logger.info("DECODE: " + groupId + ":" + artifactId + ":" +
- topic + ":" + json + " WITH " + this);
+ logger.debug("{}: decode {}:{}:{}:{}", this, groupId, artifactId, topic, json);
return this.decoders.decode(groupId, artifactId, topic, json);
}
@@ -507,8 +504,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
@Override
public String encode(String groupId, String artifactId, String topic, Object event)
throws IllegalArgumentException, IllegalStateException, UnsupportedOperationException {
- logger.info("ENCODE: " + groupId + ":" + artifactId + ":" +
- topic + ":" + event + " WITH " + this);
+ logger.debug("{}: encode {}:{}:{}:{}", this, groupId, artifactId, topic, event);
return this.encoders.encode(groupId, artifactId, topic, event);
}
@@ -518,7 +514,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
@Override
public String encode(String topic, Object event)
throws IllegalArgumentException, IllegalStateException, UnsupportedOperationException {
- logger.info("ENCODE: " + topic + ":" + event + " WITH " + this);
+ logger.debug("{}: encode {}:{}", this, topic, event);
return this.encoders.encode(topic, event);
}
@@ -528,7 +524,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
@Override
public String encode(String topic, Object event, DroolsController droolsController)
throws IllegalArgumentException, IllegalStateException, UnsupportedOperationException {
- logger.info("ENCODE: " + topic + ":" + event + ":" + droolsController + " WITH " + this);
+ logger.debug("{}: encode {}:{}:{}", this, topic, event, droolsController);
return this.encoders.encode(topic, event, droolsController);
}
@@ -537,8 +533,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
*/
@Override
public List<CoderFilters> getDecoderFilters(String groupId, String artifactId, String topic)
- throws IllegalArgumentException {
-
+ throws IllegalArgumentException {
return this.decoders.getFilters(groupId, artifactId, topic);
}
@@ -547,8 +542,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
*/
@Override
public ProtocolCoderToolset getDecoders(String groupId, String artifactId, String topic)
- throws IllegalArgumentException {
-
+ throws IllegalArgumentException {
Pair<ProtocolCoderToolset,ProtocolCoderToolset> decoderToolsets = this.decoders.getCoders(groupId, artifactId, topic);
if (decoderToolsets == null)
throw new IllegalArgumentException("Decoders not found for " + groupId + ":" + artifactId + ":" + topic);
@@ -561,8 +555,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
*/
@Override
public List<CoderFilters> getEncoderFilters(String groupId, String artifactId, String topic)
- throws IllegalArgumentException {
-
+ throws IllegalArgumentException {
return this.encoders.getFilters(groupId, artifactId, topic);
}
@@ -571,8 +564,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
*/
@Override
public CoderFilters getDecoderFilters(String groupId, String artifactId, String topic, String classname)
- throws IllegalArgumentException {
-
+ throws IllegalArgumentException {
return this.decoders.getFilters(groupId, artifactId, topic, classname);
}
@@ -581,8 +573,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
*/
@Override
public CoderFilters getEncoderFilters(String groupId, String artifactId, String topic, String classname)
- throws IllegalArgumentException {
-
+ throws IllegalArgumentException {
return this.encoders.getFilters(groupId, artifactId, topic, classname);
}
@@ -669,7 +660,7 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
* class and best fitted json parsing tools.
*/
abstract class GenericEventProtocolCoder {
- private static Logger logger = FlexLogger.getLogger(GenericEventProtocolCoder.class);
+ private static Logger logger = LoggerFactory.getLogger(GenericEventProtocolCoder.class);
/**
* Mapping topic:controller-id -> <protocol-decoder-toolset-pair>
@@ -717,13 +708,11 @@ abstract class GenericEventProtocolCoder {
throw new IllegalArgumentException("Invalid group id");
}
- if (artifactId == null || artifactId.isEmpty()) {
+ if (artifactId == null || artifactId.isEmpty())
throw new IllegalArgumentException("Invalid artifact id");
- }
- if (topic == null || topic.isEmpty()) {
+ if (topic == null || topic.isEmpty())
throw new IllegalArgumentException("Invalid Topic");
- }
if (eventClass == null) {
throw new IllegalArgumentException("Invalid Event Class");
@@ -736,16 +725,14 @@ abstract class GenericEventProtocolCoder {
if (coders.containsKey(key)) {
Pair<ProtocolCoderToolset, ProtocolCoderToolset> toolsets = coders.get(key);
- if (logger.isInfoEnabled())
- logger.info("ADDING CODER TO EXISTING: " + toolsets + " for " + key);
+ logger.info("{}: adding coders for existing {}: ", this, key, toolsets.first());
toolsets.first().addCoder(eventClass, protocolFilter, modelClassLoaderHash);
toolsets.second().addCoder(eventClass, protocolFilter, modelClassLoaderHash);
if (!reverseCoders.containsKey(reverseKey)) {
- if (logger.isInfoEnabled())
- logger.info("Multiple coder classes case: " + toolsets.first() +
- " for " + reverseKey + " - " + key);
+ logger.info("{}: adding new reverse coders (multiple classes case) for {}:{}: {}",
+ this, reverseKey, key, toolsets.first());
List<Pair<ProtocolCoderToolset,ProtocolCoderToolset>> reverseMappings =
new ArrayList<Pair<ProtocolCoderToolset,ProtocolCoderToolset>>();
@@ -783,8 +770,7 @@ abstract class GenericEventProtocolCoder {
new Pair<ProtocolCoderToolset,ProtocolCoderToolset>(gsonCoderTools,
jacksonCoderTools);
- logger.info("ADDED TOOLSET: " + key + " : " +
- coderTools + ":" + this);
+ logger.info("{}: adding coders for new {}: {}", this, key, coderTools.first());
coders.put(key, coderTools);
@@ -800,24 +786,24 @@ abstract class GenericEventProtocolCoder {
present = parserSet.first().getControllerId().equals(key);
if (present) {
/* anomaly */
- logger.error("UNEXPECTED TOOLSET REVERSE MAPPING FOUND: " + parserSet.first() +
- " for " + reverseKey + " - " + key);
+ logger.error("{}: unexpected toolset reverse mapping found for {}:{}: {}",
+ this, reverseKey, key, parserSet.first());
}
}
if (present) {
return;
} else {
- logger.info("ADDING TOOLSET REVERSE MAPPING: " + reverseKey + " : " +
- toolsets + ":" + coderTools + ":" + this);
+ logger.info("{}: adding coder set for {}: {} ", this,
+ reverseKey, coderTools.getFirst());
toolsets.add(coderTools);
}
} else {
List<Pair<ProtocolCoderToolset,ProtocolCoderToolset>> toolsets =
new ArrayList<Pair<ProtocolCoderToolset,ProtocolCoderToolset>>();
- logger.info("ADDING TOOLSET REVERSE MAPPING: " + reverseKey + " : " +
- toolsets + ":" + coderTools + ":" + this);
toolsets.add(coderTools);
+
+ logger.info("{}: adding toolset for reverse key {}: {}", this, reverseKey, toolsets);
reverseCoders.put(reverseKey, toolsets);
}
@@ -858,25 +844,22 @@ abstract class GenericEventProtocolCoder {
public void remove(String groupId, String artifactId, String topic)
throws IllegalArgumentException {
- if (groupId == null || groupId.isEmpty()) {
+ if (groupId == null || groupId.isEmpty())
throw new IllegalArgumentException("Invalid group id");
- }
- if (artifactId == null || artifactId.isEmpty()) {
+ if (artifactId == null || artifactId.isEmpty())
throw new IllegalArgumentException("Invalid artifact id");
- }
- if (topic == null || topic.isEmpty()) {
+ if (topic == null || topic.isEmpty())
throw new IllegalArgumentException("Invalid Topic");
- }
String key = this.codersKey(groupId, artifactId, topic);
synchronized(this) {
if (coders.containsKey(key)) {
Pair<ProtocolCoderToolset, ProtocolCoderToolset> p = coders.remove(key);
- logger.info("REMOVED TOOLSET: " + key + " : " + p + " FROM " +
- coders + " : " + this);
+
+ logger.info("{}: removed toolset for {}: {}", this, key, p.getFirst());
for (CoderFilters codeFilter : p.first().getCoders()) {
String className = codeFilter.getCodedClass();
@@ -889,15 +872,14 @@ abstract class GenericEventProtocolCoder {
while (toolsetsIter.hasNext()) {
Pair<ProtocolCoderToolset, ProtocolCoderToolset> toolset = toolsetsIter.next();
if (toolset.first().getControllerId().equals(key)) {
- logger.info("REMOVED CODER FROM REVERSE MAPPING of TOOLSET: " + reverseKey + " : " + toolset + " FROM " +
- reverseCoders);
+ logger.info("{}: removed coder from toolset for {} from reverse mapping {}: ",
+ this, reverseKey);
toolsetsIter.remove();
}
}
if (this.reverseCoders.get(reverseKey).isEmpty()) {
- logger.info("REMOVE FULL REVERSE MAPPING of TOOLSET: " + reverseKey + " FROM " +
- reverseCoders);
+ logger.info("{}: removing reverse mapping for {}: ", this, reverseKey);
this.reverseCoders.remove(reverseKey);
}
}
@@ -916,16 +898,14 @@ abstract class GenericEventProtocolCoder {
*/
public boolean isCodingSupported(String groupId, String artifactId, String topic) {
- if (groupId == null || groupId.isEmpty()) {
+ if (groupId == null || groupId.isEmpty())
throw new IllegalArgumentException("Invalid group id");
- }
- if (artifactId == null || artifactId.isEmpty()) {
+ if (artifactId == null || artifactId.isEmpty())
throw new IllegalArgumentException("Invalid artifact id");
- }
if (topic == null || topic.isEmpty())
- return false;
+ throw new IllegalArgumentException("Invalid Topic");
String key = this.codersKey(groupId, artifactId, topic);
synchronized(this) {
@@ -947,9 +927,8 @@ abstract class GenericEventProtocolCoder {
public Object decode(String groupId, String artifactId, String topic, String json)
throws IllegalArgumentException, UnsupportedOperationException, IllegalStateException {
- if (!isCodingSupported(groupId, artifactId, topic)) {
+ if (!isCodingSupported(groupId, artifactId, topic))
throw new IllegalArgumentException("Unsupported:" + codersKey(groupId, artifactId, topic) + " for encoding");
- }
String key = this.codersKey(groupId, artifactId, topic);
Pair<ProtocolCoderToolset,ProtocolCoderToolset> coderTools = coders.get(key);
@@ -958,8 +937,7 @@ abstract class GenericEventProtocolCoder {
if (event != null)
return event;
} catch (Exception e) {
- // TODO Auto-generated catch block
- logger.warn("Can't decode @ " + this);
+ logger.info("{}, cannot decode {}", this, json, e);
}
if (multipleToolsetRetries) {
@@ -977,10 +955,8 @@ abstract class GenericEventProtocolCoder {
return event;
}
- } catch (Exception e2) {
- // TODO Auto-generated catch block
- e2.printStackTrace();
- throw new UnsupportedOperationException(e2);
+ } catch (Exception e) {
+ throw new UnsupportedOperationException(e);
}
}
@@ -1001,14 +977,12 @@ abstract class GenericEventProtocolCoder {
public String encode(String groupId, String artifactId, String topic, Object event)
throws IllegalArgumentException, UnsupportedOperationException {
- if (!isCodingSupported(groupId, artifactId, topic)) {
+ if (!isCodingSupported(groupId, artifactId, topic))
throw new IllegalArgumentException
("Unsupported:" + codersKey(groupId, artifactId, topic));
- }
- if (event == null) {
+ if (event == null)
throw new IllegalArgumentException("Unsupported topic:" + topic);
- }
// reuse the decoder set, since there must be affinity in the model
String key = this.codersKey(groupId, artifactId, topic);
@@ -1027,7 +1001,7 @@ abstract class GenericEventProtocolCoder {
protected String encodeInternal(String key, Object event)
throws IllegalArgumentException, UnsupportedOperationException {
- logger.debug("ENCODE: " + key + ":" + event + this);
+ logger.debug("{}: encode for {}: {}", this, key, event);
Pair<ProtocolCoderToolset,ProtocolCoderToolset> coderTools = coders.get(key);
try {
@@ -1035,8 +1009,7 @@ abstract class GenericEventProtocolCoder {
if (json != null && !json.isEmpty())
return json;
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, "FIRST-ENCODE-INTERNAL: " +
- key + ":" + event, this.toString());
+ logger.warn("{}: cannot encode (first) for {}: {}", this, key, event, e);
}
if (multipleToolsetRetries) {
@@ -1054,11 +1027,9 @@ abstract class GenericEventProtocolCoder {
return json;
}
- } catch (Exception e2) {
- // TODO Auto-generated catch block
- logger.error(MessageCodes.EXCEPTION_ERROR, e2, "SECOND-ENCODE-INTERNAL: " +
- key + ":" + event, this.toString());
- throw new UnsupportedOperationException(e2);
+ } catch (Exception e) {
+ logger.error("{}: cannot encode (second) for {}: {}", this, key, event, e);
+ throw new UnsupportedOperationException(e);
}
}
@@ -1069,46 +1040,33 @@ abstract class GenericEventProtocolCoder {
* encode an object into a json string
*
* @param topic topic
- * @param encodedClass object to convert to string
+ * @param event object to convert to string
* @return the json string
* @throws IllegalArgumentException if invalid argument is provided
* @throws UnsupportedOperationException if the operation cannot be performed
*/
- public String encode(String topic, Object encodedClass)
+ public String encode(String topic, Object event)
throws IllegalArgumentException, IllegalStateException, UnsupportedOperationException {
- if (encodedClass == null) {
+ if (event == null)
throw new IllegalArgumentException("Invalid encoded class");
- }
- if (topic == null || topic.isEmpty()) {
+ if (topic == null || topic.isEmpty())
throw new IllegalArgumentException("Invalid topic");
- }
-
- logger.info("ENCODE: " + topic + ":" +
- encodedClass.getClass().getCanonicalName() + ":" +
- encodedClass);
- List<DroolsController> droolsControllers = droolsCreators(topic, encodedClass);
+ List<DroolsController> droolsControllers = droolsCreators(topic, event);
- if (droolsControllers.isEmpty()) {
- if (logger.isWarnEnabled())
- logger.warn("No Drool Controllers for: " + topic + ":" +
- encodedClass.getClass().getCanonicalName() + ":" +
- droolsControllers + " IN " + this);
- throw new IllegalArgumentException("Invalid Topic: " + topic);
- }
+ if (droolsControllers.isEmpty())
+ throw new IllegalArgumentException("no drools controller has been found");
if (droolsControllers.size() > 1) {
- if (logger.isWarnEnabled())
- logger.warn("MULTIPLE DROOLS CONTROLLERS FOUND for: " + topic + ":" +
- encodedClass.getClass().getCanonicalName() + ":" +
- droolsControllers + " IN " + this);
+ logger.warn("{}: multiple drools-controller {} for {}:{} ", this, topic,
+ droolsControllers, event.getClass().getCanonicalName());
// continue
}
String key = codersKey(droolsControllers.get(0).getGroupId(), droolsControllers.get(0).getArtifactId(), topic);
- return this.encodeInternal(key, encodedClass);
+ return this.encodeInternal(key, event);
}
/**
@@ -1123,17 +1081,11 @@ abstract class GenericEventProtocolCoder {
public String encode(String topic, Object encodedClass, DroolsController droolsController)
throws IllegalArgumentException, IllegalArgumentException, UnsupportedOperationException {
- if (encodedClass == null) {
+ if (encodedClass == null)
throw new IllegalArgumentException("Invalid encoded class");
- }
- if (topic == null || topic.isEmpty()) {
+ if (topic == null || topic.isEmpty())
throw new IllegalArgumentException("Invalid topic");
- }
-
- logger.info("ENCODE: " + topic + ":" +
- encodedClass.getClass().getCanonicalName() + ":" +
- encodedClass + ":" + droolsController);
String key = codersKey(droolsController.getGroupId(), droolsController.getArtifactId(), topic);
return this.encodeInternal(key, encodedClass);
@@ -1154,9 +1106,7 @@ abstract class GenericEventProtocolCoder {
String reverseKey = this.reverseCodersKey(topic, encodedClass.getClass().getCanonicalName());
if (!this.reverseCoders.containsKey(reverseKey)) {
- logger.warn("NO MAPPING for REVERSE KEY: " + topic + ":" +
- encodedClass.getClass().getCanonicalName() + ":" +
- encodedClass + ":" + reverseKey + " : " + this);
+ logger.warn("{}: no reverse mapping for {}", this, reverseKey);
return droolsControllers;
}
@@ -1169,13 +1119,9 @@ abstract class GenericEventProtocolCoder {
// but there should be no side-effects. Ownership is crosscheck against classname and
// classloader reference.
- if (toolsets == null || toolsets.isEmpty()) {
- logger.warn("ENCODE: " + topic + ":" +
- encodedClass.getClass().getCanonicalName() + ":" +
- encodedClass + " ENCODER NOT FOUND");
+ if (toolsets == null || toolsets.isEmpty())
throw new IllegalStateException("No Encoders toolsets available for topic "+ topic +
" encoder " + encodedClass.getClass().getCanonicalName());
- }
for (Pair<ProtocolCoderToolset, ProtocolCoderToolset> encoderSet : toolsets) {
// figure out the right toolset
@@ -1193,10 +1139,10 @@ abstract class GenericEventProtocolCoder {
}
}
- if (droolsControllers.isEmpty()) {
- throw new IllegalStateException("No Encoders toolsets available for topic "+ topic +
- " : encoder " + encodedClass.getClass().getCanonicalName());
- }
+ if (droolsControllers.isEmpty())
+ throw new IllegalStateException("No Encoders toolsets available for "+ topic +
+ ":" + encodedClass.getClass().getCanonicalName());
+
return droolsControllers;
}
@@ -1213,9 +1159,8 @@ abstract class GenericEventProtocolCoder {
public List<CoderFilters> getFilters(String groupId, String artifactId, String topic)
throws IllegalArgumentException {
- if (!isCodingSupported(groupId, artifactId, topic)) {
+ if (!isCodingSupported(groupId, artifactId, topic))
throw new IllegalArgumentException("Unsupported:" + codersKey(groupId, artifactId, topic));
- }
String key = this.codersKey(groupId, artifactId, topic);
Pair<ProtocolCoderToolset,ProtocolCoderToolset> coderTools = coders.get(key);
@@ -1234,9 +1179,8 @@ abstract class GenericEventProtocolCoder {
public Pair<ProtocolCoderToolset,ProtocolCoderToolset> getCoders(String groupId, String artifactId, String topic)
throws IllegalArgumentException {
- if (!isCodingSupported(groupId, artifactId, topic)) {
+ if (!isCodingSupported(groupId, artifactId, topic))
throw new IllegalArgumentException("Unsupported:" + codersKey(groupId, artifactId, topic));
- }
String key = this.codersKey(groupId, artifactId, topic);
Pair<ProtocolCoderToolset,ProtocolCoderToolset> coderTools = coders.get(key);
@@ -1254,13 +1198,11 @@ abstract class GenericEventProtocolCoder {
public List<CoderFilters> getFilters(String groupId, String artifactId)
throws IllegalArgumentException {
- if (groupId == null || groupId.isEmpty()) {
+ if (groupId == null || groupId.isEmpty())
throw new IllegalArgumentException("Invalid group id");
- }
- if (artifactId == null || artifactId.isEmpty()) {
+ if (artifactId == null || artifactId.isEmpty())
throw new IllegalArgumentException("Invalid artifact id");
- }
String key = this.codersKey(groupId, artifactId, "");
@@ -1285,13 +1227,11 @@ abstract class GenericEventProtocolCoder {
public List<Pair<ProtocolCoderToolset,ProtocolCoderToolset>> getCoders(String groupId, String artifactId)
throws IllegalArgumentException {
- if (groupId == null || groupId.isEmpty()) {
+ if (groupId == null || groupId.isEmpty())
throw new IllegalArgumentException("Invalid group id");
- }
- if (artifactId == null || artifactId.isEmpty()) {
+ if (artifactId == null || artifactId.isEmpty())
throw new IllegalArgumentException("Invalid artifact id");
- }
String key = this.codersKey(groupId, artifactId, "");
@@ -1319,13 +1259,11 @@ abstract class GenericEventProtocolCoder {
public CoderFilters getFilters(String groupId, String artifactId, String topic, String classname)
throws IllegalArgumentException {
- if (!isCodingSupported(groupId, artifactId, topic)) {
+ if (!isCodingSupported(groupId, artifactId, topic))
throw new IllegalArgumentException("Unsupported:" + codersKey(groupId, artifactId, topic));
- }
- if (classname == null || classname.isEmpty()) {
+ if (classname == null || classname.isEmpty())
throw new IllegalArgumentException("classname must be provided");
- }
String key = this.codersKey(groupId, artifactId, topic);
Pair<ProtocolCoderToolset,ProtocolCoderToolset> coderTools = coders.get(key);
@@ -1343,13 +1281,11 @@ abstract class GenericEventProtocolCoder {
public List<CoderFilters> getReverseFilters(String topic, String codedClass)
throws IllegalArgumentException {
- if (topic == null || topic.isEmpty()) {
+ if (topic == null || topic.isEmpty())
throw new IllegalArgumentException("Unsupported");
- }
- if (codedClass == null) {
+ if (codedClass == null)
throw new IllegalArgumentException("class must be provided");
- }
String key = this.reverseCodersKey(topic, codedClass);
List<Pair<ProtocolCoderToolset,ProtocolCoderToolset>> toolsets = this.reverseCoders.get(key);
@@ -1376,28 +1312,20 @@ abstract class GenericEventProtocolCoder {
DroolsController getDroolsController(String topic, Object fact)
throws IllegalArgumentException {
- if (topic == null || topic.isEmpty()) {
+ if (topic == null || topic.isEmpty())
throw new IllegalArgumentException("Unsupported");
- }
- if (fact == null) {
+ if (fact == null)
throw new IllegalArgumentException("class must be provided");
- }
List<DroolsController> droolsControllers = droolsCreators(topic, fact);
- if (droolsControllers.isEmpty()) {
- if (logger.isWarnEnabled())
- logger.warn("No Drool Controllers for: " + topic + ":" +
- fact.getClass().getCanonicalName() + ":" +
- droolsControllers + " IN " + this);
+ if (droolsControllers.isEmpty())
throw new IllegalArgumentException("Invalid Topic: " + topic);
- }
if (droolsControllers.size() > 1) {
- logger.warn("MULTIPLE DROOLS CONTROLLERS FOUND for: " + topic + ":" +
- fact.getClass().getCanonicalName() + ":" +
- droolsControllers + " IN " + this);
+ logger.warn("{}: multiple drools-controller {} for {}:{} ", this,
+ droolsControllers, topic, fact.getClass().getCanonicalName());
// continue
}
return droolsControllers.get(0);
@@ -1414,20 +1342,17 @@ abstract class GenericEventProtocolCoder {
List<DroolsController> getDroolsControllers(String topic, Object fact)
throws IllegalArgumentException {
- if (topic == null || topic.isEmpty()) {
+ if (topic == null || topic.isEmpty())
throw new IllegalArgumentException("Unsupported");
- }
- if (fact == null) {
+ if (fact == null)
throw new IllegalArgumentException("class must be provided");
- }
List<DroolsController> droolsControllers = droolsCreators(topic, fact);
if (droolsControllers.size() > 1) {
// unexpected
- logger.warn("MULTIPLE DROOLS CONTROLLERS FOUND for: " + topic + ":" +
- fact.getClass().getCanonicalName() + ":" +
- droolsControllers + " IN " + this);
+ logger.warn("{}: multiple drools-controller {} for {}:{} ", this,
+ droolsControllers, topic, fact.getClass().getCanonicalName());
// continue
}
return droolsControllers;
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/protocol/coders/JsonProtocolFilter.java b/policy-management/src/main/java/org/openecomp/policy/drools/protocol/coders/JsonProtocolFilter.java
index a2ce3123..d6146a30 100644
--- a/policy-management/src/main/java/org/openecomp/policy/drools/protocol/coders/JsonProtocolFilter.java
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/protocol/coders/JsonProtocolFilter.java
@@ -24,6 +24,8 @@ import java.util.ArrayList;
import java.util.List;
import org.openecomp.policy.drools.utils.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
@@ -36,6 +38,11 @@ import com.google.gson.JsonParser;
public class JsonProtocolFilter {
/**
+ * Logger
+ */
+ private static Logger logger = LoggerFactory.getLogger(JsonProtocolFilter.class);
+
+ /**
* Helper class to collect Filter information
*/
public static class FilterRule {
@@ -130,7 +137,6 @@ public class JsonProtocolFilter {
List<FilterRule> filters = new ArrayList<FilterRule>();
for (Pair<String, String> filterPair: rawFilters) {
if (filterPair.first() == null || filterPair.first().isEmpty()) {
- // TODO: warn
continue;
}
@@ -211,8 +217,6 @@ public class JsonProtocolFilter {
}
return true;
} catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
throw new IllegalArgumentException(e);
}
}
@@ -244,8 +248,8 @@ public class JsonProtocolFilter {
} catch (IllegalArgumentException ile) {
throw ile;
} catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ logger.info("{}: cannot accept {} because of {}",
+ this, json, e.getMessage(), e);
throw new IllegalArgumentException(e);
}
}
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/protocol/coders/ProtocolCoderToolset.java b/policy-management/src/main/java/org/openecomp/policy/drools/protocol/coders/ProtocolCoderToolset.java
index 2d24d7a6..fb3f95d3 100644
--- a/policy-management/src/main/java/org/openecomp/policy/drools/protocol/coders/ProtocolCoderToolset.java
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/protocol/coders/ProtocolCoderToolset.java
@@ -21,7 +21,6 @@
package org.openecomp.policy.drools.protocol.coders;
import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.time.Instant;
@@ -31,14 +30,13 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import org.openecomp.policy.common.logging.eelf.MessageCodes;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.drools.controller.DroolsController;
import org.openecomp.policy.drools.protocol.coders.EventProtocolCoder.CoderFilters;
import org.openecomp.policy.drools.protocol.coders.TopicCoderFilterConfiguration.CustomCoder;
import org.openecomp.policy.drools.protocol.coders.TopicCoderFilterConfiguration.CustomGsonCoder;
import org.openecomp.policy.drools.protocol.coders.TopicCoderFilterConfiguration.CustomJacksonCoder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -62,6 +60,11 @@ import com.google.gson.JsonSerializer;
public abstract class ProtocolCoderToolset {
/**
+ * Logger
+ */
+ private static Logger logger = LoggerFactory.getLogger(ProtocolCoderToolset.class);
+
+ /**
* topic
*/
protected final String topic;
@@ -274,8 +277,6 @@ public abstract class ProtocolCoderToolset {
try {
event = this.filteringParser.parse(json);
} catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
throw new UnsupportedOperationException(e);
}
@@ -286,8 +287,9 @@ public abstract class ProtocolCoderToolset {
return decoder;
}
} catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
+ logger.info("{}: unexpected failure accepting {} because of {}",
+ this, event, e.getMessage(), e);
+ // continue
}
}
@@ -331,7 +333,7 @@ public abstract class ProtocolCoderToolset {
* Tools used for encoding/decoding using Jackson
*/
class JacksonProtocolCoderToolset extends ProtocolCoderToolset {
- private static Logger logger = FlexLogger.getLogger(JacksonProtocolCoderToolset.class);
+ private static Logger logger = LoggerFactory.getLogger(JacksonProtocolCoderToolset.class);
/**
* decoder
*/
@@ -396,16 +398,14 @@ class JacksonProtocolCoderToolset extends ProtocolCoderToolset {
DroolsController droolsController =
DroolsController.factory.get(groupId, artifactId, "");
if (droolsController == null) {
- String error = "NO-DROOLS-CONTROLLER for: " + json + " IN " + this;
- logger.warn(error);
- throw new IllegalStateException(error);
+ logger.warn("{}: no drools-controller to process {}", this, json);
+ throw new IllegalStateException("no drools-controller to process event");
}
CoderFilters decoderFilter = filter(json);
if (decoderFilter == null) {
- String error = "NO-DECODER for: " + json + " IN " + this;
- logger.warn(error);
- throw new UnsupportedOperationException(error);
+ logger.debug("{}: no decoder to process {}", this, json);
+ throw new UnsupportedOperationException("no decoder to process event");
}
Class<?> decoderClass;
@@ -413,14 +413,13 @@ class JacksonProtocolCoderToolset extends ProtocolCoderToolset {
decoderClass =
droolsController.fetchModelClass(decoderFilter.getCodedClass());
if (decoderClass == null) {
- String error = "DECODE-ERROR FETCHING MODEL CLASS: " + ":" + json + ":" + this;
- logger.error(error);
- throw new IllegalStateException(error);
+ logger.warn("{}: cannot fetch application class {}", this, decoderFilter.getCodedClass());
+ throw new IllegalStateException("cannot fetch application class " + decoderFilter.getCodedClass());
}
} catch (Exception e) {
- String error = "DECODE-ERROR FETCHING MODEL CLASS: "+ e.getMessage() + ":" + json + ":" + this;
- logger.warn(MessageCodes.EXCEPTION_ERROR, e, error);
- throw new UnsupportedOperationException(error, e);
+ logger.warn("{}: cannot fetch application class {} because of {}", this,
+ decoderFilter.getCodedClass(), e.getMessage());
+ throw new UnsupportedOperationException("cannot fetch application class " + decoderFilter.getCodedClass(), e);
}
@@ -428,9 +427,9 @@ class JacksonProtocolCoderToolset extends ProtocolCoderToolset {
Object fact = this.decoder.readValue(json, decoderClass);
return fact;
} catch (Exception e) {
- String error = "DECODE-ERROR FROM PDP-D FRAMEWORK: "+ json + ":" + e.getMessage() + ":" + this;
- logger.error(MessageCodes.EXCEPTION_ERROR, e, error);
- throw new UnsupportedOperationException(error, e);
+ logger.warn("{} cannot decode {} into {} because of {}",
+ this, json, decoderClass.getName(), e.getMessage(), e);
+ throw new UnsupportedOperationException("cannont decode into " + decoderFilter.getCodedClass(), e);
}
}
@@ -452,9 +451,8 @@ class JacksonProtocolCoderToolset extends ProtocolCoderToolset {
String encodedEvent = this.encoder.writeValueAsString(event);
return encodedEvent;
} catch (JsonProcessingException e) {
- String error = "ENCODE-ERROR: "+ event + " IN " + this;
- logger.error(MessageCodes.EXCEPTION_ERROR, e, error);
- throw new UnsupportedOperationException(error, e);
+ logger.error("{} cannot encode {} because of {}", this, event, e.getMessage(), e);
+ throw new UnsupportedOperationException("event cannot be encoded");
}
}
@@ -472,7 +470,11 @@ class JacksonProtocolCoderToolset extends ProtocolCoderToolset {
*/
class GsonProtocolCoderToolset extends ProtocolCoderToolset {
- private static Logger logger = FlexLogger.getLogger(GsonProtocolCoderToolset.class);
+ /**
+ * Logger
+ */
+ private static Logger logger = LoggerFactory.getLogger(GsonProtocolCoderToolset.class);
+
/**
* Formatter for JSON encoding/decoding
*/
@@ -493,7 +495,8 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
try {
return ZonedDateTime.parse(element.getAsString(), format);
} catch (Exception e) {
- System.err.println(e);
+ logger.info("GsonUTCAdapter: cannot parse {} because of {}",
+ element, e.getMessage(), e);
}
return null;
}
@@ -577,16 +580,14 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
DroolsController droolsController =
DroolsController.factory.get(groupId, artifactId, "");
if (droolsController == null) {
- String error = "NO-DROOLS-CONTROLLER for: " + json + " IN " + this;
- logger.warn(error);
- throw new IllegalStateException(error);
+ logger.warn("{}: no drools-controller to process {}", this, json);
+ throw new IllegalStateException("no drools-controller to process event");
}
CoderFilters decoderFilter = filter(json);
if (decoderFilter == null) {
- String error = "NO-DECODER for: " + json + " IN " + this;
- logger.warn(error);
- throw new UnsupportedOperationException(error);
+ logger.debug("{}: no decoder to process {}", this, json);
+ throw new UnsupportedOperationException("no decoder to process event");
}
Class<?> decoderClass;
@@ -594,14 +595,13 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
decoderClass =
droolsController.fetchModelClass(decoderFilter.getCodedClass());
if (decoderClass == null) {
- String error = "DECODE-ERROR FETCHING MODEL CLASS: " + ":" + json + ":" + this;
- logger.error(error);
- throw new IllegalStateException(error);
+ logger.warn("{}: cannot fetch application class {}", this, decoderFilter.getCodedClass());
+ throw new IllegalStateException("cannot fetch application class " + decoderFilter.getCodedClass());
}
} catch (Exception e) {
- String error = "DECODE-ERROR FETCHING MODEL CLASS: "+ e.getMessage() + ":" + json + ":" + this;
- logger.warn(MessageCodes.EXCEPTION_ERROR, e, error);
- throw new UnsupportedOperationException(error, e);
+ logger.warn("{}: cannot fetch application class {} because of {}", this,
+ decoderFilter.getCodedClass(), e.getMessage());
+ throw new UnsupportedOperationException("cannot fetch application class " + decoderFilter.getCodedClass(), e);
}
if (this.customCoder != null) {
@@ -615,20 +615,19 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
("fromJson", new Class[]{String.class, Class.class});
Object fact = fromJsonMethod.invoke(gsonObject, json, decoderClass);
return fact;
- } catch (NoSuchFieldException | SecurityException | IllegalAccessException |
- NoSuchMethodException | InvocationTargetException e) {
- String error = "DECODE-ERROR-FROM-CUSTOM-CODER: " + e.getMessage() + ":" + json + ":" + this;
- logger.error(MessageCodes.EXCEPTION_ERROR, e, error);
- throw new UnsupportedOperationException(error, e);
+ } catch (Exception e) {
+ logger.warn("{}: cannot fetch application class {} because of {}", this,
+ decoderFilter.getCodedClass(), e.getMessage());
+ throw new UnsupportedOperationException("cannot fetch application class " + decoderFilter.getCodedClass(), e);
}
} else {
try {
Object fact = this.decoder.fromJson(json, decoderClass);
return fact;
} catch (Exception e) {
- String error = "DECODE-ERROR FROM PDP-D FRAMEWORK: "+ json + ":" + e.getMessage() + ":" + this;
- logger.error(MessageCodes.EXCEPTION_ERROR, e, error);
- throw new UnsupportedOperationException(error, e);
+ logger.warn("{} cannot decode {} into {} because of {}",
+ this, json, decoderClass.getName(), e.getMessage(), e);
+ throw new UnsupportedOperationException("cannont decode into " + decoderFilter.getCodedClass(), e);
}
}
}
@@ -645,9 +644,11 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
DroolsController droolsController =
DroolsController.factory.get(groupId, artifactId, "");
if (droolsController == null) {
- String error = "NO-DROOLS-CONTROLLER for: " + event + " IN " + this;
- logger.warn(error);
- throw new IllegalStateException(error);
+ logger.info("{}: no drools-controller to process {} (continue)", this, event);
+ if (this.customCoder != null) {
+ logger.warn("{}: no drools-controller to process {}", this, event);
+ throw new IllegalStateException("custom-coder but no drools-controller");
+ }
}
if (this.customCoder != null) {
@@ -661,20 +662,17 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
("toJson", new Class[]{Object.class});
String encodedJson = (String) toJsonMethod.invoke(gsonObject, event);
return encodedJson;
- } catch (NoSuchFieldException | SecurityException | IllegalAccessException |
- NoSuchMethodException | InvocationTargetException e) {
- String error = "DECODE-ERROR-FROM-CUSTOM-CODER: " + e.getMessage() + ":" + event + ":" + this;
- logger.error(MessageCodes.EXCEPTION_ERROR, e, error);
- throw new UnsupportedOperationException(error, e);
+ } catch (Exception e) {
+ logger.warn("{} cannot custom-encode {} because of {}", this, event, e.getMessage(), e);
+ throw new UnsupportedOperationException("event cannot be encoded", e);
}
} else {
try {
String encodedEvent = this.encoder.toJson(event);
return encodedEvent;
} catch (Exception e) {
- String error = "ENCODE-ERROR: "+ event + " IN " + this;
- logger.error(MessageCodes.EXCEPTION_ERROR, e, error);
- throw new UnsupportedOperationException(error, e);
+ logger.warn("{} cannot encode {} because of {}", this, event, e.getMessage(), e);
+ throw new UnsupportedOperationException("event cannot be encoded", e);
}
}
}
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/server/restful/RestManager.java b/policy-management/src/main/java/org/openecomp/policy/drools/server/restful/RestManager.java
index de666165..be6c4962 100644
--- a/policy-management/src/main/java/org/openecomp/policy/drools/server/restful/RestManager.java
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/server/restful/RestManager.java
@@ -20,6 +20,7 @@
package org.openecomp.policy.drools.server.restful;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@@ -42,9 +43,6 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
-import org.openecomp.policy.common.logging.eelf.MessageCodes;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.drools.controller.DroolsController;
import org.openecomp.policy.drools.event.comm.TopicEndpoint;
import org.openecomp.policy.drools.event.comm.TopicSink;
@@ -65,7 +63,10 @@ import org.openecomp.policy.drools.protocol.configuration.ControllerConfiguratio
import org.openecomp.policy.drools.protocol.configuration.PdpdConfiguration;
import org.openecomp.policy.drools.system.PolicyController;
import org.openecomp.policy.drools.system.PolicyEngine;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import ch.qos.logback.classic.LoggerContext;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@@ -101,7 +102,7 @@ public class RestManager {
/**
* Logger
*/
- private static Logger logger = FlexLogger.getLogger(RestManager.class);
+ private static Logger logger = LoggerFactory.getLogger(RestManager.class);
@GET
@Path("engine")
@@ -125,8 +126,7 @@ public class RestManager {
try {
PolicyEngine.manager.shutdown();
} catch (IllegalStateException e) {
- logger.warn(MessageCodes.EXCEPTION_ERROR, e,
- "shutdown: " + PolicyEngine.manager);
+ logger.error("{}: cannot shutdown {} because of {}", this, PolicyEngine.manager, e.getMessage(), e);
return Response.status(Response.Status.BAD_REQUEST).
entity(PolicyEngine.manager).
build();
@@ -211,8 +211,7 @@ public class RestManager {
success = PolicyEngine.manager.configure(configuration);
} catch (Exception e) {
success = false;
- logger.warn(MessageCodes.EXCEPTION_ERROR, e,
- "PolicyEngine", this.toString());
+ logger.info("{}: cannot configure {} because of {}", this, PolicyEngine.manager, e.getMessage(), e);
}
if (!success)
@@ -260,8 +259,7 @@ public class RestManager {
PolicyEngine.manager.activate();
} catch (Exception e) {
success = false;
- logger.warn(MessageCodes.EXCEPTION_ERROR, e,
- "PolicyEngine", this.toString());
+ logger.info("{}: cannot activate {} because of {}", this, PolicyEngine.manager, e.getMessage(), e);
}
if (!success)
@@ -285,8 +283,7 @@ public class RestManager {
PolicyEngine.manager.deactivate();
} catch (Exception e) {
success = false;
- logger.warn(MessageCodes.EXCEPTION_ERROR, e,
- "PolicyEngine", this.toString());
+ logger.info("{}: cannot deactivate {} because of {}", this, PolicyEngine.manager, e.getMessage(), e);
}
if (!success)
@@ -406,8 +403,7 @@ public class RestManager {
} catch (IllegalArgumentException e) {
// This is OK
} catch (IllegalStateException e) {
- logger.warn(MessageCodes.EXCEPTION_ERROR, e,
- controllerName, this.toString());
+ logger.info("{}: cannot get policy-controller because of {}", this, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + " not found")).build();
}
@@ -416,8 +412,7 @@ public class RestManager {
controller = PolicyEngine.manager.createPolicyController
(config.getProperty(PolicyProperties.PROPERTY_CONTROLLER_NAME), config);
} catch (IllegalArgumentException | IllegalStateException e) {
- logger.warn(MessageCodes.EXCEPTION_ERROR, e,
- controllerName, this.toString());
+ logger.warn("{}: cannot create policy-controller because of {}", this, e.getMessage(), e);
return Response.status(Response.Status.BAD_REQUEST).
entity(new Error(e.getMessage())).
build();
@@ -426,13 +421,12 @@ public class RestManager {
try {
boolean success = controller.start();
if (!success) {
- logger.warn("Can't start " + controllerName + ": " + controller.toString());
+ logger.info("{}: cannot start {}", this, controller);
return Response.status(Response.Status.PARTIAL_CONTENT).
entity(new Error(controllerName + " can't be started")).build();
}
} catch (IllegalStateException e) {
- logger.warn(MessageCodes.EXCEPTION_ERROR, e,
- controllerName, this.toString());
+ logger.info("{}: cannot start {} because of {}", this, controller, e.getMessage(), e);;
return Response.status(Response.Status.PARTIAL_CONTENT).
entity(controller).build();
}
@@ -547,14 +541,12 @@ public class RestManager {
entity(new Error(controllerName + " does not exist")).
build();
} catch (IllegalArgumentException e) {
- logger.warn(MessageCodes.EXCEPTION_ERROR, e,
- controllerName, this.toString());
+ logger.info("{}: cannot get policy-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.BAD_REQUEST).
entity(new Error(controllerName + " not found: " + e.getMessage())).
build();
} catch (IllegalStateException e) {
- logger.warn(MessageCodes.EXCEPTION_ERROR, e,
- controllerName, this.toString());
+ logger.info("{}: cannot get policy-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + " not acceptable")).build();
}
@@ -562,8 +554,7 @@ public class RestManager {
try {
PolicyEngine.manager.removePolicyController(controllerName);
} catch (IllegalArgumentException | IllegalStateException e) {
- logger.warn(MessageCodes.EXCEPTION_ERROR, e,
- controllerName + controller);
+ logger.info("{}: cannot remove policy-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).
entity(new Error(e.getMessage())).
build();
@@ -647,14 +638,12 @@ public class RestManager {
entity(new Error(controllerName + " does not exist")).
build();
} catch (IllegalArgumentException e) {
- logger.warn(MessageCodes.EXCEPTION_ERROR, e,
- controllerName, this.toString());
+ logger.info("{}: cannot update policy-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.BAD_REQUEST).
entity(new Error(controllerName + " not found: " + e.getMessage())).
build();
} catch (Exception e) {
- logger.warn(MessageCodes.EXCEPTION_ERROR, e,
- controllerName, this.toString());
+ logger.info("{}: cannot update policy-controller {} because of {}", this, controllerName, e.getMessage(), e);
return Response.status(Response.Status.NOT_ACCEPTABLE).
entity(new Error(controllerName + " not acceptable")).build();
}
@@ -2182,6 +2171,91 @@ public class RestManager {
build();
}
+ @GET
+ @Path("engine/tools/loggers")
+ @ApiOperation(
+ value="all active loggers",
+ responseContainer="List"
+ )
+ @ApiResponses(value = {
+ @ApiResponse(code=500, message="logging misconfiguration")
+ })
+ public Response loggers() {
+ List<String> names = new ArrayList<String>();
+ if (!(LoggerFactory.getILoggerFactory() instanceof LoggerContext)) {
+ logger.warn("The SLF4J logger factory is not configured for logback");
+ return Response.status(Status.INTERNAL_SERVER_ERROR).
+ entity(names).build();
+ }
+
+ LoggerContext context =
+ (LoggerContext) LoggerFactory.getILoggerFactory();
+ for (Logger logger: context.getLoggerList()) {
+ names.add(logger.getName());
+ }
+
+ return Response.status(Status.OK).
+ entity(names).
+ build();
+ }
+
+ @GET
+ @Path("engine/tools/loggers/{logger}")
+ @ApiOperation(
+ value="logging level of a logger"
+ )
+ @ApiResponses(value = {
+ @ApiResponse(code=500, message="logging misconfiguration"),
+ @ApiResponse(code=404, message="logger not found")
+ })
+ public Response loggerName(@ApiParam(value="Logger Name", required=true)
+ @PathParam("logger") String loggerName) {
+ if (!(LoggerFactory.getILoggerFactory() instanceof LoggerContext)) {
+ logger.warn("The SLF4J logger factory is not configured for logback");
+ return Response.status(Status.INTERNAL_SERVER_ERROR).build();
+ }
+
+ LoggerContext context =
+ (LoggerContext) LoggerFactory.getILoggerFactory();
+ ch.qos.logback.classic.Logger logger = context.getLogger(loggerName);
+ if (logger == null) {
+ return Response.status(Status.NOT_FOUND).build();
+ }
+
+ String loggerLevel = (logger.getLevel() != null) ? logger.getLevel().toString() : "";
+ return Response.status(Status.OK).entity(loggerLevel).build();
+ }
+
+ @PUT
+ @Path("engine/tools/loggers/{logger}/{level}")
+ @ApiOperation(
+ value="sets the logger level",
+ notes="Please use the SLF4J logger levels"
+ )
+ @ApiResponses(value = {
+ @ApiResponse(code=500, message="logging misconfiguration"),
+ @ApiResponse(code=404, message="logger not found")
+ })
+ public Response loggerName(@ApiParam(value="Logger Name", required=true)
+ @PathParam("logger") String loggerName,
+ @ApiParam(value="Logger Level", required=true)
+ @PathParam("level") String loggerLevel) {
+ if (!(LoggerFactory.getILoggerFactory() instanceof LoggerContext)) {
+ logger.warn("The SLF4J logger factory is not configured for logback");
+ return Response.status(Status.INTERNAL_SERVER_ERROR).build();
+ }
+
+ LoggerContext context =
+ (LoggerContext) LoggerFactory.getILoggerFactory();
+ ch.qos.logback.classic.Logger logger = context.getLogger(loggerName);
+ if (logger == null) {
+ return Response.status(Status.NOT_FOUND).build();
+ }
+
+ logger.setLevel(ch.qos.logback.classic.Level.toLevel(loggerLevel));
+ return Response.status(Status.OK).entity(logger.getLevel().toString()).build();
+ }
+
/**
* gets the underlying drools controller from the named policy controller
* @param controllerName the policy controller name
@@ -2204,6 +2278,13 @@ public class RestManager {
* Helper classes for aggregation of results
*/
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("rest-telemetry-api []");
+ return builder.toString();
+ }
+
/**
* Coding/Encoding Results Aggregation Helper class
*/
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/system/Main.java b/policy-management/src/main/java/org/openecomp/policy/drools/system/Main.java
index 108600b2..3b12514c 100644
--- a/policy-management/src/main/java/org/openecomp/policy/drools/system/Main.java
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/system/Main.java
@@ -25,8 +25,8 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Properties;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.openecomp.policy.drools.core.PolicyContainer;
import org.openecomp.policy.drools.persistence.SystemPersistence;
import org.openecomp.policy.drools.utils.PropertyUtil;
@@ -35,14 +35,58 @@ import org.openecomp.policy.drools.utils.PropertyUtil;
* Programmatic entry point to the management layer
*/
public class Main {
+
+ /**
+ * logback configuration file system property
+ */
+ public static final String LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY = "logback.configurationFile";
+
+ /**
+ * logback configuration file system property
+ */
+ public static final String LOGBACK_CONFIGURATION_FILE_DEFAULT = "config/logback.xml";
+
+ /**
+ * EELF logback configuration path system property
+ */
+ public static final String EELF_LOGBACK_PATH_SYSTEM_PROPERTY = "com.att.eelf.logging.file";
+
+ /**
+ * EELF logback configuration path value
+ */
+ public static final String EELF_LOGBACK_PATH_DEFAULT = "config";
/**
- * logger
+ * EELF logback configuration file system property
*/
- private static Logger logger = FlexLogger.getLogger(Main.class, true);
+ public static final String EELF_LOGBACK_FILE_SYSTEM_PROPERTY = "com.att.eelf.logging.path";
+ /**
+ * EELF logback configuration file default value
+ */
+ public static final String EELF_LOGBACK_FILE_DEFAULT = "logback.xml";
+
+
+ /**
+ * main
+ *
+ * @param args program arguments
+ */
public static void main(String args[]) {
+ /* logging defaults */
+
+ if (System.getProperty(LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY) == null)
+ System.setProperty(LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY, LOGBACK_CONFIGURATION_FILE_DEFAULT);
+
+ if (System.getProperty(EELF_LOGBACK_PATH_SYSTEM_PROPERTY) == null)
+ System.setProperty(EELF_LOGBACK_PATH_SYSTEM_PROPERTY, EELF_LOGBACK_PATH_DEFAULT);
+
+ if (System.getProperty(EELF_LOGBACK_FILE_SYSTEM_PROPERTY) == null)
+ System.setProperty(EELF_LOGBACK_FILE_SYSTEM_PROPERTY, EELF_LOGBACK_FILE_DEFAULT);
+
+ Logger logger = LoggerFactory.getLogger(Main.class);
+
File configDir = new File(SystemPersistence.CONFIG_DIR_NAME);
if (!configDir.isDirectory()) {
@@ -57,9 +101,7 @@ public class Main {
try {
PolicyContainer.globalInit(args);
} catch (Exception e) {
- System.out.println("policy-core startup failed");
- logger.warn("policy-core startup failed");
- e.printStackTrace();
+ logger.warn("Main: cannot init policy-container because of {}", e.getMessage(), e);
}
/* 1. Configure the Engine */
@@ -69,9 +111,7 @@ public class Main {
Properties properties = PropertyUtil.getProperties(policyEnginePath.toFile());
PolicyEngine.manager.configure(properties);
} catch (Exception e) {
- String msg = "Policy Engine cannot be configured with properties: " + e.getMessage() + " : " + PolicyEngine.manager;
- System.out.println(msg);
- logger.warn(msg);
+ logger.warn("Main: cannot initialize {} because of {}", PolicyEngine.manager, e.getMessage(), e);
}
/* 2. Start the Engine with the basic services only (no Policy Controllers) */
@@ -79,17 +119,12 @@ public class Main {
try {
boolean success = PolicyEngine.manager.start();
if (!success) {
- System.out.println("Policy Engine found some problems starting some components: " + PolicyEngine.manager);
- logger.warn("Policy Engine is in an invalid state: " + PolicyEngine.manager);
+ logger.warn("Main: {} has been partially started", PolicyEngine.manager);
}
} catch (IllegalStateException e) {
- String msg = "Policy Engine is starting in an unexpected state: " + e.getMessage() + " : " + PolicyEngine.manager;
- System.out.println(msg);
- logger.warn(msg);
+ logger.warn("Main: cannot start {} (bad state) because of {}", PolicyEngine.manager, e.getMessage(), e);
} catch (Exception e) {
- String msg = "Unexpected Situation. Policy Engine cannot be started: " + e.getMessage() + " : " + PolicyEngine.manager;
- System.out.println(msg);
- e.printStackTrace();
+ logger.warn("Main: cannot start {} because of {}", PolicyEngine.manager, e.getMessage(), e);
System.exit(1);
}
@@ -117,13 +152,10 @@ public class Main {
PolicyController controller = PolicyEngine.manager.createPolicyController(name, properties);
controller.start();
} catch (Exception e) {
- System.out.println("can't instantiate Policy Controller based on properties file: " +
- config + " with message " + e.getMessage());
- e.printStackTrace();
- } catch (LinkageError le) {
- System.out.println("can't instantiate Policy Controller based on properties file: " +
- config + ". A Linkage Error has been encountered: " + le.getMessage());
- le.printStackTrace();
+ logger.error("Main: cannot instantiate policy-controller {} because of {}", name, e.getMessage(), e);
+ } catch (LinkageError e) {
+ logger.warn("Main: cannot instantiate policy-controller {} (linkage) because of {}",
+ name, e.getMessage(), e);
}
}
}
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyControllerFactory.java b/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyControllerFactory.java
index c6020ea6..12a8acdc 100644
--- a/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyControllerFactory.java
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyControllerFactory.java
@@ -25,8 +25,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Properties;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.openecomp.policy.drools.controller.DroolsController;
import org.openecomp.policy.drools.features.PolicyControllerFeatureAPI;
import org.openecomp.policy.drools.protocol.configuration.DroolsConfiguration;
@@ -184,7 +184,7 @@ public interface PolicyControllerFactory {
*/
class IndexedPolicyControllerFactory implements PolicyControllerFactory {
// get an instance of logger
- private static Logger logger = FlexLogger.getLogger(PolicyControllerFactory.class);
+ private static Logger logger = LoggerFactory.getLogger(PolicyControllerFactory.class);
/**
* Policy Controller Name Index
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyEngine.java b/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyEngine.java
index f18aa78e..974a7260 100644
--- a/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyEngine.java
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyEngine.java
@@ -24,9 +24,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
-import org.openecomp.policy.common.logging.eelf.MessageCodes;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.openecomp.policy.drools.controller.DroolsController;
import org.openecomp.policy.drools.core.jmx.PdpJmxListener;
import org.openecomp.policy.drools.event.comm.Topic;
@@ -319,7 +318,7 @@ class PolicyEngineManager implements PolicyEngine {
/**
* logger
*/
- private static Logger logger = FlexLogger.getLogger(PolicyEngineManager.class);
+ private static Logger logger = LoggerFactory.getLogger(PolicyEngineManager.class);
/**
* Is the Policy Engine running?
@@ -373,8 +372,8 @@ class PolicyEngineManager implements PolicyEngine {
if (feature.beforeConfigure(this, properties))
return;
} catch (Exception e) {
- System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
- e.printStackTrace();
+ logger.error("{}: feature {} before-configure failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -386,19 +385,19 @@ class PolicyEngineManager implements PolicyEngine {
source.register(this);
}
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyEngine", "configure");
+ logger.error("{}: add-sources failed", this, e);
}
try {
this.sinks = TopicEndpoint.manager.addTopicSinks(properties);
} catch (IllegalArgumentException e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyEngine", "configure");
+ logger.error("{}: add-sinks failed", this, e);
}
try {
this.httpServers = HttpServletServer.factory.build(properties);
} catch (IllegalArgumentException e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyEngine", "configure");
+ logger.error("{}: add-http-servers failed", this, e);
}
/* policy-engine dispatch post configure hook */
@@ -407,8 +406,8 @@ class PolicyEngineManager implements PolicyEngine {
if (feature.afterConfigure(this))
return;
} catch (Exception e) {
- System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
- e.printStackTrace();
+ logger.error("{}: feature {} after-configure failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -442,8 +441,8 @@ class PolicyEngineManager implements PolicyEngine {
if (controller != null)
return controller;
} catch (Exception e) {
- System.out.println("ERROR: Feature API: " + controllerFeature.getClass().getName() + e.getMessage());
- e.printStackTrace();
+ logger.error("{}: feature {} before-controller-create failure because of {}",
+ this, controllerFeature.getClass().getName(), e.getMessage(), e);
}
}
@@ -457,8 +456,8 @@ class PolicyEngineManager implements PolicyEngine {
if (controllerFeature.afterCreate(controller))
return controller;
} catch (Exception e) {
- System.out.println("ERROR: Feature API: " + controllerFeature.getClass().getName() + e.getMessage());
- e.printStackTrace();
+ logger.error("{}: feature {} after-controller-create failure because of {}",
+ this, controllerFeature.getClass().getName(), e.getMessage(), e);
}
}
@@ -519,7 +518,7 @@ class PolicyEngineManager implements PolicyEngine {
PolicyController policyController = this.updatePolicyController(configController);
policyControllers.add(policyController);
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyEngine", "updatePolicyControllers");
+ logger.error("{}: cannot update-policy-controllers because of {}", this, e.getMessage(), e);
}
}
@@ -620,10 +619,10 @@ class PolicyEngineManager implements PolicyEngine {
return policyController;
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyEngine", "updatePolicyController " + e.getMessage());
+ logger.error("{}: cannot update-policy-controller because of {}", this, e.getMessage(), e);
throw e;
} catch (LinkageError e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyEngine", "updatePolicyController " + e.getMessage());
+ logger.error("{}: cannot update-policy-controllers (rules) because of {}", this, e.getMessage(), e);
throw new IllegalStateException(e);
}
}
@@ -640,8 +639,8 @@ class PolicyEngineManager implements PolicyEngine {
if (feature.beforeStart(this))
return true;
} catch (Exception e) {
- System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
- e.printStackTrace();
+ logger.error("{}: feature {} before-start failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -658,7 +657,8 @@ class PolicyEngineManager implements PolicyEngine {
if (!httpServer.start())
success = false;
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, httpServer.toString(), this.toString());
+ logger.error("{}: cannot start http-server {} because of {}", this,
+ httpServer, e.getMessage(), e);
}
}
@@ -669,7 +669,8 @@ class PolicyEngineManager implements PolicyEngine {
if (!source.start())
success = false;
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, source.toString(), this.toString());
+ logger.error("{}: cannot start topic-source {} because of {}", this,
+ source, e.getMessage(), e);
}
}
@@ -680,7 +681,8 @@ class PolicyEngineManager implements PolicyEngine {
if (!sink.start())
success = false;
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, sink.toString(), this.toString());
+ logger.error("{}: cannot start topic-sink {} because of {}", this,
+ sink, e.getMessage(), e);
}
}
@@ -692,7 +694,8 @@ class PolicyEngineManager implements PolicyEngine {
if (!controller.start())
success = false;
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, controller.toString(), this.toString());
+ logger.error("{}: cannot start policy-controller {} because of {}", this,
+ controller, e.getMessage(), e);
success = false;
}
}
@@ -703,8 +706,7 @@ class PolicyEngineManager implements PolicyEngine {
if (!TopicEndpoint.manager.start())
success = false;
} catch (IllegalStateException e) {
- String msg = "Topic Endpoint Manager is in an invalid state: " + e.getMessage() + " : " + this;
- logger.warn(msg);
+ logger.warn("{}: Topic Endpoint Manager is in an invalid state because of {}", this, e.getMessage(), e);
}
@@ -718,8 +720,8 @@ class PolicyEngineManager implements PolicyEngine {
if (feature.afterStart(this))
return success;
} catch (Exception e) {
- System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
- e.printStackTrace();
+ logger.error("{}: feature {} after-start failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -738,8 +740,8 @@ class PolicyEngineManager implements PolicyEngine {
if (feature.beforeStop(this))
return true;
} catch (Exception e) {
- System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
- e.printStackTrace();
+ logger.error("{}: feature {} before-stop failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -757,7 +759,8 @@ class PolicyEngineManager implements PolicyEngine {
if (!controller.stop())
success = false;
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, controller.toString(), this.toString());
+ logger.error("{}: cannot stop policy-controller {} because of {}", this,
+ controller, e.getMessage(), e);
success = false;
}
}
@@ -768,7 +771,8 @@ class PolicyEngineManager implements PolicyEngine {
if (!source.stop())
success = false;
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, source.toString(), this.toString());
+ logger.error("{}: cannot start topic-source {} because of {}", this,
+ source, e.getMessage(), e);
}
}
@@ -778,7 +782,8 @@ class PolicyEngineManager implements PolicyEngine {
if (!sink.stop())
success = false;
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, sink.toString(), this.toString());
+ logger.error("{}: cannot start topic-sink {} because of {}", this,
+ sink, e.getMessage(), e);
}
}
@@ -792,7 +797,8 @@ class PolicyEngineManager implements PolicyEngine {
if (!httpServer.stop())
success = false;
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, httpServer.toString(), this.toString());
+ logger.error("{}: cannot start http-server {} because of {}", this,
+ httpServer, e.getMessage(), e);
}
}
@@ -802,8 +808,8 @@ class PolicyEngineManager implements PolicyEngine {
if (feature.afterStop(this))
return success;
} catch (Exception e) {
- System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
- e.printStackTrace();
+ logger.error("{}: feature {} after-stop failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -822,8 +828,8 @@ class PolicyEngineManager implements PolicyEngine {
if (feature.beforeShutdown(this))
return;
} catch (Exception e) {
- System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
- e.printStackTrace();
+ logger.error("{}: feature {} before-shutdown failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -834,7 +840,8 @@ class PolicyEngineManager implements PolicyEngine {
try {
source.shutdown();
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, source.toString(), this.toString());
+ logger.error("{}: cannot shutdown topic-source {} because of {}", this,
+ source, e.getMessage(), e);
}
}
@@ -843,7 +850,8 @@ class PolicyEngineManager implements PolicyEngine {
try {
sink.shutdown();
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, sink.toString(), this.toString());
+ logger.error("{}: cannot shutdown topic-sink {} because of {}", this,
+ sink, e.getMessage(), e);
}
}
@@ -862,8 +870,8 @@ class PolicyEngineManager implements PolicyEngine {
if (feature.afterShutdown(this))
return;
} catch (Exception e) {
- System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
- e.printStackTrace();
+ logger.error("{}: feature {} after-shutdown failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -874,7 +882,7 @@ class PolicyEngineManager implements PolicyEngine {
try {
Thread.sleep(5000L);
} catch (InterruptedException e) {
- logger.warn("InterruptedException while shutting down management server: " + this.toString());
+ logger.warn("{}: interrupted-exception while shutting down management server: ", this);
}
/* shutdown all unmanaged http servers */
@@ -882,14 +890,15 @@ class PolicyEngineManager implements PolicyEngine {
try {
httpServer.shutdown();
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, httpServer.toString(), this.toString());
+ logger.error("{}: cannot shutdown http-server {} because of {}", this,
+ httpServer, e.getMessage(), e);
}
}
try {
Thread.sleep(5000L);
} catch (InterruptedException e) {
- logger.warn("InterruptedException while shutting down management server: " + this.toString());
+ logger.warn("{}: interrupted-exception while shutting down management server: ", this);
}
System.exit(0);
@@ -917,8 +926,8 @@ class PolicyEngineManager implements PolicyEngine {
if (feature.beforeLock(this))
return true;
} catch (Exception e) {
- System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
- e.printStackTrace();
+ logger.error("{}: feature {} before-lock failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -933,7 +942,8 @@ class PolicyEngineManager implements PolicyEngine {
try {
success = controller.lock() && success;
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, controller.toString(), this.toString());
+ logger.error("{}: cannot lock policy-controller {} because of {}", this,
+ controller, e.getMessage(), e);
success = false;
}
}
@@ -946,8 +956,8 @@ class PolicyEngineManager implements PolicyEngine {
if (feature.afterLock(this))
return success;
} catch (Exception e) {
- System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
- e.printStackTrace();
+ logger.error("{}: feature {} after-lock failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -966,8 +976,8 @@ class PolicyEngineManager implements PolicyEngine {
if (feature.beforeUnlock(this))
return true;
} catch (Exception e) {
- System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
- e.printStackTrace();
+ logger.error("{}: feature {} before-unlock failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -982,7 +992,8 @@ class PolicyEngineManager implements PolicyEngine {
try {
success = controller.unlock() && success;
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, controller.toString(), this.toString());
+ logger.error("{}: cannot unlock policy-controller {} because of {}", this,
+ controller, e.getMessage(), e);
success = false;
}
}
@@ -995,8 +1006,8 @@ class PolicyEngineManager implements PolicyEngine {
if (feature.afterUnlock(this))
return success;
} catch (Exception e) {
- System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
- e.printStackTrace();
+ logger.error("{}: feature {} after-unlock failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -1133,7 +1144,8 @@ class PolicyEngineManager implements PolicyEngine {
PdpdConfiguration configuration = this.decoder.fromJson(event, PdpdConfiguration.class);
this.configure(configuration);
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, "CONFIGURATION ERROR IN PDP-D POLICY ENGINE: "+ event + ":" + e.getMessage() + ":" + this);
+ logger.error("{}: configuration-error due to {} because of {}",
+ this, event, e.getMessage(), e);
}
}
@@ -1248,8 +1260,9 @@ class PolicyEngineManager implements PolicyEngine {
if (controller != null)
return controller.deliver(busType, topic, event);
} catch (Exception e) {
- logger.warn(MessageCodes.EXCEPTION_ERROR, e,
- busType + ":" + topic + " :" + event, this.toString());
+ logger.warn("{}: cannot find policy-controller to deliver {} over {}:{} because of {}",
+ this, event, busType, topic, e.getMessage(), e);
+
/* continue (try without routing through the controller) */
}
@@ -1262,8 +1275,8 @@ class PolicyEngineManager implements PolicyEngine {
return this.deliver(busType, topic, json);
} catch (Exception e) {
- logger.warn(MessageCodes.EXCEPTION_ERROR, e,
- busType + ":" + topic + " :" + event, this.toString());
+ logger.warn("{}: cannot deliver {} over {}:{} because of {}",
+ this, event, busType, topic, e.getMessage(), e);
throw e;
}
}
@@ -1300,8 +1313,8 @@ class PolicyEngineManager implements PolicyEngine {
return sink.send(event);
} catch (Exception e) {
- logger.warn(MessageCodes.EXCEPTION_ERROR, e,
- busType + ":" + topic + " :" + event, this.toString());
+ logger.warn("{}: cannot deliver {} over {}:{} because of {}",
+ this, event, busType, topic, e.getMessage(), e);
throw e;
}
}
@@ -1318,8 +1331,8 @@ class PolicyEngineManager implements PolicyEngine {
if (feature.beforeActivate(this))
return;
} catch (Exception e) {
- System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
- e.printStackTrace();
+ logger.error("{}: feature {} before-activate failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -1329,11 +1342,11 @@ class PolicyEngineManager implements PolicyEngine {
policyController.unlock();
policyController.start();
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyEngine.activate: cannot start " +
- policyController + " because of " + e.getMessage());
+ logger.error("{}: cannot activate of policy-controller {} because of {}",
+ this, policyController,e.getMessage(), e);
} catch (LinkageError e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyEngine.activate: cannot start " +
- policyController + " because of " + e.getMessage());
+ logger.error("{}: cannot activate (rules compilation) of policy-controller {} because of {}",
+ this, policyController,e.getMessage(), e);
}
}
@@ -1345,8 +1358,8 @@ class PolicyEngineManager implements PolicyEngine {
if (feature.afterActivate(this))
return;
} catch (Exception e) {
- System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
- e.printStackTrace();
+ logger.error("{}: feature {} after-activate failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
}
@@ -1363,8 +1376,8 @@ class PolicyEngineManager implements PolicyEngine {
if (feature.beforeDeactivate(this))
return;
} catch (Exception e) {
- System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
- e.printStackTrace();
+ logger.error("{}: feature {} before-deactivate failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -1374,11 +1387,11 @@ class PolicyEngineManager implements PolicyEngine {
try {
policyController.stop();
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyEngine.deactivate: cannot stop " +
- policyController + " because of " + e.getMessage());
+ logger.error("{}: cannot deactivate (stop) policy-controller {} because of {}",
+ this, policyController, e.getMessage(), e);
} catch (LinkageError e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyEngine.deactivate: cannot start " +
- policyController + " because of " + e.getMessage());
+ logger.error("{}: cannot deactivate (stop) policy-controller {} because of {}",
+ this, policyController, e.getMessage(), e);
}
}
@@ -1388,8 +1401,8 @@ class PolicyEngineManager implements PolicyEngine {
if (feature.afterDeactivate(this))
return;
} catch (Exception e) {
- System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
- e.printStackTrace();
+ logger.error("{}: feature {} after-deactivate failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
}
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/system/internal/AggregatedPolicyController.java b/policy-management/src/main/java/org/openecomp/policy/drools/system/internal/AggregatedPolicyController.java
index 36a58512..f0491624 100644
--- a/policy-management/src/main/java/org/openecomp/policy/drools/system/internal/AggregatedPolicyController.java
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/system/internal/AggregatedPolicyController.java
@@ -24,8 +24,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Properties;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.openecomp.policy.drools.controller.DroolsController;
import org.openecomp.policy.drools.event.comm.Topic;
import org.openecomp.policy.drools.event.comm.TopicEndpoint;
@@ -50,7 +50,7 @@ public class AggregatedPolicyController implements PolicyController,
/**
* Logger
*/
- private static Logger logger = FlexLogger.getLogger(AggregatedPolicyController.class);
+ private static Logger logger = LoggerFactory.getLogger(AggregatedPolicyController.class);
/**
* identifier for this policy controller
@@ -144,10 +144,7 @@ public class AggregatedPolicyController implements PolicyController,
// Register with drools infrastructure
this.droolsController = DroolsController.factory.build(properties, sources, sinks);
} catch (Exception | LinkageError e) {
- logger.error("BUILD-INIT-DROOLS: " + e.getMessage());
- e.printStackTrace();
-
- // throw back exception as input properties cause problems
+ logger.error("{}: cannot init-drools because of {}", this, e.getMessage(), e);
throw new IllegalArgumentException(e);
}
}
@@ -177,8 +174,8 @@ public class AggregatedPolicyController implements PolicyController,
if (oldDroolsConfiguration.getGroupId().equalsIgnoreCase(newDroolsConfiguration.getGroupId()) &&
oldDroolsConfiguration.getArtifactId().equalsIgnoreCase(newDroolsConfiguration.getArtifactId()) &&
oldDroolsConfiguration.getVersion().equalsIgnoreCase(newDroolsConfiguration.getVersion())) {
- logger.warn("UPDATE-DROOLS: nothing to do: identical configuration: " + oldDroolsConfiguration +
- " <=> " + newDroolsConfiguration);
+ logger.warn("{}: cannot update-drools: identical configuration {} vs {}",
+ this, oldDroolsConfiguration, newDroolsConfiguration);
return true;
}
@@ -208,8 +205,7 @@ public class AggregatedPolicyController implements PolicyController,
this.droolsController.stop();
} catch (IllegalArgumentException e) {
- logger.warn("INIT-DROOLS: " + e.getMessage());
- e.printStackTrace();
+ logger.error("{}: cannot update-drools because of {}", this, e.getMessage(), e);
return false;
}
@@ -228,17 +224,16 @@ public class AggregatedPolicyController implements PolicyController,
* {@inheritDoc}
*/
@Override
- public boolean start() throws IllegalStateException {
-
- if (logger.isInfoEnabled())
- logger.info("START: " + this);
+ public boolean start() throws IllegalStateException {
+ logger.info("{}: start", this);
for (PolicyControllerFeatureAPI feature : PolicyControllerFeatureAPI.providers.getList()) {
try {
if (feature.beforeStart(this))
return true;
} catch (Exception e) {
- logger.warn("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage(), e);
+ logger.error("{}: feature {} before-start failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -264,8 +259,8 @@ public class AggregatedPolicyController implements PolicyController,
try {
sink.start();
} catch (Exception e) {
- logger.warn("can't start sink: " + sink + " because of " + e.getMessage());
- e.printStackTrace();
+ logger.error("{}: cannot start {} because of {}",
+ this, sink, e.getMessage(), e);
}
}
@@ -274,7 +269,8 @@ public class AggregatedPolicyController implements PolicyController,
if (feature.afterStart(this))
return true;
} catch (Exception e) {
- logger.warn("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage(), e);
+ logger.error("{}: feature {} after-start failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -286,16 +282,15 @@ public class AggregatedPolicyController implements PolicyController,
*/
@Override
public boolean stop() {
-
- if (logger.isInfoEnabled())
- logger.info("STOP: " + this);
+ logger.info("{}: stop", this);
for (PolicyControllerFeatureAPI feature : PolicyControllerFeatureAPI.providers.getList()) {
try {
if (feature.beforeStop(this))
return true;
} catch (Exception e) {
- logger.warn("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage(), e);
+ logger.error("{}: feature {} before-stop failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -321,7 +316,8 @@ public class AggregatedPolicyController implements PolicyController,
if (feature.afterStop(this))
return true;
} catch (Exception e) {
- logger.warn("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage(), e);
+ logger.error("{}: feature {} after-stop failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -333,15 +329,15 @@ public class AggregatedPolicyController implements PolicyController,
*/
@Override
public void shutdown() throws IllegalStateException {
- if (logger.isInfoEnabled())
- logger.info("SHUTDOWN: " + this);
+ logger.info("{}: shutdown", this);
for (PolicyControllerFeatureAPI feature : PolicyControllerFeatureAPI.providers.getList()) {
try {
if (feature.beforeShutdown(this))
return;
} catch (Exception e) {
- logger.warn("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage(), e);
+ logger.error("{}: feature {} before-shutdown failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -354,7 +350,8 @@ public class AggregatedPolicyController implements PolicyController,
if (feature.afterShutdown(this))
return;
} catch (Exception e) {
- logger.warn("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage(), e);
+ logger.error("{}: feature {} after-shutdown failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
}
@@ -364,15 +361,15 @@ public class AggregatedPolicyController implements PolicyController,
*/
@Override
public void halt() throws IllegalStateException {
- if (logger.isInfoEnabled())
- logger.info("HALT: " + this);
+ logger.info("{}: halt", this);
for (PolicyControllerFeatureAPI feature : PolicyControllerFeatureAPI.providers.getList()) {
try {
if (feature.beforeHalt(this))
return;
} catch (Exception e) {
- logger.warn("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage(), e);
+ logger.error("{}: feature {} before-halt failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -385,7 +382,8 @@ public class AggregatedPolicyController implements PolicyController,
if (feature.afterHalt(this))
return;
} catch (Exception e) {
- logger.warn("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage(), e);
+ logger.error("{}: feature {} after-halt failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
}
@@ -398,14 +396,15 @@ public class AggregatedPolicyController implements PolicyController,
String topic, String event) {
if (logger.isDebugEnabled())
- logger.debug("EVENT NOTIFICATION: " + commType + ":" + topic + ":" + event + " INTO " + this);
+ logger.debug("{}: event offered from {}:{}: {}", this, commType, topic, event);
for (PolicyControllerFeatureAPI feature : PolicyControllerFeatureAPI.providers.getList()) {
try {
if (feature.beforeOffer(this, commType, topic, event))
return;
} catch (Exception e) {
- logger.warn("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage(), e);
+ logger.error("{}: feature {} before-offer failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -422,7 +421,8 @@ public class AggregatedPolicyController implements PolicyController,
if (feature.afterOffer(this, commType, topic, event, success))
return;
} catch (Exception e) {
- logger.warn("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage(), e);
+ logger.error("{}: feature {} after-offer failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
}
@@ -437,14 +437,15 @@ public class AggregatedPolicyController implements PolicyController,
UnsupportedOperationException {
if (logger.isDebugEnabled())
- logger.debug("DELIVER: " + commType + ":" + topic + ":" + event + " FROM " + this);
+ logger.debug("{}: deliver event to {}:{}: {}", this, commType, topic, event);
for (PolicyControllerFeatureAPI feature : PolicyControllerFeatureAPI.providers.getList()) {
try {
if (feature.beforeDeliver(this, commType, topic, event))
return true;
} catch (Exception e) {
- logger.warn("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage(), e);
+ logger.error("{}: feature {} before-deliver failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -461,9 +462,9 @@ public class AggregatedPolicyController implements PolicyController,
throw new IllegalStateException("Policy Engine is locked");
if (!this.topic2Sinks.containsKey(topic)) {
- logger.error("UNDELIVERED: " + commType + ":" + topic + ":" + event + " FROM " + this);
- throw new IllegalArgumentException
- ("Unsuported topic " + topic + " for delivery");
+ logger.warn("{}: cannot deliver event because the sink {}:{} is not registered: {}",
+ this, commType, topic, event);
+ throw new IllegalArgumentException("Unsuported topic " + topic + " for delivery");
}
boolean success = this.droolsController.deliver(this.topic2Sinks.get(topic), event);
@@ -473,7 +474,8 @@ public class AggregatedPolicyController implements PolicyController,
if (feature.afterDeliver(this, commType, topic, event, success))
return success;
} catch (Exception e) {
- logger.warn("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage(), e);
+ logger.error("{}: feature {} after-deliver failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -493,15 +495,15 @@ public class AggregatedPolicyController implements PolicyController,
*/
@Override
public boolean lock() {
- if (logger.isInfoEnabled())
- logger.info("LOCK: " + this);
+ logger.info("{}: lock", this);
for (PolicyControllerFeatureAPI feature : PolicyControllerFeatureAPI.providers.getList()) {
try {
if (feature.beforeLock(this))
return true;
} catch (Exception e) {
- logger.warn("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage(), e);
+ logger.error("{}: feature {} before-lock failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -522,7 +524,8 @@ public class AggregatedPolicyController implements PolicyController,
if (feature.afterLock(this))
return true;
} catch (Exception e) {
- logger.warn("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage(), e);
+ logger.error("{}: feature {} after-lock failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -535,15 +538,15 @@ public class AggregatedPolicyController implements PolicyController,
@Override
public boolean unlock() {
- if (logger.isInfoEnabled())
- logger.info("UNLOCK: " + this);
+ logger.info("{}: unlock", this);
for (PolicyControllerFeatureAPI feature : PolicyControllerFeatureAPI.providers.getList()) {
try {
if (feature.beforeUnlock(this))
return true;
} catch (Exception e) {
- logger.warn("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage(), e);
+ logger.error("{}: feature {} before-unlock failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
@@ -561,7 +564,8 @@ public class AggregatedPolicyController implements PolicyController,
if (feature.afterUnlock(this))
return true;
} catch (Exception e) {
- logger.warn("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage(), e);
+ logger.error("{}: feature {} after-unlock failure because of {}",
+ this, feature.getClass().getName(), e.getMessage(), e);
}
}
diff --git a/policy-endpoints/src/main/resources/schema/pdpd-configuration.jsonschema b/policy-management/src/main/resources/schemas/pdpd-configuration.jsonschema
index 34ee199a..34ee199a 100644
--- a/policy-endpoints/src/main/resources/schema/pdpd-configuration.jsonschema
+++ b/policy-management/src/main/resources/schemas/pdpd-configuration.jsonschema
diff --git a/policy-management/src/main/server/config/controller.properties.README b/policy-management/src/main/server/config/controller.properties.README
deleted file mode 100644
index e5a049c1..00000000
--- a/policy-management/src/main/server/config/controller.properties.README
+++ /dev/null
@@ -1,172 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# ONAP POLICY
-# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. 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.
-# ============LICENSE_END=========================================================
-###
-#
-# *-controller.properties configuration
-#
-#
-# The <controller-name>-controller.properties file define the
-# configuration aspects of a give controller at initialization time.
-#
-# It contains 3 major sections:
-#
-# 1. CONTROLLER
-# 2. DMAAP
-# 4. UEB
-# 5. DROOLS
-#
-# 1. CONTROLLER
-#
-# controller.name: controller unique name identifier.
-#
-# 2. DMAAP:
-# 2.1. DMAAP Sources Information
-# 2.1.1. Topics that this controller supports over DMAAP.
-# 2.1.1. DMAAP Network Information for each topic.
-# 2.1.2. Decoders information for each topic to map network input to
-# an object that will be injected into its appropriate drools
-# sessions.
-# 2.1.3. Filtering information for each decoder, to filter out from
-# drools, messages that should not be processed.
-# 2.2. DMAAP Sinks Information
-# 2.2.1. Topics that this controller supports over DMAAP.
-# 2.2.2. DMAAP Network Information for each topic.
-# 2.2.3. Encoders information for each topic to map a model object
-# to serialize network output that will be send over the
-# appropriate DMAAP topic according to its network information.
-#
-# 2.1 DMAAP Sources
-#
-# dmaap.source.topics: comma separated list of DMAAP topics source of events.
-# dmaap.source.topics.<aTopic>.servers: comma separated list of DMAAP servers to poll for events.
-# [optional] dmaap.source.topics.<aTopic>.apiKey=<APIKEY> : api key
-# [optional] dmaap.source.topics.<aTopic>.apiSecret=<APISECRET> : api secret
-# [optional] dmaap.source.topics.<aTopic>.consumerGroup=<CONSUMER-GROUP> : consumer group
-# [optional] dmaap.source.topics.<aTopic>.consumerInstance=<CONSUMER-INSTANCE> : consumer instance
-# dmaap.source.topics.<aTopic>.events: comma separated list of classes to which an event can be mapped to,
-# where <aTopic> must be declared in dmaap.source.topics
-# [optional] dmaap.source.topics.<aTopic>.events.<eventClass>.filter: comma separated list of conditions in the form of
-# pairs of "<field-name>=<field-value-regex>" values, where <field-name> identifies a field of the event, and
-# <field-value-regex> is a regular expression that that field's value in the event must match
-# against each particular instantiation of the event for this controller. Note that multiple
-# "<field-name>=<field-value-regex>" are evaluated for acceptance by AND'ing each condition.
-# Further, <aTopic> must be declared in dmaap.source.topics, and
-# <eventClass> in dmaap.source.topics.<aTopic>.events.
-# [optional] dmaap.source.topics.<aTopic>.events.custom.gson: comma separated pair, where the first item
-# is a class in the model that contains a gson parser, and the second is the actual gson parser in
-# the class. This setting overrides the PDP-D generic framework parsers with an specific model
-# provided one
-# [optional] dmaap.source.topics.<aTopic>.events.custom.jackson: comma separated pair, where the first item
-# is a class in the model that contains a jackson parser, and the second is the actual jackson parser in
-# the class. This setting overrides the PDP-D generic framework parsers with an specific model
-# provided one
-#
-# 2.2 DMAAP Sinks
-#
-# dmaap.sink.topics: comma separated list of DMAAP topics destination of locally produced events.
-# dmaap.sink.topics.<aTopic>.servers: comma separated list of DMAAP servers to send events.
-# [optional] dmaap.sink.topics.<aTopic>.apiKey=<API-KEY> : api key
-# [optional] dmaap.sink.topics.<aTopic>.apiSecret=<API-SECRET> : api secret
-# [optional] dmaap.sink.topics.<aTopic>.partitionKey=<PARTITIONKEY> : partition key
-# dmaap.sink.topics.<aTopic>.events: comma separated list of classes to which an event can be mapped to,
-# where <aTopic> must be declared in dmaap.sink.topics
-# [optional] dmaap.sink.topics.<aTopic>.events.custom.gson: comma separated pair, where the first item
-# is a class in the model that contains a gson parser, and the second is the actual gson parser in
-# the class. This setting overrides the PDP-D generic framework parsers with an specific model
-# provided one
-# [optional] dmaap.sink.topics.<aTopic>.events.custom.jackson: comma separated pair, where the first item
-# is a class in the model that contains a jackson parser, and the second is the actual jackson parser in
-# the class. This setting overrides the PDP-D generic framework parsers with an specific model
-# provided one
-#
-# 2. UEB:
-# 2.1. UEB Sources Information
-# 2.1.1. Topics that this controller supports over UEB.
-# 2.1.1. UEB Network Information for each topic.
-# 2.1.2. Decoders information for each topic to map network input to
-# an object that will be injected into its appropriate drools
-# sessions.
-# 2.1.3. Filtering information for each decoder, to filter out from
-# drools, messages that should not be processed.
-# 2.2. UEB Sinks Information
-# 2.2.1. Topics that this controller supports over UEB.
-# 2.2.2. UEB Network Information for each topic.
-# 2.2.3. Encoders information for each topic to map a model object
-# to serialize network output that will be send over the
-# appropriate UEB topic according to its network information.
-#
-#
-# 2.1 UEB Sources
-#
-# ueb.source.topics: comma separated list of UEB topics source of events.
-# ueb.source.topics.<aTopic>.servers: comma separated list of UEB servers to poll for events.
-# [optional] ueb.source.topics.<aTopic>.apiKey=<API-KEY> : api key
-# [optional] ueb.source.topics.<aTopic>.apiSecret=<API-SECRET> : api secret
-# [optional] ueb.source.topics.<aTopic>.consumerGroup=<CONSUMER-GROUP> : consumer group
-# [optional] ueb.source.topics.<aTopic>.consumerInstance=<CONSUMER-INSTANCE> : consumer instance
-# ueb.source.topics.<aTopic>.events: comma separated list of classes to which an event can be mapped to,
-# where <aTopic> must be declared in ueb.source.topics
-# ueb.source.topics.<aTopic>.events.<eventClass>.filter: comma separated list of conditions in the form of
-# pairs of "<field-name>=<field-value-regex>" values, where <field-name> identifies a field of the event, and
-# <field-value-regex> is a regular expression that that field's value in the event must match
-# against each particular instantiation of the event for this controller. Note that multiple
-# "<field-name>=<field-value-regex>" are evaluated for acceptance by AND'ing each condition.
-# Further, <aTopic> must be declared in ueb.source.topics, and
-# <eventClass> in ueb.source.topics.<aTopic>.events
-# ueb.source.topics.<aTopic>.events: comma separated list of classes to which an event can be mapped to,
-# where <aTopic> must be declared in dmaap.source.topics
-# [optional] ueb.source.topics.<aTopic>.events.<eventClass>.filter: comma separated list of conditions in the form of
-# pairs of "<field-name>=<field-value-regex>" values, where <field-name> identifies a field of the event, and
-# <field-value-regex> is a regular expression that that field's value in the event must match
-# against each particular instantiation of the event for this controller. Note that multiple
-# "<field-name>=<field-value-regex>" are evaluated for acceptance by AND'ing each condition.
-# Further, <aTopic> must be declared in dmaap.source.topics, and
-# <eventClass> in dmaap.source.topics.<aTopic>.events.
-# [optional] ueb.source.topics.<aTopic>.events.custom.gson: comma separated pair, where the first item
-# is a class in the model that contains a gson parser, and the second is the actual gson parser in
-# the class. This setting overrides the PDP-D generic framework parsers with an specific model
-# provided one
-# [optional] ueb.source.topics.<aTopic>.events.custom.jackson: comma separated pair, where the first item
-# is a class in the model that contains a jackson parser, and the second is the actual jackson parser in
-# the class. This setting overrides the PDP-D generic framework parsers with an specific model
-# provided one
-#
-# 2.1 UEB Sinks
-#
-# ueb.sink.topics: comma separated list of UEB topics destination of locally produced events.
-# ueb.sink.topics.<aTopic>.servers: comma separated list of UEB servers to send events.
-# [optional] ueb.sink.topics.<aTopic>.apiKey=<APIKEY> : api key
-# [optional] ueb.sink.topics.<aTopic>.apiSecret=<APISECRET> : api secret
-# [optional] ueb.sink.topics.<aTopic>.partitionKey=<PARTITIONKEY> : partition key
-# ueb.sink.topics.<aTopic>.events: comma separated list of classes to which an event can be mapped to,
-# where <aTopic> must be declared in ueb.sink.topics
-# [optional] ueb.sink.topics.<aTopic>.events.custom.gson: comma separated pair, where the first item
-# is a class in the model that contains a gson parser, and the second is the actual gson parser in
-# the class. This setting overrides the PDP-D generic framework parsers with an specific model
-# provided one
-# [optional] ueb.sink.topics.<aTopic>.events.custom.jackson: comma separated pair, where the first item
-# is a class in the model that contains a jackson parser, and the second is the actual jackson parser in
-# the class. This setting overrides the PDP-D generic framework parsers with an specific model
-# provided one
-#
-# 3. DROOLS (Maven Group Coordinates):
-#
-# rules.groupId: maven group id of rules jar file
-# rules.artifactId: maven artifact id of rules jar file
-# rules.version: comma separated list of versions supported and detected that include the drl.
diff --git a/policy-management/src/main/server/config/log4j.properties b/policy-management/src/main/server/config/log4j.properties
deleted file mode 100644
index 6ad25643..00000000
--- a/policy-management/src/main/server/config/log4j.properties
+++ /dev/null
@@ -1,48 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# policy-management
-# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. 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.
-# ============LICENSE_END=========================================================
-###
-
-log4j.rootLogger=INFO,stdout
-
-log4j.logger.org.apache.http.headers=INFO,stdout
-log4j.logger.org.apache.http.wire=INFO,stdout
-log4j.logger.networkLogger=INFO,network
-
-log4j.additivity.networkLogger=false
-
-log4j.appender.stdout=org.apache.log4j.RollingFileAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d %5p [%t] %m %C:%L%n
-
-log4j.appender.network=org.apache.log4j.RollingFileAppender
-log4j.appender.network.File=logs/network.log
-log4j.appender.network.layout=org.apache.log4j.PatternLayout
-log4j.appender.network.layout.ConversionPattern=[%d|%t]%m%n%n
-log4j.appender.network.MaxFileSize=50MB
-log4j.appender.network.MaxBackupIndex=4
-
-log4j.logger.debugLogger=INFO,debug
-log4j.additivity.debugLogger=false
-log4j.appender.debug=org.apache.log4j.RollingFileAppender
-log4j.appender.debug.File=logs/debug.log
-log4j.appender.debug.layout=org.apache.log4j.PatternLayout
-log4j.appender.debug.layout.ConversionPattern=[%d|%t]%m%n%n
-log4j.appender.debug.MaxFileSize=50MB
-log4j.appender.debug.MaxBackupIndex=4
-
diff --git a/policy-management/src/main/server/config/logback.xml b/policy-management/src/main/server/config/logback.xml
index 6b016206..58092cc2 100644
--- a/policy-management/src/main/server/config/logback.xml
+++ b/policy-management/src/main/server/config/logback.xml
@@ -18,194 +18,140 @@
============LICENSE_END=========================================================
-->
-<configuration scan="true" scanPeriod="3 seconds" debug="true">
- <!--<jmxConfigurator /> -->
- <!-- directory path for all other type logs -->
- <property name="logDir" value="logs" />
-
- <!-- directory path for debugging type logs -->
- <property name="debugDir" value="debug-logs" />
-
- <!-- specify the component name
- <ECOMP-component-name>::= "MSO" | "DCAE" | "ASDC " | "AAI" |"Policy" | "SDNC" | "AC" -->
- <property name="componentName" value="Policy"></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 -->
- <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="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="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{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
- <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="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="debugLoggerPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}|%X{RequestId}|%X{ClassName}|%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="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="logDirectory" value="${logDir}/${componentName}" />
- <property name="debugLogDirectory" value="${logDir}/${componentName}" />
-
-
- <!-- Example evaluator filter applied against console appender -->
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>${defaultPattern}</pattern>
- </encoder>
- </appender>
+<configuration scan="true" scanPeriod="30 seconds" debug="false">
- <!-- ============================================================================ -->
- <!-- EELF Appenders -->
- <!-- ============================================================================ -->
+ <property name="logDir" value="logs" />
- <!-- The EELFAppender is used to record events to the general application
- log -->
-
-
+ <property name="errorLog" value="error" />
+ <property name="metricLog" value="metric" />
+ <property name="auditLog" value="audit" />
+ <property name="debugLog" value="debug" />
+ <property name="networkLog" value="network" />
-
- <!-- 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.FixedWindowRollingPolicy">
- <fileNamePattern>${logDirectory}/${auditLogName}.%i.log.zip
- </fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <pattern>${defaultAuditPattern}</pattern>
- </encoder>
- </appender>
- <appender name="asyncEELFAudit" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELFAudit" />
- </appender>
+ <property name="metricPattern"
+ 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="auditPattern"
+ 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="errorPattern"
+ 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" />
-<appender name="EELFMetrics"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDirectory}/${metricsLogName}.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>${logDirectory}/${metricsLogName}.%i.log.zip
- </fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <!-- <pattern>"%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} -
- %msg%n"</pattern> -->
- <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.FixedWindowRollingPolicy">
- <fileNamePattern>${logDirectory}/${errorLogName}.%i.log.zip
- </fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
- <level>ERROR</level>
- </filter>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <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.FixedWindowRollingPolicy">
- <fileNamePattern>${debugLogDirectory}/${debugLogName}.%i.log.zip
- </fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
- <level>INFO</level>
- </filter>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <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="info" additivity="false">
- <appender-ref ref="asyncEELFDebug" />
- </logger>
-
-
-
- <root level="INFO">
- <appender-ref ref="asyncEELFDebug" />
- <appender-ref ref="asyncEELFError" />
- </root>
+ <property name="debugPattern" value="[%date|%level|%logger{0}|%thread] %msg%n" />
+ <property name="networkPattern" value="[%d|%t]%m%n" />
+
+ <appender name="AuditOut" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDir}/${auditLog}.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${logDir}/${auditLog}.%i.log.zip</fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>9</maxIndex>
+ </rollingPolicy>
+ <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>5MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <pattern>${auditPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="AsyncAuditOut" class="ch.qos.logback.classic.AsyncAppender">
+ <appender-ref ref="AuditOut" />
+ </appender>
+
+ <appender name="MetricOut" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDir}/${metricLog}.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${logDir}/${metricLog}.%i.log.zip</fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>9</maxIndex>
+ </rollingPolicy>
+ <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>5MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <pattern>${metricPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="AsyncMetricOut" class="ch.qos.logback.classic.AsyncAppender">
+ <appender-ref ref="MetricOut" />
+ </appender>
+
+ <appender name="ErrorOut" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDir}/${errorLog}.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${logDir}/${errorLog}.%i.log.zip</fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>9</maxIndex>
+ </rollingPolicy>
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>WARN</level>
+ </filter>
+ <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>15MB</maxFileSize>
+ </triggeringPolicy>
+ <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.FixedWindowRollingPolicy">
+ <fileNamePattern>${logDir}/${debugLog}.%i.log.zip</fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>9</maxIndex>
+ </rollingPolicy>
+ <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>20MB</maxFileSize>
+ </triggeringPolicy>
+ <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.FixedWindowRollingPolicy">
+ <fileNamePattern>logs/network.log.%i.zip</fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>9</maxIndex>
+ </rollingPolicy>
+ <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>15MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <pattern>${networkPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="AsyncNetworkOut" class="ch.qos.logback.classic.AsyncAppender">
+ <appender-ref ref="NetworkOut" />
+ </appender>
+
+ <logger name="com.att.eelf.audit" level="INFO">
+ <appender-ref ref="AsyncAuditOut" />
+ </logger>
+
+ <logger name="com.att.eelf.metrics" level="INFO">
+ <appender-ref ref="AsyncMetricOut" />
+ </logger>
+
+ <logger name="network" 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/policy-management/src/main/server/config/makefile b/policy-management/src/main/server/config/makefile
deleted file mode 100644
index 5a96c541..00000000
--- a/policy-management/src/main/server/config/makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-
-restart: stop start
-
-start:
- bin/policy-management-controller start
-stop:
- bin/policy-management-controller stop
-console:
- bin/policy-management-controller console
diff --git a/policy-management/src/main/server/config/policyLogger.properties b/policy-management/src/main/server/config/policyLogger.properties
deleted file mode 100644
index 4a977992..00000000
--- a/policy-management/src/main/server/config/policyLogger.properties
+++ /dev/null
@@ -1,49 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# policy-management
-# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. 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.
-# ============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
-# Set override flag. Set TRUE for override the level setups in logback.xml. Set FALSE for using the level setups of logback.xml
-override.logback.level.setup=FALSE
-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
-#################################### Set Policy Component ##################################
-# Set DROOLS for drools PDP. Set XACML to xacml PDP
-policy.component=DROOLS
diff --git a/policy-management/src/main/server/config/system.properties b/policy-management/src/main/server/config/system.properties
index feffbd00..67294c8a 100644
--- a/policy-management/src/main/server/config/system.properties
+++ b/policy-management/src/main/server/config/system.properties
@@ -20,12 +20,24 @@
# system properties passed to controller
-# start JMX server port
+# jmx
+
com.sun.management.jmxremote.port = 9991
com.sun.management.jmxremote.authenticate = false
com.sun.management.jmxremote.ssl = false
+# certs
+
javax.net.ssl.keyStore=/opt/app/policy/etc/ssl/policy-keystore
javax.net.ssl.keyStorePassword = ${{KEYSTORE_PASSWD}}
javax.net.ssl.trustStore=/opt/app/policy/etc/ssl/policy-keystore
javax.net.ssl.trustStorePassword = ${{KEYSTORE_PASSWD}}
+
+# standard logging
+
+logback.configurationFile=config/logback.xml
+
+# eelf logging
+
+com.att.eelf.logging.path=config
+com.att.eelf.logging.file=logback.xml \ No newline at end of file
diff --git a/policy-utils/pom.xml b/policy-utils/pom.xml
index 509e293c..108d66d7 100644
--- a/policy-utils/pom.xml
+++ b/policy-utils/pom.xml
@@ -32,44 +32,17 @@
</parent>
- <dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.17</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>com.att.eelf</groupId>
- <artifactId>eelf-core</artifactId>
- <version>0.0.1</version>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <version>1.1.1</version>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-core</artifactId>
- <version>1.1.1</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.7.6</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.policy.common</groupId>
- <artifactId>ECOMP-Logging</artifactId>
- <version>${common-modules.version}</version>
- </dependency>
</dependencies>
diff --git a/policy-utils/src/main/java/org/openecomp/policy/drools/utils/OrderedServiceImpl.java b/policy-utils/src/main/java/org/openecomp/policy/drools/utils/OrderedServiceImpl.java
index c5f9a343..72bf7b8b 100644
--- a/policy-utils/src/main/java/org/openecomp/policy/drools/utils/OrderedServiceImpl.java
+++ b/policy-utils/src/main/java/org/openecomp/policy/drools/utils/OrderedServiceImpl.java
@@ -27,12 +27,18 @@ import java.util.LinkedList;
import java.util.List;
import java.util.ServiceLoader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* This class is a template for building a sorted list of service instances,
* which are discovered and created using 'ServiceLoader'.
*/
public class OrderedServiceImpl<T extends OrderedService>
{
+ // logger
+ private static Logger logger = LoggerFactory.getLogger(OrderedServiceImpl.class);
+
// sorted list of instances implementing the service
private List<T> implementers = null;
@@ -113,7 +119,7 @@ public class OrderedServiceImpl<T extends OrderedService>
// create an unmodifiable version of this list
implementers = Collections.unmodifiableList(tmp);
- System.out.println("***** OrderedServiceImpl implementers:\n" + implementers);
+ logger.info("***** OrderedServiceImpl implementers:\n {}", implementers);
return(implementers);
}
diff --git a/policy-utils/src/main/java/org/openecomp/policy/drools/utils/PropertyUtil.java b/policy-utils/src/main/java/org/openecomp/policy/drools/utils/PropertyUtil.java
index 34ddcc1c..1e8dc267 100644
--- a/policy-utils/src/main/java/org/openecomp/policy/drools/utils/PropertyUtil.java
+++ b/policy-utils/src/main/java/org/openecomp/policy/drools/utils/PropertyUtil.java
@@ -382,22 +382,4 @@ public class PropertyUtil
stopListening(new File(fileName), listener);
}
- /* ============================================================ */
-
- // TEMPORARY - used to test callback interface
- static public class Test implements Listener
- {
- String name;
-
- public Test(String name)
- {
- this.name = name;
- }
-
- public void propertiesChanged(Properties properties, Set<String> changedKeys)
- {
- System.out.println("Test(" + name + ")\nproperties = " + properties
- + "\nchangedKeys = " + changedKeys);
- }
- }
}
diff --git a/policy-utils/src/main/java/org/openecomp/policy/drools/utils/ReflectionUtil.java b/policy-utils/src/main/java/org/openecomp/policy/drools/utils/ReflectionUtil.java
index 1ab68282..0d82e847 100644
--- a/policy-utils/src/main/java/org/openecomp/policy/drools/utils/ReflectionUtil.java
+++ b/policy-utils/src/main/java/org/openecomp/policy/drools/utils/ReflectionUtil.java
@@ -23,43 +23,41 @@
*/
package org.openecomp.policy.drools.utils;
-import org.openecomp.policy.common.logging.eelf.PolicyLogger;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Reflection utilities
*
*/
public class ReflectionUtil {
+ protected final static Logger logger = LoggerFactory.getLogger(ReflectionUtil.class);
+
/**
* returns (if exists) a class fetched from a given classloader
*
* @param classLoader the class loader
- * @param classname the class name
+ * @param className the class name
* @return the actual class
* @throws IllegalArgumentException if an invalid parameter has been passed in
*/
public static Class<?> fetchClass(ClassLoader classLoader,
- String classname)
+ String className)
throws IllegalArgumentException {
-
- PolicyLogger.info("FETCH-CLASS: " + classname + " FROM " + classLoader);
-
if (classLoader == null)
throw new IllegalArgumentException("A class loader must be provided");
- if (classname == null)
+ if (className == null)
throw new IllegalArgumentException("A class name to be fetched in class loader " +
classLoader + " must be provided");
try {
- Class<?> aClass = Class.forName(classname,
+ Class<?> aClass = Class.forName(className,
true,
classLoader);
return aClass;
} catch (Exception e) {
- e.printStackTrace();
- PolicyLogger.error("FETCH-CLASS: " + classname + " IN " + classLoader + " does NOT exist");
+ logger.error("FETCHED-CLASS {} IN {} does NOT EXIST", className, classLoader);
}
return null;
@@ -84,8 +82,6 @@ public class ReflectionUtil {
* @return
*/
public static boolean isSubclass(Class<?> parent, Class<?> presumedSubclass) {
- PolicyLogger.debug("IS-SUBCLASS: superclass: " + parent.getCanonicalName() +
- " subclass: " + presumedSubclass.getCanonicalName());
return (parent.isAssignableFrom(presumedSubclass));
}
diff --git a/policy-utils/src/test/java/org/openecomp/policy/drools/utils/PropertyUtilTest.java b/policy-utils/src/test/java/org/openecomp/policy/drools/utils/PropertyUtilTest.java
index 32386725..b45f1b45 100644
--- a/policy-utils/src/test/java/org/openecomp/policy/drools/utils/PropertyUtilTest.java
+++ b/policy-utils/src/test/java/org/openecomp/policy/drools/utils/PropertyUtilTest.java
@@ -34,12 +34,12 @@ import java.util.UUID;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.openecomp.policy.common.logging.eelf.PolicyLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class PropertyUtilTest
{
- // private static final Logger PolicyLogger =
-// Logger.getLogger(PropertyUtilTest.class.getName());
+ private final static Logger logger = LoggerFactory.getLogger(PropertyUtilTest.class);
private static File directory = null;
@@ -49,7 +49,7 @@ public class PropertyUtilTest
@BeforeClass
static public void setup()
{
- PolicyLogger.info("setup: creating a temporary directory");
+ logger.info("setup: creating a temporary directory");
// create a directory for temporary files
directory = new File(UUID.randomUUID().toString());
@@ -62,7 +62,7 @@ public class PropertyUtilTest
@AfterClass
static public void teardown()
{
- PolicyLogger.info("teardown: remove the temporary directory");
+ logger.info("teardown: remove the temporary directory");
// the assumption is that we only have one level of temporary files
for (File file : directory.listFiles())
@@ -114,7 +114,7 @@ public class PropertyUtilTest
{
// When a notification is received, store the values in the
// 'returns' array, and signal using the same array.
- PolicyLogger.info("Listener invoked: properties=" + properties
+ logger.info("Listener invoked: properties=" + properties
+ ", changedKeys=" + changedKeys);
returns[0] = properties;
returns[1] = changedKeys;
@@ -132,15 +132,15 @@ public class PropertyUtilTest
@Test
public void testGetProperties() throws Exception
{
- PolicyLogger.info("testGetProperties: test the basic properties file interface");
+ logger.info("testGetProperties: test the basic properties file interface");
// copy system properties
- PolicyLogger.info("Copy system properties to a file");
+ logger.info("Copy system properties to a file");
Properties prop1 = System.getProperties();
File file1 = createFile("createAndReadPropertyFile-1", prop1);
// read in properties, and compare
- PolicyLogger.info("Read in properties from new file");
+ logger.info("Read in properties from new file");
Properties prop2 = PropertyUtil.getProperties(file1);
// they should match
@@ -153,14 +153,14 @@ public class PropertyUtilTest
@Test
public void testListenerInterface() throws Exception
{
- PolicyLogger.info("testListenerInterface: test receipt of dynamic updates");
+ logger.info("testListenerInterface: test receipt of dynamic updates");
// create initial property file
Properties prop1 = new Properties();
prop1.setProperty("p1", "p1 value");
prop1.setProperty("p2", "p2 value");
prop1.setProperty("p3", "p3 value");
- PolicyLogger.info("Create initial properties file: " + prop1);
+ logger.info("Create initial properties file: " + prop1);
File file1 = createFile("createAndReadPropertyFile-2", prop1);
// create a listener for the notification interface
@@ -169,7 +169,7 @@ public class PropertyUtilTest
// read it in, and do a comparison
Properties prop2 = PropertyUtil.getProperties(file1, listener);
- PolicyLogger.info("Read in properties: " + prop2);
+ logger.info("Read in properties: " + prop2);
assertEquals(prop1, prop2);
assertEquals(prop2.getProperty("p1"), "p1 value");
assertEquals(prop2.getProperty("p2"), "p2 value");
@@ -179,7 +179,7 @@ public class PropertyUtilTest
prop2.remove("p1"); // remove one property
prop2.setProperty("p2", "new p2 value"); // change one property
prop2.setProperty("p4", "p4 value"); // add a new property
- PolicyLogger.info("Modified properties: " + prop2);
+ logger.info("Modified properties: " + prop2);
// now, update the file, and wait for notification
synchronized(returns)
diff --git a/policy-utils/src/test/resources/log4j.properties b/policy-utils/src/test/resources/log4j.properties
deleted file mode 100644
index 0063f104..00000000
--- a/policy-utils/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# policy-utils
-# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. 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.
-# ============LICENSE_END=========================================================
-###
-
-log4j.rootLogger=INFO, out
-
-# CONSOLE appender not used by default
-log4j.appender.out=org.apache.log4j.ConsoleAppender
-log4j.appender.out.layout=org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern=%d %-5p %-30.30c{1} %4L - %m%n
diff --git a/pom.xml b/pom.xml
index 373e6b62..7edfc1ee 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,8 +42,9 @@
<jersey.version>2.22.2</jersey.version>
<jersey.swagger.version>1.5.13</jersey.swagger.version>
<jackson.version>2.8.4</jackson.version>
- <http.client>4.5</http.client>
- <http.core>4.4.4</http.core>
+ <http.client.version>4.5</http.client.version>
+ <http.core.version>4.4.4</http.core.version>
+ <logback.version>1.2.3</logback.version>
<sonar.language>java</sonar.language>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
@@ -102,9 +103,8 @@
</site>
</distributionManagement>
- <dependencies>
+ <dependencies/>
- </dependencies>
<dependencyManagement>
<dependencies>
<dependency>
@@ -165,12 +165,17 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
- <version>${http.client}</version>
+ <version>${http.client.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
- <version>${http.core}</version>
+ <version>${http.core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>${logback.version}</version>
</dependency>
</dependencies>
</dependencyManagement>