diff options
author | Magnusen, Drew (dm741q) <dm741q@att.com> | 2017-08-02 13:00:23 -0500 |
---|---|---|
committer | Magnusen, Drew (dm741q) <dm741q@att.com> | 2017-08-04 08:02:00 -0500 |
commit | 09ca5f00b5fb88d35987e1922c34cae8469ed79d (patch) | |
tree | 4a91d76e1d51257bf2279e06cf96cbd760ae8e6e /common-logging/src/main/java/org/onap/policy/common/logging/ONAPLoggingContext.java | |
parent | a7ab43dbd252c5bc70e490f4db94940e6985f25a (diff) |
[POLICY-98] Code cleanup for sonar issues.
Modified code in ECOMP-Logging to resolve critical/major sonar issues.
Not all issues were resolved as some guidance needs to be provided for
specific cases.
Restored config/policyLogger.properties file. It was modified by a junit
test.
Change-Id: I49fee98b2497d9d503d81bbbacbb1b416e1058a7
Signed-off-by: Magnusen, Drew (dm741q) <dm741q@att.com>
Diffstat (limited to 'common-logging/src/main/java/org/onap/policy/common/logging/ONAPLoggingContext.java')
-rw-r--r-- | common-logging/src/main/java/org/onap/policy/common/logging/ONAPLoggingContext.java | 56 |
1 files changed, 4 insertions, 52 deletions
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/ONAPLoggingContext.java b/common-logging/src/main/java/org/onap/policy/common/logging/ONAPLoggingContext.java index bbaf2e0e..3932f426 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/ONAPLoggingContext.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/ONAPLoggingContext.java @@ -20,9 +20,6 @@ package org.onap.policy.common.logging; -//import static org.onap.policy.common.logging.eelf.Configuration.TRANSACTION_BEGIN_TIME_STAMP; -//import static org.onap.policy.common.logging.eelf.Configuration.TRANSACTION_ELAPSED_TIME; -//import static org.onap.policy.common.logging.eelf.Configuration.TRANSACTION_END_TIME_STAMP; import java.text.SimpleDateFormat; import java.time.Duration; @@ -88,7 +85,6 @@ public class ONAPLoggingContext { private static LoggingContextFactory.Builder loggingContextBuilder = new LoggingContextFactory.Builder(); protected SharedLoggingContext context = null; -// private long transactionStartTime = 0; private Instant transactionStartTime; private Instant metricStartTime; @@ -132,7 +128,6 @@ public class ONAPLoggingContext { * the duration of the transaction. */ public void transactionStarted() { -// transactionStartTime = System.currentTimeMillis(); transactionStartTime = Instant.now(); setTransactionBeginTimestamp(transactionStartTime); } @@ -154,7 +149,6 @@ public class ONAPLoggingContext { * the duration of the metric. */ public void metricStarted() { -// transactionStartTime = System.currentTimeMillis(); metricStartTime = Instant.now(); setMetricBeginTimestamp(metricStartTime); } @@ -419,32 +413,6 @@ public class ONAPLoggingContext { return context.get(CLASSNAME, ""); } - /** - * Set the value for the data item with key "timer". - * An alternative to calling this method directly is to call - * <code>transactionStarted()</code> at the start of transaction - * processing and <code>transactionEnded()</code> at the end, - * which will compute the time difference in milliseconds - * and store the result as the "timer" value. - * - * @param id - */ -// public void setTimer(Long timer) { -// context.put(TIMER, timer); -// } - -// public void setTimer(Long elapsedtime) { -// String unit = " milliseconds"; -// context.put(TRANSACTION_ELAPSED_TIME, elapsedtime + unit); -// } - - /** - * Get the value for the data item with key "timer" - * @return current value, or 0 if not set - */ -// public long getTimer() { -// return context.get(TRANSACTION_ELAPSED_TIME, 0); -// } /** * Set the value for the data item with key "TransactionBeginTimestamp" @@ -499,16 +467,8 @@ public class ONAPLoggingContext { public void setTransactionElapsedTime(Instant transactionEndTime) { long ns = Duration.between(transactionStartTime, transactionEndTime).toMillis(); - //String unit = " Seconds"; - //if(ns == 1){ - //unit = " Second"; - //} - - //if(ns < 1){ - //ns = Duration.between(transactionStartTime, transactionEndTime).toMillis(); - //unit = " milliseconds"; - //} - context.put(TRANSACTION_ELAPSED_TIME, ns); // + unit); + + context.put(TRANSACTION_ELAPSED_TIME, ns); } /** @@ -572,16 +532,8 @@ public class ONAPLoggingContext { public void setMetricElapsedTime(Instant metricEndTime) { long ns = Duration.between(metricStartTime, metricEndTime).toMillis(); - //String unit = " Seconds"; - //if(ns == 1){ - //unit = " Second"; - //} - - //if(ns < 1){ - //ns = Duration.between(metricStartTime, metricEndTime).toMillis(); - //unit = " milliseconds"; - //} - context.put(METRIC_ELAPSED_TIME, ns); // + unit); + + context.put(METRIC_ELAPSED_TIME, ns); } /** |