aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core
diff options
context:
space:
mode:
authorvempo <vitaliy.emporopulo@amdocs.com>2018-04-04 16:31:11 +0300
committerOren Kleks <orenkle@amdocs.com>2018-04-08 04:45:25 +0000
commit6040ee42d045f4dfaaf29a4cdd9ed93c6f20cff9 (patch)
tree1fbdd5c2f903013348ee9b9f5df0f4d9e5591842 /openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core
parentd6982006c27288936d8b0d9eee18068854036f45 (diff)
Minor improvements in hostname for logging
Minor concurrency and naming improvements. Change-Id: I14dfb6d83dd5b84d5a8bb5cb67eda9f490b0e85a Issue-ID: SDC-772 Signed-off-by: vempo <vitaliy.emporopulo@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core')
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/context/HostAddressCache.java (renamed from openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/context/HostAddress.java)8
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/GlobalContextProvider.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/context/HostAddressCacheTest.java (renamed from openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/context/HostAddressTest.java)8
3 files changed, 10 insertions, 10 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/context/HostAddress.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/context/HostAddressCache.java
index bcfef6ca01..afe2b0b1d1 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/context/HostAddress.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/context/HostAddressCache.java
@@ -29,22 +29,22 @@ import java.net.UnknownHostException;
* @since 26 Mar 2018
*/
@SuppressWarnings({"UseOfSystemOutOrSystemErr", "CallToPrintStackTrace", "squid:S106", "squid:S1148"})
-public class HostAddress {
+public class HostAddressCache {
private static final long DEFAULT_REFRESH_INTERVAL = 60000L; // 1 min
private final long interval;
- private CacheEntry cachedAddress;
+ private volatile CacheEntry cachedAddress;
- public HostAddress() {
+ public HostAddressCache() {
this(DEFAULT_REFRESH_INTERVAL);
}
/**
* Creates a cache for host address with a custom refresh interval.
*/
- public HostAddress(long refreshInterval) {
+ public HostAddressCache(long refreshInterval) {
this.interval = refreshInterval;
this.cachedAddress = new CacheEntry(System.currentTimeMillis(), read());
}
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/GlobalContextProvider.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/GlobalContextProvider.java
index 5f2963ec40..97cac2e9ca 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/GlobalContextProvider.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/GlobalContextProvider.java
@@ -19,7 +19,7 @@ package org.openecomp.sdc.logging.slf4j;
import java.net.InetAddress;
import java.util.EnumMap;
import java.util.Map;
-import org.openecomp.sdc.logging.context.HostAddress;
+import org.openecomp.sdc.logging.context.HostAddressCache;
import org.openecomp.sdc.logging.context.InstanceId;
/**
@@ -30,7 +30,7 @@ import org.openecomp.sdc.logging.context.InstanceId;
*/
class GlobalContextProvider implements ContextProvider {
- private static final HostAddress HOST_ADDRESS_CACHE = new HostAddress();
+ private static final HostAddressCache HOST_ADDRESS_CACHE = new HostAddressCache();
@Override
public Map<ContextField, String> values() {
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/context/HostAddressTest.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/context/HostAddressCacheTest.java
index 319bf19dcc..6d7a636840 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/context/HostAddressTest.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/context/HostAddressCacheTest.java
@@ -33,17 +33,17 @@ import org.testng.annotations.Test;
* @since 28 Mar 2018
*/
@PrepareForTest(InetAddress.class)
-public class HostAddressTest extends PowerMockTestCase {
+public class HostAddressCacheTest extends PowerMockTestCase {
@Test
public void hostAddressIsAlwaysPopulated() {
- assertNotNull(new HostAddress().get());
+ assertNotNull(new HostAddressCache().get());
}
@Test
public void cachedAddressRemainsTheSameWhenGotWithingRefreshInterval() throws UnknownHostException {
mockInetAddress(1);
- HostAddress addressCache = new HostAddress(1000);
+ HostAddressCache addressCache = new HostAddressCache(1000);
addressCache.get();
addressCache.get();
}
@@ -51,7 +51,7 @@ public class HostAddressTest extends PowerMockTestCase {
@Test
public void cachedAddressReplacedWhenGotAfterRefreshInterval() throws UnknownHostException {
mockInetAddress(2);
- HostAddress addressCache = new HostAddress(-1);
+ HostAddressCache addressCache = new HostAddressCache(-1);
addressCache.get();
addressCache.get();
}