/** * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ @Override public void afterPropertiesSet() throws Exception { if (this.infinispanCacheContainer == null) { throw new IllegalStateException("No Infinispan CacheContainer has been set"); } this.logger.info("Initializing named Infinispan cache ..."); this.infinispanCache = this.infinispanCacheContainer.getCache(); this.logger.info("New Infinispan cache [" + this.infinispanCache + "] initialized"); }
@Override public ProxyManager<String> resolve(String cacheName) { Cache<Object, Object> cache = cacheContainer.getCache(cacheName); // TODO how to create an instance of ReadWriteMap return Bucket4j.extension(io.github.bucket4j.grid.infinispan.Infinispan.class).proxyManagerForMap(null); }
@BeforeMethod public void setUp() { cm = TestCacheManagerFactory.createCacheManager(false); cache = cm.getCache(); }
private <T> void startAndIndexEntityData(String cacheName, CacheContainer cacheContainer, Function<Integer, T> provider, Class<T> type) { Cache<Integer, T> cache; if (cacheName == null) { cache = cacheContainer.getCache(); } else { cache = cacheContainer.getCache(cacheName); } populateData(cache, provider); assertIndexPopulated(cache, type); }
private Future<Cache<String, String>> startCache(final CacheContainer cm, final String cacheName, boolean nonBlockingStartup) { final Callable<Cache<String, String>> cacheCreator = () -> cm.getCache(cacheName); if (nonBlockingStartup) { return fork(cacheCreator); } else { try { Cache<String, String> cache = cacheCreator.call(); return CompletableFuture.completedFuture(cache); } catch (Exception e) { return CompletableFutures.completedExceptionFuture(e); } } }
@AfterMethod(alwaysRun = true) public void clearCache() { if (cacheManager != null) { cacheManager.getCache().clear(); } Util.recursiveFileRemove(indexDir); }
@BeforeMethod public void setUp() { cm = TestCacheManagerFactory.createCacheManager(false); cache = cm.getCache(); listener = new CacheListener(); cache.addListener(listener); }
public ProxyManager<String> resolve(String cacheName) { Cache<Object, Object> cache = cacheContainer.getCache(cacheName); if (cache == null) { throw new JCacheNotFoundException(cacheName); } FunctionalMapImpl functionalMap = FunctionalMapImpl.create(cache.getAdvancedCache()); return Bucket4j.extension(Infinispan.class).proxyManagerForMap(ReadWriteMapImpl.create(functionalMap)); }
public void testTransientEntrypUpdates() { Cache<Integer, String> cache = cm.getCache(); cache.put(1, "boo", -1, TimeUnit.SECONDS, 10, TimeUnit.SECONDS); cache.put(1, "boo2"); cache.put(1, "boo3"); }
public void testKeySetAfterExpiryInPut(Method m) throws Exception { Cache<Integer, String> cache = cm.getCache(); Map dataIn = new HashMap(); dataIn.put(1, v(m, 1)); dataIn.put(2, v(m, 2)); final long lifespan = EXPIRATION_TIMEOUT; cache.putAll(dataIn, lifespan, TimeUnit.MILLISECONDS); timeService.advance(lifespan + 100); assertEquals(0, cache.keySet().size()); }
private void doTestEntrySetAfterExpiryInPut(Method m, CacheContainer cc) throws Exception { Cache<Integer, String> cache = cc.getCache(); Map dataIn = new HashMap(); dataIn.put(1, v(m, 1)); dataIn.put(2, v(m, 2)); final long lifespan = EXPIRATION_TIMEOUT; cache.putAll(dataIn, lifespan, TimeUnit.MILLISECONDS); timeService.advance(lifespan + 100); assertEquals(0, cache.entrySet().size()); }
@BeforeClass public void setUp() { ConfigurationBuilder c = new ConfigurationBuilder(); c.invocationBatching().enable(); cacheContainer = TestCacheManagerFactory.createCacheManager(c); cache = cacheContainer.getCache(); tm = TestingUtil.getTransactionManager(cache); }
@Test public void profileInfinispanLocalDirectory() throws InterruptedException, IOException { CacheContainer cacheManager = CacheTestSupport.createLocalCacheManager(); try { Cache cache = cacheManager.getCache(); Directory dir = DirectoryBuilder.newDirectoryInstance(cache, cache, cache, "iname").create(); testDirectory(dir, "InfinispanLocal"); } finally { cacheManager.stop(); } }
protected List<Address> topology(CacheContainer cm) { return cm.getCache(cacheName).getAdvancedCache().getRpcManager().getTransport().getMembers(); }
private void doTest(CacheMode m) { CacheContainer cc = null; try { cc = TestCacheManagerFactory.createCacheManager(m, true); QueryInterceptor queryInterceptor = TestingUtil.findInterceptor(cc.getCache(), QueryInterceptor.class); assertNotNull("Didn't find a query interceptor in the chain!!", queryInterceptor); } finally { TestingUtil.killCacheManagers(cc); } } }
@Test public void testChunkBordersOnInfinispan() throws IOException { Cache cache = cacheManager.getCache(); cache.clear(); Directory dir = DirectoryBuilder.newDirectoryInstance(cache, cache, cache, INDEXNAME).chunkSize(13).create(); testChunkBorders(dir, cache); cache.clear(); }
@BeforeClass public void setUp() { cfg = TestCacheManagerFactory.getDefaultCacheConfiguration(true); cfg .persistence() .passivation(true) .addStore(DummyInMemoryStoreConfigurationBuilder.class); cm = TestCacheManagerFactory.createCacheManager(cfg); cache = cm.getCache(); store = (AdvancedLoadWriteStore) TestingUtil.getCacheLoader(cache); tm = TestingUtil.getTransactionManager(cache); }
@Test public void profileInfinispanLocalDirectory() throws InterruptedException, IOException { CacheContainer cacheContainer = CacheTestSupport.createLocalCacheManager(); try { Cache cache = cacheContainer.getCache(); Directory dir = DirectoryBuilder.newDirectoryInstance(cache, cache, cache, indexName).chunkSize(CHUNK_SIZE).create(); stressTestDirectoryInternal(dir, dir, "InfinispanLocal"); verifyDirectoryState(); } finally { cacheContainer.stop(); } }
@BeforeMethod public void setUp() throws Exception { ConfigurationBuilder builder = TestCacheManagerFactory.getDefaultCacheConfiguration(true); builder.transaction().autoCommit(false) .clustering().cacheMode(CacheMode.LOCAL) .locking().isolationLevel(IsolationLevel.REPEATABLE_READ); cm = TestCacheManagerFactory.createCacheManager(builder); cache = cm.getCache(); tm = TestingUtil.getTransactionManager(cache); mockNotifier = mock(CacheNotifier.class); origNotifier = TestingUtil.replaceComponent(cache, CacheNotifier.class, mockNotifier, true); }
@BeforeMethod public void setUp() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.invocationBatching().enable() .clustering().cacheMode(CacheMode.LOCAL) .locking().concurrencyLevel(2000) .lockAcquisitionTimeout(120000) .isolationLevel(IsolationLevel.READ_COMMITTED); cacheContainer = TestCacheManagerFactory.createCacheManager(cb); Cache c = cacheContainer.getCache(); cache = new TreeCacheImpl<>(c); }