From: mpriyank Date: Mon, 27 Nov 2023 13:53:12 +0000 (+0000) Subject: Expose hazelcast cluster info X-Git-Tag: 3.4.1~27^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;ds=sidebyside;h=1ae90809b3d3ccdbd0669145d0e4f9f56d7371cd;p=cps.git Expose hazelcast cluster info - exposing hazelcast cluster and health related rest endpoints to be used in the testware - added test to support it - also added RTD docs Issue-ID: CPS-1980 Change-Id: I926013bee05603a43050b861f677885a2511fffc Signed-off-by: mpriyank --- 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 0efabfd3b..660176d5e 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.RestEndpointGroup; import com.hazelcast.config.SetConfig; import com.hazelcast.core.Hazelcast; import com.hazelcast.core.HazelcastInstance; @@ -64,6 +65,7 @@ public class HazelcastCacheConfig { config.setClusterName(clusterName); config.setClassLoader(org.onap.cps.spi.model.Dataspace.class.getClassLoader()); + exposeClusterInformation(config); updateDiscoveryMode(config); return config; } @@ -97,4 +99,9 @@ public class HazelcastCacheConfig { } } + protected void exposeClusterInformation(final Config config) { + config.getNetworkConfig().getRestApiConfig().setEnabled(true) + .enableGroups(RestEndpointGroup.HEALTH_CHECK, RestEndpointGroup.CLUSTER_READ); + } + } 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 415e9fd49..022cd74ea 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 @@ -20,6 +20,8 @@ package org.onap.cps.cache +import com.hazelcast.config.Config +import com.hazelcast.config.RestEndpointGroup import spock.lang.Specification class HazelcastCacheConfigSpec extends Specification { @@ -58,4 +60,17 @@ class HazelcastCacheConfigSpec extends Specification { 'Set Config' | HazelcastCacheConfig.createSetConfig('my set config') || false | false | true } + def 'Verify Hazelcast Cluster Information'() { + given: 'a test configuration' + def testConfig = new Config() + when: 'cluster information is exposed' + objectUnderTest.exposeClusterInformation(testConfig) + then: 'REST api configs are enabled' + assert testConfig.networkConfig.restApiConfig.enabled + and: 'only health check and cluster read are enabled' + def enabledGroups = testConfig.networkConfig.restApiConfig.enabledGroups + assert enabledGroups.size() == 2 + assert enabledGroups.containsAll([RestEndpointGroup.CLUSTER_READ, RestEndpointGroup.HEALTH_CHECK]) + } + } diff --git a/docs/admin-guide.rst b/docs/admin-guide.rst index b58e74033..1c4d7455f 100644 --- a/docs/admin-guide.rst +++ b/docs/admin-guide.rst @@ -192,6 +192,18 @@ Prometheus Metrics can be checked at the following endpoint http://:8080/actuator/prometheus +Hazelcast +--------- + +Hazelcast cluster state and health check can be seen using the below endpoints + +.. code:: + + http://:/hazelcast/health + http://:/hazelcast/rest/management/cluster/state + +See also : :ref:`cps_common_distributed_datastructures` + Naming Validation ----------------- diff --git a/docs/deployment.rst b/docs/deployment.rst index 59e2adafe..eb5804e5b 100644 --- a/docs/deployment.rst +++ b/docs/deployment.rst @@ -296,6 +296,9 @@ CPS-Core Docker Installation CPS-Core can also be installed in a docker environment. Latest `docker-compose `_ is included in the repo to start all the relevant services. The latest instructions are covered in the `README `_. +.. Below Label is used by documentation for other CPS components to link here, do not remove even if it gives a warning +.. _cps_common_distributed_datastructures: + CPS-Core and NCMP Distributed Datastructures ============================================