/** * Retrieves a DistributedObjectFuture or creates it if it is not available. * If {@code initialize} is false and DistributedObject implements {@link InitializingObject}, * {@link InitializingObject#initialize()} will be called before {@link DistributedObjectFuture#get()} returns. * * @param name The name of the DistributedObject proxy object to retrieve or create. * @param publishEvent true if a DistributedObjectEvent should be fired. * @param initialize true if the DistributedObject proxy object should be initialized. */ public DistributedObjectFuture getOrCreateProxyFuture(String name, boolean publishEvent, boolean initialize) { DistributedObjectFuture proxyFuture = proxies.get(name); if (proxyFuture == null) { if (!proxyService.nodeEngine.isRunning()) { throw new HazelcastInstanceNotActiveException(); } proxyFuture = createProxy(name, publishEvent, initialize); if (proxyFuture == null) { return getOrCreateProxyFuture(name, publishEvent, initialize); } } return proxyFuture; }
/** * Retrieves a DistributedObjectFuture or creates it if it is not available. * If {@code initialize} is false and DistributedObject implements {@link InitializingObject}, * {@link InitializingObject#initialize()} will be called before {@link DistributedObjectFuture#get()} returns. * * @param name The name of the DistributedObject proxy object to retrieve or create. * @param publishEvent true if a DistributedObjectEvent should be fired. * @param initialize true if the DistributedObject proxy object should be initialized. */ public DistributedObjectFuture getOrCreateProxyFuture(String name, boolean publishEvent, boolean initialize) { DistributedObjectFuture proxyFuture = proxies.get(name); if (proxyFuture == null) { if (!proxyService.nodeEngine.isRunning()) { throw new HazelcastInstanceNotActiveException(); } proxyFuture = createProxy(name, publishEvent, initialize); if (proxyFuture == null) { return getOrCreateProxyFuture(name, publishEvent, initialize); } } return proxyFuture; }
@Override public void initializeDistributedObject(String serviceName, String name) { checkServiceNameNotNull(serviceName); checkObjectNameNotNull(name); ProxyRegistry registry = getOrCreateRegistry(serviceName); registry.createProxy(name, true, true); createdCounter.inc(); }
@Override public void initializeDistributedObject(String serviceName, String name) { checkServiceNameNotNull(serviceName); checkObjectNameNotNull(name); ProxyRegistry registry = getOrCreateRegistry(serviceName); registry.createProxy(name, true, true); createdCounter.inc(); }
@Override public void run() { try { registry.createProxy(proxyInfo.getObjectName(), false, true); } catch (CacheNotExistsException e) { // this can happen when a cache destroy event is received // after the cache config is replicated during join (pre-join) // but before the cache proxy is created (post-join) getLogger().fine("Could not create Cache[" + proxyInfo.getObjectName() + "]. It is already destroyed.", e); } catch (ReplicatedMapCantBeCreatedOnLiteMemberException e) { // this happens when there is a lite member in the cluster // and a data member creates a ReplicatedMap proxy // (this is totally expected and doesn't need logging) ignore(e); } catch (Exception e) { logProxyCreationFailure(proxyInfo, e); } } }
@Override public void run() { try { registry.createProxy(proxyInfo.getObjectName(), false, true); } catch (CacheNotExistsException e) { // this can happen when a cache destroy event is received // after the cache config is replicated during join (pre-join) // but before the cache proxy is created (post-join) getLogger().fine("Could not create Cache[" + proxyInfo.getObjectName() + "]. It is already destroyed.", e); } catch (ReplicatedMapCantBeCreatedOnLiteMemberException e) { // this happens when there is a lite member in the cluster // and a data member creates a ReplicatedMap proxy // (this is totally expected and doesn't need logging) ignore(e); } catch (Exception e) { logProxyCreationFailure(proxyInfo, e); } } }
@Override public void dispatchEvent(final DistributedObjectEventPacket eventPacket, Object ignore) { String serviceName = eventPacket.getServiceName(); if (eventPacket.getEventType() == CREATED) { try { final ProxyRegistry registry = getOrCreateRegistry(serviceName); if (!registry.contains(eventPacket.getName())) { registry.createProxy(eventPacket.getName(), false, true); // listeners will be called if proxy is created here. } } catch (HazelcastInstanceNotActiveException ignored) { ignore(ignored); } } else { final ProxyRegistry registry = registries.get(serviceName); if (registry != null) { registry.destroyProxy(eventPacket.getName(), false); } } }
@Override public void dispatchEvent(final DistributedObjectEventPacket eventPacket, Object ignore) { String serviceName = eventPacket.getServiceName(); if (eventPacket.getEventType() == CREATED) { try { final ProxyRegistry registry = getOrCreateRegistry(serviceName); if (!registry.contains(eventPacket.getName())) { registry.createProxy(eventPacket.getName(), false, true); // listeners will be called if proxy is created here. } } catch (HazelcastInstanceNotActiveException ignored) { ignore(ignored); } } else { final ProxyRegistry registry = registries.get(serviceName); if (registry != null) { registry.destroyProxy(eventPacket.getName(), false); } } }