use of com.hazelcast.spi.impl.eventservice.EventRegistration in project hazelcast by hazelcast.
the class MapEventPublisherImpl method publishMapPartitionLostEvent.
@Override
public void publishMapPartitionLostEvent(Address caller, String mapName, int partitionId) {
Collection<EventRegistration> registrations = new LinkedList<>();
for (EventRegistration registration : getRegistrations(mapName)) {
if (registration.getFilter() instanceof MapPartitionLostEventFilter) {
registrations.add(registration);
}
}
if (registrations.isEmpty()) {
return;
}
String thisNodesAddress = getThisNodesAddress();
MapPartitionEventData eventData = new MapPartitionEventData(thisNodesAddress, mapName, caller, partitionId);
publishEventInternal(registrations, eventData, partitionId);
}
use of com.hazelcast.spi.impl.eventservice.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.impl.eventservice.EventRegistration in project hazelcast by hazelcast.
the class NodeQueryCacheEventService method publishLocalEvent.
// TODO needs refactoring.
private void publishLocalEvent(String cacheId, Object eventData, Extractors extractors) {
Collection<EventRegistration> eventRegistrations = getRegistrations(cacheId);
if (eventRegistrations.isEmpty()) {
return;
}
for (EventRegistration eventRegistration : eventRegistrations) {
Registration registration = (Registration) eventRegistration;
Object listener = registration.getListener();
if (!(listener instanceof QueryCacheListenerAdapter)) {
continue;
}
Object eventDataToPublish = eventData;
int orderKey = -1;
if (eventDataToPublish instanceof LocalCacheWideEventData) {
orderKey = cacheId.hashCode();
} else if (eventDataToPublish instanceof LocalEntryEventData) {
LocalEntryEventData localEntryEventData = (LocalEntryEventData) eventDataToPublish;
if (localEntryEventData.getEventType() != EventLostEvent.EVENT_TYPE) {
EventFilter filter = registration.getFilter();
if (!canPassFilter(localEntryEventData, filter, extractors)) {
continue;
} else {
boolean includeValue = isIncludeValue(filter);
eventDataToPublish = includeValue ? localEntryEventData : localEntryEventData.cloneWithoutValue();
Data keyData = localEntryEventData.getKeyData();
orderKey = keyData == null ? -1 : keyData.hashCode();
}
}
}
publishEventInternal(registration, eventDataToPublish, orderKey);
}
}
use of com.hazelcast.spi.impl.eventservice.EventRegistration in project hazelcast by hazelcast.
the class NodeQueryCacheEventService method sendEventToSubscriber.
@Override
public void sendEventToSubscriber(String name, Object eventData, int orderKey) {
Collection<EventRegistration> eventRegistrations = getRegistrations(name);
if (eventRegistrations.isEmpty()) {
return;
}
for (EventRegistration eventRegistration : eventRegistrations) {
Registration registration = (Registration) eventRegistration;
Object listener = registration.getListener();
if (listener instanceof QueryCacheListenerAdapter) {
continue;
}
publishEventInternal(registration, eventData, orderKey);
}
}
use of com.hazelcast.spi.impl.eventservice.EventRegistration in project hazelcast by hazelcast.
the class NodeQueryCacheEventService method hasListener.
@Override
public boolean hasListener(String mapName, String cacheId) {
Collection<EventRegistration> eventRegistrations = getRegistrations(cacheId);
if (eventRegistrations.isEmpty()) {
return false;
}
for (EventRegistration eventRegistration : eventRegistrations) {
Registration registration = (Registration) eventRegistration;
Object listener = registration.getListener();
if (listener instanceof QueryCacheListenerAdapter) {
return true;
}
}
return false;
}
Aggregations