Expose hazelcast cluster info 49/136649/3
authormpriyank <priyank.maheshwari@est.tech>
Mon, 27 Nov 2023 13:53:12 +0000 (13:53 +0000)
committermpriyank <priyank.maheshwari@est.tech>
Mon, 27 Nov 2023 16:53:28 +0000 (16:53 +0000)
- 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 <priyank.maheshwari@est.tech>
cps-service/src/main/java/org/onap/cps/cache/HazelcastCacheConfig.java
cps-service/src/test/groovy/org/onap/cps/cache/HazelcastCacheConfigSpec.groovy
docs/admin-guide.rst
docs/deployment.rst

index 0efabfd..660176d 100644 (file)
@@ -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);
+    }
+
 }
index 415e9fd..022cd74 100644 (file)
@@ -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])
+    }
+
 }
index b58e740..1c4d745 100644 (file)
@@ -192,6 +192,18 @@ Prometheus Metrics can be checked at the following endpoint
 
     http://<cps-component-service-name>:8080/actuator/prometheus
 
+Hazelcast
+---------
+
+Hazelcast cluster state and health check can be seen using the below endpoints
+
+.. code::
+
+    http://<cps-component-service-name>:<member-port>/hazelcast/health
+    http://<cps-component-service-name>:<member-port>/hazelcast/rest/management/cluster/state
+
+See also : :ref:`cps_common_distributed_datastructures`
+
 Naming Validation
 -----------------
 
index 59e2ada..eb5804e 100644 (file)
@@ -296,6 +296,9 @@ CPS-Core Docker Installation
 CPS-Core can also be installed in a docker environment. Latest `docker-compose <https://github.com/onap/cps/blob/master/docker-compose/docker-compose.yml>`_ is included in the repo to start all the relevant services.
 The latest instructions are covered in the `README <https://github.com/onap/cps/blob/master/docker-compose/README.md>`_.
 
+.. 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
 ============================================