use of com.hazelcast.spi.impl.eventservice.EventService in project hazelcast by hazelcast.
the class AddCPGroupAvailabilityListenerMessageTask method processInternal.
@Override
protected CompletableFuture<UUID> processInternal() {
EventService eventService = clientEngine.getEventService();
CPGroupAvailabilityListener listener = new ClientCPGroupAvailabilityListener(endpoint);
boolean local = parameters;
if (local) {
UUID id = eventService.registerLocalListener(getServiceName(), TOPIC, listener).getId();
return CompletableFuture.completedFuture(id);
}
return eventService.registerListenerAsync(getServiceName(), TOPIC, listener).thenApplyAsync(EventRegistration::getId, CALLER_RUNS);
}
use of com.hazelcast.spi.impl.eventservice.EventService 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());
}
}
use of com.hazelcast.spi.impl.eventservice.EventService in project hazelcast by hazelcast.
the class AddCPMembershipListenerMessageTask method processInternal.
@Override
protected CompletableFuture<UUID> processInternal() {
EventService eventService = clientEngine.getEventService();
CPMembershipListener listener = new ClientCPMembershipListener(endpoint);
boolean local = parameters;
if (local) {
UUID id = eventService.registerLocalListener(getServiceName(), TOPIC, listener).getId();
return CompletableFuture.completedFuture(id);
}
return eventService.registerListenerAsync(getServiceName(), TOPIC, listener).thenApplyAsync(EventRegistration::getId, CALLER_RUNS);
}
use of com.hazelcast.spi.impl.eventservice.EventService in project hazelcast by hazelcast.
the class ClusterServiceImpl method removeMembershipListener.
public boolean removeMembershipListener(@Nonnull UUID registrationId) {
checkNotNull(registrationId, "registrationId cannot be null");
EventService eventService = nodeEngine.getEventService();
return eventService.deregisterListener(SERVICE_NAME, SERVICE_NAME, registrationId);
}
use of com.hazelcast.spi.impl.eventservice.EventService in project hazelcast by hazelcast.
the class ClusterServiceImpl method addMembershipListener.
@Nonnull
public UUID addMembershipListener(@Nonnull MembershipListener listener) {
checkNotNull(listener, "listener cannot be null");
EventService eventService = nodeEngine.getEventService();
EventRegistration registration;
if (listener instanceof InitialMembershipListener) {
lock.lock();
try {
((InitialMembershipListener) listener).init(new InitialMembershipEvent(this, getMembers()));
registration = eventService.registerLocalListener(SERVICE_NAME, SERVICE_NAME, listener);
} finally {
lock.unlock();
}
} else {
registration = eventService.registerLocalListener(SERVICE_NAME, SERVICE_NAME, listener);
}
return registration.getId();
}
Aggregations