use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MembershipManager method sendMemberListToOthers.
/**
* Invoked on the master to send the member list (see {@link MembersUpdateOp}) to non-master nodes.
*/
private void sendMemberListToOthers() {
if (!clusterService.isMaster() || !clusterService.isJoined() || clusterService.getClusterJoinManager().isMastershipClaimInProgress()) {
if (logger.isFineEnabled()) {
logger.fine("Cannot publish member list to cluster. Is-master: " + clusterService.isMaster() + ", joined: " + clusterService.isJoined() + " , mastership claim in progress: " + clusterService.getClusterJoinManager().isMastershipClaimInProgress());
}
return;
}
MemberMap memberMap = getMemberMap();
MembersView membersView = memberMap.toMembersView();
if (logger.isFineEnabled()) {
logger.fine("Sending member list to the non-master nodes: " + memberListString());
}
for (MemberImpl member : memberMap.getMembers()) {
if (member.localMember()) {
continue;
}
MembersUpdateOp op = new MembersUpdateOp(member.getUuid(), membersView, clusterService.getClusterTime(), null, false);
op.setCallerUuid(clusterService.getThisUuid());
nodeEngine.getOperationService().send(op, member.getAddress());
}
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MembershipManager method registerThisMember.
private void registerThisMember() {
MemberImpl thisMember = getLocalMember();
memberMapRef.set(MemberMap.singleton(thisMember));
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MembershipManager method fetchLatestMembersView.
@SuppressWarnings({ "checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity" })
private MembersView fetchLatestMembersView(MemberMap localMemberMap, Set<MemberImpl> members, Map<MemberInfo, Future<MembersView>> futures) {
MembersView latestMembersView = localMemberMap.toTailMembersView(node.getLocalMember(), true);
for (MemberImpl member : members) {
futures.put(new MemberInfo(member), invokeFetchMembersViewOp(member.getAddress(), member.getUuid()));
}
long mastershipClaimTimeout = SECONDS.toMillis(mastershipClaimTimeoutSeconds);
while (clusterService.isJoined()) {
boolean done = true;
for (Entry<MemberInfo, Future<MembersView>> e : new ArrayList<>(futures.entrySet())) {
MemberInfo member = e.getKey();
Address address = member.getAddress();
Future<MembersView> future = e.getValue();
long startNanos = Timer.nanos();
try {
long timeout = min(FETCH_MEMBER_LIST_MILLIS, Math.max(mastershipClaimTimeout, 1));
MembersView membersView = future.get(timeout, MILLISECONDS);
if (membersView.isLaterThan(latestMembersView)) {
if (logger.isFineEnabled()) {
logger.fine("A more recent " + membersView + " is received from " + address);
}
latestMembersView = membersView;
// If we discover a new member via a fetched member list, we should also ask for its members view.
// there are some new members added to the futures map. lets wait for their results.
done &= !fetchMembersViewFromNewMembers(membersView, futures);
}
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
} catch (ExecutionException ignored) {
// we couldn't learn MembersView of 'address'. It will be removed from the cluster.
EmptyStatement.ignore(ignored);
} catch (TimeoutException ignored) {
MemberInfo latestMemberInfo = latestMembersView.getMember(address);
MemberImpl memberImpl = new MemberImpl(member.getAddress(), member.getVersion(), false, member.getUuid());
if (mastershipClaimTimeout > 0 && !isMemberSuspected(memberImpl) && latestMemberInfo != null) {
// we don't suspect from 'address' and we need to learn its response
done = false;
// Mastership claim is idempotent.
// We will retry our claim to member until it explicitly rejects or accepts our claim.
// We can't just rely on invocation retries, because if connection is dropped while
// our claim is on the wire, invocation won't get any response and will eventually timeout.
futures.put(latestMemberInfo, invokeFetchMembersViewOp(address, latestMemberInfo.getUuid()));
}
}
mastershipClaimTimeout -= Timer.millisElapsed(startNanos);
}
if (done) {
break;
}
}
return latestMembersView;
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MembershipManager method memberListString.
String memberListString() {
MemberMap memberMap = getMemberMap();
Collection<MemberImpl> members = memberMap.getMembers();
StringBuilder sb = new StringBuilder("\n\nMembers {").append("size:").append(members.size()).append(", ").append("ver:").append(memberMap.getVersion()).append("} [");
for (Member member : members) {
sb.append("\n\t").append(member);
}
sb.append("\n]\n");
return sb.toString();
}
use of com.hazelcast.cluster.impl.MemberImpl 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);
}
Aggregations