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());
}
}
}
Aggregations