private VendorCacheManager() { try { // manager = new DefaultCacheManager(repositoryFileName); manager = new DefaultCacheManager(); } catch (Exception e) { LOGGER.error("Cannot start manager " + e.toString()); } }
public void init() throws DBException { try { infinispanManager = new DefaultCacheManager("infinispan-config.xml"); } catch (IOException e) { throw new DBException(e); } }
@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; }
/** * Create cache manager with custom config file. * * @param file config file * @return cache manager */ public static EmbeddedCacheManager create(String file) { try { return new DefaultCacheManager(file); } catch (IOException ex) { log.error("", ex); throw new PippoRuntimeException(ex); } } }
/** * Create cache manager with custom idle time. * * @param idleTime idle time in seconds * @return cache manager */ public static EmbeddedCacheManager create(long idleTime) { Configuration configuration = new ConfigurationBuilder() .expiration().maxIdle(idleTime, TimeUnit.SECONDS) .build(); return new DefaultCacheManager(configuration); }
@Bean @Qualifier("RateLimit") public ReadWriteMap<String, GridBucketState> map() { DefaultCacheManager cacheManager = new DefaultCacheManager(); cacheManager.defineConfiguration("rateLimit", new ConfigurationBuilder().build()); AdvancedCache<String, GridBucketState> cache = cacheManager.<String, GridBucketState>getCache("rateLimit").getAdvancedCache(); FunctionalMapImpl<String, GridBucketState> functionalMap = FunctionalMapImpl.create(cache); return ReadWriteMapImpl.create(functionalMap); }
protected ServerCache getXmlCache(Configurable configurable) { String path = (String)configurable.getConfiguration().getProperty("server.request.cache.infinispan.config.file"); if (path == null) path = getConfigProperty("server.request.cache.infinispan.config.file"); if (path == null) return null; String name = (String)configurable.getConfiguration().getProperty("server.request.cache.infinispan.cache.name"); if (name == null) name = getConfigProperty("server.request.cache.infinispan.cache.name"); if (name == null) throw new RuntimeException(Messages.MESSAGES.needToSpecifyCacheName()); try { Cache<Object, Object> c = new DefaultCacheManager(path).getCache(name); return new InfinispanCache(c); } catch (IOException e) { throw new RuntimeException(e); } } }
protected ServerCache getDefaultCache() { GlobalConfiguration gconfig = new GlobalConfigurationBuilder() .globalJmxStatistics() .allowDuplicateDomains(true) .enable() .jmxDomain("custom-cache") .build(); Configuration configuration = new ConfigurationBuilder() .eviction() .strategy(EvictionStrategy.LIRS) .maxEntries(100) .jmxStatistics().enable() .build(); EmbeddedCacheManager manager = new DefaultCacheManager(gconfig, configuration); Cache<Object, Object> c = manager.getCache("custom-cache"); return new InfinispanCache(c); }
private EmbeddedCacheManager embeddedCacheManager() throws IOException { if(configurationFile == null) { GlobalConfigurationBuilder global = new GlobalConfigurationBuilder(); global.globalJmxStatistics().allowDuplicateDomains(true); return new DefaultCacheManager(global.build(), new ConfigurationBuilder().build()); } else { return new DefaultCacheManager(configurationFile); } }
@Test(expectedExceptions = CacheConfigurationException.class, expectedExceptionsMessageRegExp = "ISPN000436:.*") public void testMissingDefaultConfiguration() { GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder(); gcb.globalJmxStatistics().jmxDomain("infinispan-" + UUID.randomUUID()); EmbeddedCacheManager cm = new DefaultCacheManager(gcb.build()); try { cm.getCache("someCache"); } finally { cm.stop(); } }
private static DefaultCacheManager newDefaultCacheManager(boolean start, ConfigurationBuilderHolder holder) { setNodeName(holder.getGlobalConfigurationBuilder()); DefaultCacheManager defaultCacheManager = new DefaultCacheManager(holder, start); TestResourceTracker.addResource(new TestResourceTracker.CacheManagerCleaner(defaultCacheManager)); return defaultCacheManager; }
private static DefaultCacheManager newDefaultCacheManager(boolean start, GlobalConfigurationBuilder gc, ConfigurationBuilder c) { setNodeName(gc); GlobalConfiguration globalConfiguration = gc.build(); DefaultCacheManager defaultCacheManager = new DefaultCacheManager(globalConfiguration, c.build(globalConfiguration), start); TestResourceTracker.addResource(new TestResourceTracker.CacheManagerCleaner(defaultCacheManager)); return defaultCacheManager; }
private Cache<Object, Object> createManagerAndGetCache(int startFailures) { GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder().globalJmxStatistics().allowDuplicateDomains(true).build(); ConfigurationBuilder cb = TestCacheManagerFactory.getDefaultCacheConfiguration(false); Configuration config = cb.persistence() .addStore(DummyInMemoryStoreConfigurationBuilder.class) .startFailures(startFailures) .build(); return new DefaultCacheManager(globalConfiguration, config).getCache(); }
private Cache<Object, Object> createManagerAndGetCache(boolean failSilently, int queueSize) { GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder().globalJmxStatistics().allowDuplicateDomains(true).build(); ConfigurationBuilder cb = TestCacheManagerFactory.getDefaultCacheConfiguration(false); Configuration config = cb.persistence().availabilityInterval(AVAILABILITY_INTERVAL) .addStore(DummyInMemoryStoreConfigurationBuilder.class) .async().enable().modificationQueueSize(queueSize).failSilently(failSilently) .build(); return new DefaultCacheManager(globalConfiguration, config).getCache(); }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder(); gcb.globalJmxStatistics().jmxDomain(JMX_DOMAIN).mBeanServerLookup(new PerThreadMBeanServerLookup()).enable(); ConfigurationBuilder dcc = TestCacheManagerFactory.getDefaultCacheConfiguration(true); dcc.transaction().autoCommit(false); dcc.memory().size(1000); dcc.jmxStatistics().enable(); server = PerThreadMBeanServerLookup.getThreadMBeanServer(); return new DefaultCacheManager(gcb.build(), dcc.build()); }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder(); gcb.globalJmxStatistics().jmxDomain(JMX_DOMAIN).mBeanServerLookup(new PerThreadMBeanServerLookup()).enable(); ConfigurationBuilder dcc = TestCacheManagerFactory.getDefaultCacheConfiguration(true); dcc.transaction().autoCommit(false); dcc.memory().size(1000); dcc.jmxStatistics().enable(); server = PerThreadMBeanServerLookup.getThreadMBeanServer(); return new DefaultCacheManager(gcb.build(), dcc.build()); }
private EmbeddedCacheManager createCacheManager(String name1, JChannel ch1) { GlobalConfigurationBuilder gcb1 = new GlobalConfigurationBuilder(); gcb1.transport().nodeName(ch1.getName()).distributedSyncTimeout(10, SECONDS); CustomChannelLookup.registerChannel(gcb1, ch1, name1, false); ConfigurationBuilder replCfg = new ConfigurationBuilder(); replCfg.clustering().cacheMode(CacheMode.REPL_SYNC); replCfg.clustering().stateTransfer().timeout(10, SECONDS); EmbeddedCacheManager cm1 = new DefaultCacheManager(gcb1.build(), replCfg.build(), false); registerCacheManager(cm1); cm1.defineConfiguration(CACHE_NAME, replCfg.build()); return cm1; }
public void testDefaultEnlistment() { ConfigurationBuilder builder = getLocalBuilder(); builder.transaction().transactionMode(TransactionMode.TRANSACTIONAL); dcm = new DefaultCacheManager(getGlobalConfig(), builder.build()); Cache<Object,Object> cache = dcm.getCache(); assertFalse(cache.getCacheConfiguration().transaction().useSynchronization()); assertFalse(cache.getCacheConfiguration().transaction().recovery().enabled()); cache.put("k", "v"); assertEquals("v", cache.get("k")); }
public void testXAEnlistmentNoRecovery() { ConfigurationBuilder builder = getLocalBuilder(); builder.transaction() .transactionMode(TransactionMode.TRANSACTIONAL) .useSynchronization(false) .recovery().disable(); dcm = new DefaultCacheManager(getGlobalConfig(), builder.build()); Cache<Object,Object> cache = dcm.getCache(); assertFalse(cache.getCacheConfiguration().transaction().useSynchronization()); assertFalse(cache.getCacheConfiguration().transaction().recovery().enabled()); }
public void testXAEnlistment() { ConfigurationBuilder builder = getLocalBuilder(); builder.transaction() .transactionMode(TransactionMode.TRANSACTIONAL) .useSynchronization(false); dcm = new DefaultCacheManager(getGlobalConfig(), builder.build()); Cache<Object,Object> cache = dcm.getCache(); assertFalse(cache.getCacheConfiguration().transaction().useSynchronization()); assertFalse(cache.getCacheConfiguration().transaction().recovery().enabled()); cache.put("k", "v"); assertEquals("v", cache.get("k")); }