How to stop and turn off the entire cluster of forest stone?

How do you stop and end a forest stone cluster? My observation from testing is that whenever a node stops HazelcastInstance # shutdown (), the cluster tries to rebalance or back up the data. How can I first “stop” a cluster and then close it? (Or is my observation wrong?)

+4
source share
3 answers

You can use isClusterSafe as below:

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;
    }
}
}
+4
source

When testing, I often use Hazelcast.shutdownAll ()

This will destroy all instances.

0
source

.

HazelcastInstance.getLifecycleService().shutdown();
0

Source: https://habr.com/ru/post/1527605/


All Articles