Search in sources :

Example 1 with LinkedAddresses

use of com.hazelcast.internal.server.tcp.LinkedAddresses in project hazelcast by hazelcast.

the class TcpIpJoiner method searchForOtherClusters.

@Override
public void searchForOtherClusters() {
    final Collection<Address> possibleAddresses;
    try {
        possibleAddresses = getPossibleAddresses();
    } catch (Throwable e) {
        logger.severe(e);
        return;
    }
    LocalAddressRegistry addressRegistry = node.getLocalAddressRegistry();
    possibleAddresses.removeAll(addressRegistry.getLocalAddresses());
    node.getClusterService().getMembers().forEach(member -> {
        LinkedAddresses addresses = addressRegistry.linkedAddressesOf(member.getUuid());
        if (addresses != null) {
            Set<Address> knownMemberAddresses = addresses.getAllAddresses();
            possibleAddresses.removeAll(knownMemberAddresses);
        } else {
            // do not expect this case in the normal conditions, except for disconnections happens
            // at the same time
            possibleAddresses.remove(member.getAddress());
        }
    });
    if (possibleAddresses.isEmpty()) {
        return;
    }
    SplitBrainJoinMessage request = node.createSplitBrainJoinMessage();
    for (Address address : possibleAddresses) {
        SplitBrainMergeCheckResult result = sendSplitBrainJoinMessageAndCheckResponse(address, request);
        if (result == SplitBrainMergeCheckResult.LOCAL_NODE_SHOULD_MERGE) {
            logger.warning(node.getThisAddress() + " is merging [tcp/ip] to " + address);
            setTargetAddress(address);
            startClusterMerge(address, request.getMemberListVersion());
            return;
        }
    }
}
Also used : Address(com.hazelcast.cluster.Address) InetAddress(java.net.InetAddress) LocalAddressRegistry(com.hazelcast.internal.server.tcp.LocalAddressRegistry) LinkedAddresses(com.hazelcast.internal.server.tcp.LinkedAddresses) SplitBrainMergeCheckResult(com.hazelcast.internal.cluster.impl.SplitBrainJoinMessage.SplitBrainMergeCheckResult)

Example 2 with LinkedAddresses

use of com.hazelcast.internal.server.tcp.LinkedAddresses in project hazelcast by hazelcast.

the class ClusterMismatchOp method run.

@Override
public void run() {
    NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    Connection connection = getConnection();
    String message = "Node could not join cluster at node: " + connection.getRemoteAddress() + " Cause: the target cluster has a different cluster-name";
    Node node = nodeEngine.getNode();
    LinkedAddresses linkedAddresses = node.getLocalAddressRegistry().linkedAddressesOf(getCallerUuid());
    connection.close(message, null);
    ILogger logger = nodeEngine.getLogger("com.hazelcast.cluster");
    logger.warning(message);
    if (linkedAddresses != null) {
        for (Address address : linkedAddresses.getAllAddresses()) {
            node.getJoiner().blacklist(address, true);
        }
    } else {
        node.getJoiner().blacklist(getCallerAddress(), true);
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Address(com.hazelcast.cluster.Address) Node(com.hazelcast.instance.impl.Node) Connection(com.hazelcast.internal.nio.Connection) ILogger(com.hazelcast.logging.ILogger) LinkedAddresses(com.hazelcast.internal.server.tcp.LinkedAddresses)

Aggregations

Address (com.hazelcast.cluster.Address)2 LinkedAddresses (com.hazelcast.internal.server.tcp.LinkedAddresses)2 Node (com.hazelcast.instance.impl.Node)1 SplitBrainMergeCheckResult (com.hazelcast.internal.cluster.impl.SplitBrainJoinMessage.SplitBrainMergeCheckResult)1 Connection (com.hazelcast.internal.nio.Connection)1 LocalAddressRegistry (com.hazelcast.internal.server.tcp.LocalAddressRegistry)1 ILogger (com.hazelcast.logging.ILogger)1 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)1 InetAddress (java.net.InetAddress)1