summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Cruz <dc443y@att.com>2019-03-11 15:29:14 -0500
committerPamela Dragosh <pdragosh@research.att.com>2019-03-19 11:43:44 +0000
commit71513a08caa8fd80c732d53d97b242e4b3a3f5c6 (patch)
tree7908248883a94b7dd8c9586b0bd30940881c10b2
parentf3260414bad28d0a807e60f703f1d87a1cc38f6a (diff)
Change LoggerFactoryWrapper to NetLoggerUtil
Removed LoggerFactoryWrapper references to use NetLoggerUtil. Issue-ID: POLICY-1499 Change-Id: I6f7066f4523736672e17d2e1e609c38c44852769 Signed-off-by: Daniel Cruz <dc443y@att.com>
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java12
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java16
-rw-r--r--controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncManager.java14
-rw-r--r--controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoManager.java19
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcManager.java14
-rw-r--r--controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelperEmbedded.java11
6 files changed, 40 insertions, 46 deletions
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java
index f9a01a70c..8b4c832da 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java
@@ -42,7 +42,9 @@ import java.util.UUID;
import org.apache.commons.io.IOUtils;
import org.apache.http.entity.ContentType;
import org.json.JSONObject;
-import org.onap.policy.common.utils.slf4j.LoggerFactoryWrapper;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.drools.system.PolicyEngine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -50,10 +52,6 @@ import org.slf4j.LoggerFactory;
public class PolicyGuardXacmlHelper {
private static final Logger logger = LoggerFactory.getLogger(PolicyGuardXacmlHelper.class);
- private static final Logger netLogger = LoggerFactoryWrapper.getNetworkLogger();
-
- // Constant for the systme line separator
- private static final String SYSTEM_LS = System.lineSeparator();
private UrlEntry[] restUrls = null;
private int restUrlIndex = 0;
@@ -115,10 +113,10 @@ public class PolicyGuardXacmlHelper {
//
UrlEntry urlEntry = restUrls[restUrlIndex];
String jsonRequestString = jsonReq.toString();
- netLogger.info("[OUT|{}|{}|]{}{}", "GUARD", urlEntry.restUrl, SYSTEM_LS, jsonRequestString);
+ NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, urlEntry.restUrl.toString(), jsonRequestString);
response = callRestfulPdp(new ByteArrayInputStream(jsonReq.toString().getBytes()), urlEntry.restUrl,
urlEntry.authorization, urlEntry.clientAuth, urlEntry.environment);
- netLogger.info("[IN|{}|{}|]{}{}", "GUARD", urlEntry.restUrl, SYSTEM_LS, response);
+ NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, urlEntry.restUrl.toString(), response);
} catch (Exception e) {
logger.error("Error in sending RESTful request: ", e);
}
diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java
index 6136aee93..e609e932e 100644
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java
+++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java
@@ -28,7 +28,9 @@ import java.util.Map;
import java.util.UUID;
import org.onap.policy.aai.util.Serialization;
-import org.onap.policy.common.utils.slf4j.LoggerFactoryWrapper;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.rest.RestManager;
import org.onap.policy.rest.RestManager.Pair;
import org.slf4j.Logger;
@@ -39,15 +41,9 @@ import org.slf4j.LoggerFactory;
*/
public final class AaiManager {
- /** The Constant LINE_SEPARATOR. */
- private static final String LINE_SEPARATOR = System.lineSeparator();
-
/** The Constant logger. */
private static final Logger logger = LoggerFactory.getLogger(AaiManager.class);
- /** The Constant netLogger. */
- private static final Logger netLogger = LoggerFactoryWrapper.getNetworkLogger();
-
/** The rest manager. */
// The REST manager used for processing REST calls for this AAI manager
private final RestManager restManager;
@@ -79,7 +75,7 @@ public final class AaiManager {
logger.debug("RestManager.post before");
String requestJson = Serialization.gsonPretty.toJson(request);
- netLogger.info("[OUT|{}|{}|]{}{}", "AAI", url, LINE_SEPARATOR, requestJson);
+ NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, url, requestJson);
Pair<Integer, String> httpDetails =
restManager.post(url, username, password, headers, "application/json", requestJson);
logger.debug("RestManager.post after");
@@ -168,7 +164,7 @@ public final class AaiManager {
int attemptsLeft = 3;
while (attemptsLeft-- > 0) {
- netLogger.info("[OUT|{}|{}|]", "AAI", urlGet);
+ NetLoggerUtil.getNetworkLogger().info("[OUT|{}|{}|]", CommInfrastructure.REST, urlGet);
Pair<Integer, String> httpDetailsGet = restManager.get(urlGet, username, password, headers);
if (httpDetailsGet == null) {
logger.info("AAI GET Null Response to {}", urlGet);
@@ -228,7 +224,7 @@ public final class AaiManager {
final Class<T> classOfResponse) {
try {
T response = Serialization.gsonPretty.fromJson(httpDetails.second, classOfResponse);
- netLogger.info("[IN|{}|{}|]{}{}", "AAI", url, LINE_SEPARATOR, httpDetails.second);
+ NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, url, httpDetails.second);
return response;
} catch (JsonSyntaxException e) {
logger.error("postQuery threw: ", e);
diff --git a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncManager.java b/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncManager.java
index ae43200ef..9d8c9798e 100644
--- a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncManager.java
+++ b/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncManager.java
@@ -28,7 +28,9 @@ import java.util.HashMap;
import java.util.Map;
import org.drools.core.WorkingMemory;
-import org.onap.policy.common.utils.slf4j.LoggerFactoryWrapper;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.rest.RestManager;
import org.onap.policy.rest.RestManager.Pair;
@@ -38,7 +40,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class SdncManager implements Runnable {
- private static final String SYSTEM_LS = System.lineSeparator();
private String sdncUrlBase;
private String username;
@@ -46,7 +47,6 @@ public final class SdncManager implements Runnable {
private SdncRequest sdncRequest;
private WorkingMemory workingMem;
private static final Logger logger = LoggerFactory.getLogger(SdncManager.class);
- private static final Logger netLogger = LoggerFactoryWrapper.getNetworkLogger();
// The REST manager used for processing REST calls for this Sdnc manager
private RestManager restManager;
@@ -100,8 +100,8 @@ public final class SdncManager implements Runnable {
try {
String sdncRequestJson = Serialization.gsonPretty.toJson(sdncRequest);
- netLogger.info("[OUT|{}|{}|]{}{}", "Sdnc", sdncUrl, SYSTEM_LS, sdncRequestJson);
- logger.info("[OUT|{}|{}|]{}{}", "Sdnc", sdncUrl, SYSTEM_LS, sdncRequestJson);
+ NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, sdncUrl, sdncRequestJson);
+ logger.info("[OUT|{}|{}|]{}{}", CommInfrastructure.REST, sdncUrl, NetLoggerUtil.SYSTEM_LS, sdncRequestJson);
httpDetails = restManager.post(sdncUrl, username, password, headers, "application/json",
sdncRequestJson);
@@ -118,8 +118,8 @@ public final class SdncManager implements Runnable {
try {
SdncResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, SdncResponse.class);
- netLogger.info("[IN|{}|{}|]{}{}", "Sdnc", sdncUrl, SYSTEM_LS, httpDetails.second);
- logger.info("[IN|{}|{}|]{}{}", "Sdnc", sdncUrl, SYSTEM_LS, httpDetails.second);
+ NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, sdncUrl, httpDetails.second);
+ logger.info("[IN|{}|{}|]{}{}", "Sdnc", sdncUrl, NetLoggerUtil.SYSTEM_LS, httpDetails.second);
String body = Serialization.gsonPretty.toJson(response);
logger.info("Response to Sdnc Heal post:");
logger.info(body);
diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoManager.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoManager.java
index 7c145e01d..836ebc85b 100644
--- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoManager.java
+++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoManager.java
@@ -30,7 +30,9 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import org.drools.core.WorkingMemory;
-import org.onap.policy.common.utils.slf4j.LoggerFactoryWrapper;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.rest.RestManager;
import org.onap.policy.rest.RestManager.Pair;
@@ -47,7 +49,6 @@ import org.slf4j.LoggerFactory;
*/
public final class SoManager {
private static final Logger logger = LoggerFactory.getLogger(SoManager.class);
- private static final Logger netLogger = LoggerFactoryWrapper.getNetworkLogger();
private static ExecutorService executors = Executors.newCachedThreadPool();
@@ -85,8 +86,8 @@ public final class SoManager {
final String password, final SoRequest request) {
// Issue the HTTP POST request to SO to create the service instance
String requestJson = Serialization.gsonPretty.toJson(request);
- netLogger.info("[OUT|{}|{}|{}|{}|{}|{}|]{}{}", "SO", url, username, password, createSimpleHeaders(), MEDIA_TYPE,
- LINE_SEPARATOR, requestJson);
+ NetLoggerUtil.getNetworkLogger().info("[OUT|{}|{}|{}|{}|{}|{}|]{}{}", "SO", url, username, password,
+ createSimpleHeaders(), MEDIA_TYPE, LINE_SEPARATOR, requestJson);
Pair<Integer, String> httpResponse =
restManager.post(url, username, password, createSimpleHeaders(), MEDIA_TYPE, requestJson);
@@ -183,13 +184,13 @@ public final class SoManager {
.equals(SoOperationType.SCALE_OUT)) {
url = urlBase + "/serviceInstantiation/v7/serviceInstances/" + serviceInstanceId + "/vnfs/"
+ vnfInstanceId + "/vfModules/scaleOut";
- netLogger.info("[OUT|{}|{}|]{}{}", "SO", url, LINE_SEPARATOR, soJson);
+ NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, url, soJson);
httpResponse = restManager.post(url, username, password, createSimpleHeaders(), MEDIA_TYPE, soJson);
} else if (request.getOperationType() != null && request.getOperationType()
.equals(SoOperationType.DELETE_VF_MODULE)) {
url = urlBase + "/serviceInstances/v7/" + serviceInstanceId + "/vnfs/" + vnfInstanceId
+ "/vfModules/" + vfModuleInstanceId;
- netLogger.info("[OUT|{}|{}|]{}{}", "SO", url, LINE_SEPARATOR, soJson);
+ NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, url, soJson);
httpResponse = restManager.delete(url, username, password, createSimpleHeaders(), MEDIA_TYPE, soJson);
} else {
return null;
@@ -252,8 +253,8 @@ public final class SoManager {
}
// Issue a GET to find the current status of our request
- netLogger.info("[OUT|{}|{}|{}|{}|{}|{}|]{}", "SO", urlGet, username, password, createSimpleHeaders(),
- MEDIA_TYPE, LINE_SEPARATOR);
+ NetLoggerUtil.getNetworkLogger().info("[OUT|{}|{}|{}|{}|{}|{}|]{}", "SO", urlGet, username, password,
+ createSimpleHeaders(), MEDIA_TYPE, LINE_SEPARATOR);
Pair<Integer, String> httpResponse = restManager.get(urlGet, username, password, createSimpleHeaders());
// Get our response
@@ -304,7 +305,7 @@ public final class SoManager {
response.setHttpResponseCode(httpResponse.first);
}
- netLogger.info("[IN|{}|{}|]{}{}", "SO", requestUrl, LINE_SEPARATOR, httpResponse.second);
+ NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, requestUrl, httpResponse.second);
if (logger.isDebugEnabled()) {
logger.debug("***** Response to SO Request to URL {}:", requestUrl);
diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcManager.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcManager.java
index 0acab8b05..7cea2f181 100644
--- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcManager.java
+++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcManager.java
@@ -26,7 +26,9 @@ import java.util.HashMap;
import java.util.Map;
import org.drools.core.WorkingMemory;
-import org.onap.policy.common.utils.slf4j.LoggerFactoryWrapper;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.rest.RestManager;
import org.onap.policy.rest.RestManager.Pair;
@@ -35,7 +37,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class VfcManager implements Runnable {
- private static final String SYSTEM_LS = System.lineSeparator();
private String vfcUrlBase;
private String username;
@@ -43,7 +44,6 @@ public final class VfcManager implements Runnable {
private VfcRequest vfcRequest;
private WorkingMemory workingMem;
private static final Logger logger = LoggerFactory.getLogger(VfcManager.class);
- private static final Logger netLogger = LoggerFactoryWrapper.getNetworkLogger();
// The REST manager used for processing REST calls for this VFC manager
private RestManager restManager;
@@ -95,7 +95,7 @@ public final class VfcManager implements Runnable {
String vfcUrl = vfcUrlBase + "/ns/" + vfcRequest.getNsInstanceId() + "/heal";
try {
String vfcRequestJson = Serialization.gsonPretty.toJson(vfcRequest);
- netLogger.info("[OUT|{}|{}|]{}{}", "VFC", vfcUrl, SYSTEM_LS, vfcRequestJson);
+ NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, vfcUrl, vfcRequestJson);
httpDetails = restManager.post(vfcUrl, username, password, headers, "application/json", vfcRequestJson);
} catch (Exception e) {
@@ -116,7 +116,7 @@ public final class VfcManager implements Runnable {
try {
VfcResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, VfcResponse.class);
- netLogger.info("[IN|{}|{}|]{}{}", "VFC", vfcUrl, SYSTEM_LS, httpDetails.second);
+ NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, vfcUrl, httpDetails.second);
String body = Serialization.gsonPretty.toJson(response);
logger.debug("Response to VFC Heal post:");
logger.debug(body);
@@ -128,10 +128,10 @@ public final class VfcManager implements Runnable {
VfcResponse responseGet = null;
while (attemptsLeft-- > 0) {
- netLogger.info("[OUT|{}|{}|]", "VFC", urlGet);
+ NetLoggerUtil.getNetworkLogger().info("[OUT|{}|{}|]", "VFC", urlGet);
Pair<Integer, String> httpDetailsGet = restManager.get(urlGet, username, password, headers);
responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.second, VfcResponse.class);
- netLogger.info("[IN|{}|{}|]{}{}", "VFC", urlGet, SYSTEM_LS, httpDetailsGet.second);
+ NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, vfcUrl, httpDetailsGet.second);
responseGet.setRequestId(vfcRequest.getRequestId().toString());
body = Serialization.gsonPretty.toJson(responseGet);
logger.debug("Response to VFC Heal get:");
diff --git a/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelperEmbedded.java b/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelperEmbedded.java
index 075482ee2..d51a862db 100644
--- a/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelperEmbedded.java
+++ b/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelperEmbedded.java
@@ -48,7 +48,9 @@ import java.util.UUID;
import org.apache.commons.io.IOUtils;
import org.apache.http.entity.ContentType;
import org.json.JSONObject;
-import org.onap.policy.common.utils.slf4j.LoggerFactoryWrapper;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.guard.PolicyGuardResponse;
import org.onap.policy.guard.PolicyGuardXacmlRequestAttributes;
@@ -59,10 +61,7 @@ import org.slf4j.LoggerFactory;
public class PolicyGuardXacmlHelperEmbedded {
private static final Logger logger = LoggerFactory.getLogger(PolicyGuardXacmlHelperEmbedded.class);
- private static final Logger netLogger = LoggerFactoryWrapper.getNetworkLogger();
- // Constant for the system line separator
- private static final String SYSTEM_LS = System.lineSeparator();
private String propfile;
private UrlEntry[] restUrls = null;
private int restUrlIndex = 0;
@@ -128,10 +127,10 @@ public class PolicyGuardXacmlHelperEmbedded {
//
UrlEntry urlEntry = restUrls[restUrlIndex];
String jsonRequestString = jsonReq.toString();
- netLogger.info("[OUT|{}|{}|]{}{}", "GUARD", urlEntry.restUrl, SYSTEM_LS, jsonRequestString);
+ NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, urlEntry.restUrl.toString(), jsonRequestString);
response = callRestfulPdp(new ByteArrayInputStream(jsonReq.toString().getBytes()), urlEntry.restUrl,
urlEntry.authorization, urlEntry.clientAuth, urlEntry.environment);
- netLogger.info("[IN|{}|{}|]{}{}", "GUARD", urlEntry.restUrl, SYSTEM_LS, response);
+ NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, urlEntry.restUrl.toString(), response);
} catch (Exception e) {
logger.error("Error in sending RESTful request", e);
}