@Override public ExpirationConfiguration get() { return new ConfigurationBuilder().expiration() .wakeUpInterval(this.interval) .lifespan(this.lifespan) .maxIdle(this.maxIdle) .create(); } }
@Override public ExpirationConfiguration get() { return new ConfigurationBuilder().expiration() .wakeUpInterval(this.interval) .lifespan(this.lifespan) .maxIdle(this.maxIdle) .create(); } }
public void testWakeupInterval() { ExpirationManagerImpl em = new ExpirationManagerImpl(); Configuration cfg = getCfg().expiration().wakeUpInterval(789L).build(); ScheduledExecutorService mockService = mock(ScheduledExecutorService.class); em.initialize(mockService, "", cfg); ScheduledFuture mockFuture = mock(ScheduledFuture.class); when(mockService.scheduleWithFixedDelay(isA(ExpirationManagerImpl.ScheduledTask.class), eq(789l), eq(789l), eq(TimeUnit.MILLISECONDS))) .thenReturn(mockFuture); em.start(); assertEquals(mockFuture, em.expirationTask); verify(mockService).scheduleWithFixedDelay(any(Runnable.class), anyLong(), anyLong(), any(TimeUnit.class)); // expect that the executor was never used!! } }
@Override protected void configure(ConfigurationBuilder config) { config // Prevent the reaper from running, reaperEnabled(false) doesn't work when a store is present .expiration().wakeUpInterval(Long.MAX_VALUE) .persistence().addStore(DummyInMemoryStoreConfigurationBuilder.class); } }
private ConfigurationBuilder getActionTokenCacheConfig() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.memory() .evictionStrategy(EvictionStrategy.NONE) .evictionType(EvictionType.COUNT) .size(InfinispanConnectionProvider.ACTION_TOKEN_CACHE_DEFAULT_MAX); cb.expiration() .maxIdle(InfinispanConnectionProvider.ACTION_TOKEN_MAX_IDLE_SECONDS, TimeUnit.SECONDS) .wakeUpInterval(InfinispanConnectionProvider.ACTION_TOKEN_WAKE_UP_INTERVAL_SECONDS, TimeUnit.SECONDS); return cb; }
@Override protected void configure(ConfigurationBuilder config) { config // Prevent the reaper from running, reaperEnabled(false) doesn't work when a store is present .expiration().wakeUpInterval(Long.MAX_VALUE) .persistence().addSingleFileStore().location(TestingUtil.tmpDirectory(this.getClass())); }
/** * Clean the configuration template to prevent conflicts */ protected void resetConfiguration(ConfigurationBuilder confBuilder) { confBuilder.invocationBatching().enable().eviction().strategy(EvictionStrategy.NONE).maxEntries(-1).expiration() .lifespan(-1L).maxIdle(-1L).wakeUpInterval(60000L); } }
protected static org.infinispan.configuration.cache.ConfigurationBuilder getExpiryCacheConfig() { ConfigurationBuilder builder = getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC); builder.expiration().lifespan(EXPIRATION_TIMEOUT).wakeUpInterval(100, TimeUnit.MILLISECONDS); return hotRodCacheConfiguration(builder); }
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder defaultClusteredCacheConfig2 = getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, false); defaultClusteredCacheConfig2.expiration().lifespan(EXPIRATION_TIMEOUT).wakeUpInterval(100, TimeUnit.MILLISECONDS); createClusteredCaches(2, "expiry", defaultClusteredCacheConfig2); cacheManagers.forEach(cm -> replaceComponent(cm, TimeService.class, controlledTimeService, true)); waitForClusterToForm("expiry"); } }
@Override protected void configure(ConfigurationBuilder config) { config // Prevent the reaper from running, reaperEnabled(false) doesn't work when a store is present .expiration().wakeUpInterval(Long.MAX_VALUE) .clustering().cacheMode(CacheMode.DIST_SYNC) .persistence().addSingleFileStore().location(TestingUtil.tmpDirectory(this.getClass())); }
public void testNoExpirationThread() { ExpirationManagerImpl em = new ExpirationManagerImpl(); Configuration cfg = getCfg().expiration().wakeUpInterval(0L).build(); ScheduledExecutorService mockService = mock(ScheduledExecutorService.class); em.initialize(mockService, "", cfg); em.start(); assertNull("Expiration task is not null! Should not have scheduled anything!", em.expirationTask); }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { ConfigurationBuilder builder = TestCacheManagerFactory.getDefaultCacheConfiguration(false); builder.persistence().addStore(SimpleLoaderConfigurationBuilder.class); // Effectively disabling reaper builder.expiration().wakeUpInterval(1, TimeUnit.DAYS); EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(builder); TestingUtil.replaceComponent(cm, TimeService.class, timeService, true); cache = cm.getCache(); return cm; }
@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 void createCacheManagers() throws Throwable { ConfigurationBuilder builder = getDefaultClusteredCacheConfig(CacheMode.SCATTERED_SYNC, false); builder.clustering().biasAcquisition(BiasAcquisition.ON_WRITE); // Scan biases frequently builder.expiration().wakeUpInterval(100); createCluster(builder, 3); waitForClusterToForm(); Arrays.stream(managers()).forEach( cm -> TestingUtil.replaceComponent(cm, TimeService.class, timeService, true)); rpcManager0 = ControlledRpcManager.replaceRpcManager(cache(0)); rpcManager1 = CountingRpcManager.replaceRpcManager(cache(1)); TestingUtil.wrapInboundInvocationHandler(cache(0), handler -> handler0 = new RenewWaitingInvocationHandler(handler)); }
private static ConfigurationBuilder config(boolean passivation, int threads) { ConfigurationBuilder config = new ConfigurationBuilder(); config.expiration().wakeUpInterval(100); config.memory().size(1); config.persistence() .passivation(passivation) .addStore(LockableStoreConfigurationBuilder.class) .async() .enabled(USE_ASYNC_STORE) .threadPoolSize(threads); return config; }
@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; }