jgroupsXml = jgroupsXml.replaceAll("mcast_addr=\"[0-9.]+\"", String.format("mcast_addr=\"%s\"", config.getClusterAddress()));
jgroupsXml = jgroupsXml.replaceAll("mcast_port=\"[0-9]+\"", String.format("mcast_port=\"%d\"", config.getClusterPort()));
GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder()
.classLoader(InfinispanEmbeddedCacheManager.class.getClassLoader())
.transport()
.defaultTransport()
.clusterName(config.getClusterName())
.machineId("instance-" + config.getDatacenterId())
.addProperty("configurationXml", jgroupsXml)
.distributedSyncTimeout(config.getClusterTimeout())
.globalJmxStatistics()
.jmxDomain("org.apache.marmotta.kiwi")
.allowDuplicateDomains(true)
.serialization()
.addAdvancedExternalizer(externalizers)
.build();
defaultConfiguration = new ConfigurationBuilder()
.clustering()
.cacheMode(CacheMode.REPL_ASYNC)
.async()
.asyncMarshalling()
.stateTransfer()
.fetchInMemoryState(false)
.timeout(config.getClusterTimeout())
.eviction()
.strategy(EvictionStrategy.LIRS)
.maxEntries(100000)
.expiration()
.lifespan(30, TimeUnit.MINUTES)
.maxIdle(10, TimeUnit.MINUTES)
.build();
cacheManager = new DefaultCacheManager(globalConfiguration, defaultConfiguration, true);
log.info("initialised Infinispan replicated cache manager (cluster name: {})", globalConfiguration.transport().clusterName());
}