Search in sources :

Example 1 with CPMembershipEventImpl

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

the class MetadataRaftGroupManager method sendMembershipEvents.

private void sendMembershipEvents(Collection<CPMemberInfo> currentMembers, Collection<CPMemberInfo> newMembers) {
    if (!isMetadataGroupLeader()) {
        return;
    }
    EventService eventService = nodeEngine.getEventService();
    Collection<CPMemberInfo> addedMembers = new LinkedHashSet<>(newMembers);
    addedMembers.removeAll(currentMembers);
    for (CPMemberInfo member : addedMembers) {
        CPMembershipEvent event = new CPMembershipEventImpl(member, EventType.ADDED);
        eventService.publishEvent(SERVICE_NAME, EVENT_TOPIC_MEMBERSHIP, event, EVENT_TOPIC_MEMBERSHIP.hashCode());
    }
    Collection<CPMemberInfo> removedMembers = new LinkedHashSet<>(currentMembers);
    removedMembers.removeAll(newMembers);
    for (CPMemberInfo member : removedMembers) {
        CPMembershipEvent event = new CPMembershipEventImpl(member, EventType.REMOVED);
        eventService.publishEvent(SERVICE_NAME, EVENT_TOPIC_MEMBERSHIP, event, EVENT_TOPIC_MEMBERSHIP.hashCode());
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) EventService(com.hazelcast.spi.impl.eventservice.EventService) CPMembershipEvent(com.hazelcast.cp.event.CPMembershipEvent) CPMembershipEventImpl(com.hazelcast.cp.event.impl.CPMembershipEventImpl)

Aggregations

CPMembershipEvent (com.hazelcast.cp.event.CPMembershipEvent)1 CPMembershipEventImpl (com.hazelcast.cp.event.impl.CPMembershipEventImpl)1 EventService (com.hazelcast.spi.impl.eventservice.EventService)1 LinkedHashSet (java.util.LinkedHashSet)1