aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be')
-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();
}