use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class ClusterServiceImpl method promoteLocalLiteMember.
@Override
public void promoteLocalLiteMember() {
MemberImpl member = getLocalMember();
if (!member.isLiteMember()) {
throw new IllegalStateException(member + " is not a lite member!");
}
MemberImpl master = getMasterMember();
PromoteLiteMemberOp op = new PromoteLiteMemberOp();
op.setCallerUuid(member.getUuid());
InvocationFuture<MembersView> future = nodeEngine.getOperationService().invokeOnTarget(SERVICE_NAME, op, master.getAddress());
MembersView view = future.joinInternal();
lock.lock();
try {
if (!member.getAddress().equals(master.getAddress())) {
updateMembers(view, master.getAddress(), master.getUuid(), getThisUuid());
}
MemberImpl localMemberInMemberList = membershipManager.getMember(member.getAddress());
boolean result = localMemberInMemberList.isLiteMember();
node.getNodeExtension().getAuditlogService().eventBuilder(AuditlogTypeIds.CLUSTER_PROMOTE_MEMBER).message("Promotion of the lite member").addParameter("success", result).addParameter("address", node.getThisAddress()).log();
if (result) {
throw new IllegalStateException("Cannot promote to data member! Previous master was: " + master.getAddress() + ", Current master is: " + getMasterAddress());
}
} finally {
lock.unlock();
}
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class ClusterHeartbeatManager method handleHeartbeat.
public void handleHeartbeat(MembersViewMetadata senderMembersViewMetadata, UUID receiverUuid, long timestamp, Collection<MemberInfo> suspectedMembers) {
Address senderAddress = senderMembersViewMetadata.getMemberAddress();
try {
long timeout = Math.min(TimeUnit.SECONDS.toMillis(1), heartbeatIntervalMillis / 2);
if (!clusterServiceLock.tryLock(timeout, MILLISECONDS)) {
logger.warning("Cannot handle heartbeat from " + senderAddress + ", could not acquire lock in time.");
return;
}
} catch (InterruptedException e) {
logger.warning("Cannot handle heartbeat from " + senderAddress + ", thread interrupted.");
Thread.currentThread().interrupt();
return;
}
try {
if (!clusterService.isJoined()) {
if (clusterService.getThisUuid().equals(receiverUuid)) {
logger.fine("Ignoring heartbeat of sender: " + senderMembersViewMetadata + ", because node is not joined!");
} else {
// we know that sender version is 3.9 so we send explicit suspicion back even if we are not joined...
logger.fine("Sending explicit suspicion to " + senderAddress + " for heartbeat " + senderMembersViewMetadata + ", because this node has received an invalid heartbeat before it joins to the cluster");
OperationService operationService = nodeEngine.getOperationService();
Operation op = new ExplicitSuspicionOp(senderMembersViewMetadata);
operationService.send(op, senderAddress);
}
return;
}
MembershipManager membershipManager = clusterService.getMembershipManager();
MemberImpl member = membershipManager.getMember(senderAddress, senderMembersViewMetadata.getMemberUuid());
if (member != null) {
if (clusterService.getThisUuid().equals(receiverUuid)) {
if (onHeartbeat(member, timestamp)) {
// local timestamp is used on purpose here
membershipManager.handleReceivedSuspectedMembers(member, clusterClock.getClusterTime(), suspectedMembers);
}
return;
}
logger.warning("Local UUID mismatch on received heartbeat. local UUID: " + clusterService.getThisUuid() + " received UUID: " + receiverUuid + " with " + senderMembersViewMetadata);
}
onInvalidHeartbeat(senderMembersViewMetadata);
} finally {
clusterServiceLock.unlock();
}
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class PartialDisconnectionHandler method buildConnectionGraph.
private Graph<MemberImpl> buildConnectionGraph(Set<MemberImpl> members, Map<MemberImpl, Set<MemberImpl>> disconnections) {
Graph<MemberImpl> graph = new Graph<>();
members.forEach(graph::add);
for (MemberImpl member1 : members) {
for (MemberImpl member2 : members) {
if (!isDisconnected(disconnections, member1, member2)) {
graph.connect(member1, member2);
}
}
}
return graph;
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MemberMap method headMemberSet.
Set<MemberImpl> headMemberSet(Member member, boolean inclusive) {
ensureMemberExist(member);
Set<MemberImpl> result = new LinkedHashSet<>();
for (MemberImpl m : members) {
if (!m.equals(member)) {
result.add(m);
continue;
}
if (inclusive) {
result.add(m);
}
break;
}
return result;
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MemberMap method putMember.
private static void putMember(Map<Address, MemberImpl> addressMap, Map<UUID, MemberImpl> uuidMap, MemberImpl member) {
MemberImpl current = addressMap.put(member.getAddress(), member);
if (current != null) {
throw new IllegalArgumentException("Replacing existing member with address: " + member);
}
current = uuidMap.put(member.getUuid(), member);
if (current != null) {
throw new IllegalArgumentException("Replacing existing member with UUID: " + member);
}
}
Aggregations