use of com.hazelcast.internal.cluster.MemberInfo in project hazelcast by hazelcast.
the class ClusterJoinManager method startJoin.
private void startJoin() {
logger.fine("Starting join...");
clusterServiceLock.lock();
try {
InternalPartitionService partitionService = node.getPartitionService();
try {
joinInProgress = true;
// pause migrations until join, member-update and post-join operations are completed
partitionService.pauseMigration();
Collection<MemberImpl> members = clusterService.getMemberImpls();
Collection<MemberInfo> memberInfos = createMemberInfoList(members);
for (MemberInfo memberJoining : joiningMembers.values()) {
memberInfos.add(memberJoining);
}
long time = clusterClock.getClusterTime();
// post join operations must be lock free, that means no locks at all:
// no partition locks, no key-based locks, no service level locks!
Operation[] postJoinOps = nodeEngine.getPostJoinOperations();
boolean createPostJoinOperation = (postJoinOps != null && postJoinOps.length > 0);
PostJoinOperation postJoinOp = (createPostJoinOperation ? new PostJoinOperation(postJoinOps) : null);
clusterService.updateMembers(memberInfos, node.getThisAddress());
int count = members.size() - 1 + joiningMembers.size();
List<Future> calls = new ArrayList<Future>(count);
PartitionRuntimeState partitionRuntimeState = partitionService.createPartitionState();
for (MemberInfo member : joiningMembers.values()) {
long startTime = clusterClock.getClusterStartTime();
Operation finalizeJoinOperation = new FinalizeJoinOperation(member.getUuid(), memberInfos, postJoinOp, time, clusterService.getClusterId(), startTime, clusterStateManager.getState(), clusterService.getClusterVersion(), partitionRuntimeState);
calls.add(invokeClusterOperation(finalizeJoinOperation, member.getAddress()));
}
for (MemberImpl member : members) {
if (member.localMember() || joiningMembers.containsKey(member.getAddress())) {
continue;
}
Operation memberInfoUpdateOperation = new MemberInfoUpdateOperation(member.getUuid(), memberInfos, time, partitionRuntimeState, true);
calls.add(invokeClusterOperation(memberInfoUpdateOperation, member.getAddress()));
}
int timeout = Math.min(calls.size() * FINALIZE_JOIN_TIMEOUT_FACTOR, FINALIZE_JOIN_MAX_TIMEOUT);
waitWithDeadline(calls, timeout, TimeUnit.SECONDS, whileFinalizeJoinsExceptionHandler);
} finally {
reset();
partitionService.resumeMigration();
}
} finally {
clusterServiceLock.unlock();
}
}
use of com.hazelcast.internal.cluster.MemberInfo in project hazelcast by hazelcast.
the class ClusterHeartbeatManager method sendMemberListToOthers.
/** Invoked on the master to send the member list (see {@link MemberInfoUpdateOperation}) to non-master nodes. */
private void sendMemberListToOthers() {
if (!node.isMaster()) {
return;
}
Collection<MemberImpl> members = clusterService.getMemberImpls();
List<MemberInfo> memberInfos = createMemberInfoList(members);
for (MemberImpl member : members) {
if (member.localMember()) {
continue;
}
MemberInfoUpdateOperation op = new MemberInfoUpdateOperation(member.getUuid(), memberInfos, clusterClock.getClusterTime(), null, false);
nodeEngine.getOperationService().send(op, member.getAddress());
}
}
use of com.hazelcast.internal.cluster.MemberInfo in project hazelcast by hazelcast.
the class ClusterServiceImpl method doUpdateMembers.
private void doUpdateMembers(Collection<MemberInfo> members) {
MemberMap currentMemberMap = memberMapRef.get();
String scopeId = thisAddress.getScopeId();
Collection<MemberImpl> newMembers = new LinkedList<MemberImpl>();
MemberImpl[] updatedMembers = new MemberImpl[members.size()];
int memberIndex = 0;
for (MemberInfo memberInfo : members) {
Address address = memberInfo.getAddress();
MemberImpl member = currentMemberMap.getMember(address);
if (member == null) {
member = createMember(memberInfo, scopeId);
newMembers.add(member);
long now = clusterClock.getClusterTime();
clusterHeartbeatManager.onHeartbeat(member, now);
clusterHeartbeatManager.acceptMasterConfirmation(member, now);
repairPartitionTableIfReturningMember(member);
}
updatedMembers[memberIndex++] = member;
}
setMembers(updatedMembers);
sendMembershipEvents(currentMemberMap.getMembers(), newMembers);
MemberMap membersRemovedInNotActiveState = membersRemovedInNotActiveStateRef.get();
membersRemovedInNotActiveStateRef.set(MemberMap.cloneExcluding(membersRemovedInNotActiveState, updatedMembers));
clusterHeartbeatManager.heartbeat();
logger.info(membersString());
}
Aggregations