use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MembershipManager method removeFromMissingMembers.
private void removeFromMissingMembers(MemberImpl... members) {
Map<Object, MemberImpl> m = new HashMap<>(missingMembersRef.get());
if (isHotRestartEnabled()) {
for (MemberImpl member : members) {
m.remove(member.getUuid());
}
} else {
for (MemberImpl member : members) {
m.remove(member.getAddress());
}
}
missingMembersRef.set(unmodifiableMap(m));
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MembershipManager method fetchMembersViewFromNewMembers.
private boolean fetchMembersViewFromNewMembers(MembersView membersView, Map<MemberInfo, Future<MembersView>> futures) {
boolean isNewMemberPresent = false;
for (MemberInfo member : membersView.getMembers()) {
Address memberAddress = member.getAddress();
if (!(node.getThisAddress().equals(memberAddress) || isMemberSuspected(new MemberImpl(member.getAddress(), member.getVersion(), false, member.getUuid())) || futures.containsKey(member))) {
// this is a new member for us. lets ask its members view
if (logger.isFineEnabled()) {
logger.fine("Asking MembersView of " + memberAddress);
}
futures.put(member, invokeFetchMembersViewOp(memberAddress, member.getUuid()));
isNewMemberPresent = true;
}
}
return isNewMemberPresent;
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MembershipManager method repairPartitionTableIfReturningMember.
private void repairPartitionTableIfReturningMember(MemberImpl member) {
if (!clusterService.isMaster()) {
return;
}
if (clusterService.getClusterState().isMigrationAllowed()) {
return;
}
if (!node.getNodeExtension().isStartCompleted()) {
return;
}
MemberImpl missingMember = getMissingMember(member.getAddress(), member.getUuid());
if (missingMember != null) {
boolean repair;
Level level;
if (isHotRestartEnabled()) {
repair = !missingMember.getAddress().equals(member.getAddress());
level = Level.INFO;
} else {
repair = !missingMember.getUuid().equals(member.getUuid());
level = Level.FINE;
}
if (repair) {
logger.log(level, member + " is returning with a new identity. Old one was: " + missingMember + ". Will update partition table with the new identity.");
InternalPartitionServiceImpl partitionService = node.partitionService;
partitionService.replaceMember(missingMember, member);
}
}
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MembershipManager method updateMembers.
// handles both new and left members
void updateMembers(MembersView membersView) {
MemberMap currentMemberMap = memberMapRef.get();
Collection<MemberImpl> addedMembers = new LinkedList<>();
Collection<MemberImpl> removedMembers = new LinkedList<>();
ClusterHeartbeatManager clusterHeartbeatManager = clusterService.getClusterHeartbeatManager();
MemberImpl[] members = new MemberImpl[membersView.size()];
int memberIndex = 0;
// Indicates whether we received a notification on lite member membership change
// (e.g. its promotion to a data member)
boolean updatedLiteMember = false;
for (MemberInfo memberInfo : membersView.getMembers()) {
Address address = memberInfo.getAddress();
MemberImpl member = currentMemberMap.getMember(address);
if (member != null && member.getUuid().equals(memberInfo.getUuid())) {
if (member.isLiteMember()) {
updatedLiteMember = true;
}
member = createNewMemberImplIfChanged(memberInfo, member);
members[memberIndex++] = member;
continue;
}
if (member != null) {
assert !(member.localMember() && member.equals(getLocalMember())) : "Local " + member + " cannot be replaced with " + memberInfo;
// UUID changed: means member has gone and come back with a new uuid
removedMembers.add(member);
}
member = createMember(memberInfo, memberInfo.getAttributes());
addedMembers.add(member);
long now = clusterService.getClusterTime();
clusterHeartbeatManager.onHeartbeat(member, now);
repairPartitionTableIfReturningMember(member);
members[memberIndex++] = member;
}
MemberMap newMemberMap = membersView.toMemberMap();
for (MemberImpl member : currentMemberMap.getMembers()) {
if (!newMemberMap.contains(member.getAddress())) {
removedMembers.add(member);
}
}
setMembers(MemberMap.createNew(membersView.getVersion(), members));
if (updatedLiteMember) {
node.partitionService.updateMemberGroupSize();
}
for (MemberImpl member : removedMembers) {
closeConnections(member.getAddress(), "Member left event received from master");
handleMemberRemove(memberMapRef.get(), member);
}
clusterService.getClusterJoinManager().insertIntoRecentlyJoinedMemberSet(addedMembers);
sendMembershipEvents(currentMemberMap.getMembers(), addedMembers, !clusterService.isJoined());
removeFromMissingMembers(members);
clusterHeartbeatManager.heartbeat();
clusterService.printMemberList();
// async call
node.getNodeExtension().scheduleClusterVersionAutoUpgrade();
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MembershipManager method addToMissingMembers.
private void addToMissingMembers(MemberImpl... members) {
Map<Object, MemberImpl> m = new HashMap<>(missingMembersRef.get());
if (isHotRestartEnabled()) {
for (MemberImpl member : members) {
m.put(member.getUuid(), member);
}
} else {
for (MemberImpl member : members) {
m.put(member.getAddress(), member);
}
}
missingMembersRef.set(unmodifiableMap(m));
}
Aggregations