protected AbstractHashDistAwareResponse createHashDistAwareResp(int topologyId, Map<Address, ServerAddress> serverEndpointsMap, Configuration cfg) { return new HashDistAwareResponse(topologyId, serverEndpointsMap, 0, cfg.clustering().hash().numOwners(), Constants.DEFAULT_CONSISTENT_HASH_VERSION_1x, Integer.MAX_VALUE); }
@Override protected AbstractHashDistAwareResponse createHashDistAwareResp(int topologyId, Map<Address, ServerAddress> serverEndpointsMap, Configuration cfg) { return new HashDistAware11Response(topologyId, serverEndpointsMap, cfg.clustering().hash().numOwners(), Constants.DEFAULT_CONSISTENT_HASH_VERSION_1x, Integer.MAX_VALUE, 1); }
@ManagedAttribute(description = "Number of replicas for each key", displayName = "Replication Degree") public double getReplicationDegree() { switch (cacheConfiguration.clustering().cacheMode()) { case DIST_SYNC: case DIST_ASYNC: return cacheConfiguration.clustering().hash().numOwners(); case REPL_ASYNC: case REPL_SYNC: return rpcManager.getMembers().size(); default: return 1; } }
protected MagicKey magicKey(Cache<Object, String> cache1, Cache<Object, String> cache2) { if (cache1.getCacheConfiguration().clustering().hash().numOwners() < 2) { return new MagicKey(cache1); } else { return new MagicKey(cache1, cache2); } }
public void testNumOwners() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.clustering().cacheMode(CacheMode.DIST_SYNC); cb.clustering().hash().numOwners(5); Configuration c = cb.build(); Assert.assertEquals(5, c.clustering().hash().numOwners()); try { cb.clustering().hash().numOwners(0); Assert.fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { } }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNumOwners() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.clustering().cacheMode(CacheMode.DIST_SYNC); cb.clustering().hash().numOwners(5); Configuration c = cb.build(); Assert.assertEquals(5, c.clustering().hash().numOwners()); // negative test cb.clustering().hash().numOwners(0); }
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder defaultConfig = getDefaultClusteredCacheConfig(cacheMode); log.debug("defaultConfig = " + defaultConfig.build().clustering().hash().numOwners()); defaultConfig.clustering().l1().disable().stateTransfer().fetchInMemoryState(true); createClusteredCaches(5, defaultConfig); ConsistentHash hash = cache(0).getAdvancedCache().getDistributionManager().getWriteConsistentHash(); List<Address> members = hash.getMembers(); addresses = members.toArray(new Address[members.size()]); }
private static void assertCounterAndCacheConfiguration(CounterManagerConfiguration config, Configuration cacheConfig) { AssertJUnit.assertEquals(CacheMode.DIST_SYNC, cacheConfig.clustering().cacheMode()); AssertJUnit.assertEquals(config.numOwners(), cacheConfig.clustering().hash().numOwners()); AssertJUnit.assertEquals(config.reliability() == Reliability.CONSISTENT, cacheConfig.clustering().partitionHandling().whenSplit() == PartitionHandling.DENY_READ_WRITES); AssertJUnit.assertFalse(cacheConfig.clustering().l1().enabled()); AssertJUnit.assertEquals(TransactionMode.NON_TRANSACTIONAL, cacheConfig.transaction().transactionMode()); }
private void doSimpleConcurrentTest(final Operation operation) throws Exception { cache(0).getCacheConfiguration().clustering().hash().numOwners()); final Object key = new MagicKey(cache(0), cache(1));
public void testSimpleDistributedClusterModeDefault() throws Exception { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.clustering().cacheMode(DIST_SYNC) .hash().numOwners(3).numSegments(51); cm = TestCacheManagerFactory.createClusteredCacheManager(builder); cm.defineConfiguration("my-cache", builder.build()); Cache<?, ?> cache = cm.getCache("my-cache"); // These are all overridden values ClusteringConfiguration clusteringCfg = cache.getCacheConfiguration().clustering(); assertEquals(DIST_SYNC, clusteringCfg.cacheMode()); assertEquals(3, clusteringCfg.hash().numOwners()); assertEquals(51, clusteringCfg.hash().numSegments()); }
public void testSimpleDistributedClusterModeNamedCache() throws Exception { final String cacheName = "my-cache"; final Configuration config = new ConfigurationBuilder() .clustering().cacheMode(DIST_SYNC) .hash().numOwners(3).numSegments(51).build(); cm = TestCacheManagerFactory.createClusteredCacheManager(); cm.defineConfiguration(cacheName, config); Cache<?, ?> cache = cm.getCache(cacheName); ClusteringConfiguration clusteringCfg = cache.getCacheConfiguration().clustering(); assertEquals(DIST_SYNC, clusteringCfg.cacheMode()); assertEquals(3, clusteringCfg.hash().numOwners()); assertEquals(51, clusteringCfg.hash().numSegments()); }
assertEquals(1200, c.clustering().l1().cleanupTaskFrequency()); assertEquals(3, c.clustering().hash().numOwners()); assertTrue(c.clustering().l1().enabled()); assertEquals(120000, c.clustering().stateTransfer().timeout()); assertEquals(3, c.clustering().hash().numOwners()); assertTrue(c.clustering().l1().enabled()); assertEquals(0.0f, c.clustering().hash().capacityFactor());
assertFalse(c.invocationBatching().enabled()); assertEquals(1200000, c.clustering().l1().lifespan()); assertEquals(4, c.clustering().hash().numOwners()); assertEquals(35000, c.clustering().remoteTimeout()); assertEquals(2, c.clustering().hash().numSegments());