Search in sources :

Example 6 with Node

use of com.hazelcast.instance.Node 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 7 with Node

use of com.hazelcast.instance.Node 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 8 with Node

use of com.hazelcast.instance.Node in project hazelcast by hazelcast.

the class AuthenticationFailureOperation method run.

@Override
public void run() {
    final NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    final Node node = nodeEngine.getNode();
    final ILogger logger = nodeEngine.getLogger("com.hazelcast.security");
    logger.severe("Node could not join cluster. Authentication failed on master node! Node is going to shutdown now!");
    node.shutdown(true);
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Node(com.hazelcast.instance.Node) ILogger(com.hazelcast.logging.ILogger)

Example 9 with Node

use of com.hazelcast.instance.Node in project hazelcast by hazelcast.

the class ConfigMismatchOperation method run.

@Override
public void run() {
    NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    Node node = nodeEngine.getNode();
    ILogger logger = nodeEngine.getLogger("com.hazelcast.cluster");
    logger.severe("Node could not join cluster. A Configuration mismatch was detected: " + msg + " Node is going to shutdown now!");
    node.shutdown(true);
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Node(com.hazelcast.instance.Node) ILogger(com.hazelcast.logging.ILogger)

Example 10 with Node

use of com.hazelcast.instance.Node in project hazelcast by hazelcast.

the class MergeClustersOperation method run.

@Override
public void run() {
    final Address caller = getCallerAddress();
    final NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    final Node node = nodeEngine.getNode();
    final Address masterAddress = node.getMasterAddress();
    final ILogger logger = node.loggingService.getLogger(this.getClass().getName());
    boolean local = caller == null;
    if (!local && !caller.equals(masterAddress)) {
        logger.warning("Ignoring merge instruction sent from non-master endpoint: " + caller);
        return;
    }
    logger.warning(node.getThisAddress() + " is merging to " + newTargetAddress + ", because: instructed by master " + masterAddress);
    nodeEngine.getExecutionService().execute(ExecutionService.SYSTEM_EXECUTOR, new Runnable() {

        @Override
        public void run() {
            node.getClusterService().merge(newTargetAddress);
        }
    });
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Address(com.hazelcast.nio.Address) Node(com.hazelcast.instance.Node) ILogger(com.hazelcast.logging.ILogger)

Aggregations

Node (com.hazelcast.instance.Node)131 HazelcastInstance (com.hazelcast.core.HazelcastInstance)60 Test (org.junit.Test)50 QuickTest (com.hazelcast.test.annotation.QuickTest)45 ParallelTest (com.hazelcast.test.annotation.ParallelTest)42 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)21 ClientEventRegistration (com.hazelcast.client.spi.impl.listener.ClientEventRegistration)18 Address (com.hazelcast.nio.Address)17 Config (com.hazelcast.config.Config)14 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)13 ILogger (com.hazelcast.logging.ILogger)10 Data (com.hazelcast.nio.serialization.Data)10 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)10 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)9 StringUtil.bytesToString (com.hazelcast.util.StringUtil.bytesToString)8 CountDownLatch (java.util.concurrent.CountDownLatch)8 ClusterService (com.hazelcast.internal.cluster.ClusterService)7 SerializationService (com.hazelcast.spi.serialization.SerializationService)7 ItemListener (com.hazelcast.core.ItemListener)6 Operation (com.hazelcast.spi.Operation)6