/** * Creates a new cache manager, starts it, and adds it to the list of known cache managers on the current thread. * Uses a default clustered cache manager global config. * * @return the new CacheManager */ protected EmbeddedCacheManager addClusterEnabledCacheManager() { return addClusterEnabledCacheManager(new TransportFlags()); }
/** * Creates a new non-transactional cache manager, starts it, and adds it to the list of known cache managers on the * current thread. Uses a default clustered cache manager global config. * * @param defaultConfig default cfg to use * @return the new CacheManager */ protected EmbeddedCacheManager addClusterEnabledCacheManager(ConfigurationBuilder defaultConfig) { return addClusterEnabledCacheManager(defaultConfig, new TransportFlags()); }
/** * Creates an cache manager that does support clustering. */ public static EmbeddedCacheManager createClusteredCacheManager() { return createClusteredCacheManager(new ConfigurationBuilder(), new TransportFlags()); }
private JChannel createChannel(String name, int portRange) throws Exception { String configString = JGroupsConfigBuilder .getJGroupsConfig(ConcurrentStartChanelLookupTest.class.getName(), new TransportFlags().withPortRange(portRange)); JChannel channel = new JChannel(new ByteArrayInputStream(configString.getBytes())); channel.setName(name); channel.connect(ConcurrentStartChanelLookupTest.class.getSimpleName()); log.tracef("Channel %s connected: %s", channel, channel.getViewAsString()); return channel; } }
private JChannel createChannel(String name, int portRange) throws Exception { String configString = JGroupsConfigBuilder .getJGroupsConfig(ConcurrentStartForkChannelTest.class.getName(), new TransportFlags().withPortRange(portRange)); JChannel channel = new JChannel(new ByteArrayInputStream(configString.getBytes())); channel.setName(name); channel.connect(ConcurrentStartForkChannelTest.class.getSimpleName()); log.tracef("Channel %s connected: %s", channel, channel.getViewAsString()); return channel; }
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder cb = configuration(); createClusteredCaches(3, cb, new TransportFlags().withFD(true)); }
void performRehashEvent(boolean offline) { joinerManager = addClusterEnabledCacheManager(new TransportFlags()); joinerManager.defineConfiguration(cacheName, configuration.build()); joiner = joinerManager.getCache(cacheName); }
protected EmbeddedCacheManager createCacheManager(String cacheName) { EmbeddedCacheManager cm = addClusterEnabledCacheManager(configurationBuilder, new TransportFlags().withMerge(true)); cm.defineConfiguration(cacheName, configurationBuilder.build()); return cm; }
@Override protected void createCacheManagers() throws Throwable { caches = createClusteredCaches(2, "test", getDefaultClusteredCacheConfig(cacheMode), new TransportFlags().withFD(true).withMerge(true)); c1 = caches.get(0); c2 = caches.get(1); d1 = TestingUtil.getDiscardForCache(c1.getCacheManager()); d2 = TestingUtil.getDiscardForCache(c2.getCacheManager()); }
@Override protected void createCacheManagers() throws Throwable { for (int i = 0; i < CLUSTER_SIZE; i++) { GlobalConfigurationBuilder gc = GlobalConfigurationBuilder.defaultClusteredBuilder(); gc.transport().initialClusterSize(CLUSTER_SIZE).initialClusterTimeout(CLUSTER_TIMEOUT_SECONDS, TimeUnit.SECONDS); cacheManagers.add(TestCacheManagerFactory.createClusteredCacheManager(false, gc, getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC), new TransportFlags().withPortRange(i), false)); } }
private CacheContainer createManager(ConfigurationBuilder builder) { GlobalConfigurationBuilder gcb1 = GlobalConfigurationBuilder.defaultClusteredBuilder(); gcb1.globalJmxStatistics().enable().jmxDomain(jmxDomain) .mBeanServerLookup(new PerThreadMBeanServerLookup()); CacheContainer cacheManager = TestCacheManagerFactory.createClusteredCacheManager(gcb1, builder, new TransportFlags(), true); cacheManager.start(); return cacheManager; }
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.clustering().cacheMode(cacheMode) .partitionHandling().enabled(false); createClusteredCaches(4, cb, new TransportFlags().withFD(true).withMerge(true)); }
@Override protected void createCacheManagers() throws Throwable { cfgBuilder = getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, true); cfgBuilder.transaction().transactionManagerLookup(new EmbeddedTransactionManagerLookup()); cfgBuilder.clustering().hash().numOwners(2); cfgBuilder.clustering().stateTransfer().fetchInMemoryState(true); cfgBuilder.clustering().stateTransfer().timeout(20000); GlobalConfigurationBuilder gcb0 = new GlobalConfigurationBuilder().clusteredDefault(); addClusterEnabledCacheManager(gcb0, cfgBuilder, new TransportFlags().withFD(true)); GlobalConfigurationBuilder gcb1 = new GlobalConfigurationBuilder().clusteredDefault(); addClusterEnabledCacheManager(gcb1, cfgBuilder, new TransportFlags().withFD(true)); }
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder defaultConfig = getDefaultClusteredCacheConfig(cacheMode, false); createClusteredCaches(3, defaultConfig, new TransportFlags().withFD(true).withMerge(true)); DISCARD d1 = TestingUtil.getDiscardForCache(manager(0)); DISCARD d2 = TestingUtil.getDiscardForCache(manager(1)); DISCARD d3 = TestingUtil.getDiscardForCache(manager(2)); discard = new DISCARD[]{d1, d2, d3}; }
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder dcc = cacheConfiguration(); dcc.clustering() .cacheMode(cacheMode).partitionHandling().whenSplit(partitionHandling).mergePolicy(mergePolicy) .hash().keyPartitioner(PARTITIONER); createClusteredCaches(numMembersInCluster, dcc, new TransportFlags().withFD(true).withMerge(true)); waitForClusterToForm(); }
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder dcc = cacheConfiguration(); dcc.clustering().cacheMode(cacheMode) .partitionHandling().whenSplit(PartitionHandling.ALLOW_READ_WRITES).mergePolicy(MergePolicy.PREFERRED_ALWAYS); String[] cacheNames = getCacheNames(); createClusteredCaches(numMembersInCluster, dcc, new TransportFlags().withFD(true).withMerge(true), cacheNames); waitForClusterToForm(CacheContainer.DEFAULT_CACHE_NAME); waitForClusterToForm(cacheNames); }
@Override protected void createCacheManagers() throws Throwable { localConfig = new ConfigurationBuilder(); clusteredConfig = new ConfigurationBuilder(); clusteredConfig.clustering().cacheMode(CacheMode.REPL_SYNC).stateTransfer().timeout(30, TimeUnit.SECONDS); for (int i = 0; i < 2; i++) addClusterEnabledCacheManager(localConfig, new TransportFlags().withFD(true)); d1 = TestingUtil.getDiscardForCache(manager(0)); d2 = TestingUtil.getDiscardForCache(manager(1)); }
@Override protected void createCacheManagers() throws Throwable { defaultConfig = getDefaultClusteredCacheConfig(cacheMode, transactional); createClusteredCaches(3, defaultConfig, new TransportFlags().withFD(true).withMerge(true)); defineConfigurationOnAllManagers(CACHE_NAME, defaultConfig); c1 = cache(0, CACHE_NAME); c2 = cache(1, CACHE_NAME); c3 = cache(2, CACHE_NAME); d1 = TestingUtil.getDiscardForCache(c1.getCacheManager()); d2 = TestingUtil.getDiscardForCache(c2.getCacheManager()); d3 = TestingUtil.getDiscardForCache(c3.getCacheManager()); }
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder dcc = cacheConfiguration(); dcc.clustering() .cacheMode(cacheMode) .partitionHandling().whenSplit(partitionHandling).mergePolicy(mergePolicy) .hash().numOwners(numberOfOwners); for (int i = 0; i < numMembersInCluster; i++) { EmbeddedCacheManager cm = addClusterEnabledCacheManager(dcc, new TransportFlags().withFD(true).withMerge(true)); Cache cache = cm.getCache(); disableDiscoveryProtocol(channel(cache)); } }
@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(); }