chf.setOwnerIndexes(1, 2); addClusterEnabledCacheManager(builder).getCache(); chf.setOwnerIndexes(0, 1); Future<?> stoppingCacheFuture = fork(() -> killMember(2));
chFactory.setOwnerIndexes(new int[][]{{0, 2}, {0, 2}});
factory.setOwnerIndexes(1, 2); addClusterEnabledCacheManager(configuration(), new TransportFlags().withFD(true)); Future<Cache<Object, Object>> joiner = fork(() -> cacheManagers.get(3).getCache());
@Override protected void createCacheManagers() throws Throwable { ControlledConsistentHashFactory chf = new ControlledConsistentHashFactory.Default(0, 1); ConfigurationBuilder builder = TestCacheManagerFactory.getDefaultCacheConfiguration(true); builder .clustering() .cacheMode(CacheMode.REPL_SYNC) .hash() .numSegments(1) .consistentHashFactory(chf) .expiration() .lifespan(10, TimeUnit.SECONDS) .transaction() .transactionMode(TransactionMode.TRANSACTIONAL) .lockingMode(LockingMode.OPTIMISTIC) .locking() .isolationLevel(IsolationLevel.REPEATABLE_READ) .writeSkewCheck(true) .versioning() .enable() .scheme(VersioningScheme.SIMPLE); createCluster(builder, 2); TestingUtil.replaceComponent(manager(0), TimeService.class, timeService, true); expirationManager1 = cache(0).getAdvancedCache().getExpirationManager(); TestingUtil.replaceComponent(manager(1), TimeService.class, timeService, true); expirationManager2 = cache(1).getAdvancedCache().getExpirationManager(); }
@Override protected void createCacheManagers() throws Throwable { configurationBuilder = getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, true, true); configurationBuilder.transaction().transactionManagerLookup(new EmbeddedTransactionManagerLookup()); configurationBuilder.clustering().remoteTimeout(30000, TimeUnit.MILLISECONDS); configurationBuilder.clustering().hash().l1().disable(); configurationBuilder.locking().lockAcquisitionTimeout(TestingUtil.shortTimeoutMillis()); configurationBuilder.clustering().stateTransfer().fetchInMemoryState(true); ControlledConsistentHashFactory consistentHashFactory = new ControlledConsistentHashFactory.Default(new int[][]{{KILLED_INDEX, ORIGINATOR_INDEX}, {KILLED_INDEX, OTHER_INDEX}}); configurationBuilder.clustering().hash().numSegments(2).consistentHashFactory(consistentHashFactory); createCluster(configurationBuilder, 3); waitForClusterToForm(); originatorCache = cache(ORIGINATOR_INDEX); killedCache = cache(KILLED_INDEX); otherCache = cache(OTHER_INDEX); // Set up the consistent hash after node 1 is killed consistentHashFactory.setOwnerIndexes(new int[][]{{ORIGINATOR_INDEX, OTHER_INDEX}, {OTHER_INDEX, ORIGINATOR_INDEX}}); // TODO Add another test method with ownership changing from [KILLED_INDEX, OTHER_INDEX] to [ORIGINATOR_INDEX, OTHER_INDEX] // i.e. the originator is a non-owner at first, and becomes the primary owner when the prepare is retried }
protected ConfigurationBuilder createConfigurationBuilder(boolean isOptimistic) { ConfigurationBuilder builder = getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, true, true); builder.transaction().transactionMode(TransactionMode.TRANSACTIONAL) .transactionManagerLookup(new EmbeddedTransactionManagerLookup()); if (isOptimistic) { builder.transaction().lockingMode(LockingMode.OPTIMISTIC) .locking().isolationLevel(IsolationLevel.REPEATABLE_READ); } else { builder.transaction().lockingMode(LockingMode.PESSIMISTIC); } // Make it impossible for a key to be owned by nodes 0 and 2 consistentHashFactory = new ControlledConsistentHashFactory.Default(new int[][]{{0, 1}, {1, 2}}); builder.clustering().hash().numOwners(2).numSegments(2).consistentHashFactory(consistentHashFactory); builder.clustering().stateTransfer().fetchInMemoryState(true).awaitInitialTransfer(false); builder.clustering().l1().disable().locking().lockAcquisitionTimeout(TestingUtil.shortTimeoutMillis()); return builder; }
@Override protected void createCacheManagers() throws Throwable { ControlledConsistentHashFactory consistentHashFactory = new ControlledConsistentHashFactory.Default(1, 2); ConfigurationBuilder builder = new ConfigurationBuilder(); builder.clustering().cacheMode(CacheMode.DIST_SYNC); builder.clustering().remoteTimeout(2000); builder.clustering().hash().numSegments(1).consistentHashFactory(consistentHashFactory); builder.transaction().transactionMode(TransactionMode.TRANSACTIONAL); builder.transaction().completedTxTimeout(COMPLETED_TX_TIMEOUT); addClusterEnabledCacheManager(builder); addClusterEnabledCacheManager(builder); addClusterEnabledCacheManager(builder); waitForClusterToForm(); }
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder config = new ConfigurationBuilder(); config.clustering().cacheMode(CacheMode.DIST_SYNC); config.transaction().lockingMode(LockingMode.OPTIMISTIC); config.clustering().locking().lockAcquisitionTimeout(2, SECONDS); config.clustering().hash().numSegments(1) .consistentHashFactory(new ControlledConsistentHashFactory.Default(1, 0)); config.transaction().transactionManagerLookup(new EmbeddedTransactionManagerLookup()) .cacheStopTimeout(1, SECONDS); createCluster(config, 2); waitForClusterToForm(); } }
@Override protected void createCacheManagers() throws Throwable { ControlledConsistentHashFactory consistentHashFactory = new ControlledConsistentHashFactory.Default(1, 2); ConfigurationBuilder builder = new ConfigurationBuilder(); builder.clustering().cacheMode(CacheMode.DIST_SYNC); builder.clustering().remoteTimeout(2000); builder.clustering().hash().numSegments(1).consistentHashFactory(consistentHashFactory); builder.transaction().transactionMode(TransactionMode.TRANSACTIONAL); addClusterEnabledCacheManager(builder); addClusterEnabledCacheManager(builder); addClusterEnabledCacheManager(builder); waitForClusterToForm(); }
@Override protected void createCacheManagers() throws Throwable { controlledCHFactory = new ControlledConsistentHashFactory.Default(new int[][]{{1, 2}, {2, 3}}); ConfigurationBuilder configuration = getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, true); configuration.clustering().cacheMode(CacheMode.DIST_SYNC); configuration.clustering().hash().numSegments(2).numOwners(2).consistentHashFactory(controlledCHFactory); configuration.transaction().lockingMode(LockingMode.OPTIMISTIC) .locking().isolationLevel(IsolationLevel.REPEATABLE_READ); for (int i = 0; i < 4; i++) { addClusterEnabledCacheManager(configuration, new TransportFlags().withFD(true)); } waitForClusterToForm(); }
private static ConfigurationBuilder config() { ConfigurationBuilder builder = getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, true); builder.transaction() .useSynchronization(false) .transactionManagerLookup(new EmbeddedTransactionManagerLookup()) .recovery().disable(); builder.locking().lockAcquisitionTimeout(1, TimeUnit.MINUTES).isolationLevel(IsolationLevel.READ_COMMITTED); builder.clustering() .remoteTimeout(1, TimeUnit.MINUTES) .hash().numOwners(1).numSegments(1) .consistentHashFactory(new ControlledConsistentHashFactory.Default(0)) .stateTransfer().fetchInMemoryState(false); return builder; }
@Override protected void createCacheManagers() throws Throwable { consistentHashFactory = new ControlledConsistentHashFactory.Default(new int[][]{{0, 1}, {1, 2}, {2, 3}, {3, 0}}); ConfigurationBuilder builderUsed = new ConfigurationBuilder(); builderUsed.clustering().cacheMode(cacheMode); if (cacheMode == CacheMode.DIST_SYNC) { builderUsed.clustering().clustering().hash().numOwners(2).numSegments(4).consistentHashFactory(consistentHashFactory); } createClusteredCaches(4, CACHE_NAME, builderUsed); }
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder cb = getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC); ControlledConsistentHashFactory.Default chf = new ControlledConsistentHashFactory.Default( new int[][]{{0, 1}, {0, 2}, {2, 3}}); cb.clustering().hash().numOwners(2).numSegments(3).consistentHashFactory(chf); createClusteredCaches(5, cb); }
@Override protected void createCacheManagers() throws Throwable { chFactory = new ControlledConsistentHashFactory.Default(new int[][]{{0, 1}, {0, 2}}); cb = new ConfigurationBuilder(); cb.clustering().cacheMode(CacheMode.DIST_SYNC).hash().consistentHashFactory(chFactory).numSegments(2); cb.transaction().transactionMode(TransactionMode.TRANSACTIONAL); createCluster(cb, 3); // make sure the caches are started in proper order for (int i = 0; i < 3; ++i) cache(i); }
@Override public Object[] factory() { return new Object[]{ new RehashClusterListenerTest(new ControlledConsistentHashFactory.Default(1, 2)).cacheMode(CacheMode.DIST_SYNC), new RehashClusterListenerTest(new ControlledConsistentHashFactory.Scattered(1)).cacheMode(CacheMode.SCATTERED_SYNC), }; }
@Override protected void createCacheManagers() throws Throwable { cchf = new ControlledConsistentHashFactory.Default(new int[][]{{0, 1}, {1, 2}, {2, 3}, {3, 0}}); configBuilder = getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC); configBuilder.clustering().partitionHandling().whenSplit(PartitionHandling.DENY_READ_WRITES); configBuilder.clustering().hash().numSegments(4).stateTransfer().timeout(30000); }
protected ConfigurationBuilder getConfigurationBuilder() { consistentHashFactory = new ControlledConsistentHashFactory.Default(0, 1); ConfigurationBuilder c = new ConfigurationBuilder(); c.clustering().cacheMode(CacheMode.DIST_SYNC); c.clustering().hash().consistentHashFactory(consistentHashFactory).numSegments(1); c.transaction().transactionMode(TransactionMode.TRANSACTIONAL); c.transaction().lockingMode(LockingMode.PESSIMISTIC); return c; }
@Override protected void createCacheManagers() throws Throwable { dcc = getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, true); dcc.transaction().transactionManagerLookup(new EmbeddedTransactionManagerLookup()); consistentHashFactory = new ControlledConsistentHashFactory.Default(1); dcc.clustering().hash().numOwners(1).numSegments(1).consistentHashFactory(consistentHashFactory); createCluster(dcc, 2); waitForClusterToForm(); }
@Override protected void createCacheManagers() throws Throwable { chf = new ControlledConsistentHashFactory.Default(0, 1); cb = new ConfigurationBuilder(); cb.transaction().transactionMode(TransactionMode.TRANSACTIONAL).useSynchronization(false); cb.clustering().cacheMode(CacheMode.DIST_SYNC).hash().numSegments(1).consistentHashFactory(chf); createCluster(cb, 3); waitForClusterToForm(); }
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder builder = getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, true); builder.transaction().lockingMode(LockingMode.PESSIMISTIC); builder.clustering().hash().consistentHashFactory(new ControlledConsistentHashFactory.Default(1, 2)) .numSegments(1) .numOwners(2); createClusteredCaches(4, builder); }