summaryrefslogtreecommitdiffstats
path: root/aai-core
diff options
context:
space:
mode:
authorVenkata Harish K Kajur <vk250x@att.com>2017-11-27 17:48:33 -0500
committerVenkata Harish K Kajur <vk250x@att.com>2017-11-28 02:05:02 -0500
commit7877b6a1818c463fa50418cd72787430fadb3505 (patch)
treea28f21dc2bdc039d12761cd64961a3c133cdc883 /aai-core
parentdd6d9048332c71716ef24b2cfc8ce93b02139a2a (diff)
Add tunnel bandwidth vendor and allow max bandwith
Issue-ID: AAI-516 Change-Id: I1aa18b9b1237c4696fbbdd88f5c889bf6a51d2ec Signed-off-by: Venkata Harish K Kajur <vk250x@att.com>
Diffstat (limited to 'aai-core')
-rw-r--r--aai-core/src/main/java/org/onap/aai/logging/LoggingContext.java61
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/AAIConstants.java4
2 files changed, 55 insertions, 10 deletions
diff --git a/aai-core/src/main/java/org/onap/aai/logging/LoggingContext.java b/aai-core/src/main/java/org/onap/aai/logging/LoggingContext.java
index 1e61c659..7d9dcce5 100644
--- a/aai-core/src/main/java/org/onap/aai/logging/LoggingContext.java
+++ b/aai-core/src/main/java/org/onap/aai/logging/LoggingContext.java
@@ -48,7 +48,16 @@ public class LoggingContext {
private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(LoggingContext.class);
private static final String PREVIOUS_CONTEXTS_KEY = "_PREVIOUS_CONTEXTS";
-
+
+ //Response codes from ECOMP Logging Guidelines
+ public static final String SUCCESS = "0";
+ public static final String PERMISSION_ERROR = "100";
+ public static final String AVAILABILITY_TIMEOUT_ERROR = "200";
+ public static final String DATA_ERROR = "200";
+ public static final String SCHEMA_ERROR = "400";
+ public static final String BUSINESS_PROCESS_ERROR = "500";
+ public static final String UNKNOWN_ERROR = "900";
+
//ECOMP Specific Log Event Fields
public static enum LoggingField {
START_TIME("startTime"),
@@ -75,7 +84,7 @@ public class LoggingContext {
//ECOMP Specific Metric Log Event Fields
TARGET_ENTITY("targetEntity"),
-
+ TARGET_SERVICE_NAME("targetServiceName"),
//A&AI Specific Log Event Fields
COMPONENT("component"),
STOP_WATCH_START("stopWatchStart");
@@ -99,7 +108,7 @@ public class LoggingContext {
LoggingContext.serverIpAddress();
}
- private static void startTime() {
+ public static void startTime() {
MDC.put(LoggingField.START_TIME.toString(), LogFormatTools.getCurrentDateTime());
}
@@ -115,8 +124,7 @@ public class LoggingContext {
MDC.put(LoggingField.REQUEST_ID.toString(), requestId.toString());
}
- public static void requestId(String requestId) throws AAIException {
-
+ public static void requestId(String requestId) {
try {
if(requestId == null){
throw new IllegalArgumentException();
@@ -129,7 +137,15 @@ public class LoggingContext {
} catch (IllegalArgumentException e) {
final UUID generatedRequestUuid = UUID.randomUUID();
MDC.put(LoggingField.REQUEST_ID.toString(), generatedRequestUuid.toString());
- LOGGER.warn("Unable to use UUID " + requestId + " (Not formatted properly). Using generated UUID=" + generatedRequestUuid);
+ LoggingContext.save();
+ AAIException ex = new AAIException("AAI_7405", e);
+ String responseCode = Integer.toString(ex.getErrorObject().getHTTPResponseCode().getStatusCode());
+ LoggingContext.responseCode(responseCode);
+
+ LOGGER.warn("Unable to use UUID " + requestId + " (Not formatted properly). Using generated UUID="
+ + generatedRequestUuid);
+ LoggingContext.restore();
+
}
}
@@ -177,6 +193,10 @@ public class LoggingContext {
MDC.put(LoggingField.SEVERITY.toString(), String.valueOf(severity));
}
+ public static void successStatusFields() {
+ responseCode(SUCCESS);
+ statusCode(LoggingContext.StatusCode.COMPLETE);
+ }
private static void serverIpAddress() {
try {
MDC.put(LoggingField.SERVER_IP_ADDRESS.toString(), InetAddress.getLocalHost().getHostAddress());
@@ -247,6 +267,17 @@ public class LoggingContext {
MDC.put(LoggingField.TARGET_ENTITY.toString(), targetEntity);
}
+ public static void targetServiceName(String targetServiceName) {
+ MDC.put(LoggingField.TARGET_SERVICE_NAME.toString(), targetServiceName);
+ }
+
+ public static boolean isStopWatchStarted() {
+ final String rawStopWatchStart = MDC.get(LoggingField.STOP_WATCH_START.toString());
+ if (rawStopWatchStart == null) {
+ return false;
+ }
+ return true;
+ }
public static void stopWatchStart() {
MDC.put(LoggingField.STOP_WATCH_START.toString(), String.valueOf(System.nanoTime()));
}
@@ -328,10 +359,12 @@ public class LoggingContext {
@SuppressWarnings("unchecked")
final Iterator<String> keys = previousContext.keys();
-
+ boolean foundElapsedTime = false;
while (keys.hasNext()) {
final String key = keys.next();
-
+ if (LoggingField.ELAPSED_TIME.toString().equals(key)) {
+ foundElapsedTime = true;
+ }
try {
MDC.put(key, previousContext.getString(key));
} catch (JSONException e) {
@@ -339,12 +372,22 @@ public class LoggingContext {
// or the value is invalid (they are all strings)
}
}
-
+ if ( !foundElapsedTime ) {
+ MDC.remove(LoggingField.ELAPSED_TIME.toString());
+ }
MDC.put(PREVIOUS_CONTEXTS_KEY, removeLast(previousContexts).toString());
} catch (JSONException e) {
//Ignore, the previousContext is serialized from a JSONObject
}
}
+ public static void restoreIfPossible() {
+ try {
+ restore();
+ }
+ catch (LoggingContextNotExistsException e) {
+ //Ignore
+ }
+ }
/**
* AJSC declares an ancient version of org.json:json in one of the parent POMs of this project.
diff --git a/aai-core/src/main/java/org/onap/aai/util/AAIConstants.java b/aai-core/src/main/java/org/onap/aai/util/AAIConstants.java
index 9b7afe52..9c0eac0e 100644
--- a/aai-core/src/main/java/org/onap/aai/util/AAIConstants.java
+++ b/aai-core/src/main/java/org/onap/aai/util/AAIConstants.java
@@ -38,7 +38,6 @@ public final class AAIConstants {
/** etc directory, relative to AAI_HOME */
public static final String AAI_HOME_ETC = AAI_HOME_BUNDLECONFIG + AAI_FILESEP + "etc" + AAI_FILESEP;
public static final String AAI_HOME_ETC_APP_PROPERTIES = AAI_HOME_ETC + "appprops" + AAI_FILESEP;
- public static final String AAI_V2_OUTPUT_TRANSFORMS = AAIConstants.AAI_HOME_ETC_APP_PROPERTIES + AAIConstants.AAI_FILESEP + "output" + AAIConstants.AAI_FILESEP;
public static final String AAI_HOME_ETC_AUTH = AAI_HOME_ETC + "auth" + AAI_FILESEP;
public static final String AAI_CONFIG_FILENAME = AAI_HOME_ETC_APP_PROPERTIES + "aaiconfig.properties";
public static final String AAI_AUTH_CONFIG_FILENAME = AAI_HOME_ETC_AUTH + "aai_policy.json";
@@ -142,6 +141,9 @@ public final class AAIConstants {
/** Service description for LRSI */
public static final String AAI_SERVICEDESCRIPTION_LRSI = "aai.servicedescription.lrsi";
+ /** Micro-service Names */
+ public static final String AAI_TRAVERSAL_MS = "aai-traversal";
+ public static final String AAI_RESOURCES_MS = "aai-resources";
/**
* Instantiates a new AAI constants.
*/