summaryrefslogtreecommitdiffstats
path: root/policy-management/src/main/java/org/onap
diff options
context:
space:
mode:
Diffstat (limited to 'policy-management/src/main/java/org/onap')
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java2
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/Main.java38
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java54
3 files changed, 65 insertions, 29 deletions
diff --git a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
index cd1edca5..15c97237 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
@@ -64,7 +64,7 @@ import org.onap.policy.drools.protocol.configuration.ControllerConfiguration;
import org.onap.policy.drools.protocol.configuration.PdpdConfiguration;
import org.onap.policy.drools.system.PolicyController;
import org.onap.policy.drools.system.PolicyEngine;
-import org.onap.policy.drools.utils.LoggerUtil;
+import org.onap.policy.drools.utils.logging.LoggerUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/Main.java b/policy-management/src/main/java/org/onap/policy/drools/system/Main.java
index 314bbc04..43216000 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/system/Main.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/system/Main.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-management
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -20,14 +20,14 @@
package org.onap.policy.drools.system;
-import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Properties;
import org.onap.policy.drools.persistence.SystemPersistence;
import org.onap.policy.drools.properties.PolicyProperties;
-import org.onap.policy.drools.utils.LoggerUtil;
+import org.onap.policy.drools.utils.logging.LoggerUtil;
+import org.onap.policy.drools.utils.logging.MDCTransaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,7 +56,6 @@ public class Main {
* main
*
* @param args program arguments
- * @throws IOException
*/
public static void main(String[] args) {
@@ -110,16 +109,23 @@ public class Main {
/* 2. Start the Engine with the basic services only (no Policy Controllers) */
+ MDCTransaction trans =
+ MDCTransaction.newTransaction(null, null).setServiceName(Main.class.getSimpleName()).
+ setTargetEntity("engine").setTargetServiceName("start");
try {
final boolean success = PolicyEngine.manager.start();
if (!success) {
- logger.warn("Main: {} has been partially started", PolicyEngine.manager);
+ trans.setStatusCode(false).setResponseDescription("partial start").flush();
+ logger.warn(LoggerUtil.TRANSACTION_LOG_MARKER, "Main: {} has been partially started", PolicyEngine.manager);
+ } else {
+ trans.setStatusCode(true).transaction();
}
} catch (final IllegalStateException e) {
- logger.warn("Main: cannot start {} (bad state) because of {}", PolicyEngine.manager,
- e.getMessage(), e);
+ trans.setStatusCode(false).setResponseCode(e.getClass().getSimpleName()).setResponseDescription(e.getMessage()).flush();
+ logger.warn(LoggerUtil.TRANSACTION_LOG_MARKER, "Main: cannot start {} (bad state) because of {}", PolicyEngine.manager, e.getMessage(), e);
} catch (final Exception e) {
- logger.warn("Main: cannot start {} because of {}", PolicyEngine.manager, e.getMessage(), e);
+ trans.setStatusCode(false).setResponseCode(e.getClass().getSimpleName()).setResponseDescription(e.getMessage()).flush();
+ logger.warn(LoggerUtil.TRANSACTION_LOG_MARKER, "Main: cannot start {} because of {}", PolicyEngine.manager, e.getMessage(), e);
System.exit(1);
}
@@ -130,14 +136,24 @@ public class Main {
final String controllerName =
controllerProperties.getProperty(PolicyProperties.PROPERTY_CONTROLLER_NAME);
try {
+ trans =
+ MDCTransaction.newTransaction(null, null).setServiceName(Main.class.getSimpleName()).
+ setTargetEntity("controller:" + controllerName).setTargetServiceName("start");
+
final PolicyController controller =
PolicyEngine.manager.createPolicyController(controllerName, controllerProperties);
controller.start();
+
+ trans.setStatusCode(true).
+ setResponseDescription(controller.getDrools().getCanonicalSessionNames().toString()).
+ transaction();
} catch (final Exception e) {
- logger.error("Main: cannot instantiate policy-controller {} because of {}", controllerName,
- e.getMessage(), e);
+ trans.setStatusCode(false).setResponseCode(e.getClass().getSimpleName()).setResponseDescription(e.getMessage()).flush();
+ logger.error(LoggerUtil.TRANSACTION_LOG_MARKER, "Main: cannot instantiate policy-controller {} because of {}",
+ controllerName, e.getMessage(), e);
} catch (final LinkageError e) {
- logger.warn("Main: cannot instantiate policy-controller {} (linkage) because of {}",
+ trans.setStatusCode(false).setResponseCode(e.getClass().getSimpleName()).setResponseDescription(e.getMessage()).flush();
+ logger.warn(LoggerUtil.TRANSACTION_LOG_MARKER, "Main: cannot instantiate policy-controller {} (linkage) because of {}",
controllerName, e.getMessage(), e);
}
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java
index a1fee763..d7275578 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java
@@ -44,6 +44,8 @@ import org.onap.policy.drools.protocol.coders.EventProtocolCoder;
import org.onap.policy.drools.protocol.configuration.ControllerConfiguration;
import org.onap.policy.drools.protocol.configuration.PdpdConfiguration;
import org.onap.policy.drools.server.restful.RestManager;
+import org.onap.policy.drools.utils.logging.LoggerUtil;
+import org.onap.policy.drools.utils.logging.MDCTransaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -139,7 +141,6 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener {
/**
* registers a new Policy Controller with the Policy Engine initialized per properties.
*
- * @param controller name
* @param properties properties to initialize the Policy Controller
* @throws IllegalArgumentException when invalid or insufficient properties are provided
* @throws IllegalStateException when the engine is in a state where this operation is not
@@ -276,7 +277,6 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener {
/**
* Attempts the dispatching of an "event" object over communication infrastructure "busType"
*
- * @param eventBus Communication infrastructure identifier
* @param topic topic
* @param event the event object to send
*
@@ -292,7 +292,6 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener {
/**
* Attempts the dispatching of an "event" object over communication infrastructure "busType"
*
- * @param eventBus Communication infrastructure enum
* @param topic topic
* @param event the event object to send
*
@@ -308,7 +307,6 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener {
/**
* Attempts delivering of an String over communication infrastructure "busType"
*
- * @param eventBus Communication infrastructure identifier
* @param topic topic
* @param event the event object to send
*
@@ -591,12 +589,22 @@ private static final String ENGINE_LOCKED_MSG = "Policy Engine is locked";
final String entity = config.getEntity();
+ MDCTransaction mdcTrans = MDCTransaction.newTransaction(config.getRequestID(), "brmsgw");
+ if (this.getSources().size() == 1) {
+ Topic topic = this.getSources().get(0);
+ mdcTrans.setServiceName(topic.getTopic()).setRemoteHost(topic.getServers().toString()).
+ setTargetEntity(config.getEntity());
+ }
+
switch (entity) {
- case PdpdConfiguration.CONFIG_ENTITY_CONTROLLER:
- return controllerConfig(config);
+ case PdpdConfiguration.CONFIG_ENTITY_CONTROLLER:
+ boolean success = controllerConfig(config);
+ mdcTrans.resetSubTransaction().setStatusCode(success).transaction();
+ return success;
default:
final String msg = "Configuration Entity is not supported: " + entity;
- logger.warn(msg);
+ mdcTrans.resetSubTransaction().setStatusCode(false).setResponseDescription(msg).flush();
+ logger.warn(LoggerUtil.TRANSACTION_LOG_MARKER_NAME, msg);
throw new IllegalArgumentException(msg);
}
}
@@ -613,11 +621,18 @@ private static final String ENGINE_LOCKED_MSG = "Policy Engine is locked";
}
for (final ControllerConfiguration configController : configControllers) {
+ MDCTransaction mdcTrans =
+ MDCTransaction.newSubTransaction(null).setTargetEntity(configController.getName()).
+ setTargetServiceName(configController.getOperation()).
+ setTargetVirtualEntity(configController.getDrools().toString());
try {
final PolicyController policyController = this.updatePolicyController(configController);
policyControllers.add(policyController);
+ mdcTrans.setStatusCode(true).transaction();
} catch (final Exception e) {
- logger.error("{}: cannot update-policy-controllers because of {}", this, e.getMessage(), e);
+ mdcTrans.setStatusCode(false).setResponseCode(e.getClass().getName()).
+ setResponseDescription(e.getMessage()).flush();
+ logger.error(LoggerUtil.TRANSACTION_LOG_MARKER_NAME, "{}: cannot update-policy-controllers because of {}", this, e.getMessage(), e);
}
}
@@ -1423,18 +1438,23 @@ private static final String ENGINE_LOCKED_MSG = "Policy Engine is locked";
/* only this one supported for now */
final List<ControllerConfiguration> configControllers = config.getControllers();
if (configControllers == null || configControllers.isEmpty()) {
- if (logger.isInfoEnabled())
- logger.info("No controller configuration provided: " + config);
+ logger.info("No controller configuration provided: {}" + config);
return false;
}
- final List<PolicyController> policyControllers =
- this.updatePolicyControllers(config.getControllers());
- if (policyControllers == null || policyControllers.isEmpty())
- return false;
- else if (policyControllers.size() == configControllers.size())
- return true;
- return false;
+ final List<PolicyController> policyControllers = this.updatePolicyControllers(config.getControllers());
+
+ boolean success;
+
+ if (policyControllers == null || policyControllers.isEmpty()) {
+ success = false;
+ } else if (policyControllers.size() == configControllers.size()) {
+ success = true;
+ } else {
+ success = false;
+ }
+
+ return success;
}
@Override