use of com.hazelcast.internal.cluster.impl.MembershipManager in project hazelcast-jet by hazelcast.
the class JobExecutionService method verifyClusterInformation.
private void verifyClusterInformation(long jobId, long executionId, Address coordinator, int coordinatorMemberListVersion, Set<MemberInfo> participants) {
Address masterAddress = nodeEngine.getMasterAddress();
if (!coordinator.equals(masterAddress)) {
failIfNotRunning();
throw new IllegalStateException(String.format("Coordinator %s cannot initialize %s. Reason: it is not the master, the master is %s", coordinator, jobAndExecutionId(jobId, executionId), masterAddress));
}
ClusterServiceImpl clusterService = (ClusterServiceImpl) nodeEngine.getClusterService();
MembershipManager membershipManager = clusterService.getMembershipManager();
int localMemberListVersion = membershipManager.getMemberListVersion();
Address thisAddress = nodeEngine.getThisAddress();
if (coordinatorMemberListVersion > localMemberListVersion) {
assert !masterAddress.equals(thisAddress) : String.format("Local node: %s is master but InitOperation has coordinator member list version: %s larger than " + " local member list version: %s", thisAddress, coordinatorMemberListVersion, localMemberListVersion);
nodeEngine.getOperationService().send(new TriggerMemberListPublishOp(), masterAddress);
throw new RetryableHazelcastException(String.format("Cannot initialize %s for coordinator %s, local member list version %s," + " coordinator member list version %s", jobAndExecutionId(jobId, executionId), coordinator, localMemberListVersion, coordinatorMemberListVersion));
}
boolean isLocalMemberParticipant = false;
for (MemberInfo participant : participants) {
if (participant.getAddress().equals(thisAddress)) {
isLocalMemberParticipant = true;
}
if (membershipManager.getMember(participant.getAddress(), participant.getUuid()) == null) {
throw new TopologyChangedException(String.format("Cannot initialize %s for coordinator %s: participant %s not found in local member list." + " Local member list version: %s, coordinator member list version: %s", jobAndExecutionId(jobId, executionId), coordinator, participant, localMemberListVersion, coordinatorMemberListVersion));
}
}
if (!isLocalMemberParticipant) {
throw new IllegalArgumentException(String.format("Cannot initialize %s since member %s is not in participants: %s", jobAndExecutionId(jobId, executionId), thisAddress, participants));
}
}
use of com.hazelcast.internal.cluster.impl.MembershipManager in project hazelcast by hazelcast.
the class ClusterViewListenerService method getMemberListViewMessage.
private ClientMessage getMemberListViewMessage() {
MembershipManager membershipManager = ((ClusterServiceImpl) nodeEngine.getClusterService()).getMembershipManager();
MembersView membersView = membershipManager.getMembersView();
int version = membersView.getVersion();
List<MemberInfo> members = membersView.getMembers();
ArrayList<MemberInfo> memberInfos = new ArrayList<>();
for (MemberInfo member : members) {
memberInfos.add(new MemberInfo(clientAddressOf(member.getAddress()), member.getUuid(), member.getAttributes(), member.isLiteMember(), member.getVersion(), member.getAddressMap()));
}
return ClientAddClusterViewListenerCodec.encodeMembersViewEvent(version, memberInfos);
}
use of com.hazelcast.internal.cluster.impl.MembershipManager in project hazelcast by hazelcast.
the class PromoteLiteMemberOp method run.
@Override
public void run() throws Exception {
ClusterServiceImpl service = getService();
Address callerAddress = getCallerAddress();
UUID callerUuid = getCallerUuid();
MembershipManager membershipManager = service.getMembershipManager();
response = membershipManager.promoteToDataMember(callerAddress, callerUuid);
}
use of com.hazelcast.internal.cluster.impl.MembershipManager in project hazelcast by hazelcast.
the class JobExecutionService method verifyClusterInformation.
private void verifyClusterInformation(long jobId, long executionId, Address coordinator, int coordinatorMemberListVersion, Set<MemberInfo> participants) {
Address masterAddress = nodeEngine.getMasterAddress();
ClusterServiceImpl clusterService = (ClusterServiceImpl) nodeEngine.getClusterService();
MembershipManager membershipManager = clusterService.getMembershipManager();
int localMemberListVersion = membershipManager.getMemberListVersion();
Address thisAddress = nodeEngine.getThisAddress();
if (coordinatorMemberListVersion > localMemberListVersion) {
if (masterAddress == null) {
// elected or split brain merge will happen).
throw new RetryableHazelcastException(String.format("Cannot initialize %s for coordinator %s, local member list version %s," + " coordinator member list version %s. And also, since the master address" + " is not known to this member, cannot request a new member list from master.", jobIdAndExecutionId(jobId, executionId), coordinator, localMemberListVersion, coordinatorMemberListVersion));
}
assert !masterAddress.equals(thisAddress) : String.format("Local node: %s is master but InitOperation has coordinator member list version: %s larger than " + " local member list version: %s", thisAddress, coordinatorMemberListVersion, localMemberListVersion);
nodeEngine.getOperationService().send(new TriggerMemberListPublishOp(), masterAddress);
throw new RetryableHazelcastException(String.format("Cannot initialize %s for coordinator %s, local member list version %s," + " coordinator member list version %s", jobIdAndExecutionId(jobId, executionId), coordinator, localMemberListVersion, coordinatorMemberListVersion));
}
// If the participant members can receive the new member list before the
// coordinator, and we can also get into the
// "coordinatorMemberListVersion < localMemberListVersion" case. If this
// situation occurs when a job participant leaves, then the job start will
// fail. Since the unknown participating member situation couldn't
// be resolved with retrying the InitExecutionOperation for this
// case, we do nothing here and let it fail below if some participant
// isn't found.
// The job start won't fail if this situation occurs when a new member
// is added to the cluster, because all job participants are known to the
// other participating members. The only disadvantage of this is that a
// newly added member will not be a job participant and partition mapping
// may not be completely proper in this case.
boolean isLocalMemberParticipant = false;
for (MemberInfo participant : participants) {
if (participant.getAddress().equals(thisAddress)) {
isLocalMemberParticipant = true;
}
if (membershipManager.getMember(participant.getAddress(), participant.getUuid()) == null) {
throw new TopologyChangedException(String.format("Cannot initialize %s for coordinator %s: participant %s not found in local member list." + " Local member list version: %s, coordinator member list version: %s", jobIdAndExecutionId(jobId, executionId), coordinator, participant, localMemberListVersion, coordinatorMemberListVersion));
}
}
if (!isLocalMemberParticipant) {
throw new IllegalArgumentException(String.format("Cannot initialize %s since member %s is not in participants: %s", jobIdAndExecutionId(jobId, executionId), thisAddress, participants));
}
}
Aggregations