aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2018-02-06 16:42:25 +0100
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2018-02-06 16:42:25 +0100
commit0dac2dec76cd3b97f0865fc817c1ef8d227a68a1 (patch)
treeabf683486b2e9cca19826807ee933b2a933bbe23 /src/main/java
parent221d3d78efa95377729f20b5a5db6f9f6dc1ae73 (diff)
Improve logs in Policy methods.
Add info to the logs of the methods calling policy. Issue-ID: CLAMP-85 Change-Id: I6213b380ba66a93be3a0c06d62781b1e4934544b Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java b/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java
index 2e2169f8..b4cad949 100644
--- a/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java
+++ b/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -62,18 +62,18 @@ import org.springframework.context.ApplicationContext;
* Policy utility methods - specifically, send the policy.
*/
public class PolicyClient {
- protected static final String POLICY_PREFIX_BASE = "Config_";
- protected static final String LOG_POLICY_PREFIX = "Response is ";
+ protected static final String POLICY_PREFIX_BASE = "Config_";
+ protected static final String LOG_POLICY_PREFIX = "Response is ";
protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyClient.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
- protected static final String POLICY_MSTYPE_PROPERTY_NAME = "policy.ms.type";
- protected static final String POLICY_ONAPNAME_PROPERTY_NAME = "policy.onap.name";
+ protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
+ protected static final String POLICY_MSTYPE_PROPERTY_NAME = "policy.ms.type";
+ protected static final String POLICY_ONAPNAME_PROPERTY_NAME = "policy.onap.name";
@Value("${org.onap.clamp.config.files.cldsPolicyConfig:'classpath:/clds/clds-policy-config.properties'}")
- protected String cldsPolicyConfigFile;
+ protected String cldsPolicyConfigFile;
@Autowired
- protected ApplicationContext appContext;
+ protected ApplicationContext appContext;
@Autowired
- protected RefProp refProp;
+ protected RefProp refProp;
/**
* Perform BRMS policy type.
@@ -229,15 +229,19 @@ public class PolicyClient {
responseMessage = response.getResponseMessage();
}
} catch (Exception e) {
+ LoggingUtils.setResponseContext("900", "Policy send failed", this.getClass().getName());
+ LoggingUtils.setErrorContext("900", "Policy send error");
logger.error("Exception occurred during policy communication", e);
throw new PolicyClientException("Exception while communicating with Policy", e);
}
logger.info(LOG_POLICY_PREFIX + responseMessage);
LoggingUtils.setTimeContext(startTime, new Date());
if (response.getResponseCode() == 200) {
+ LoggingUtils.setResponseContext("0", "Policy send success", this.getClass().getName());
logger.info("Policy send successful");
metricsLogger.info("Policy send success");
} else {
+ LoggingUtils.setResponseContext("900", "Policy send failed", this.getClass().getName());
logger.warn("Policy send failed: " + responseMessage);
metricsLogger.info("Policy send failure");
throw new BadRequestException("Policy send failed: " + responseMessage);
@@ -274,20 +278,27 @@ public class PolicyClient {
PolicyChangeResponse response;
String responseMessage = "";
try {
+ LoggingUtils.setTargetContext("Policy", "pushPolicy");
logger.info("Attempting to push policy...");
response = getPolicyEngine().pushPolicy(pushPolicyParameters);
if (response != null) {
responseMessage = response.getResponseMessage();
}
} catch (Exception e) {
+ LoggingUtils.setResponseContext("900", "Policy push failed", this.getClass().getName());
+ LoggingUtils.setErrorContext("900", "Policy push error");
logger.error("Exception occurred during policy communication", e);
throw new PolicyClientException("Exception while communicating with Policy", e);
}
logger.info(LOG_POLICY_PREFIX + responseMessage);
if (response != null && (response.getResponseCode() == 200 || response.getResponseCode() == 204)) {
+ LoggingUtils.setResponseContext("0", "Policy push success", this.getClass().getName());
logger.info("Policy push successful");
+ metricsLogger.info("Policy push success");
} else {
+ LoggingUtils.setResponseContext("900", "Policy push failed", this.getClass().getName());
logger.warn("Policy push failed: " + responseMessage);
+ metricsLogger.info("Policy push failure");
throw new BadRequestException("Policy push failed: " + responseMessage);
}
return responseMessage;
@@ -331,6 +342,11 @@ public class PolicyClient {
return versions;
}
+ /**
+ * This method create a new policy engine.
+ *
+ * @return A new policy engine
+ */
private PolicyEngine getPolicyEngine() {
PolicyEngine policyEngine;
try {
@@ -383,6 +399,7 @@ public class PolicyClient {
*
* @param prop
* The ModelProperties
+ *
* @return The response message from policy
*/
protected String deletePolicy(ModelProperties prop, String policyType) {