use of com.hazelcast.internal.cluster.impl.operations.FinalizeJoinOp in project hazelcast by hazelcast.
the class ClusterJoinManager method checkIfJoinRequestFromAnExistingMember.
@SuppressWarnings("checkstyle:cyclomaticcomplexity")
private boolean checkIfJoinRequestFromAnExistingMember(JoinMessage joinMessage, ServerConnection connection) {
Address targetAddress = joinMessage.getAddress();
MemberImpl member = clusterService.getMember(targetAddress);
if (member == null) {
return checkIfUsingAnExistingMemberUuid(joinMessage);
}
if (joinMessage.getUuid().equals(member.getUuid())) {
sendMasterAnswer(targetAddress);
if (clusterService.isMaster() && !isMastershipClaimInProgress()) {
if (logger.isFineEnabled()) {
logger.fine(format("Ignoring join request, member already exists: %s", joinMessage));
}
// send members update back to node trying to join again...
boolean deferPartitionProcessing = isMemberRestartingWithPersistence(member.getAttributes());
OnJoinOp preJoinOp = preparePreJoinOps();
OnJoinOp postJoinOp = preparePostJoinOp();
PartitionRuntimeState partitionRuntimeState = node.getPartitionService().createPartitionState();
Operation op = new FinalizeJoinOp(member.getUuid(), clusterService.getMembershipManager().getMembersView(), preJoinOp, postJoinOp, clusterClock.getClusterTime(), clusterService.getClusterId(), clusterClock.getClusterStartTime(), clusterStateManager.getState(), clusterService.getClusterVersion(), partitionRuntimeState, deferPartitionProcessing);
op.setCallerUuid(clusterService.getThisUuid());
invokeClusterOp(op, targetAddress);
}
return true;
}
// after I suspect from the target.
if (clusterService.isMaster() || targetAddress.equals(clusterService.getMasterAddress())) {
String msg = format("New join request has been received from an existing endpoint %s." + " Removing old member and processing join request...", member);
logger.warning(msg);
clusterService.suspectMember(member, msg, false);
ServerConnection existing = node.getServer().getConnectionManager(MEMBER).get(targetAddress);
if (existing != connection) {
if (existing != null) {
existing.close(msg, null);
}
node.getServer().getConnectionManager(MEMBER).register(targetAddress, joinMessage.getUuid(), connection);
}
}
return true;
}
use of com.hazelcast.internal.cluster.impl.operations.FinalizeJoinOp in project hazelcast by hazelcast.
the class ClusterDataSerializerHook method createFactory.
@Override
public DataSerializableFactory createFactory() {
ConstructorFunction<Integer, IdentifiedDataSerializable>[] constructors = new ConstructorFunction[LEN];
constructors[AUTH_FAILURE] = arg -> new AuthenticationFailureOp();
constructors[ADDRESS] = arg -> new Address();
constructors[MEMBER] = arg -> new MemberImpl();
constructors[HEARTBEAT] = arg -> new HeartbeatOp();
constructors[CONFIG_CHECK] = arg -> new ConfigCheck();
constructors[MEMBER_HANDSHAKE] = arg -> new MemberHandshake();
constructors[MEMBER_INFO_UPDATE] = arg -> new MembersUpdateOp();
constructors[FINALIZE_JOIN] = arg -> new FinalizeJoinOp();
constructors[BEFORE_JOIN_CHECK_FAILURE] = arg -> new BeforeJoinCheckFailureOp();
constructors[CHANGE_CLUSTER_STATE] = arg -> new CommitClusterStateOp();
constructors[CONFIG_MISMATCH] = arg -> new ConfigMismatchOp();
constructors[CLUSTER_MISMATCH] = arg -> new ClusterMismatchOp();
constructors[SPLIT_BRAIN_MERGE_VALIDATION] = arg -> new SplitBrainMergeValidationOp();
constructors[JOIN_REQUEST_OP] = arg -> new JoinRequestOp();
constructors[LOCK_CLUSTER_STATE] = arg -> new LockClusterStateOp();
constructors[MASTER_CLAIM] = arg -> new JoinMastershipClaimOp();
constructors[WHOIS_MASTER] = arg -> new WhoisMasterOp();
constructors[MERGE_CLUSTERS] = arg -> new MergeClustersOp();
constructors[POST_JOIN] = arg -> new OnJoinOp();
constructors[ROLLBACK_CLUSTER_STATE] = arg -> new RollbackClusterStateOp();
constructors[MASTER_RESPONSE] = arg -> new MasterResponseOp();
constructors[SHUTDOWN_NODE] = arg -> new ShutdownNodeOp();
constructors[TRIGGER_MEMBER_LIST_PUBLISH] = arg -> new TriggerMemberListPublishOp();
constructors[CLUSTER_STATE_TRANSACTION_LOG_RECORD] = arg -> new ClusterStateTransactionLogRecord();
constructors[MEMBER_INFO] = arg -> new MemberInfo();
constructors[JOIN_MESSAGE] = arg -> new JoinMessage();
constructors[JOIN_REQUEST] = arg -> new JoinRequest();
constructors[MIGRATION_INFO] = arg -> new MigrationInfo();
constructors[MEMBER_VERSION] = arg -> new MemberVersion();
constructors[CLUSTER_STATE_CHANGE] = arg -> new ClusterStateChange();
constructors[SPLIT_BRAIN_JOIN_MESSAGE] = arg -> new SplitBrainJoinMessage();
constructors[VERSION] = arg -> new Version();
constructors[FETCH_MEMBER_LIST_STATE] = arg -> new FetchMembersViewOp();
constructors[EXPLICIT_SUSPICION] = arg -> new ExplicitSuspicionOp();
constructors[MEMBERS_VIEW] = arg -> new MembersView();
constructors[TRIGGER_EXPLICIT_SUSPICION] = arg -> new TriggerExplicitSuspicionOp();
constructors[MEMBERS_VIEW_METADATA] = arg -> new MembersViewMetadata();
constructors[HEARTBEAT_COMPLAINT] = arg -> new HeartbeatComplaintOp();
constructors[PROMOTE_LITE_MEMBER] = arg -> new PromoteLiteMemberOp();
constructors[VECTOR_CLOCK] = arg -> new VectorClock();
constructors[ENDPOINT_QUALIFIER] = arg -> new EndpointQualifier();
return new ArrayDataSerializableFactory(constructors);
}
use of com.hazelcast.internal.cluster.impl.operations.FinalizeJoinOp 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();
}
}
Aggregations