use of com.hazelcast.spi.impl.eventservice.EventService in project hazelcast by hazelcast.
the class MultiMapEventsPublisher method publishMultiMapEvent.
public void publishMultiMapEvent(String mapName, EntryEventType eventType, int numberOfEntriesAffected) {
EventService eventService = nodeEngine.getEventService();
Collection<EventRegistration> registrations = eventService.getRegistrations(MultiMapService.SERVICE_NAME, mapName);
if (registrations.isEmpty()) {
return;
}
Address caller = nodeEngine.getThisAddress();
String source = caller.toString();
MapEventData mapEventData = new MapEventData(source, mapName, caller, eventType.getType(), numberOfEntriesAffected);
eventService.publishEvent(MultiMapService.SERVICE_NAME, registrations, mapEventData, mapName.hashCode());
}
use of com.hazelcast.spi.impl.eventservice.EventService in project hazelcast by hazelcast.
the class ProxyRegistry method publish.
private void publish(DistributedObjectEventPacket event) {
EventService eventService = proxyService.nodeEngine.getEventService();
Collection<EventRegistration> registrations = eventService.getRegistrations(ProxyServiceImpl.SERVICE_NAME, ProxyServiceImpl.SERVICE_NAME);
eventService.publishRemoteEvent(ProxyServiceImpl.SERVICE_NAME, registrations, event, event.getName().hashCode());
}
use of com.hazelcast.spi.impl.eventservice.EventService in project hazelcast by hazelcast.
the class ProxyRegistry method destroyProxy.
/**
* Destroys a proxy.
*
* @param name The name of the proxy to destroy.
* @param source The UUID of the client or member which initialized destroyProxy.
* @param publishEvent true if this destroy should be published.
*/
void destroyProxy(String name, UUID source, boolean publishEvent) {
final DistributedObjectFuture proxyFuture = proxies.remove(name);
if (proxyFuture == null) {
return;
}
DistributedObject proxy;
try {
proxy = proxyFuture.getNow();
} catch (Throwable t) {
proxyService.logger.warning("Cannot destroy proxy [" + serviceName + ":" + name + "], since its creation is failed with " + t.getClass().getName() + ": " + t.getMessage());
return;
}
if (proxy == null) {
// complete exceptionally the proxy future
try {
proxyFuture.setError(new DistributedObjectDestroyedException("Proxy [" + serviceName + ":" + name + "] " + "was destroyed while being created. This may result in incomplete cleanup of resources."));
} catch (IllegalStateException e) {
// proxy was set and initialized in the meanwhile
proxy = proxyFuture.get();
}
}
if (proxy != null) {
EventService eventService = proxyService.nodeEngine.getEventService();
ProxyEventProcessor callback = new ProxyEventProcessor(proxyService.listeners.values(), DESTROYED, serviceName, name, proxy, source);
eventService.executeEventCallback(callback);
}
if (publishEvent) {
publish(new DistributedObjectEventPacket(DESTROYED, serviceName, name, source));
}
}
use of com.hazelcast.spi.impl.eventservice.EventService in project hazelcast by hazelcast.
the class PublishOperation method run.
@Override
public void run() throws Exception {
TopicService service = getService();
TopicEvent topicEvent = new TopicEvent(name, message, getCallerAddress());
EventService eventService = getNodeEngine().getEventService();
Collection<EventRegistration> registrations = eventService.getRegistrations(TopicService.SERVICE_NAME, name);
Lock lock = service.getOrderLock(name);
lock.lock();
try {
eventService.publishEvent(TopicService.SERVICE_NAME, registrations, topicEvent, name.hashCode());
} finally {
lock.unlock();
}
}
use of com.hazelcast.spi.impl.eventservice.EventService in project hazelcast by hazelcast.
the class ClientMigrationListenerTest method assertRegistrationsSizeEventually.
private void assertRegistrationsSizeEventually(HazelcastInstance instance, int size) {
assertTrueEventually(() -> {
EventService eventService = getNode(instance).getNodeEngine().getEventService();
Collection<EventRegistration> registrations = eventService.getRegistrations(SERVICE_NAME, MIGRATION_EVENT_TOPIC);
assertEquals(size, registrations.size());
});
}
Aggregations