use of com.hazelcast.spi.impl.eventservice.InternalEventService in project hazelcast by hazelcast.
the class ProxyRegistry method doCreateProxy.
private DistributedObjectFuture doCreateProxy(String name, boolean publishEvent, boolean initialize, DistributedObjectFuture proxyFuture) {
DistributedObject proxy;
try {
proxy = service.createDistributedObject(name);
if (initialize && proxy instanceof InitializingObject) {
try {
((InitializingObject) proxy).initialize();
} catch (Exception e) {
// log and throw exception to be handled in outer catch block
proxyService.logger.warning("Error while initializing proxy: " + proxy, e);
throw e;
}
}
proxyFuture.set(proxy);
} catch (Throwable e) {
// proxy creation or initialization failed
// deregister future to avoid infinite hang on future.get()
proxyFuture.setError(e);
proxies.remove(name);
throw ExceptionUtil.rethrow(e);
}
InternalEventService eventService = proxyService.nodeEngine.getEventService();
ProxyEventProcessor callback = new ProxyEventProcessor(proxyService.listeners.values(), CREATED, serviceName, name, proxy);
eventService.executeEventCallback(callback);
if (publishEvent) {
publish(new DistributedObjectEventPacket(CREATED, serviceName, name));
}
return proxyFuture;
}
use of com.hazelcast.spi.impl.eventservice.InternalEventService in project hazelcast by hazelcast.
the class PartitionLostListenerRegistrationTest method assertRegistrationsSizeEventually.
private void assertRegistrationsSizeEventually(final HazelcastInstance instance, final int expectedSize) {
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
final InternalEventService eventService = getNode(instance).getNodeEngine().getEventService();
assertEquals(expectedSize, eventService.getRegistrations(SERVICE_NAME, PARTITION_LOST_EVENT_TOPIC).size());
}
});
}
});
}
use of com.hazelcast.spi.impl.eventservice.InternalEventService in project hazelcast by hazelcast.
the class AbstractCacheRecordStore method closeListeners.
protected void closeListeners() {
InternalEventService eventService = (InternalEventService) cacheService.getNodeEngine().getEventService();
Collection<EventRegistration> candidates = eventService.getRegistrations(ICacheService.SERVICE_NAME, name);
for (EventRegistration eventRegistration : candidates) {
eventService.close(eventRegistration);
}
}
use of com.hazelcast.spi.impl.eventservice.InternalEventService in project hazelcast by hazelcast.
the class ProxyRegistry method destroyProxy.
/**
* Destroys a proxy.
*
* @param name The name of the proxy to destroy.
* @param publishEvent true if this destroy should be published.
*/
void destroyProxy(String name, boolean publishEvent) {
final DistributedObjectFuture proxyFuture = proxies.remove(name);
if (proxyFuture == null) {
return;
}
DistributedObject proxy;
try {
proxy = proxyFuture.get();
} catch (Throwable t) {
proxyService.logger.warning("Cannot destroy proxy [" + serviceName + ":" + name + "], since its creation is failed with " + t.getClass().getName() + ": " + t.getMessage());
return;
}
InternalEventService eventService = proxyService.nodeEngine.getEventService();
ProxyEventProcessor callback = new ProxyEventProcessor(proxyService.listeners.values(), DESTROYED, serviceName, name, proxy);
eventService.executeEventCallback(callback);
if (publishEvent) {
publish(new DistributedObjectEventPacket(DESTROYED, serviceName, name));
}
}
Aggregations