/** * Returns the name of the default cache. * @return a cache name */ default String getDefaultCacheName() { return this.getCacheManagerConfiguration().defaultCacheName().orElse(null); } }
@Override public EmbeddedCacheManager get() { GlobalConfiguration config = this.configuration.get(); String defaultCacheName = config.defaultCacheName().orElse(null); // We need to create a dummy default configuration if cache has a default cache Configuration defaultConfiguration = (defaultCacheName != null) ? new ConfigurationBuilder().build() : null; EmbeddedCacheManager manager = new DefaultCacheManager(config, defaultConfiguration, false); // Undefine the default cache, if we defined one if (defaultCacheName != null) { manager.undefineConfiguration(defaultCacheName); } // Override GlobalConfigurationManager with a local implementation @SuppressWarnings("deprecation") BasicComponentRegistry registry = manager.getGlobalComponentRegistry().getComponent(BasicComponentRegistry.class); registry.replaceComponent(GlobalConfigurationManager.class.getName(), new LocalGlobalConfigurationManager(), false); registry.rewire(); manager.start(); manager.addListener(this); InfinispanLogger.ROOT_LOGGER.debugf("%s cache container started", this.name); return manager; }
private static boolean isDefaultCacheName(GlobalConfiguration globalConfiguration, String cacheName) { String defaultCacheName = globalConfiguration.defaultCacheName().orElse( null ); return cacheName.equals( defaultCacheName ); }
private static boolean isDefaultCacheName(GlobalConfiguration globalConfiguration, String cacheName) { String defaultCacheName = globalConfiguration.defaultCacheName().orElse( null ); return cacheName.equals( defaultCacheName ); }
/** * Returns the name of the default cache. * @return a cache name */ default String getDefaultCacheName() { return this.getCacheManagerConfiguration().defaultCacheName().orElse(null); } }
private Session validateSession(final String sessionId) { if (sessionId == null) { Session session = new SessionImpl(codecRegistry, cacheManager, null, timeService); cacheManager.getCacheManagerConfiguration().defaultCacheName().ifPresent(session::setCurrentCache); return session; } if (!sessions.containsKey(sessionId)) { throw log.invalidSession(sessionId); } return sessions.get(sessionId); }
private static Configuration defaultCacheConfiguration(TransactionManagerLookupDelegator transactionManagerLookupDelegator, EmbeddedCacheManager tmpCacheManager, GlobalConfiguration globalConfiguration) { if ( tmpCacheManager.getDefaultCacheConfiguration() != null ) { String defaultCacheName = globalConfiguration.defaultCacheName().orElse( null ); return updateConfiguration( defaultCacheName, transactionManagerLookupDelegator, tmpCacheManager.getDefaultCacheConfiguration() ); } return null; }
private static Configuration defaultCacheConfiguration(TransactionManagerLookupDelegator transactionManagerLookupDelegator, EmbeddedCacheManager tmpCacheManager, GlobalConfiguration globalConfiguration) { if ( tmpCacheManager.getDefaultCacheConfiguration() != null ) { String defaultCacheName = globalConfiguration.defaultCacheName().orElse( null ); return updateConfiguration( defaultCacheName, transactionManagerLookupDelegator, tmpCacheManager.getDefaultCacheConfiguration() ); } return null; }
public static Set<String> getInternalAndUserCacheNames(EmbeddedCacheManager cacheManager) { Set<String> testCaches = new HashSet<>(cacheManager.getCacheNames()); if (cacheManager.isDefaultRunning()) { String defaultCacheName = cacheManager.getCacheManagerConfiguration().defaultCacheName().orElse(CacheContainer.DEFAULT_CACHE_NAME); testCaches.add(defaultCacheName); } testCaches.addAll(getInternalCacheNames(cacheManager)); return testCaches; }
@Override public void reset() { if (cacheManager.getCacheManagerConfiguration().defaultCacheName().isPresent()) resetCache(cacheManager.getCache()); for (String cacheName : cacheManager.getCacheNames()) { resetCache(cacheManager.getCache(cacheName)); } timestamp = timeService.time(); }
private static Set<Cache> getRunningCaches(EmbeddedCacheManager cacheContainer) { if (cacheContainer == null || !cacheContainer.getStatus().allowInvocations()) return Collections.emptySet(); Set<String> running = new LinkedHashSet<>(getOrderedCacheNames(cacheContainer)); extractGlobalComponent(cacheContainer, InternalCacheRegistry.class).filterPrivateCaches(running); running.addAll(cacheContainer.getCacheNames()); running.add(cacheContainer.getCacheManagerConfiguration().defaultCacheName().orElse(DEFAULT_CACHE_NAME)); return running.stream() .map(s -> cacheContainer.getCache(s, false)) .filter(Objects::nonNull) .filter(c -> c.getStatus().allowInvocations()) .collect(Collectors.toCollection(LinkedHashSet::new)); }
@Override public EmbeddedCacheManager get() { GlobalConfiguration config = this.configuration.get(); String defaultCacheName = config.defaultCacheName().orElse(null); // We need to create a dummy default configuration if cache has a default cache Configuration defaultConfiguration = (defaultCacheName != null) ? new ConfigurationBuilder().build() : null; EmbeddedCacheManager manager = new DefaultCacheManager(config, defaultConfiguration, false); // Undefine the default cache, if we defined one if (defaultCacheName != null) { manager.undefineConfiguration(defaultCacheName); } // Override GlobalConfigurationManager with a local implementation @SuppressWarnings("deprecation") BasicComponentRegistry registry = manager.getGlobalComponentRegistry().getComponent(BasicComponentRegistry.class); registry.replaceComponent(GlobalConfigurationManager.class.getName(), new LocalGlobalConfigurationManager(), false); registry.rewire(); manager.start(); manager.addListener(this); InfinispanLogger.ROOT_LOGGER.debugf("%s cache container started", this.name); return manager; }
@Override protected void rebuildIndexes() throws Exception { String cacheManagerName = manager(0).getCacheManagerConfiguration().globalJmxStatistics().cacheManagerName(); ObjectName massIndexerObjName = getMassIndexerObjectName( BASE_JMX_DOMAIN + 0, cacheManagerName, manager(0).getCacheManagerConfiguration().defaultCacheName().get()); server.invoke(massIndexerObjName, "start", new Object[0], new String[0]); }
@Override public void call() { GlobalConfiguration globalCfg = cm.getCacheManagerConfiguration(); assertFalse(globalCfg.defaultCacheName().isPresent()); assertNull(cm.getDefaultCacheConfiguration()); assertEquals(CacheMode.REPL_SYNC, cm.getCacheConfiguration("default").clustering().cacheMode()); }