Search in sources :

Example 1 with ShutdownNodeOperation

use of com.hazelcast.internal.cluster.impl.operations.ShutdownNodeOperation in project hazelcast by hazelcast.

the class ClusterServiceImpl method shutdownNodes.

private void shutdownNodes() {
    final Operation op = new ShutdownNodeOperation();
    logger.info("Sending shutting down operations to all members...");
    Collection<Member> members = getMembers(NON_LOCAL_MEMBER_SELECTOR);
    final long timeout = node.getProperties().getNanos(GroupProperty.CLUSTER_SHUTDOWN_TIMEOUT_SECONDS);
    final long startTime = System.nanoTime();
    while ((System.nanoTime() - startTime) < timeout && !members.isEmpty()) {
        for (Member member : members) {
            nodeEngine.getOperationService().send(op, member.getAddress());
        }
        try {
            Thread.sleep(CLUSTER_SHUTDOWN_SLEEP_DURATION_IN_MILLIS);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            logger.warning("Shutdown sleep interrupted. ", e);
            break;
        }
        members = getMembers(NON_LOCAL_MEMBER_SELECTOR);
    }
    logger.info("Number of other nodes remaining: " + getSize(NON_LOCAL_MEMBER_SELECTOR) + ". Shutting down itself.");
    final HazelcastInstanceImpl hazelcastInstance = node.hazelcastInstance;
    hazelcastInstance.getLifecycleService().shutdown();
}
Also used : HazelcastInstanceImpl(com.hazelcast.instance.HazelcastInstanceImpl) ShutdownNodeOperation(com.hazelcast.internal.cluster.impl.operations.ShutdownNodeOperation) MemberInfoUpdateOperation(com.hazelcast.internal.cluster.impl.operations.MemberInfoUpdateOperation) Operation(com.hazelcast.spi.Operation) TriggerMemberListPublishOperation(com.hazelcast.internal.cluster.impl.operations.TriggerMemberListPublishOperation) MemberRemoveOperation(com.hazelcast.internal.cluster.impl.operations.MemberRemoveOperation) ShutdownNodeOperation(com.hazelcast.internal.cluster.impl.operations.ShutdownNodeOperation) Member(com.hazelcast.core.Member)

Aggregations

Member (com.hazelcast.core.Member)1 HazelcastInstanceImpl (com.hazelcast.instance.HazelcastInstanceImpl)1 MemberInfoUpdateOperation (com.hazelcast.internal.cluster.impl.operations.MemberInfoUpdateOperation)1 MemberRemoveOperation (com.hazelcast.internal.cluster.impl.operations.MemberRemoveOperation)1 ShutdownNodeOperation (com.hazelcast.internal.cluster.impl.operations.ShutdownNodeOperation)1 TriggerMemberListPublishOperation (com.hazelcast.internal.cluster.impl.operations.TriggerMemberListPublishOperation)1 Operation (com.hazelcast.spi.Operation)1