Search in sources :

Example 1 with InternalEventService

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;
}
Also used : DistributedObject(com.hazelcast.core.DistributedObject) AbstractDistributedObject(com.hazelcast.spi.AbstractDistributedObject) InitializingObject(com.hazelcast.spi.InitializingObject) InternalEventService(com.hazelcast.spi.impl.eventservice.InternalEventService) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException)

Example 2 with InternalEventService

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());
                }
            });
        }
    });
}
Also used : InternalEventService(com.hazelcast.spi.impl.eventservice.InternalEventService) AssertTask(com.hazelcast.test.AssertTask)

Example 3 with InternalEventService

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);
    }
}
Also used : InternalEventService(com.hazelcast.spi.impl.eventservice.InternalEventService) EventRegistration(com.hazelcast.spi.EventRegistration)

Example 4 with InternalEventService

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));
    }
}
Also used : DistributedObject(com.hazelcast.core.DistributedObject) AbstractDistributedObject(com.hazelcast.spi.AbstractDistributedObject) InternalEventService(com.hazelcast.spi.impl.eventservice.InternalEventService)

Aggregations

InternalEventService (com.hazelcast.spi.impl.eventservice.InternalEventService)4 DistributedObject (com.hazelcast.core.DistributedObject)2 AbstractDistributedObject (com.hazelcast.spi.AbstractDistributedObject)2 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)1 EventRegistration (com.hazelcast.spi.EventRegistration)1 InitializingObject (com.hazelcast.spi.InitializingObject)1 AssertTask (com.hazelcast.test.AssertTask)1