summaryrefslogtreecommitdiffstats
path: root/controlloop/common/feature-controlloop-trans/src/main
diff options
context:
space:
mode:
authorJoseph Chou <jc2555@att.com>2020-06-09 14:14:56 -0400
committerJoseph Chou <jc2555@att.com>2020-06-15 14:03:40 -0400
commit44162d56a81c1a04a70bfeca0b79d8d50f1a82a8 (patch)
tree66e9f45e44bcf85d25e796f84fb95e3720dbd507 /controlloop/common/feature-controlloop-trans/src/main
parent586a5d357470e4ab7e22481c852dd1cd1ace352d (diff)
change audit and metric formats in feature-controlloop-trans
logging enhancement Issue-ID: POLICY-2579 Change-Id: Id1e0230d3cd2ac6d921be86f127f3721c65f3e52 Signed-off-by: Joseph Chou <jc2555@att.com>
Diffstat (limited to 'controlloop/common/feature-controlloop-trans/src/main')
-rw-r--r--controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/CacheBasedControlLoopMetricsManager.java33
1 files changed, 32 insertions, 1 deletions
diff --git a/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/CacheBasedControlLoopMetricsManager.java b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/CacheBasedControlLoopMetricsManager.java
index 75e0f1f4d..956d28ed8 100644
--- a/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/CacheBasedControlLoopMetricsManager.java
+++ b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/CacheBasedControlLoopMetricsManager.java
@@ -28,10 +28,12 @@ import java.time.Instant;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.apache.commons.collections4.CollectionUtils;
+import org.onap.policy.controlloop.ControlLoopNotificationType;
import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.drools.persistence.SystemPersistenceConstants;
@@ -54,6 +56,22 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
private long transactionTimeout = ControlLoopMetricsFeature.CL_CACHE_TRANS_TIMEOUT_SECONDS_DEFAULT;
+ /**
+ * Numeric response code.
+ */
+ private static final Map<String, String> note2code = Map.of(
+ ControlLoopNotificationType.ACTIVE.name(), "100",
+ ControlLoopNotificationType.REJECTED.name(), "200",
+ ControlLoopNotificationType.OPERATION.name(), "300",
+ ControlLoopNotificationType.OPERATION_SUCCESS.name(), "301",
+ ControlLoopNotificationType.OPERATION_FAILURE.name(), "302",
+ ControlLoopNotificationType.FINAL_FAILURE.name(), "400",
+ ControlLoopNotificationType.FINAL_SUCCESS.name(), "401",
+ ControlLoopNotificationType.FINAL_OPENLOOP.name(), "402"
+ );
+
+ private static final String UNKNOWN_RESPONSE_CODE = "900";
+
public CacheBasedControlLoopMetricsManager() {
Properties properties = SystemPersistenceConstants.getManager()
@@ -288,7 +306,11 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
+ ":" + notification.getPolicyName() + ":" + notification.getPolicyVersion())
.setProcessKey("" + notification.getAai())
.setTargetEntity(notification.getTargetType() + "." + notification.getTarget())
- .setResponseCode((notification.getNotification() != null) ? notification.getNotification().name() : "-")
+ .setResponseCode((notification.getNotification() != null)
+ ? notificationTypeToResponseCode(notification.getNotification().name())
+ : UNKNOWN_RESPONSE_CODE)
+ .setCustomField1((notification.getNotification() != null)
+ ? notification.getNotification().name() : "")
.setResponseDescription(notification.getMessage())
.setClientIpAddress(notification.getClosedLoopEventClient());
}
@@ -362,4 +384,13 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
+ getCacheOccupancy()
+ "}";
}
+
+ private String notificationTypeToResponseCode(String notificationType) {
+ String code = note2code.get(notificationType);
+ if (code != null) {
+ return code;
+ } else {
+ return UNKNOWN_RESPONSE_CODE;
+ }
+ }
}