Refine search
@Override public TransactionConfiguration get() { TransactionConfigurationBuilder builder = new ConfigurationBuilder().transaction() .lockingMode(this.locking) .cacheStopTimeout(this.timeout) .transactionMode((this.mode == TransactionMode.NONE) ? org.infinispan.transaction.TransactionMode.NON_TRANSACTIONAL : org.infinispan.transaction.TransactionMode.TRANSACTIONAL) .useSynchronization(this.mode == TransactionMode.NON_XA) .recovery().enabled(this.mode == TransactionMode.FULL_XA).transaction() ; switch (this.mode) { case NONE: { break; } case BATCH: { builder.transactionManagerLookup(new TransactionManagerProvider(EmbeddedTransactionManager.getInstance())); break; } case NON_XA: { builder.transactionSynchronizationRegistryLookup(new TransactionSynchronizationRegistryProvider(this.tsrDependency.get())); // fall through } default: { builder.transactionManagerLookup(new TransactionManagerProvider(ContextTransactionManager.getInstance())); } } return builder.create(); } }
private static void amendJTA(ConfigurationBuilder builder) { if (builder.transaction().transactionMode() == TransactionMode.TRANSACTIONAL && builder.transaction().transactionManagerLookup() == null) { builder.transaction().transactionManagerLookup(Util.getInstance(TransactionSetup.getManagerLookup(), TestCacheManagerFactory.class.getClassLoader())); } }
private static void markAsTransactional(boolean transactional, ConfigurationBuilder builder) { if (!transactional) { builder.transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL); } else { builder.transaction() .transactionMode(TransactionMode.TRANSACTIONAL); if (!Util.isOSGiContext()) { //automatically change default TM lookup to the desired one but only outside OSGi. In OSGi we need to use GenericTransactionManagerLookup builder.transaction().transactionManagerLookup(Util.getInstance(TransactionSetup.getManagerLookup(), TestCacheManagerFactory.class.getClassLoader())); } } }
private Configuration getRevisionCacheConfig(long maxEntries) { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.invocationBatching().enable().transaction().transactionMode(TransactionMode.TRANSACTIONAL); // Use Embedded manager even in managed ( wildfly/eap ) environment. We don't want infinispan to participate in global transaction cb.transaction().transactionManagerLookup(new EmbeddedTransactionManagerLookup()); cb.transaction().lockingMode(LockingMode.PESSIMISTIC); cb.memory() .evictionStrategy(EvictionStrategy.REMOVE) .evictionType(EvictionType.COUNT) .size(maxEntries); return cb.build(); }
@Test public void testDummyTMGetCache() throws Exception { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.transaction().use1PcForAutoCommitTransactions(true) .transactionManagerLookup(new EmbeddedTransactionManagerLookup()); withCacheManager(new CacheManagerCallable(createCacheManager()) { @Override public void call() { cm.getCache(); } }); }
@Override protected ConfigurationBuilder configure() { ConfigurationBuilder config = super.configure(); config.transaction().transactionManagerLookup(new EmbeddedTransactionManagerLookup()) .clustering().cacheMode(CacheMode.REPL_SYNC); return config; } }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.invocationBatching().enable(); cb.transaction().transactionManagerLookup(null); return TestCacheManagerFactory.createCacheManager(cb); }
@Override protected EmbeddedCacheManager createCacheManager() { ConfigurationBuilder config = getDefaultStandaloneCacheConfig(true); config.transaction().transactionManagerLookup(new EmbeddedTransactionManagerLookup()).useSynchronization(true); return TestCacheManagerFactory.createCacheManager(config); }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { EmbeddedCacheManager cacheManager = TestCacheManagerFactory.createCacheManager(getDefaultStandaloneCacheConfig(true)); ConfigurationBuilder builder = getDefaultStandaloneCacheConfig(true); builder.transaction().useSynchronization(true); builder.transaction().transactionManagerLookup(new EmbeddedTransactionManagerLookup()); cacheManager.defineConfiguration(SYNC_CACHE_NAME, builder.build()); builder = getDefaultStandaloneCacheConfig(true); builder.transaction().useSynchronization(false); builder.transaction().transactionManagerLookup(new EmbeddedTransactionManagerLookup()); cacheManager.defineConfiguration(XA_CACHE_NAME, builder.build()); return cacheManager; }
public void testOverride() { final ConfigurationBuilder c = new ConfigurationBuilder(); c.transaction().transactionMode(TransactionMode.TRANSACTIONAL) .transactionManagerLookup(new EmbeddedTransactionManagerLookup()); withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.createCacheManager()){ @Override public void call() { cm.defineConfiguration("transactional", c.build()); Cache<?, ?> cache = cm.getCache("transactional"); assert cache.getCacheConfiguration().transaction().transactionMode().isTransactional(); } }); }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { ConfigurationBuilder c = getDefaultStandaloneCacheConfig(true); c.transaction().transactionManagerLookup(new EmbeddedTransactionManagerLookup()).useSynchronization(false).recovery().disable(); return TestCacheManagerFactory.createCacheManager(c); }
protected <K, V> Cache<K, V> createCache(String name) { ConfigurationBuilder c = new ConfigurationBuilder(); c.transaction().transactionManagerLookup(new MyDummyTransactionManagerLookup()); c.invocationBatching().enable(); c.transaction().transactionMode(TransactionMode.TRANSACTIONAL); cacheManager.defineConfiguration(name, c.build()); return cacheManager.getCache(name); }
protected ConfigurationBuilder buildConfiguration() { final ConfigurationBuilder conf = getDefaultClusteredCacheConfig(CacheMode.REPL_SYNC, true); conf.transaction() .lockingMode(LockingMode.PESSIMISTIC) .transactionManagerLookup(new EmbeddedTransactionManagerLookup()) .locking().lockAcquisitionTimeout(TestingUtil.shortTimeoutMillis()); return conf; }
public void testFineGrainedAtomicMapWithoutTransactionManagerLookupSet() { ConfigurationBuilder builder = buildConfiguration(); builder.transaction().transactionMode(TransactionMode.TRANSACTIONAL).transactionManagerLookup(null); cacheManager.defineConfiguration("fgahm_without_tmlookup", builder.build()); Cache<String, String> fgahmCache = cacheManager.getCache("fgahm_without_tmlookup"); FineGrainedAtomicMap<String, String> map = AtomicMapLookup.getFineGrainedAtomicMap(fgahmCache, "key"); assert map.isEmpty(); map.put("a", "b"); assert map.get("a").equals("b"); // now re-retrieve the map and make sure we see the diffs assert AtomicMapLookup.getFineGrainedAtomicMap(fgahmCache, "key").get("a").equals("b"); }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { final ConfigurationBuilder config = getDefaultStandaloneCacheConfig(true); config.transaction().lockingMode(LockingMode.PESSIMISTIC) .transactionManagerLookup(new EmbeddedTransactionManagerLookup()) .useSynchronization(false) .recovery().disable(); return TestCacheManagerFactory.createCacheManager(config); }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.transaction() .transactionMode(TransactionMode.TRANSACTIONAL) .useSynchronization(false) .transactionManagerLookup(new EmbeddedTransactionManagerLookup()) .recovery().enable(); return TestCacheManagerFactory.createCacheManager(cb); }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { final ConfigurationBuilder config = getDefaultStandaloneCacheConfig(true); config .transaction() .lockingMode(LockingMode.OPTIMISTIC) .transactionManagerLookup(new EmbeddedTransactionManagerLookup()) .useSynchronization(false) .recovery() .disable(); return TestCacheManagerFactory.createCacheManager(config); }
protected void createCacheManagers() throws Throwable { ConfigurationBuilder cfg = getDefaultClusteredCacheConfig(cacheMode, true); cfg.transaction().transactionManagerLookup(new EmbeddedTransactionManagerLookup()) .lockingMode(LockingMode.PESSIMISTIC) .locking().lockAcquisitionTimeout(TestingUtil.shortTimeoutMillis()); createClusteredCaches(2, "testcache", cfg); }
public void testAtomicMapWithoutTransactionManagerLookupSet() { ConfigurationBuilder builder = buildConfiguration(); builder.transaction().transactionMode(TransactionMode.TRANSACTIONAL).transactionManagerLookup(null); cacheManager.defineConfiguration("ahm_without_tmlookup", builder.build()); Cache<String, String> ahmCache = cacheManager.getCache("ahm_without_tmlookup"); AtomicMap<String, String> map = AtomicMapLookup.getAtomicMap(ahmCache, "key"); assert map.isEmpty(); map.put("a", "b"); assert map.get("a").equals("b"); // now re-retrieve the map and make sure we see the diffs assert AtomicMapLookup.getAtomicMap(ahmCache, "key").get("a").equals("b"); }
@Override protected void createCacheManagers() throws Throwable { final ConfigurationBuilder conf = getDefaultClusteredCacheConfig(cacheMode, true); conf.transaction() .lockingMode(LockingMode.OPTIMISTIC) .transactionManagerLookup(new EmbeddedTransactionManagerLookup()); conf.locking().isolationLevel(IsolationLevel.READ_COMMITTED); createCluster(conf, 2); waitForClusterToForm(); k = getKeyForCache(0); }