use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class Node method createSplitBrainJoinMessage.
public SplitBrainJoinMessage createSplitBrainJoinMessage() {
MemberImpl localMember = getLocalMember();
boolean liteMember = localMember.isLiteMember();
Collection<Address> memberAddresses = clusterService.getMemberAddresses();
int dataMemberCount = clusterService.getSize(DATA_MEMBER_SELECTOR);
Version clusterVersion = clusterService.getClusterVersion();
int memberListVersion = clusterService.getMembershipManager().getMemberListVersion();
return new SplitBrainJoinMessage(Packet.VERSION, buildInfo.getBuildNumber(), version, address, localMember.getUuid(), liteMember, createConfigCheck(), memberAddresses, dataMemberCount, clusterVersion, memberListVersion);
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class Node method createJoinRequest.
public JoinRequest createJoinRequest(Address remoteAddress) {
final Credentials credentials = (remoteAddress != null && securityContext != null) ? securityContext.getCredentialsFactory().newCredentials(remoteAddress) : null;
final Set<UUID> excludedMemberUuids = nodeExtension.getInternalHotRestartService().getExcludedMemberUuids();
MemberImpl localMember = getLocalMember();
return new JoinRequest(Packet.VERSION, buildInfo.getBuildNumber(), version, address, localMember.getUuid(), localMember.isLiteMember(), createConfigCheck(), credentials, localMember.getAttributes(), excludedMemberUuids, localMember.getAddressMap());
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class ClusterJoinManager method startJoin.
/**
* Starts join process on master member.
*/
private void startJoin() {
logger.fine("Starting join...");
clusterServiceLock.lock();
try {
InternalPartitionService partitionService = node.getPartitionService();
boolean shouldTriggerRepartition = true;
try {
joinInProgress = true;
// pause migrations until join, member-update and post-join operations are completed
partitionService.pauseMigration();
MemberMap memberMap = clusterService.getMembershipManager().getMemberMap();
MembersView newMembersView = MembersView.cloneAdding(memberMap.toMembersView(), joiningMembers.values());
long time = clusterClock.getClusterTime();
// member list must be updated on master before preparation of pre-/post-join ops so other operations which have
// to be executed on stable cluster can detect the member list version change and retry in case of topology change
UUID thisUuid = clusterService.getThisUuid();
if (!clusterService.updateMembers(newMembersView, node.getThisAddress(), thisUuid, thisUuid)) {
return;
}
// post join operations must be lock free, that means no locks at all:
// no partition locks, no key-based locks, no service level locks!
OnJoinOp preJoinOp = preparePreJoinOps();
OnJoinOp postJoinOp = preparePostJoinOp();
// this is the current partition assignment state, not taking into account the
// currently joining members
PartitionRuntimeState partitionRuntimeState = partitionService.createPartitionState();
for (MemberInfo member : joiningMembers.values()) {
if (isMemberRestartingWithPersistence(member.getAttributes()) && isMemberRejoining(memberMap, member.getAddress(), member.getUuid())) {
logger.info(member + " is rejoining the cluster");
// do not trigger repartition immediately, wait for joining member to load hot-restart data
shouldTriggerRepartition = false;
}
long startTime = clusterClock.getClusterStartTime();
Operation op = new FinalizeJoinOp(member.getUuid(), newMembersView, preJoinOp, postJoinOp, time, clusterService.getClusterId(), startTime, clusterStateManager.getState(), clusterService.getClusterVersion(), partitionRuntimeState, !shouldTriggerRepartition);
op.setCallerUuid(thisUuid);
invokeClusterOp(op, member.getAddress());
}
for (MemberImpl member : memberMap.getMembers()) {
if (member.localMember() || joiningMembers.containsKey(member.getAddress())) {
continue;
}
Operation op = new MembersUpdateOp(member.getUuid(), newMembersView, time, partitionRuntimeState, true);
op.setCallerUuid(thisUuid);
invokeClusterOp(op, member.getAddress());
}
} finally {
reset();
if (shouldTriggerRepartition) {
partitionService.resumeMigration();
}
}
} finally {
clusterServiceLock.unlock();
}
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class ClusterServiceImpl method promoteAndGetLocalMember.
MemberImpl promoteAndGetLocalMember() {
MemberImpl member = getLocalMember();
assert member.isLiteMember() : "Local member is not lite member!";
assert lock.isHeldByCurrentThread() : "Called without holding cluster service lock!";
localMember = new MemberImpl.Builder(member.getAddressMap()).version(member.getVersion()).localMember(true).uuid(member.getUuid()).attributes(member.getAttributes()).memberListJoinVersion(member.getMemberListJoinVersion()).instance(node.hazelcastInstance).build();
node.loggingService.setThisMember(localMember);
return localMember;
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class ClusterServiceImpl method handleMastershipClaim.
public MembersView handleMastershipClaim(@Nonnull Address candidateAddress, @Nonnull UUID candidateUuid) {
checkNotNull(candidateAddress);
checkNotNull(candidateUuid);
checkFalse(getThisAddress().equals(candidateAddress), "cannot accept my own mastership claim!");
lock.lock();
try {
checkTrue(isJoined(), candidateAddress + " claims mastership but this node is not joined!");
checkFalse(isMaster(), candidateAddress + " claims mastership but this node is master!");
MemberImpl masterCandidate = membershipManager.getMember(candidateAddress, candidateUuid);
checkTrue(masterCandidate != null, candidateAddress + " claims mastership but it is not a member!");
MemberMap memberMap = membershipManager.getMemberMap();
if (!shouldAcceptMastership(memberMap, masterCandidate)) {
String message = "Cannot accept mastership claim of " + candidateAddress + " at the moment. There are more suitable master candidates in the member list.";
logger.fine(message);
throw new RetryableHazelcastException(message);
}
if (!membershipManager.clearMemberSuspicion(masterCandidate, "Mastership claim")) {
throw new IllegalStateException("Cannot accept mastership claim of " + candidateAddress + ". " + getMasterAddress() + " is already master.");
}
setMasterAddress(masterCandidate.getAddress());
MembersView response = memberMap.toTailMembersView(masterCandidate, true);
logger.warning("Mastership of " + candidateAddress + " is accepted. Response: " + response);
return response;
} finally {
lock.unlock();
}
}
Aggregations