Search in sources :

Example 1 with SplitBrainMergeCheckResult

use of com.hazelcast.internal.cluster.impl.SplitBrainJoinMessage.SplitBrainMergeCheckResult in project hazelcast by hazelcast.

the class MulticastJoiner method searchForOtherClusters.

@Override
public void searchForOtherClusters() {
    node.multicastService.send(node.createSplitBrainJoinMessage());
    SplitBrainJoinMessage splitBrainMsg;
    try {
        while ((splitBrainMsg = splitBrainJoinMessages.poll(3, TimeUnit.SECONDS)) != null) {
            if (logger.isFineEnabled()) {
                logger.fine("Received  " + splitBrainMsg);
            }
            Address targetAddress = splitBrainMsg.getAddress();
            if (node.clusterService.getMember(targetAddress) != null) {
                if (logger.isFineEnabled()) {
                    logger.fine("Ignoring merge join response, since " + targetAddress + " is already a member.");
                }
                continue;
            }
            SplitBrainJoinMessage request = node.createSplitBrainJoinMessage();
            SplitBrainMergeCheckResult result = sendSplitBrainJoinMessageAndCheckResponse(targetAddress, request);
            if (result == SplitBrainMergeCheckResult.LOCAL_NODE_SHOULD_MERGE) {
                logger.warning(node.getThisAddress() + " is merging [multicast] to " + targetAddress);
                startClusterMerge(targetAddress, clusterService.getMemberListVersion());
                return;
            }
            if (result == SplitBrainMergeCheckResult.REMOTE_NODE_SHOULD_MERGE) {
                // other side should join to us. broadcast a new SplitBrainJoinMessage.
                node.multicastService.send(node.createSplitBrainJoinMessage());
            }
        }
    } catch (InterruptedException e) {
        currentThread().interrupt();
        logger.fine(e);
    } catch (Exception e) {
        logger.warning(e);
    }
}
Also used : Address(com.hazelcast.cluster.Address) SplitBrainMergeCheckResult(com.hazelcast.internal.cluster.impl.SplitBrainJoinMessage.SplitBrainMergeCheckResult)

Example 2 with SplitBrainMergeCheckResult

use of com.hazelcast.internal.cluster.impl.SplitBrainJoinMessage.SplitBrainMergeCheckResult 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 3 with SplitBrainMergeCheckResult

use of com.hazelcast.internal.cluster.impl.SplitBrainJoinMessage.SplitBrainMergeCheckResult in project hazelcast by hazelcast.

the class MockJoiner method searchForOtherClusters.

public void searchForOtherClusters() {
    Collection<Address> possibleAddresses = new ArrayList<Address>(registry.getJoinAddresses());
    possibleAddresses.remove(node.getThisAddress());
    possibleAddresses.removeAll(node.getClusterService().getMemberAddresses());
    SplitBrainJoinMessage request = node.createSplitBrainJoinMessage();
    for (Address address : possibleAddresses) {
        SplitBrainMergeCheckResult result = sendSplitBrainJoinMessageAndCheckResponse(address, request);
        if (result == SplitBrainMergeCheckResult.LOCAL_NODE_SHOULD_MERGE) {
            startClusterMerge(address, request.getMemberListVersion());
            return;
        }
    }
}
Also used : Address(com.hazelcast.cluster.Address) ArrayList(java.util.ArrayList) SplitBrainJoinMessage(com.hazelcast.internal.cluster.impl.SplitBrainJoinMessage) SplitBrainMergeCheckResult(com.hazelcast.internal.cluster.impl.SplitBrainJoinMessage.SplitBrainMergeCheckResult)

Example 4 with SplitBrainMergeCheckResult

use of com.hazelcast.internal.cluster.impl.SplitBrainJoinMessage.SplitBrainMergeCheckResult in project hazelcast by hazelcast.

the class SplitBrainMergeValidationOp method checkSplitBrainJoinMessage.

private boolean checkSplitBrainJoinMessage() {
    ClusterServiceImpl service = getService();
    ILogger logger = getLogger();
    try {
        if (!service.getClusterJoinManager().validateJoinMessage(request)) {
            // surprise to users and may cause unexpected issues.
            return false;
        }
        if (!service.getClusterVersion().equals(request.getClusterVersion())) {
            logger.info("Join check from " + getCallerAddress() + " failed validation due to incompatible version," + "remote cluster version is " + request.getClusterVersion() + ", this cluster is " + service.getClusterVersion());
            return false;
        }
        SplitBrainMergeCheckResult result = service.getClusterJoinManager().shouldMerge(request);
        if (result == REMOTE_NODE_SHOULD_MERGE) {
            return service.getMembershipManager().verifySplitBrainMergeMemberListVersion(request);
        }
        return result != CANNOT_MERGE;
    } catch (Exception e) {
        if (logger.isFineEnabled()) {
            logger.fine("Could not validate split-brain join message! -> " + e.getMessage());
        }
        return false;
    }
}
Also used : ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) ILogger(com.hazelcast.logging.ILogger) SplitBrainMergeCheckResult(com.hazelcast.internal.cluster.impl.SplitBrainJoinMessage.SplitBrainMergeCheckResult) IOException(java.io.IOException)

Aggregations

SplitBrainMergeCheckResult (com.hazelcast.internal.cluster.impl.SplitBrainJoinMessage.SplitBrainMergeCheckResult)4 Address (com.hazelcast.cluster.Address)3 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)1 SplitBrainJoinMessage (com.hazelcast.internal.cluster.impl.SplitBrainJoinMessage)1 LinkedAddresses (com.hazelcast.internal.server.tcp.LinkedAddresses)1 LocalAddressRegistry (com.hazelcast.internal.server.tcp.LocalAddressRegistry)1 ILogger (com.hazelcast.logging.ILogger)1 IOException (java.io.IOException)1 InetAddress (java.net.InetAddress)1 ArrayList (java.util.ArrayList)1