Search in sources :

Example 1 with CPGroupAvailabilityEventImpl

use of com.hazelcast.cp.event.impl.CPGroupAvailabilityEventImpl in project hazelcast by hazelcast.

the class RaftService method publishGroupAvailabilityEvents.

private void publishGroupAvailabilityEvents(MemberImpl removedMember) {
    ClusterService clusterService = nodeEngine.getClusterService();
    if (clusterService.getClusterVersion().isUnknownOrLessThan(Versions.V4_1)) {
        return;
    }
    // they will be the ones that keep track of unreachable CP members.
    for (CPGroupId groupId : metadataGroupManager.getActiveGroupIds()) {
        CPGroupSummary group = metadataGroupManager.getGroup(groupId);
        Collection<CPMember> missing = new ArrayList<>();
        boolean availabilityDecreased = false;
        for (CPMember member : group.members()) {
            if (member.getAddress().equals(removedMember.getAddress())) {
                // Group's availability decreased because of this removed member
                availabilityDecreased = true;
                missing.add(member);
            } else if (clusterService.getMember(member.getAddress()) == null) {
                missing.add(member);
            }
        }
        if (availabilityDecreased) {
            CPGroupAvailabilityEvent e = new CPGroupAvailabilityEventImpl(group.id(), group.members(), missing);
            nodeEngine.getEventService().publishEvent(SERVICE_NAME, EVENT_TOPIC_AVAILABILITY, e, EVENT_TOPIC_AVAILABILITY.hashCode());
        }
    }
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) CPGroupAvailabilityEventImpl(com.hazelcast.cp.event.impl.CPGroupAvailabilityEventImpl) CPGroupAvailabilityEvent(com.hazelcast.cp.event.CPGroupAvailabilityEvent) ClusterService(com.hazelcast.internal.cluster.ClusterService) ArrayList(java.util.ArrayList) CPMember(com.hazelcast.cp.CPMember)

Aggregations

CPGroupId (com.hazelcast.cp.CPGroupId)1 CPMember (com.hazelcast.cp.CPMember)1 CPGroupAvailabilityEvent (com.hazelcast.cp.event.CPGroupAvailabilityEvent)1 CPGroupAvailabilityEventImpl (com.hazelcast.cp.event.impl.CPGroupAvailabilityEventImpl)1 ClusterService (com.hazelcast.internal.cluster.ClusterService)1 ArrayList (java.util.ArrayList)1