aboutsummaryrefslogtreecommitdiff
path: root/connector
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2021-01-09 18:55:15 +0100
committerThomas Lenz <thomas.lenz@egiz.gv.at>2021-01-09 18:55:15 +0100
commit8d8221ab72222bae0fe50bfd1e8b4266eec40e11 (patch)
tree1e9160835ea07764097a582635ba445e4132a620 /connector
parent9187a20824ff808d4d1ad235ff8fa32cc03ef744 (diff)
downloadNational_eIDAS_Gateway-8d8221ab72222bae0fe50bfd1e8b4266eec40e11.tar.gz
National_eIDAS_Gateway-8d8221ab72222bae0fe50bfd1e8b4266eec40e11.tar.bz2
National_eIDAS_Gateway-8d8221ab72222bae0fe50bfd1e8b4266eec40e11.zip
add HealthIndicator to check Apache-Ignite cluster-state
Diffstat (limited to 'connector')
-rw-r--r--connector/src/main/java/at/asitplus/eidas/specific/connector/health/IgniteClusterHealthIndicator.java52
-rw-r--r--connector/src/main/resources/specific_eIDAS_connector.storage.beans.xml9
-rw-r--r--connector/src/test/java/at/asitplus/eidas/specific/connector/test/MainClassExecutableModeTest.java2
3 files changed, 59 insertions, 4 deletions
diff --git a/connector/src/main/java/at/asitplus/eidas/specific/connector/health/IgniteClusterHealthIndicator.java b/connector/src/main/java/at/asitplus/eidas/specific/connector/health/IgniteClusterHealthIndicator.java
new file mode 100644
index 00000000..10517565
--- /dev/null
+++ b/connector/src/main/java/at/asitplus/eidas/specific/connector/health/IgniteClusterHealthIndicator.java
@@ -0,0 +1,52 @@
+package at.asitplus.eidas.specific.connector.health;
+
+import org.apache.ignite.Ignite;
+import org.springframework.boot.actuate.health.Health;
+import org.springframework.boot.actuate.health.HealthIndicator;
+
+import eu.eidas.auth.cache.IgniteInstanceInitializerSpecificCommunication;
+import lombok.Setter;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * HealthCheck that validate Nodes in Apache-Ignite Cluster.
+ *
+ * @author tlenz
+ *
+ */
+@Slf4j
+public class IgniteClusterHealthIndicator implements HealthIndicator {
+
+ @Setter
+ protected IgniteInstanceInitializerSpecificCommunication igniteInstanceInitializerSpecificCommunication;
+
+ @Override
+ public Health health() {
+ final Ignite instance = igniteInstanceInitializerSpecificCommunication.getInstance();
+
+ // check if Apache Ignite cluster is active
+ if (!instance.cluster().active()) {
+ return Health.outOfService().build();
+
+ }
+
+ final Health.Builder healthBuilder;
+ // Status UP requires more than 1 node because MS-Connector and eIDAS-Node operations as
+ // micro-services
+ if (instance.cluster().nodes().size() > 1) {
+ healthBuilder = Health.up();
+
+ } else {
+ // Something looks wrong if only a single node was found because MS-Connector and eIDAS-Node
+ // operations as micro-services
+ healthBuilder = Health.outOfService();
+
+ }
+
+ healthBuilder.withDetail("#Nodes", instance.cluster().nodes().size());
+ log.trace("Ignite state. #Nodes: {}", instance.cluster().nodes().size());
+ return healthBuilder.build();
+
+ }
+
+}
diff --git a/connector/src/main/resources/specific_eIDAS_connector.storage.beans.xml b/connector/src/main/resources/specific_eIDAS_connector.storage.beans.xml
index 08c7b672..2e4d1742 100644
--- a/connector/src/main/resources/specific_eIDAS_connector.storage.beans.xml
+++ b/connector/src/main/resources/specific_eIDAS_connector.storage.beans.xml
@@ -27,12 +27,15 @@
<bean id="msNodeCacheImpl"
class="eu.eidas.auth.cache.ConcurrentCacheServiceIgniteSpecificCommunicationImpl">
- <property
- name="igniteInstanceInitializerSpecificCommunication"
- ref="eidasIgniteInstanceInitializerSpecificCommunication" />
+ <property name="igniteInstanceInitializerSpecificCommunication" ref="eidasIgniteInstanceInitializerSpecificCommunication" />
<property name="cacheName" value="msConnectorCache" />
</bean>
+ <bean id="IgniteClusterState"
+ class="at.asitplus.eidas.specific.connector.health.IgniteClusterHealthIndicator">
+ <property name="igniteInstanceInitializerSpecificCommunication" ref="eidasIgniteInstanceInitializerSpecificCommunication" />
+ </bean>
+
<!-- bean id="defaultHazelcastInstance" class="java.lang.String"> <constructor-arg
value="eidasHazelcastInstance"/> </bean> <bean id="eidasHazelcastInstanceInitializer"
diff --git a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/MainClassExecutableModeTest.java b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/MainClassExecutableModeTest.java
index 9f4088f2..86df55df 100644
--- a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/MainClassExecutableModeTest.java
+++ b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/MainClassExecutableModeTest.java
@@ -106,7 +106,7 @@ public class MainClassExecutableModeTest {
final HttpUriRequest httpGetHealth = new HttpGet("http://localhost:8080/ms_connector/actuator/health");
final CloseableHttpResponse httpRespHealth = client.execute(httpGetHealth);
- Assert.assertEquals("http statusCode", 200, httpRespHealth.getStatusLine().getStatusCode());
+ Assert.assertEquals("http statusCode", 503, httpRespHealth.getStatusLine().getStatusCode());
}