@Override protected EmbeddedCacheManager createCacheManager() throws Exception { ConfigurationBuilder cfg = new ConfigurationBuilder(); cfg.memory().size(MAX_CACHE_ELEMENTS) .expiration().wakeUpInterval(3000L) .build(); EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(cfg); cache = cm.getCache(); return cm; }
private Cache<String, Integer> configureAndBuildCache(int capacity) { ConfigurationBuilder config = new ConfigurationBuilder(); config .memory().size(capacity) .expiration().wakeUpInterval(5000L).maxIdle(120000L); String cacheName = "cache" + capacity; cacheManager.defineConfiguration(cacheName, config.build()); return cacheManager.getCache(cacheName); }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { ConfigurationBuilder cfg = new ConfigurationBuilder(); cfg.memory().size(CACHE_SIZE).evictionType(EvictionType.COUNT).storageType(StorageType.BINARY) .expiration().wakeUpInterval(100L) .locking().useLockStriping(false) // to minimise chances of deadlock in the unit test .build(); cacheManager = TestCacheManagerFactory.createCacheManager(cfg); cache = cacheManager.getCache(); return cacheManager; }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { ConfigurationBuilder config = getDefaultStandaloneCacheConfig(true); config .memory().size(10) .expiration().wakeUpInterval(10L) .persistence().addStore(DummyInMemoryStoreConfigurationBuilder.class) .build(); EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(config); cache = cm.getCache(); tm = getTransactionManager(cache); return cm; }
protected EmbeddedCacheManager createCacheManager() throws Exception { ConfigurationBuilder cfgBuilder = new ConfigurationBuilder(); cfgBuilder.memory().size(128) // 128 max entries .expiration().wakeUpInterval(100L) .locking().useLockStriping(false) // to minimize chances of deadlock in the unit test .invocationBatching().enable(true); EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(cfgBuilder); cache = cm.getCache(); cache.addListener(new EvictionFunctionalTest.EvictionListener()); return cm; }
protected EmbeddedCacheManager createCacheManager() throws Exception { ConfigurationBuilder builder = TestCacheManagerFactory.getDefaultCacheConfiguration(false); builder.memory().size(CACHE_SIZE).storageType(getStorageType()) .expiration().wakeUpInterval(100L).locking() .useLockStriping(false) // to minimize chances of deadlock in the unit test .invocationBatching(); EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(builder); cache = cm.getCache(); evictionListener = new EvictionListener(); cache.addListener(evictionListener); TestingUtil.replaceComponent(cm, TimeService.class, timeService = new ControlledTimeService(), true); return cm; }
@BeforeClass public void setup() throws Exception { ConfigurationBuilder serverBuilder = TestCacheManagerFactory.getDefaultCacheConfiguration(false); serverBuilder.memory().size(100) .expiration().wakeUpInterval(10L); serverCacheManager = TestCacheManagerFactory.createCacheManager( hotRodCacheConfiguration(serverBuilder)); serverCache = serverCacheManager.getCache(); hrServer = HotRodClientTestingUtil.startHotRodServer(serverCacheManager); ConfigurationBuilder clientBuilder = TestCacheManagerFactory.getDefaultCacheConfiguration(false); clientBuilder.persistence().addStore(RemoteStoreConfigurationBuilder.class) .rawValues(true) .addServer() .host(hrServer.getHost()) .port(hrServer.getPort()); clientCacheManager = TestCacheManagerFactory.createCacheManager(clientBuilder); clientCache = clientCacheManager.getCache(); org.infinispan.client.hotrod.configuration.ConfigurationBuilder rcmBuilder = new org.infinispan.client.hotrod.configuration.ConfigurationBuilder(); rcmBuilder.addServer() .host(hrServer.getHost()) .port(hrServer.getPort()); remoteCacheManager = new RemoteCacheManager(rcmBuilder.build()); remoteCacheManager.start(); remoteCache = remoteCacheManager.getCache(); }
@Override protected AdvancedLoadWriteStore createStore() throws Exception { ConfigurationBuilder localBuilder = TestCacheManagerFactory.getDefaultCacheConfiguration(false); localBuilder.memory().evictionType(EvictionType.COUNT).size(WRITE_DELETE_BATCH_MAX_ENTRIES) .expiration().wakeUpInterval(10L); localCacheManager = TestCacheManagerFactory.createCacheManager( new GlobalConfigurationBuilder().defaultCacheName(REMOTE_CACHE), hotRodCacheConfiguration(localBuilder)); localCacheManager.getCache(REMOTE_CACHE); TestingUtil.replaceComponent(localCacheManager, TimeService.class, timeService, true); localCacheManager.getCache(REMOTE_CACHE).getAdvancedCache().getComponentRegistry().rewire(); hrServer = HotRodClientTestingUtil.startHotRodServer(localCacheManager); ConfigurationBuilder builder = TestCacheManagerFactory.getDefaultCacheConfiguration(false); RemoteStoreConfigurationBuilder storeConfigurationBuilder = builder .persistence() .addStore(RemoteStoreConfigurationBuilder.class) .rawValues(true) .remoteCacheName(REMOTE_CACHE); storeConfigurationBuilder .addServer() .host(hrServer.getHost()) .port(hrServer.getPort()); RemoteStore remoteStore = new RemoteStore(); remoteStore.init(createContext(builder.build())); return remoteStore; }
@Override protected AdvancedLoadWriteStore createStore() throws Exception { ConfigurationBuilder localBuilder = TestCacheManagerFactory.getDefaultCacheConfiguration(false); localBuilder.memory().evictionType(EvictionType.COUNT).size(WRITE_DELETE_BATCH_MAX_ENTRIES).expiration().wakeUpInterval(10L); localCacheManager = TestCacheManagerFactory.createServerModeCacheManager(localBuilder); localCacheManager.defineConfiguration(REMOTE_CACHE, localCacheManager.getDefaultCacheConfiguration()); localCacheManager.getCache(REMOTE_CACHE); TestingUtil.replaceComponent(localCacheManager, TimeService.class, timeService, true); localCacheManager.getCache(REMOTE_CACHE).getAdvancedCache().getComponentRegistry().rewire(); RestServerConfigurationBuilder restServerConfigurationBuilder = new RestServerConfigurationBuilder(); restServerConfigurationBuilder.port(0); restServer = new RestServer(); restServer.start(restServerConfigurationBuilder.build(), localCacheManager); ConfigurationBuilder builder = TestCacheManagerFactory.getDefaultCacheConfiguration(false); RestStoreConfigurationBuilder storeConfigurationBuilder = builder.persistence() .addStore(RestStoreConfigurationBuilder.class); storeConfigurationBuilder.host(restServer.getHost()).port(restServer.getPort()).path("/rest/" + REMOTE_CACHE); storeConfigurationBuilder.connectionPool().maxTotalConnections(10).maxConnectionsPerHost(10); storeConfigurationBuilder.validate(); RestStore restStore = new RestStore(); restStore.init(createContext(builder.build())); return restStore; }
@Override protected AdvancedLoadWriteStore createStore() throws Exception { ConfigurationBuilder localBuilder = TestCacheManagerFactory.getDefaultCacheConfiguration(false); localBuilder.memory().evictionType(EvictionType.COUNT).size(WRITE_DELETE_BATCH_MAX_ENTRIES).expiration().wakeUpInterval(10L); // Set it to dist so it has segments localBuilder.clustering().cacheMode(CacheMode.DIST_SYNC); GlobalConfigurationBuilder globalConfig = new GlobalConfigurationBuilder().clusteredDefault(); globalConfig.globalJmxStatistics().defaultCacheName(REMOTE_CACHE); localCacheManager = TestCacheManagerFactory.createClusteredCacheManager( globalConfig, hotRodCacheConfiguration(localBuilder)); localCacheManager.getCache(REMOTE_CACHE); TestingUtil.replaceComponent(localCacheManager, TimeService.class, timeService, true); localCacheManager.getCache(REMOTE_CACHE).getAdvancedCache().getComponentRegistry().rewire(); hrServer = HotRodClientTestingUtil.startHotRodServer(localCacheManager); // In case if the server has to unmarshall the value, make sure to use the same marshaller hrServer.setMarshaller(getMarshaller()); ConfigurationBuilder builder = TestCacheManagerFactory .getDefaultCacheConfiguration(false); RemoteStoreConfigurationBuilder storeConfigurationBuilder = builder .persistence() .addStore(RemoteStoreConfigurationBuilder.class) .remoteCacheName(REMOTE_CACHE); storeConfigurationBuilder .addServer() .host(hrServer.getHost()) .port(hrServer.getPort()); RemoteStore remoteStore = new RemoteStore(); remoteStore.init(createContext(builder.build())); return remoteStore; }