private ConfigurationBuilder defineConfiguration() { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.transaction().transactionMode(TransactionMode.TRANSACTIONAL) .locking().isolationLevel(IsolationLevel.REPEATABLE_READ) .clustering().cacheMode(CacheMode.REPL_SYNC) .persistence().addStore(DummyInMemoryStoreConfigurationBuilder.class) .storeName(this.getClass().getName()).preload(true); return builder; }
public void testNoneIsolationLevelInCluster() { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.locking().isolationLevel(IsolationLevel.NONE) .clustering().cacheMode(CacheMode.REPL_SYNC).build(); withCacheManager(new CacheManagerCallable( TestCacheManagerFactory.createClusteredCacheManager(builder)) { @Override public void call() { Configuration cfg = cm.getCache().getCacheConfiguration(); assertEquals(IsolationLevel.READ_COMMITTED, cfg.locking().isolationLevel()); } }); }
public MetadataManager(DefaultCacheManager cacheManager){ Configuration cacheConfiguration = cacheManager.getCacheConfiguration(Support.AVRO_METADATA_CACHE_NAME); if (cacheConfiguration == null) { ConfigurationBuilder cfg = new ConfigurationBuilder(); CacheMode cacheMode = cacheManager.getDefaultCacheConfiguration().clustering().cacheMode().equals(CacheMode.LOCAL) ? CacheMode.LOCAL : CacheMode.REPL_SYNC; cfg .transaction().lockingMode(LockingMode.PESSIMISTIC).syncCommitPhase(true).syncRollbackPhase(true) .persistence().addSingleFileStore().location(System.getProperty("java.io.tmpdir") + "/" + cacheManager.getNodeAddress()) // mandatory .locking().isolationLevel(IsolationLevel.READ_COMMITTED).useLockStriping(false) .clustering().cacheMode(cacheMode) .stateTransfer().fetchInMemoryState(true) .dataContainer().keyEquivalence(new ByteArrayEquivalence()); // for HotRod compatibility if (cacheMode.equals(CacheMode.REPL_SYNC)) cfg.clustering().stateTransfer().awaitInitialTransfer(true); cacheManager.defineConfiguration(Support.AVRO_METADATA_CACHE_NAME, cfg.build()); this.cacheManager = cacheManager; this.marshaller= Externalizer.getInstance(); this.knownSchemas = new ConcurrentHashMap<>(); knownSchemas.put(Request.getClassSchema().getFullName(), Request.getClassSchema()); knownSchemas.put(Response.getClassSchema().getFullName(), Response.getClassSchema()); } }
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder c = new ConfigurationBuilder(); c .locking() .isolationLevel(IsolationLevel.READ_COMMITTED) .lockAcquisitionTimeout(60000) .useLockStriping(false) .clustering() .cacheMode(CacheMode.DIST_SYNC) .remoteTimeout(30000) .l1().disable() .transaction() .lockingMode(LockingMode.PESSIMISTIC) .transactionManagerLookup(new EmbeddedTransactionManagerLookup()); GlobalConfigurationBuilder gc = GlobalConfigurationBuilder.defaultClusteredBuilder(); gc.transport().distributedSyncTimeout(60000); List<EmbeddedCacheManager> cacheManagers = new LinkedList<>(); for (int i = 0; i < NUM_NODES; i++) cacheManagers.add(createClusteredCacheManager(gc, c)); registerCacheManager(cacheManagers.toArray(new EmbeddedCacheManager[NUM_NODES])); }
private ConfigurationBuilder getClusteredCfg(CacheMode mode, boolean l1) { ConfigurationBuilder cfg = getBaseCfg(); cfg .locking().lockAcquisitionTimeout(60000) .clustering().cacheMode(mode).remoteTimeout(60000).stateTransfer().fetchInMemoryState(false); if (mode.isDistributed()) { cfg.clustering().l1().enabled(l1).lifespan(120000); } return cfg; }
private ConfigurationBuilder configuration() { ConfigurationBuilder configurationBuilder = getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, true); configurationBuilder.transaction() .transactionMode(TransactionMode.TRANSACTIONAL) .lockingMode(LockingMode.OPTIMISTIC) .locking().lockAcquisitionTimeout(TestingUtil.shortTimeoutMillis()) .isolationLevel(IsolationLevel.REPEATABLE_READ) .clustering().hash().numOwners(2).groups().enabled() .stateTransfer().fetchInMemoryState(false); return configurationBuilder; }
protected ConfigurationBuilder createTopologyCacheConfig(long distSyncTimeout) { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.clustering().cacheMode(CacheMode.REPL_SYNC).remoteTimeout(configuration.topologyReplTimeout()) .locking().lockAcquisitionTimeout(configuration.topologyLockTimeout()) .clustering().partitionHandling().mergePolicy(null) .expiration().lifespan(-1).maxIdle(-1); if (configuration.topologyStateTransfer()) { builder .clustering() .stateTransfer() .awaitInitialTransfer(configuration.topologyAwaitInitialTransfer()) .fetchInMemoryState(true) .timeout(distSyncTimeout + configuration.topologyReplTimeout()); } else { builder.persistence().addClusterLoader().remoteCallTimeout(configuration.topologyReplTimeout()); } return builder; }
protected ConfigurationBuilder defaultRecoveryConfig() { ConfigurationBuilder builder = getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, true); builder.transaction().transactionManagerLookup(new EmbeddedTransactionManagerLookup()) .useSynchronization(false) .recovery().enable() .locking().useLockStriping(false) .clustering().hash().numOwners(2) .l1().disable() .stateTransfer().fetchInMemoryState(false); return builder; }
@Override protected void createCacheManagers() throws Throwable { dccc = getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, true, true); dccc.transaction() .transactionManagerLookup(new EmbeddedTransactionManagerLookup()) .lockingMode(LockingMode.PESSIMISTIC) .locking().lockAcquisitionTimeout(TestingUtil.shortTimeoutMillis()) .clustering().hash().numOwners(1).numSegments(3) .l1().disable() .stateTransfer().fetchInMemoryState(true); createCluster(dccc, 2); waitForClusterToForm(); }
private ConfigurationBuilder configuration() { ConfigurationBuilder configurationBuilder = getDefaultClusteredCacheConfig(CacheMode.REPL_SYNC, true); configurationBuilder.clustering().hash().numSegments(60); configurationBuilder.transaction() .transactionMode(TransactionMode.TRANSACTIONAL) .lockingMode(LockingMode.OPTIMISTIC) .locking().lockAcquisitionTimeout(TestingUtil.shortTimeoutMillis()) .isolationLevel(IsolationLevel.REPEATABLE_READ) .clustering().hash().numOwners(2).groups().enabled() .stateTransfer().fetchInMemoryState(false); return configurationBuilder; }
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder builder = TestCacheManagerFactory.getDefaultCacheConfiguration(true); builder.clustering().cacheMode(CacheMode.DIST_SYNC) .l1().disable() .clustering().stateTransfer().fetchInMemoryState(true) .locking().useLockStriping(false) .clustering().hash().numOwners(3).numSegments(60) .stateTransfer().chunkSize(50); createCluster(builder, 4); c0 = cache(0); c1 = cache(1); c2 = cache(2); c3 = cache(3); waitForClusterToForm(); log.debug("Rehash is complete!"); expected = new HashMap<Integer, BigObject>(); }
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder config = getDefaultClusteredCacheConfig(cacheMode, true); config .locking().lockAcquisitionTimeout(LOCK_TIMEOUT) .clustering().remoteTimeout(REPL_TIMEOUT) .clustering().hash().numOwners(numOwners) .transaction().transactionManagerLookup(new EmbeddedTransactionManagerLookup()) .transaction().completedTxTimeout(3600000); createCluster(config, 3); waitForClusterToForm(); failPrepareInterceptor = new FailPrepareInterceptor(); advancedCache(2).addInterceptor(failPrepareInterceptor, 1); }
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder configuration = getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, true); configuration.transaction().transactionManagerLookup(new EmbeddedTransactionManagerLookup()) .useSynchronization(false) .recovery().enable() .locking().useLockStriping(false) .clustering().hash().numOwners(2) .clustering().l1().disable().stateTransfer().fetchInMemoryState(false); createCluster(configuration, 2); waitForClusterToForm(); advancedCache(1).getAsyncInterceptorChain().addInterceptorBefore(new ForceFailureInterceptor(), InvocationContextInterceptor.class); }
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder configuration = getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, true); configuration.transaction().transactionManagerLookup(new EmbeddedTransactionManagerLookup()) .useSynchronization(false) .recovery().enable() .jmxStatistics().enable() .locking().useLockStriping(false) .clustering().hash().numOwners(3) .l1().disable(); EmbeddedCacheManager cm1 = TestCacheManagerFactory.createClusteredCacheManager(createGlobalConfigurationBuilder(), configuration, new TransportFlags(), true); EmbeddedCacheManager cm2 = TestCacheManagerFactory.createClusteredCacheManager(createGlobalConfigurationBuilder(), configuration, new TransportFlags(), true); EmbeddedCacheManager cm3 = TestCacheManagerFactory.createClusteredCacheManager(createGlobalConfigurationBuilder(), configuration, new TransportFlags(), true); registerCacheManager(cm1, cm2, cm3); defineConfigurationOnAllManagers("test", configuration); cache(0, "test"); cache(1, "test"); cache(2, "test"); TestingUtil.waitForNoRebalance(caches("test")); threadMBeanServer = PerThreadMBeanServerLookup.getThreadMBeanServer(); assert showInDoubtTransactions(0).isEmpty(); assert showInDoubtTransactions(1).isEmpty(); assert showInDoubtTransactions(2).isEmpty(); tx1 = beginAndSuspendTx(cache(2, "test")); prepareTransaction(tx1); log.trace("Shutting down a cache " + address(cache(2, "test"))); TestingUtil.killCacheManagers(manager(2)); TestingUtil.blockUntilViewsReceived(90000, false, cache(0, "test"), cache(1, "test")); }