summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ncmp-service/src/main/java')
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/embeddedcache/SynchronizationCacheConfig.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/embeddedcache/SynchronizationCacheConfig.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/embeddedcache/SynchronizationCacheConfig.java
index ac2bd45969..0b67266375 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/embeddedcache/SynchronizationCacheConfig.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/embeddedcache/SynchronizationCacheConfig.java
@@ -28,19 +28,28 @@ import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.map.IMap;
import java.util.concurrent.BlockingQueue;
+import lombok.extern.slf4j.Slf4j;
import org.onap.cps.spi.model.DataNode;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* Core infrastructure of the hazelcast distributed caches for Module Sync and Data Sync use cases.
*/
+@Slf4j
@Configuration
public class SynchronizationCacheConfig {
public static final int MODULE_SYNC_STARTED_TTL_SECS = 600;
public static final int DATA_SYNC_SEMAPHORE_TTL_SECS = 1800;
+ @Value("${hazelcast.mode.kubernetes.enabled}")
+ private boolean cacheKubernetesEnabled;
+
+ @Value("${hazelcast.mode.kubernetes.service-name}")
+ private String cacheKubernetesServiceName;
+
private static final QueueConfig commonQueueConfig = createQueueConfig();
private static final MapConfig moduleSyncStartedConfig = createMapConfig("moduleSyncStartedConfig");
private static final MapConfig dataSyncSemaphoresConfig = createMapConfig("dataSyncSemaphoresConfig");
@@ -92,6 +101,7 @@ public class SynchronizationCacheConfig {
config.addQueueConfig((QueueConfig) namedConfig);
}
config.setClusterName("synchronization-caches");
+ updateDiscoveryMode(config);
return config;
}
@@ -109,4 +119,12 @@ public class SynchronizationCacheConfig {
return mapConfig;
}
+ private void updateDiscoveryMode(final Config config) {
+ if (cacheKubernetesEnabled) {
+ log.info("Enabling kubernetes mode with service-name : {}", cacheKubernetesServiceName);
+ config.getNetworkConfig().getJoin().getKubernetesConfig().setEnabled(true)
+ .setProperty("service-name", cacheKubernetesServiceName);
+ }
+ }
+
}