use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MembershipManager method shrinkMissingMembers.
void shrinkMissingMembers(Collection<UUID> memberUuidsToRemove) {
clusterServiceLock.lock();
try {
Map<Object, MemberImpl> m = new HashMap<>(missingMembersRef.get());
Iterator<MemberImpl> it = m.values().iterator();
while (it.hasNext()) {
MemberImpl member = it.next();
if (memberUuidsToRemove.contains(member.getUuid())) {
if (logger.isFineEnabled()) {
logger.fine("Removing " + member + " from members removed in not joinable state.");
}
it.remove();
}
}
missingMembersRef.set(unmodifiableMap(m));
} finally {
clusterServiceLock.unlock();
}
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MembershipManager method handleExplicitSuspicion.
void handleExplicitSuspicion(MembersViewMetadata expectedMembersViewMetadata, Address suspectedAddress) {
clusterServiceLock.lock();
try {
MembersViewMetadata localMembersViewMetadata = createLocalMembersViewMetadata();
if (!localMembersViewMetadata.equals(expectedMembersViewMetadata)) {
if (logger.isFineEnabled()) {
logger.fine("Ignoring explicit suspicion of " + suspectedAddress + ". Expected: " + expectedMembersViewMetadata + ", Local: " + localMembersViewMetadata);
}
return;
}
MemberImpl suspectedMember = getMember(suspectedAddress);
if (suspectedMember == null) {
if (logger.isFineEnabled()) {
logger.fine("No need for explicit suspicion, " + suspectedAddress + " is not a member.");
}
return;
}
suspectMember(suspectedMember, "explicit suspicion", true);
} finally {
clusterServiceLock.unlock();
}
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MembershipManager method sendMemberListToMember.
/**
* Sends the current member list to the {@code target}. Called on the master node.
*
* @param target the destination for the member update operation
*/
public void sendMemberListToMember(Address target) {
clusterServiceLock.lock();
try {
if (!clusterService.isMaster() || !clusterService.isJoined()) {
if (logger.isFineEnabled()) {
logger.fine("Cannot publish member list to " + target + ". Is-master: " + clusterService.isMaster() + ", joined: " + clusterService.isJoined());
}
return;
}
if (clusterService.getThisAddress().equals(target)) {
return;
}
MemberMap memberMap = memberMapRef.get();
MemberImpl member = memberMap.getMember(target);
if (member == null) {
if (logger.isFineEnabled()) {
logger.fine("Not member: " + target + ", cannot send member list.");
}
return;
}
if (logger.isFineEnabled()) {
logger.fine("Sending member list to member: " + target + " " + memberListString());
}
MembersUpdateOp op = new MembersUpdateOp(member.getUuid(), memberMap.toMembersView(), clusterService.getClusterTime(), null, false);
op.setCallerUuid(clusterService.getThisUuid());
nodeEngine.getOperationService().send(op, target);
} finally {
clusterServiceLock.unlock();
}
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MembershipManager method setMissingMembers.
void setMissingMembers(Collection<MemberImpl> members) {
clusterServiceLock.lock();
try {
Map<Object, MemberImpl> m = new HashMap<>(members.size());
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));
} finally {
clusterServiceLock.unlock();
}
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MembershipManager method promoteToDataMember.
public MembersView promoteToDataMember(Address address, UUID uuid) {
clusterServiceLock.lock();
try {
ensureLiteMemberPromotionIsAllowed();
MemberMap memberMap = getMemberMap();
MemberImpl member = memberMap.getMember(address, uuid);
if (member == null) {
throw new IllegalStateException(uuid + "/" + address + " is not a member!");
}
if (!member.isLiteMember()) {
if (logger.isFineEnabled()) {
logger.fine(member + " is not lite member, no promotion is required.");
}
return memberMap.toMembersView();
}
logger.info("Promoting " + member + " to normal member.");
MemberImpl[] members = memberMap.getMembers().toArray(new MemberImpl[0]);
for (int i = 0; i < members.length; i++) {
if (member.equals(members[i])) {
if (member.localMember()) {
member = clusterService.promoteAndGetLocalMember();
} else {
member = new MemberImpl.Builder(member.getAddressMap()).version(member.getVersion()).localMember(member.localMember()).uuid(member.getUuid()).attributes(member.getAttributes()).memberListJoinVersion(members[i].getMemberListJoinVersion()).instance(node.hazelcastInstance).build();
}
members[i] = member;
break;
}
}
MemberMap newMemberMap = MemberMap.createNew(memberMap.getVersion() + 1, members);
setMembers(newMemberMap);
sendMemberListToOthers();
node.partitionService.memberAdded(member);
clusterService.printMemberList();
return newMemberMap.toMembersView();
} finally {
clusterServiceLock.unlock();
}
}
Aggregations