aboutsummaryrefslogtreecommitdiffstats
path: root/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java
diff options
context:
space:
mode:
authorJorge Hernandez <jh1730@att.com>2018-03-25 23:34:27 -0500
committerJorge Hernandez <jh1730@att.com>2018-03-26 10:08:52 -0500
commit13e9aa8e0613877c3ce63c878978e9cb31b92c48 (patch)
treed42f4da2d39deb372da5a9d279d233ab4bbb7c21 /policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java
parent5c205833e4b2e8f6cfe938641cdbceaf680da92b (diff)
l2 management maturity pdp-d
configurable log location metric/audit log for transaction metrics conforming to new field definition. support metrics/audits records with custom logback filters so they are not intrusive with developer log testing. Change-Id: I7a4dcc6790b85539e613ad8705e731e7298ce106 Issue-ID: POLICY-533 Signed-off-by: Jorge Hernandez <jh1730@att.com>
Diffstat (limited to 'policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java')
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java54
1 files changed, 37 insertions, 17 deletions
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