diff options
author | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2021-01-09 18:55:15 +0100 |
---|---|---|
committer | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2021-01-09 18:55:15 +0100 |
commit | 8d8221ab72222bae0fe50bfd1e8b4266eec40e11 (patch) | |
tree | 1e9160835ea07764097a582635ba445e4132a620 /connector/src/main | |
parent | 9187a20824ff808d4d1ad235ff8fa32cc03ef744 (diff) | |
download | National_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/src/main')
-rw-r--r-- | connector/src/main/java/at/asitplus/eidas/specific/connector/health/IgniteClusterHealthIndicator.java | 52 | ||||
-rw-r--r-- | connector/src/main/resources/specific_eIDAS_connector.storage.beans.xml | 9 |
2 files changed, 58 insertions, 3 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" |