Search in sources :

Example 26 with Node

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

the class MockJoiner method lookupJoinAddress.

private Address lookupJoinAddress() {
    Node foundNode = findAliveNode();
    if (foundNode == null) {
        logger.fine("Picking this node as master, no other running node has been detected.");
        return node.getThisAddress();
    }
    logger.fine("Found alive node. Will try to connect to " + foundNode.getThisAddress());
    return foundNode.getThisAddress();
}
Also used : Node(com.hazelcast.instance.Node)

Example 27 with Node

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

the class MockJoiner method findAliveNode.

private Node findAliveNode() {
    Collection<Address> joinAddresses = registry.getJoinAddresses();
    logger.fine("Searching possible addresses for master " + joinAddresses);
    for (Address address : joinAddresses) {
        Node foundNode = registry.getNode(address);
        if (foundNode == null) {
            logger.fine("Node for " + address + " is null.");
            continue;
        }
        verifyInvariant(address.equals(foundNode.getThisAddress()), "The address should be equal to the one in the found node");
        if (foundNode.getThisAddress().equals(node.getThisAddress())) {
            continue;
        }
        if (!foundNode.isRunning()) {
            logger.fine("Node for " + address + " is not running. -> " + foundNode.getState());
            continue;
        }
        if (!foundNode.joined()) {
            logger.fine("Node for " + address + " is not joined yet.");
            continue;
        }
        if (isBlacklisted(address)) {
            logger.fine("Node for " + address + " is blacklisted and should not be joined.");
            continue;
        }
        logger.fine("Found an alive node. Will ask master of " + address);
        return foundNode;
    }
    return null;
}
Also used : Address(com.hazelcast.nio.Address) Node(com.hazelcast.instance.Node)

Example 28 with Node

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

the class SplitBrainTestSupport method unblockCommunicationBetween.

public static void unblockCommunicationBetween(HazelcastInstance h1, HazelcastInstance h2) {
    FirewallingMockConnectionManager h1CM = getFireWalledConnectionManager(h1);
    FirewallingMockConnectionManager h2CM = getFireWalledConnectionManager(h2);
    Node h1Node = getNode(h1);
    Node h2Node = getNode(h2);
    h1CM.unblock(h2Node.getThisAddress());
    h2CM.unblock(h1Node.getThisAddress());
}
Also used : Node(com.hazelcast.instance.Node) FirewallingMockConnectionManager(com.hazelcast.nio.tcp.FirewallingMockConnectionManager)

Example 29 with Node

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

the class HazelcastTestSupport method closeConnectionBetween.

// ################################################
// ########## cluster and instance state ##########
// ################################################
public static void closeConnectionBetween(HazelcastInstance h1, HazelcastInstance h2) {
    if (h1 == null || h2 == null) {
        return;
    }
    Node n1 = TestUtil.getNode(h1);
    Node n2 = TestUtil.getNode(h2);
    if (n1 != null && n2 != null) {
        n1.clusterService.removeAddress(n2.address, null);
        n2.clusterService.removeAddress(n1.address, null);
    }
}
Also used : Node(com.hazelcast.instance.Node)

Example 30 with Node

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

the class ServiceManagerImpl method readServiceDescriptors.

private void readServiceDescriptors() {
    Node node = nodeEngine.getNode();
    try {
        ClassLoader classLoader = node.getConfigClassLoader();
        Iterator<Class<RemoteServiceDescriptorProvider>> iter = com.hazelcast.util.ServiceLoader.classIterator(PROVIDER_ID, classLoader);
        while (iter.hasNext()) {
            Class<RemoteServiceDescriptorProvider> clazz = iter.next();
            Constructor<RemoteServiceDescriptorProvider> constructor = clazz.getDeclaredConstructor();
            RemoteServiceDescriptorProvider provider = constructor.newInstance();
            RemoteServiceDescriptor[] services = provider.createRemoteServiceDescriptors();
            for (RemoteServiceDescriptor serviceDescriptor : services) {
                registerService(serviceDescriptor.getServiceName(), serviceDescriptor.getService(nodeEngine));
            }
        }
    } catch (Exception e) {
        throw ExceptionUtil.rethrow(e);
    }
}
Also used : RemoteServiceDescriptorProvider(com.hazelcast.spi.impl.servicemanager.RemoteServiceDescriptorProvider) Node(com.hazelcast.instance.Node) RemoteServiceDescriptor(com.hazelcast.spi.impl.servicemanager.RemoteServiceDescriptor) HazelcastException(com.hazelcast.core.HazelcastException)

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