public SSOClusterManager() { this(DefaultCacheContainerRegistry.getInstance()); }
@Override public <K, V> Cache<K, V> getCache() { return this.getCache(CacheContainer.DEFAULT_CACHE_NAME); }
private EmbeddedCacheManager getCacheManager() { return this.registry.getCacheContainer(this.cacheContainerName); }
public void add(CacheContainerRegistryConfigurationEntry configEntry) throws NamingException String id = configEntry.getId(); CacheContainerConfiguration config = configEntry.getConfiguration(); GlobalConfiguration globalConfig = config.getGlobalConfiguration(); EmbeddedCacheManager container = this.factory.createCacheContainer(config); String jndiName = configEntry.getJndiName(); List<String> aliases = configEntry.getAliases(); CacheContainerRegistryEntry entry = new CacheContainerRegistryEntry(id, container, jndiName, aliases); this.start(entry);
public void start() throws Exception { CacheContainerRegistryConfiguration registry = this.source.getRegistryConfiguration(); for (CacheContainerRegistryConfigurationEntry entry: registry.getEntries()) { this.add(entry); } CacheContainerRegistryConfigurationEntry defaultEntry = registry.getDefaultEntry(); if (defaultEntry == null) { defaultEntry = registry.getEntries().get(0); } this.defaultContainer = this.containers.get(defaultEntry.getId()).getContainer(); singleton.compareAndSet(null, this); }
private void start(CacheContainerRegistryEntry entry) { EmbeddedCacheManager container = entry.getContainer(); container.start(); container.addListener(this.factory); String jndiName = entry.getJndiName(); if (jndiName != null) { try { logger.info("Binding " + entry.getId() + " cache container to " + jndiName); this.bind(jndiName, container); } catch (NamingException e) { logger.warn(e.getMessage(), e); } } }
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 EmbeddedCacheManager createCacheContainer(CacheContainerConfiguration configuration) GlobalConfiguration global = configuration.getGlobalConfiguration(); EmbeddedCacheManager manager = new DefaultCacheManager(global, configuration.getDefaultConfiguration(), false); for (Configuration config: configuration.getNamedConfigurations()) return new DefaultCacheContainer(manager);
public void remove(CacheContainerRegistryConfigurationEntry configEntry) { CacheContainerRegistryEntry entry = this.containers.remove(configEntry.getId()); if (entry != null) { for (String alias: entry.getAliases()) { this.aliases.remove(alias); } this.stop(entry); } }
String containerName = this.appendCacheName(globalConfig.getCacheManagerName(), cacheName); EmbeddedCacheManager container = this.containers.get(containerName); global.setClusterName(this.appendCacheName(globalConfig.getClusterName(), cacheName)); global.getTransportProperties().setProperty(DefaultCacheContainerFactory.CHANNEL_ID, global.getClusterName()); container = new SingletonCacheManager(this, cacheName, global, config);
@Override public void init() { if (LOG.isDebugEnabled()) { LOG.debug("init: reuse current cache?" + (cache!=null? "yes" : "no") + ", cache name=" + this.cacheName); } if(this.cache == null) // only create the treecache once (stop + start will use the same treecache) { CacheContainer container = this.registry.getCacheContainer(this.containerName); Cache<String, Binding> underlyingCache = (this.cacheName == null) ? container.<String, Binding>getCache() : container.<String, Binding>getCache(this.cacheName); if (!underlyingCache.getStatus().allowInvocations()) { underlyingCache.start(); } this.cache = this.treeCacheFactory.createTreeCache(underlyingCache); } else if (!cache.getCache().getStatus().allowInvocations()) { cache.getCache().start(); } }
@CacheStarted public void cacheStarted(CacheStartedEvent event) { log("Started", event.getCacheName(), event.getCacheManager()); }
/** * {@inheritDoc} * @see org.jboss.ha.ispn.CacheContainerRegistry#getCacheContainer(java.lang.String) */ @Override public EmbeddedCacheManager getCacheContainer(String alias) { CacheContainerRegistryEntry entry = null; if (alias != null) { // Resolve alias, if possible String id = this.aliases.get(alias); entry = this.containers.get((id != null) ? id : alias); } // Return default cache manager, if name was not found or if it was null return (entry != null) ? entry.getContainer() : this.defaultContainer; }
public void stop() throws Exception { singleton.set(null); for (CacheContainerRegistryEntry entry: this.containers.values()) { this.stop(entry); } this.aliases.clear(); this.containers.clear(); this.defaultContainer = null; }
/** * {@inheritDoc} * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object) */ @Override public CacheContainerConfiguration unmarshal(InfinispanConfiguration configuration) { return new CacheContainerConfiguration(configuration.parseGlobalConfiguration(), configuration.parseDefaultConfiguration(), configuration.parseNamedConfigurations().values()); } }
/** * {@inheritDoc} * @see org.infinispan.manager.EmbeddedCacheManager#isRunning(java.lang.String) */ @Override public boolean isRunning(String cacheName) { EmbeddedCacheManager container = this.containers.get(this.appendCacheName(this.container.getGlobalConfiguration().getCacheManagerName(), cacheName)); return (container != null) ? container.isDefaultRunning() : this.container.isRunning(cacheName); }
/** * {@inheritDoc} * @see org.jboss.web.tomcat.service.session.distributedcache.ispn.CacheSource#getCache(org.jboss.web.tomcat.service.session.distributedcache.spi.LocalDistributableSessionManager) */ @Override public <K, V> Cache<K, V> getCache(LocalDistributableSessionManager manager) { return this.registry.getCacheContainer().getCache(manager.getEngineName()); } }
EmbeddedCacheManager container = event.getCacheManager(); log("Stopped", cacheName, container);
@Override public <K, V> Cache<K, V> getCache(LocalDistributableSessionManager manager) { ReplicationConfig config = manager.getReplicationConfig(); String containerName = config.getCacheName(); String templateCacheName = null; if ((containerName != null) && !containerName.isEmpty()) { String[] parts = containerName.split(DELIMITER); if (parts.length == 2) { containerName = parts[0]; templateCacheName = parts[1]; } } String cacheName = manager.getName(); EmbeddedCacheManager container = this.registry.getCacheContainer(containerName); this.applyOverrides(container.defineConfiguration(cacheName, templateCacheName, new Configuration()), config); return container.<K, V>getCache(cacheName); }
CacheContainer container = this.registry.getCacheContainer(containerName); this.cache = (cacheName == null) ? container.<SSOKey, Object>getCache() : container.<SSOKey, Object>getCache(cacheName);