Search in sources :

Example 1 with ClusterServiceImpl

use of com.hazelcast.internal.cluster.impl.ClusterServiceImpl in project hazelcast by hazelcast.

the class ShutdownNodeOperation method run.

@Override
public void run() {
    final ClusterServiceImpl clusterService = getService();
    final ILogger logger = getLogger();
    final ClusterState clusterState = clusterService.getClusterState();
    if (clusterState == ClusterState.PASSIVE) {
        final NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
        if (nodeEngine.isRunning()) {
            logger.info("Shutting down node in cluster passive state. Requested by: " + getCallerAddress());
            new Thread(new Runnable() {

                @Override
                public void run() {
                    final Node node = nodeEngine.getNode();
                    node.hazelcastInstance.getLifecycleService().shutdown();
                }
            }, nodeEngine.getHazelcastThreadGroup().getThreadNamePrefix(".clusterShutdown")).start();
        } else {
            logger.info("Node is already shutting down. NodeState: " + nodeEngine.getNode().getState());
        }
    } else {
        logger.severe("Can not shut down node because cluster is in " + clusterState + " state. Requested by: " + getCallerAddress());
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) ClusterState(com.hazelcast.cluster.ClusterState) Node(com.hazelcast.instance.Node) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) ILogger(com.hazelcast.logging.ILogger)

Example 2 with ClusterServiceImpl

use of com.hazelcast.internal.cluster.impl.ClusterServiceImpl in project hazelcast by hazelcast.

the class SplitBrainMergeValidationOperation method afterRun.

@Override
public void afterRun() throws Exception {
    if (removeCaller) {
        ClusterServiceImpl service = getService();
        Address caller = getCallerAddress();
        service.removeAddress(caller, "Removing " + caller + ", since it thinks it's already split from this cluster " + "and looking to merge.");
    }
}
Also used : Address(com.hazelcast.nio.Address) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl)

Example 3 with ClusterServiceImpl

use of com.hazelcast.internal.cluster.impl.ClusterServiceImpl in project hazelcast by hazelcast.

the class SplitBrainMergeValidationOperation method run.

@Override
public void run() {
    ClusterServiceImpl service = getService();
    NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    Node node = nodeEngine.getNode();
    if (!preCheck(node)) {
        return;
    }
    if (!masterCheck(node)) {
        return;
    }
    if (request != null) {
        ILogger logger = getLogger();
        try {
            if (service.getClusterJoinManager().validateJoinMessage(request)) {
                // surprise to users and may cause unexpected issues.
                if (service.getClusterVersion().equals(request.getClusterVersion())) {
                    response = node.createSplitBrainJoinMessage();
                } else {
                    logger.info("Join check from " + getCallerAddress() + " failed validation due to incompatible version," + "remote cluster version is " + request.getClusterVersion() + ", this cluster is " + service.getClusterVersion());
                }
            }
            if (logger.isFineEnabled()) {
                logger.fine("Returning " + response + " to " + getCallerAddress());
            }
        } catch (Exception e) {
            if (logger.isFineEnabled()) {
                logger.fine("Could not validate split-brain join message! -> " + e.getMessage());
            }
        }
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Node(com.hazelcast.instance.Node) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) ILogger(com.hazelcast.logging.ILogger) IOException(java.io.IOException)

Example 4 with ClusterServiceImpl

use of com.hazelcast.internal.cluster.impl.ClusterServiceImpl in project hazelcast by hazelcast.

the class TriggerMemberListPublishOperation method run.

@Override
public void run() throws Exception {
    final ClusterServiceImpl clusterService = getService();
    clusterService.sendMemberListToMember(getCallerAddress());
}
Also used : ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl)

Example 5 with ClusterServiceImpl

use of com.hazelcast.internal.cluster.impl.ClusterServiceImpl in project hazelcast by hazelcast.

the class ChangeClusterStateOperation method run.

@Override
public void run() throws Exception {
    ClusterServiceImpl service = getService();
    ClusterStateManager clusterStateManager = service.getClusterStateManager();
    getLogger().info("Changing cluster state state to " + stateChange + ", Initiator: " + initiator + " transient: " + isTransient);
    clusterStateManager.commitClusterState(stateChange, initiator, txnId, isTransient);
}
Also used : ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) ClusterStateManager(com.hazelcast.internal.cluster.impl.ClusterStateManager)

Aggregations

ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)41 Node (com.hazelcast.instance.Node)13 Address (com.hazelcast.nio.Address)13 ILogger (com.hazelcast.logging.ILogger)9 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)8 ClusterState (com.hazelcast.cluster.ClusterState)6 MemberImpl (com.hazelcast.instance.MemberImpl)5 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 OperationService (com.hazelcast.spi.OperationService)4 Member (com.hazelcast.core.Member)3 MemberLeftException (com.hazelcast.core.MemberLeftException)3 ClusterStateManager (com.hazelcast.internal.cluster.impl.ClusterStateManager)3 Config (com.hazelcast.config.Config)2 InternalPartition (com.hazelcast.internal.partition.InternalPartition)2 Connection (com.hazelcast.nio.Connection)2 Operation (com.hazelcast.spi.Operation)2 InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)2 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)2 ParallelTest (com.hazelcast.test.annotation.ParallelTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2