How do you stop and shutdown a hazelcast cluster? My observation from testing is that whenever a node ist stopped by HazelcastInstance#shutdown() the cluster tries to re-balance or backup the data. How can I first "stop" the cluster and then shut it down? (Or is my observation wrong?)
Now you retrieve information about your cluster's health status (member state, cluster state, cluster size, etc.) by launching http://<your member's host IP>:5701/hazelcast/health on your preferred browser.
Monitoring Hazelcast via REST API To monitor health of the cluster or member state via REST API, one has to enable REST API based communication to the members. This can be done by configuration and also programmatically. This displays that there is 1 member in our cluster and it is Active.
You can use isClusterSafe as in below example :
public class ShutdownCluster {
public static void main(String[] args) throws Exception {
HazelcastInstance member1 = Hazelcast.newHazelcastInstance();
HazelcastInstance member2 = Hazelcast.newHazelcastInstance();
HazelcastInstance member3 = Hazelcast.newHazelcastInstance();
if(member1.getPartitionService().isClusterSafe()) {
IExecutorService executorService = member1.getExecutorService(ShutdownCluster.class.getName());
executorService.executeOnAllMembers(new ShutdownMember());
}
}
private static class ShutdownMember implements Runnable, HazelcastInstanceAware, Serializable {
private HazelcastInstance node;
@Override
public void run() {
node.getLifecycleService().shutdown();
}
@Override
public void setHazelcastInstance(HazelcastInstance node) {
this.node = node;
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With