diff options
author | mpriyank <priyank.maheshwari@est.tech> | 2023-04-24 12:51:24 +0100 |
---|---|---|
committer | mpriyank <priyank.maheshwari@est.tech> | 2023-04-24 17:58:10 +0100 |
commit | d64fa3440d5ed07aa3f35573cfaec5825f002811 (patch) | |
tree | d261c3d8054618bcd5574966d6c9c24419d2e484 /cps-ncmp-service/src/main/java | |
parent | 2de9389a61f0feb37f0bcc22d6269e36dcfbd47c (diff) |
Extend capability of distributed cache
- Extend cache configs to be able to work in stanalone mode as well as
in cluster mode in kubernetes.
- Expose the parameters to enable or disable the feature.
- to make it work in standalone mode autodiscovery config will take care , and
to run it on kubernetes enable the kubernetes option and provide the
service name property.
Issue-ID: CPS-1637
Change-Id: I704c4aa11e65b17b5be80048e4246079014d8bb7
Signed-off-by: mpriyank <priyank.maheshwari@est.tech>
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.java | 18 |
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); + } + } + } |