use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MembershipManager method suspectMember.
void suspectMember(MemberImpl suspectedMember, String reason, boolean closeConnection) {
assert !suspectedMember.equals(getLocalMember()) : "Cannot suspect from myself!";
assert !suspectedMember.localMember() : "Cannot be local member";
final MemberMap localMemberMap;
final Set<MemberImpl> membersToAsk;
clusterServiceLock.lock();
try {
if (!clusterService.isJoined()) {
if (logger.isFineEnabled()) {
logger.fine("Cannot handle suspect of " + suspectedMember + " because this node is not joined...");
}
return;
}
ClusterJoinManager clusterJoinManager = clusterService.getClusterJoinManager();
if (clusterService.isMaster() && !clusterJoinManager.isMastershipClaimInProgress()) {
removeMember(suspectedMember, reason, closeConnection);
return;
}
if (!addSuspectedMember(suspectedMember, reason, closeConnection)) {
return;
}
if (!tryStartMastershipClaim()) {
return;
}
localMemberMap = getMemberMap();
membersToAsk = collectMembersToAsk(localMemberMap);
logger.info("Local " + localMemberMap.toMembersView() + " with suspected members: " + suspectedMembers + " and initial addresses to ask: " + membersToAsk);
} finally {
clusterServiceLock.unlock();
}
ExecutorService executor = nodeEngine.getExecutionService().getExecutor(MASTERSHIP_CLAIM_EXECUTOR_NAME);
executor.submit(new DecideNewMembersViewTask(localMemberMap, membersToAsk));
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MembershipManager method decideNewMembersView.
private MembersView decideNewMembersView(MemberMap localMemberMap, Set<MemberImpl> members) {
Map<MemberInfo, Future<MembersView>> futures = new HashMap<>();
MembersView latestMembersView = fetchLatestMembersView(localMemberMap, members, futures);
if (logger.isFineEnabled()) {
logger.fine("Latest " + latestMembersView + " before final decision...");
}
// within the most recent members view, select the members that have reported their members view successfully
List<MemberInfo> finalMembers = new ArrayList<>();
for (MemberInfo member : latestMembersView.getMembers()) {
Address address = member.getAddress();
if (node.getThisAddress().equals(address)) {
finalMembers.add(member);
continue;
}
// if it is not certain if a member has accepted the mastership claim, its response will be ignored
Future<MembersView> future = futures.get(member);
if (isMemberSuspected(new MemberImpl(member.getAddress(), member.getVersion(), false, member.getUuid()))) {
if (logger.isFineEnabled()) {
logger.fine(member + " is excluded because suspected");
}
continue;
} else if (future == null || !future.isDone()) {
if (logger.isFineEnabled()) {
logger.fine(member + " is excluded because I don't know its response");
}
continue;
}
addAcceptedMemberInfo(finalMembers, member, future);
}
int finalVersion = latestMembersView.getVersion() + 1;
return new MembersView(finalVersion, finalMembers);
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MembershipManager method verifySplitBrainMergeMemberListVersion.
public boolean verifySplitBrainMergeMemberListVersion(SplitBrainJoinMessage joinMessage) {
Address caller = joinMessage.getAddress();
int callerMemberListVersion = joinMessage.getMemberListVersion();
clusterServiceLock.lock();
try {
if (!clusterService.isMaster()) {
logger.warning("Cannot verify member list version: " + callerMemberListVersion + " from " + caller + " because this node is not master");
return false;
} else if (clusterService.getClusterJoinManager().isMastershipClaimInProgress()) {
logger.warning("Cannot verify member list version: " + callerMemberListVersion + " from " + caller + " because mastership claim is in progress");
return false;
}
MemberMap memberMap = getMemberMap();
if (memberMap.getVersion() < callerMemberListVersion) {
int newVersion = callerMemberListVersion + 1;
logger.info("Updating local member list version: " + memberMap.getVersion() + " to " + newVersion + " because of split brain merge caller: " + caller + " with member list version: " + callerMemberListVersion);
MemberImpl[] members = memberMap.getMembers().toArray(new MemberImpl[0]);
MemberMap newMemberMap = MemberMap.createNew(newVersion, members);
setMembers(newMemberMap);
sendMemberListToOthers();
clusterService.printMemberList();
}
return true;
} finally {
clusterServiceLock.unlock();
}
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MembershipManager method sendMembershipEvents.
void sendMembershipEvents(Collection<MemberImpl> currentMembers, Collection<MemberImpl> newMembers, boolean sortMembers) {
List<Member> eventMembers = new ArrayList<>(currentMembers);
if (!newMembers.isEmpty()) {
for (MemberImpl newMember : newMembers) {
// sync calls
node.getPartitionService().memberAdded(newMember);
node.getNodeExtension().onMemberListChange();
// async events
eventMembers.add(newMember);
if (sortMembers) {
sortMembersInMembershipOrder(eventMembers);
}
sendMembershipEventNotifications(newMember, unmodifiableSet(new LinkedHashSet<>(eventMembers)), true);
}
}
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class NodeMulticastListener method handleActiveAndJoined.
private void handleActiveAndJoined(JoinMessage joinMessage) {
if (!(joinMessage instanceof JoinRequest)) {
logDroppedMessage(joinMessage);
return;
}
ClusterServiceImpl clusterService = node.getClusterService();
Address masterAddress = clusterService.getMasterAddress();
if (clusterService.isMaster()) {
JoinMessage response = new JoinMessage(Packet.VERSION, node.getBuildInfo().getBuildNumber(), node.getVersion(), node.getThisAddress(), node.getThisUuid(), node.isLiteMember(), node.createConfigCheck());
node.multicastService.send(response);
} else if (joinMessage.getAddress().equals(masterAddress)) {
MemberImpl master = node.getClusterService().getMember(masterAddress);
if (master != null) {
UUID uuidFromMaster = master.getUuid();
UUID uuidInJoinRequest = joinMessage.getUuid();
if (!uuidFromMaster.equals(uuidInJoinRequest)) {
String message = "New join request has been received from current master address. " + "The UUID in the join request (" + uuidInJoinRequest + ") is different from the " + "known master one (" + uuidFromMaster + "). Suspecting the master address: " + masterAddress;
logger.warning(message);
// I just make a local suspicion. Probably other nodes will eventually suspect as well.
clusterService.suspectMember(master, message, false);
}
}
}
}
Aggregations