Search in sources :

Example 1 with MembershipManager

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));
    }
}
Also used : Address(com.hazelcast.nio.Address) RetryableHazelcastException(com.hazelcast.spi.exception.RetryableHazelcastException) MemberInfo(com.hazelcast.internal.cluster.MemberInfo) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) MembershipManager(com.hazelcast.internal.cluster.impl.MembershipManager) TriggerMemberListPublishOp(com.hazelcast.internal.cluster.impl.operations.TriggerMemberListPublishOp) TopologyChangedException(com.hazelcast.jet.core.TopologyChangedException)

Example 2 with MembershipManager

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);
}
Also used : MemberInfo(com.hazelcast.internal.cluster.MemberInfo) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) ArrayList(java.util.ArrayList) MembershipManager(com.hazelcast.internal.cluster.impl.MembershipManager) MembersView(com.hazelcast.internal.cluster.impl.MembersView)

Example 3 with MembershipManager

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);
}
Also used : Address(com.hazelcast.cluster.Address) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) MembershipManager(com.hazelcast.internal.cluster.impl.MembershipManager) UUID(java.util.UUID)

Example 4 with MembershipManager

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));
    }
}
Also used : Address(com.hazelcast.cluster.Address) RetryableHazelcastException(com.hazelcast.spi.exception.RetryableHazelcastException) MemberInfo(com.hazelcast.internal.cluster.MemberInfo) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) MembershipManager(com.hazelcast.internal.cluster.impl.MembershipManager) TriggerMemberListPublishOp(com.hazelcast.internal.cluster.impl.operations.TriggerMemberListPublishOp) TopologyChangedException(com.hazelcast.jet.core.TopologyChangedException)

Aggregations

ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)4 MembershipManager (com.hazelcast.internal.cluster.impl.MembershipManager)4 MemberInfo (com.hazelcast.internal.cluster.MemberInfo)3 Address (com.hazelcast.cluster.Address)2 TriggerMemberListPublishOp (com.hazelcast.internal.cluster.impl.operations.TriggerMemberListPublishOp)2 TopologyChangedException (com.hazelcast.jet.core.TopologyChangedException)2 RetryableHazelcastException (com.hazelcast.spi.exception.RetryableHazelcastException)2 MembersView (com.hazelcast.internal.cluster.impl.MembersView)1 Address (com.hazelcast.nio.Address)1 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1