use of com.hazelcast.spi.EventRegistration in project hazelcast by hazelcast.
the class EventServiceImpl method registerListenerInternal.
private EventRegistration registerListenerInternal(String serviceName, String topic, EventFilter filter, Object listener, boolean localOnly) {
if (listener == null) {
throw new IllegalArgumentException("Listener required!");
}
if (filter == null) {
throw new IllegalArgumentException("EventFilter required!");
}
EventServiceSegment segment = getSegment(serviceName, true);
String id = UuidUtil.newUnsecureUuidString();
Registration reg = new Registration(id, serviceName, topic, filter, nodeEngine.getThisAddress(), listener, localOnly);
if (!segment.addRegistration(topic, reg)) {
return null;
}
if (!localOnly) {
invokeRegistrationOnOtherNodes(serviceName, reg);
}
return reg;
}
use of com.hazelcast.spi.EventRegistration in project hazelcast by hazelcast.
the class EventServiceImpl method publishEvent.
@Override
public void publishEvent(String serviceName, Collection<EventRegistration> registrations, Object event, int orderKey) {
Data eventData = null;
for (EventRegistration registration : registrations) {
if (!(registration instanceof Registration)) {
throw new IllegalArgumentException();
}
if (isLocal(registration)) {
executeLocal(serviceName, event, registration, orderKey);
continue;
}
if (eventData == null) {
eventData = serializationService.toData(event);
}
EventEnvelope eventEnvelope = new EventEnvelope(registration.getId(), serviceName, eventData);
sendEvent(registration.getSubscriber(), eventEnvelope, orderKey);
}
}
use of com.hazelcast.spi.EventRegistration in project hazelcast by hazelcast.
the class EventServiceImpl method publishRemoteEvent.
@Override
public void publishRemoteEvent(String serviceName, Collection<EventRegistration> registrations, Object event, int orderKey) {
if (registrations.isEmpty()) {
return;
}
Data eventData = serializationService.toData(event);
for (EventRegistration registration : registrations) {
if (!(registration instanceof Registration)) {
throw new IllegalArgumentException();
}
if (isLocal(registration)) {
continue;
}
EventEnvelope eventEnvelope = new EventEnvelope(registration.getId(), serviceName, eventData);
sendEvent(registration.getSubscriber(), eventEnvelope, orderKey);
}
}
use of com.hazelcast.spi.EventRegistration in project hazelcast by hazelcast.
the class ReplicatedMapEventPublishingService method fireMapClearedEvent.
public void fireMapClearedEvent(int deletedEntrySize, String name) {
EventService eventService = nodeEngine.getEventService();
Collection<EventRegistration> registrations = eventService.getRegistrations(SERVICE_NAME, name);
if (registrations.isEmpty()) {
return;
}
MapEventData mapEventData = new MapEventData(name, name, nodeEngine.getThisAddress(), EntryEventType.CLEAR_ALL.getType(), deletedEntrySize);
eventService.publishEvent(SERVICE_NAME, registrations, mapEventData, name.hashCode());
}
use of com.hazelcast.spi.EventRegistration in project hazelcast by hazelcast.
the class QueueOperation method hasListener.
public boolean hasListener() {
EventService eventService = getNodeEngine().getEventService();
Collection<EventRegistration> registrations = eventService.getRegistrations(getServiceName(), name);
return registrations.size() > 0;
}
Aggregations