use of com.hazelcast.internal.server.tcp.LocalAddressRegistry 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.server.tcp.LocalAddressRegistry in project hazelcast by hazelcast.
the class TcpIpJoiner method isThisNodeMasterCandidate.
@SuppressWarnings("checkstyle:NestedIfDepth")
private boolean isThisNodeMasterCandidate(Collection<Address> addresses) {
int thisHashCode = node.getThisAddress().hashCode();
for (Address address : addresses) {
if (isBlacklisted(address)) {
continue;
}
if (node.getServer().getConnectionManager(MEMBER).get(address) != null) {
LocalAddressRegistry addressRegistry = node.getLocalAddressRegistry();
UUID memberUuid = addressRegistry.uuidOf(address);
if (memberUuid != null) {
Address primaryAddress = addressRegistry.getPrimaryAddress(memberUuid);
if (primaryAddress != null) {
if (thisHashCode > primaryAddress.hashCode()) {
return false;
}
}
}
}
}
return true;
}
Aggregations