@Override public void start() { GlobalConfigurationBuilder builder = new GlobalConfigurationBuilder(); // WFLY-6685 Prevent Infinispan from registering channel mbeans // The JGroups subsystem already does this builder.globalJmxStatistics().read(this.configuration.globalJmxStatistics()).disable(); // ISPN-4755 workaround TransportConfiguration transport = this.configuration.transport(); builder.transport() .clusterName(transport.clusterName()) .distributedSyncTimeout(transport.distributedSyncTimeout()) .initialClusterSize(transport.initialClusterSize()) .initialClusterTimeout(transport.initialClusterTimeout(), TimeUnit.MILLISECONDS) .machineId(transport.machineId()) .nodeName(transport.nodeName()) .rackId(transport.rackId()) .siteId(transport.siteId()) .transport(transport.transport()) .withProperties(transport.properties()) ; this.configuration = builder.build(); super.start(); }
public static void setNodeName(GlobalConfigurationBuilder builder) { String nextNodeName = TestResourceTracker.getNextNodeName(); // Set the node name even for local managers in order to set the name of the worker threads builder.transport().nodeName(nextNodeName); }
.nodeName(nodeName) .siteId(siteName) .transport(transport)
private static Cache mockCache(String nodeName, Configuration configuration, TimeService timeService) { String cacheName = "mock-cache"; AdvancedCache cache = mock(AdvancedCache.class, RETURNS_DEEP_STUBS); GlobalConfiguration gc = new GlobalConfigurationBuilder() .transport().nodeName(nodeName) .build(); Set<String> cachesSet = new HashSet<>(); EmbeddedCacheManager cm = mock(EmbeddedCacheManager.class); when(cm.getCacheManagerConfiguration()).thenReturn(gc); GlobalComponentRegistry gcr = new GlobalComponentRegistry(gc, cm, cachesSet); BasicComponentRegistry gbcr = gcr.getComponent(BasicComponentRegistry.class); gbcr.replaceComponent(TimeService.class.getName(), timeService, true); ComponentRegistry registry = new ComponentRegistry(cacheName, configuration, cache, gcr, configuration.getClass().getClassLoader()); when(cache.getClassLoader()).thenReturn(PersistenceMockUtil.class.getClassLoader()); when(cache.getCacheManager().getCacheManagerConfiguration()) .thenReturn(gc); when(cache.getName()).thenReturn(cacheName); when(cache.getAdvancedCache()).thenReturn(cache); when(cache.getComponentRegistry()).thenReturn(registry); when(cache.getStatus()).thenReturn(ComponentStatus.RUNNING); when(cache.getCacheConfiguration()).thenReturn(configuration); return cache; }
public void amendConfiguration(ConfigurationBuilderHolder holder) { TransportConfigurationBuilder transport = holder.getGlobalConfigurationBuilder().transport(); transport.nodeName(TestResourceTracker.getNextNodeName()); transport.clusterName(TestResourceTracker.getCurrentTestName()); // minimize number of threads using unlimited cached thread pool transport.remoteCommandThreadPool().threadPoolFactory(CachedThreadPoolExecutorFactory.create()); transport.transportThreadPool().threadPoolFactory(CachedThreadPoolExecutorFactory.create()); for (Map.Entry<String, ConfigurationBuilder> cfg : holder.getNamedConfigurationBuilders().entrySet()) { amendCacheConfiguration(cfg.getKey(), cfg.getValue()); } // disable simple cache for testing as we need to insert interceptors if (!pendingPutsSimple) { holder.getNamedConfigurationBuilders().get(DEF_PENDING_PUTS_RESOURCE).simpleCache(false); } }
private EmbeddedCacheManager createCacheManagerProgrammatically() { System.out.println("Starting a cache manager with a programmatic configuration"); DefaultCacheManager cacheManager = new DefaultCacheManager( GlobalConfigurationBuilder.defaultClusteredBuilder() .transport().nodeName(nodeName).addProperty("configurationFile", "jgroups.xml") .build(), new ConfigurationBuilder() .clustering() .cacheMode(CacheMode.REPL_SYNC) .build() ); // The only way to get the "repl" cache to be exactly the same as the default cache is to not define it at all cacheManager.defineConfiguration("dist", new ConfigurationBuilder() .clustering() .cacheMode(CacheMode.DIST_SYNC) .hash().numOwners(2) .build() ); return cacheManager; }
builder.transport().nodeName(value); break;
private EmbeddedCacheManager createCacheManager(String name1, JChannel ch1) { GlobalConfigurationBuilder gcb1 = new GlobalConfigurationBuilder(); gcb1.transport().nodeName(ch1.getName()).distributedSyncTimeout(10, SECONDS); CustomChannelLookup.registerChannel(gcb1, ch1, name1, false); ConfigurationBuilder replCfg = new ConfigurationBuilder(); replCfg.clustering().cacheMode(CacheMode.REPL_SYNC); replCfg.clustering().stateTransfer().timeout(10, SECONDS); EmbeddedCacheManager cm1 = new DefaultCacheManager(gcb1.build(), replCfg.build(), false); registerCacheManager(cm1); cm1.defineConfiguration(CACHE_NAME, replCfg.build()); return cm1; }
@Override public void start() { GlobalConfigurationBuilder builder = new GlobalConfigurationBuilder(); // WFLY-6685 Prevent Infinispan from registering channel mbeans // The JGroups subsystem already does this builder.globalJmxStatistics().read(this.configuration.globalJmxStatistics()).disable(); // ISPN-4755 workaround TransportConfiguration transport = this.configuration.transport(); builder.transport() .clusterName(transport.clusterName()) .distributedSyncTimeout(transport.distributedSyncTimeout()) .initialClusterSize(transport.initialClusterSize()) .initialClusterTimeout(transport.initialClusterTimeout(), TimeUnit.MILLISECONDS) .machineId(transport.machineId()) .nodeName(transport.nodeName()) .rackId(transport.rackId()) .siteId(transport.siteId()) .transport(transport.transport()) .withProperties(transport.properties()) ; this.configuration = builder.build(); super.start(); }
@Override protected void createCacheManagers() throws Throwable { Configuration distConfig = getDefaultClusteredCacheConfig(cacheMode, false).build(); for (int i = 0; i < NUM_NODES; i++) { GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder(); gcb.transport().defaultTransport().nodeName(TestResourceTracker.getNameForIndex(i)); BlockingThreadPoolExecutorFactory remoteExecutorFactory = new BlockingThreadPoolExecutorFactory( 10, 1, 0, 60000); gcb.transport().remoteCommandThreadPool().threadPoolFactory(remoteExecutorFactory); EmbeddedCacheManager cm = new DefaultCacheManager(gcb.build()); registerCacheManager(cm); cm.defineConfiguration(CACHE_NAME, distConfig); log.infof("Started cache manager %s", cm.getAddress()); } waitForClusterToForm(CACHE_NAME); }
Exception { GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder(); gcb.transport().nodeName(channel.getName()); gcb.transport().distributedSyncTimeout(30, TimeUnit.SECONDS);
@Override public Void call() throws Exception { GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder(); gcb.transport().defaultTransport().nodeName(nodeName) .addProperty(JGroupsTransport.CONFIGURATION_STRING, configurator.getProtocolStackString()); BlockingThreadPoolExecutorFactory transportExecutorFactory = new BlockingThreadPoolExecutorFactory(
@Override public Object call() throws Exception { GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder(); gcb.transport().defaultTransport().nodeName(nodeName); // gcb.transport().machineId(machineId); BlockingThreadPoolExecutorFactory remoteExecutorFactory = new BlockingThreadPoolExecutorFactory( 10, 1, 0, 60000); gcb.transport().remoteCommandThreadPool().threadPoolFactory(remoteExecutorFactory); BlockingThreadPoolExecutorFactory stateTransferExecutorFactory = new BlockingThreadPoolExecutorFactory( 4, 1, 0, 60000); gcb.transport().stateTransferThreadPool().threadPoolFactory(stateTransferExecutorFactory); EmbeddedCacheManager cm = new DefaultCacheManager(gcb.build()); try { for (int j = 0; j < NUM_CACHES/2; j++) { cm.defineConfiguration("repl-cache-" + j, replConfig); cm.defineConfiguration("dist-cache-" + j, distConfig); } for (int j = 0; j < NUM_CACHES/2; j++) { Cache<Object, Object> replCache = cm.getCache("repl-cache-" + j); replCache.put(cm.getAddress(), "bla"); Cache<Object, Object> distCache = cm.getCache("dist-cache-" + j); distCache.put(cm.getAddress(), "bla"); } } finally { registerCacheManager(cm); } log.infof("Started cache manager %s", cm.getAddress()); return null; } });