@Test(expectedExceptions = CacheConfigurationException.class, expectedExceptionsMessageRegExp = "ISPN(\\d)*: Cannot enable Invocation Batching when the Transaction Mode is NON_TRANSACTIONAL, set the transaction mode to TRANSACTIONAL") public void testInvocationBatchingAndNonTransactional() throws Exception { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.transaction() .transactionMode(NON_TRANSACTIONAL) .invocationBatching() .enable(); withCacheManager(new CacheManagerCallable(createCacheManager(cb))); }
private Configuration getInternalCacheConfig() { ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); // allow the registry to work for local caches as well as clustered caches CacheMode cacheMode = cacheManager.getGlobalComponentRegistry().getGlobalConfiguration().isClustered() ? CacheMode.REPL_SYNC : CacheMode.LOCAL; configurationBuilder.clustering().cacheMode(cacheMode); // use invocation batching (cache-only transactions) for high consistency as writes are expected to be rare in this cache configurationBuilder.transaction().transactionMode(TransactionMode.TRANSACTIONAL) .transactionManagerLookup(null).invocationBatching().enable(); configurationBuilder.security().authorization().disable(); return configurationBuilder.build(); }
/** * Create the configuration for the internal cache. */ private Configuration getInternalCacheConfig() { ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); // allow the registry to work for local caches as well as clustered caches CacheMode cacheMode = cacheManager.getGlobalComponentRegistry().getGlobalConfiguration().isClustered() ? CacheMode.REPL_SYNC : CacheMode.LOCAL; configurationBuilder.clustering().cacheMode(cacheMode); // use invocation batching (cache-only transactions) for high consistency as writes are expected to be rare in this cache configurationBuilder.transaction().transactionMode(TransactionMode.TRANSACTIONAL) .transactionManagerLookup(null).invocationBatching().enable(); configurationBuilder.security().authorization().disable(); return configurationBuilder.build(); }
@Override protected void doTest(TransactionManagerLookup tml) { EmbeddedCacheManager ecm = null; try { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.transaction().transactionManagerLookup(tml) .invocationBatching().enable(); ecm = TestCacheManagerFactory.createCacheManager(cb); TreeCache<Object, Object> tc = new TreeCacheFactory().createTreeCache(ecm.<Object, Object>getCache()); tc.put("/a/b/c", "k", "v"); assert "v".equals(tc.get("/a/b/c", "k")); } finally { TestingUtil.killCacheManagers(ecm); } } }
private Cache getCache() { GlobalConfigurationBuilder gc = GlobalConfigurationBuilder.defaultClusteredBuilder(); ConfigurationBuilder c = new ConfigurationBuilder(); c.clustering().cacheMode(CacheMode.REPL_SYNC) .remoteTimeout(30000) .transaction().invocationBatching().enable() .locking().lockAcquisitionTimeout(60000).useLockStriping(false); EmbeddedCacheManager container = TestCacheManagerFactory.createClusteredCacheManager(gc, c); cacheContainers.add(container); container.defineConfiguration("TestCache", c.build()); return container.getCache("TestCache"); } }
builder.transaction().transactionMode(org.infinispan.transaction.TransactionMode.TRANSACTIONAL).invocationBatching().enable(); } else { builder.transaction().invocationBatching().disable();
@BeforeMethod protected void setUp() throws Exception { ConfigurationBuilder configurationBuilder = TestCacheManagerFactory.getDefaultCacheConfiguration(true); configurationBuilder.transaction().invocationBatching().enable() .clustering().cacheMode(CacheMode.DIST_SYNC) .clustering().hash().numOwners(1) .clustering().stateTransfer().fetchInMemoryState(false); manager1 = TestCacheManagerFactory.createClusteredCacheManager(configurationBuilder); manager1.defineConfiguration("test", configurationBuilder.build()); cache1 = manager1.getCache("test").getAdvancedCache(); ex1 = Executors.newSingleThreadExecutor(getTestThreadFactory("KeyGenerator1")); keyAffinityService1 = KeyAffinityServiceFactory.newLocalKeyAffinityService(cache1, new RndKeyGenerator(), ex1, KEY_QUEUE_SIZE); log.trace("Address for manager1: " + manager1.getAddress()); manager2 = TestCacheManagerFactory.createClusteredCacheManager(configurationBuilder); manager2.defineConfiguration("test", configurationBuilder.build()); cache2 = manager2.getCache("test").getAdvancedCache(); ex2 = Executors.newSingleThreadExecutor(getTestThreadFactory("KeyGenerator2")); keyAffinityService2 = KeyAffinityServiceFactory.newLocalKeyAffinityService(cache2, new RndKeyGenerator(), ex2, KEY_QUEUE_SIZE); log.trace("Address for manager2: " + manager2.getAddress()); TestingUtil.blockUntilViewsReceived(60000, cache1, cache2); Thread.sleep(5000); }
private ConfigurationBuilder makeCfg() { ConfigurationBuilder cfg = new ConfigurationBuilder(); cfg.transaction() .transactionMode(TransactionMode.TRANSACTIONAL).invocationBatching().enable() .clustering().cacheMode(CacheMode.REPL_SYNC) .clustering().sync() .stateTransfer().fetchInMemoryState(true) .transaction().lockingMode(LockingMode.PESSIMISTIC) .locking().isolationLevel(IsolationLevel.READ_COMMITTED).useLockStriping(false) .customInterceptors().addInterceptor() .interceptor(new ProtobufMetadataManagerInterceptor()).after(PessimisticLockingInterceptor.class); return cfg; }
protected void createCacheManagers() throws Throwable { ConfigurationBuilder c = new ConfigurationBuilder(); c.clustering().cacheMode(CacheMode.REPL_SYNC) .remoteTimeout(30000) .transaction().transactionMode(TransactionMode.TRANSACTIONAL) .invocationBatching().enable() .locking().lockAcquisitionTimeout(60000).useLockStriping(false); EmbeddedCacheManager container = TestCacheManagerFactory.createClusteredCacheManager(c); container.start(); registerCacheManager(container); container.defineConfiguration(TEST_CACHE, c.build()); container.startCaches(TEST_CACHE); Cache cache1 = container.getCache(TEST_CACHE); assert cache1.getCacheConfiguration().clustering().cacheMode().equals(CacheMode.REPL_SYNC); cache1.start(); container = TestCacheManagerFactory.createClusteredCacheManager(c); container.start(); registerCacheManager(container); container.defineConfiguration(TEST_CACHE, c.build()); container.startCaches(TEST_CACHE); Cache cache2 = container.getCache(TEST_CACHE); assert cache2.getCacheConfiguration().clustering().cacheMode().equals(CacheMode.REPL_SYNC); }