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);
}
}
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;
}
}
}
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;
}
}
}
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;
}
}
Aggregations