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 <priyank.maheshwari@est.tech>
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 0efabfd..660176d 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.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 @@
 
         config.setClusterName(clusterName);
         config.setClassLoader(org.onap.cps.spi.model.Dataspace.class.getClassLoader());
+        exposeClusterInformation(config);
         updateDiscoveryMode(config);
         return config;
     }
@@ -97,4 +99,9 @@
         }
     }
 
+    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 415e9fd..022cd74 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 @@
             '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 b58e740..1c4d745 100644
--- a/docs/admin-guide.rst
+++ b/docs/admin-guide.rst
@@ -192,6 +192,18 @@
 
     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
 -----------------
 
diff --git a/docs/deployment.rst b/docs/deployment.rst
index 59e2ada..eb5804e 100644
--- a/docs/deployment.rst
+++ b/docs/deployment.rst
@@ -296,6 +296,9 @@
 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
 ============================================