@Override public void close() { this.cache.removeListener(this); this.cache.getCacheManager().removeListener(this); // Cleanup any unregistered listeners for (ExecutorService executor : this.listeners.values()) { PrivilegedAction<List<Runnable>> action = () -> executor.shutdownNow(); WildFlySecurityManager.doUnchecked(action); } this.listeners.clear(); }
@Override public void accept(EmbeddedCacheManager manager) { manager.removeListener(this); manager.stop(); InfinispanLogger.ROOT_LOGGER.debugf("%s cache container stopped", this.name); }
@Override public void removeListener(Object listener) { this.container.removeListener(listener); }
@Override public void unlistenRoleChange(IListenRoleChange i) { EmbeddedCacheManager manager = this.cm; if (manager == null) { // In case we cannot fetch the information, lets assume we // are standby, so to have less responsibility. return; } if (this.roleChangeListeners != null) { this.roleChangeListeners.remove(i); } if ((this.roleChangeListeners != null && this.roleChangeListeners .isEmpty()) && (this.cacheManagerListener != null)) { manager.removeListener(this.cacheManagerListener); this.cacheManagerListener = null; this.roleChangeListeners = null; } }
/** * {@inheritDoc} */ @Override public void stop() throws CacheLoaderException { cacheManager.removeListener(listener); super.stop(); }
@Override public void close() { this.cache.removeListener(this); this.cache.getCacheManager().removeListener(this); // Cleanup any unregistered listeners for (ExecutorService executor : this.listeners.values()) { PrivilegedAction<List<Runnable>> action = () -> executor.shutdownNow(); WildFlySecurityManager.doUnchecked(action); } this.listeners.clear(); }
@Override public void accept(EmbeddedCacheManager manager) { manager.removeListener(this); manager.stop(); InfinispanLogger.ROOT_LOGGER.debugf("%s cache container stopped", this.name); }
@Test public void removeListener() { Object listener = new Object(); this.subject.removeListener(listener); verify(this.manager).removeListener(listener); }
/** * {@inheritDoc} * @see org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManager#stop() */ @Override public void stop() { if (this.jvmRouteHandler != null) { EmbeddedCacheManager container = (EmbeddedCacheManager) this.sessionCache.getCacheManager(); container.removeListener(this.jvmRouteHandler); } this.sessionCache.removeListener(this); this.sessionCache.stop(); }
private void stop(CacheContainerRegistryEntry entry) { String jndiName = entry.getJndiName(); if (jndiName != null) { try { logger.info("Unbinding " + entry.getId() + " cache container from " + jndiName); this.unbind(jndiName); } catch (NamingException e) { logger.warn(e.getMessage(), e); } } EmbeddedCacheManager container = entry.getContainer(); container.removeListener(this.factory); container.stop(); }
public static boolean stopAndUnregisterContainer(final EmbeddedCacheManager container, final Object listener) { PrivilegedAction<Boolean> action = () -> { if (container.getStatus().allowInvocations()) { container.removeListener(listener); container.stop(); return true; } else { return false; } }; return doPrivileged(action); }
@Override public void stop(StopContext context) { Cache<Address, Map.Entry<K, V>> cache = this.cache.getValue(); cache.removeListener(this); cache.getCacheManager().removeListener(this); Operation<Void> operation = new Operation<Void>() { @Override public Void invoke(Cache<Address, Map.Entry<K, V>> cache) { cache.remove(getLocalAddress(cache)); return null; } }; // Add SKIP_LOCKING flag to so that we aren't blocked by state transfer lock this.invoker.invoke(this.cache.getValue(), operation, Flag.SKIP_REMOTE_LOOKUP, Flag.SKIP_LOCKING); }
@CacheStopped public void stopped(CacheStoppedEvent event) { EmbeddedCacheManager container = event.getCacheManager(); String containerName = container.getGlobalConfiguration().getCacheManagerName(); synchronized (lockManagers) { LockManagerEntry entry = lockManagers.get(containerName); if (entry != null) { String cacheName = event.getCacheName(); debug("Deregistering \"%s\" cache from lock manager for \"%s\" container", cacheName, containerName); // Returns true if this was the last cache if (entry.removeCache(cacheName)) { debug("Stopped lock manager for \"%s\" container", containerName); lockManagers.remove(containerName); container.removeListener(entry); } } } } }
public void testAddRemoveListenerWhileNotRunning() throws Exception { GetCacheManagerCheckListener listener = new GetCacheManagerCheckListener(); ConfigurationBuilderHolder holder = new ConfigurationBuilderHolder(); holder.getGlobalConfigurationBuilder().clusteredDefault().defaultCacheName("default"); holder.newConfigurationBuilder("default").clustering().cacheMode(CacheMode.DIST_SYNC); EmbeddedCacheManager cmA = TestCacheManagerFactory.createClusteredCacheManager(false, holder, false); EmbeddedCacheManager cmB = null; try { cmA.addListener(listener); cmA.getCache(); cmB = TestCacheManagerFactory.createClusteredCacheManager(); cmB.getCache(); assertNotNull(listener.firstEvent.get(10, TimeUnit.SECONDS)); } finally { TestingUtil.killCacheManagers(cmA, cmB); } // Should not throw an exception? cmA.removeListener(listener); }