Configuration cacheConfig1 = new Configuration();
cacheConfig1.setMultiplexerStack(stackName);
cacheConfig1.setCacheMode("REPL_SYNC");
DependencyInjectedConfigurationRegistry registry1 = new DependencyInjectedConfigurationRegistry();
registry1.registerConfiguration("config1", cacheConfig1);
CacheManager cacheManager1 = new CacheManager(registry1, factory1);
HAPartitionCacheHandlerImpl cacheHandler1 = new HAPartitionCacheHandlerImpl();
cacheHandler1.setCacheManager(cacheManager1);
cacheHandler1.setCacheConfigName("config1");
DistributedStateImpl ds1 = new DistributedStateImpl();
ds1.setCacheHandler(cacheHandler1);
partition1 = new ClusterPartition();
partition1.setPartitionName(partitionName);
partition1.setCacheHandler(cacheHandler1);
partition1.setStateTransferTimeout(30000);
partition1.setMethodCallTimeout(60000);
partition1.setDistributedStateImpl(ds1);
partition1.setBindIntoJndi(false);
partition1.create();
partition1.start();
DistributedReplicantManager drm1 = partition1.getDistributedReplicantManager();
Thread.sleep(10000);
// Use a different stack name with the same config to avoid singleton conflicts
stackName = "tunnel2";
JChannelFactory factory2 = new JChannelFactory();
factory2.setMultiplexerConfig(muxFile);
factory2.setNamingServicePort(1099);
factory2.setNodeName("node2");
factory2.setExposeChannels(false);
factory2.setExposeProtocols(false);
factory2.create();
factory2.start();
Configuration cacheConfig2 = new Configuration();
cacheConfig2.setMultiplexerStack(stackName);
cacheConfig2.setCacheMode("REPL_SYNC");
DependencyInjectedConfigurationRegistry registry2 = new DependencyInjectedConfigurationRegistry();
registry2.registerConfiguration("config2", cacheConfig2);
CacheManager cacheManager2 = new CacheManager(registry2, factory2);
HAPartitionCacheHandlerImpl cacheHandler2 = new HAPartitionCacheHandlerImpl();
cacheHandler2.setCacheManager(cacheManager2);