aboutsummaryrefslogtreecommitdiffstats
path: root/cps-service/src
diff options
context:
space:
mode:
Diffstat (limited to 'cps-service/src')
-rw-r--r--cps-service/src/main/java/org/onap/cps/cache/HazelcastCacheConfig.java12
-rw-r--r--cps-service/src/test/groovy/org/onap/cps/cache/HazelcastCacheConfigSpec.groovy13
2 files changed, 22 insertions, 3 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/cache/HazelcastCacheConfig.java b/cps-service/src/main/java/org/onap/cps/cache/HazelcastCacheConfig.java
index 405e6e2a88..067191b5a5 100644
--- a/cps-service/src/main/java/org/onap/cps/cache/HazelcastCacheConfig.java
+++ b/cps-service/src/main/java/org/onap/cps/cache/HazelcastCacheConfig.java
@@ -24,6 +24,7 @@ import com.hazelcast.config.Config;
import com.hazelcast.config.MapConfig;
import com.hazelcast.config.NamedConfig;
import com.hazelcast.config.QueueConfig;
+import com.hazelcast.config.SetConfig;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import lombok.extern.slf4j.Slf4j;
@@ -57,6 +58,10 @@ public class HazelcastCacheConfig {
if (namedConfig instanceof QueueConfig) {
config.addQueueConfig((QueueConfig) namedConfig);
}
+ if (namedConfig instanceof SetConfig) {
+ config.addSetConfig((SetConfig) namedConfig);
+ }
+
config.setClusterName(clusterName);
updateDiscoveryMode(config);
return config;
@@ -76,6 +81,13 @@ public class HazelcastCacheConfig {
return commonQueueConfig;
}
+ protected static SetConfig createSetConfig(final String configName) {
+ final SetConfig commonSetConfig = new SetConfig(configName);
+ commonSetConfig.setBackupCount(1);
+ commonSetConfig.setAsyncBackupCount(1);
+ return commonSetConfig;
+ }
+
protected void updateDiscoveryMode(final Config config) {
if (cacheKubernetesEnabled) {
log.info("Enabling kubernetes mode with service-name : {}", cacheKubernetesServiceName);
diff --git a/cps-service/src/test/groovy/org/onap/cps/cache/HazelcastCacheConfigSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/cache/HazelcastCacheConfigSpec.groovy
index 8efd48547e..415e9fd496 100644
--- a/cps-service/src/test/groovy/org/onap/cps/cache/HazelcastCacheConfigSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/cache/HazelcastCacheConfigSpec.groovy
@@ -45,10 +45,17 @@ class HazelcastCacheConfigSpec extends Specification {
} else {
assert result.config.queueConfigs.isEmpty()
}
+ and: 'if applicable it has a set config with the expected name'
+ if (expectSetConfig) {
+ assert result.config.setConfigs.values()[0].name == 'my set config'
+ } else {
+ assert result.config.setConfigs.isEmpty()
+ }
where: 'the following configs are used'
- scenario | config || expectMapConfig | expectQueueConfig
- 'Map Config' | HazelcastCacheConfig.createMapConfig('my map config') || true | false
- 'Queue Config' | HazelcastCacheConfig.createQueueConfig('my queue config') || false | true
+ scenario | config || expectMapConfig | expectQueueConfig | expectSetConfig
+ 'Map Config' | HazelcastCacheConfig.createMapConfig('my map config') || true | false | false
+ 'Queue Config' | HazelcastCacheConfig.createQueueConfig('my queue config') || false | true | false
+ 'Set Config' | HazelcastCacheConfig.createSetConfig('my set config') || false | false | true
}
}