本文整理汇总了Java中org.infinispan.configuration.global.GlobalConfigurationBuilder类的典型用法代码示例。如果您正苦于以下问题:Java GlobalConfigurationBuilder类的具体用法?Java GlobalConfigurationBuilder怎么用?Java GlobalConfigurationBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GlobalConfigurationBuilder类属于org.infinispan.configuration.global包,在下文中一共展示了GlobalConfigurationBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCacheManager
import org.infinispan.configuration.global.GlobalConfigurationBuilder; //导入依赖的package包/类
@Bean(destroyMethod = "stop")
public EmbeddedCacheManager createCacheManager() {
GlobalConfigurationBuilder globalCfg = new GlobalConfigurationBuilder();
globalCfg.globalJmxStatistics().allowDuplicateDomains(true).disable(); // get rid of this?
ConfigurationBuilder cacheCfg = new ConfigurationBuilder();
cacheCfg.jmxStatistics().disable();
cacheCfg.indexing()
.index(Index.ALL)
.addIndexedEntity(Fruit.class)
.addIndexedEntity(CEntity.class)
.addIndexedEntity(SimpleEntity.class)
.addProperty("default.directory_provider", "local-heap")
.addProperty("lucene_version", "LUCENE_CURRENT");
return new DefaultCacheManager(globalCfg.build(), cacheCfg.build());
}
示例2: clusteredCacheManager
import org.infinispan.configuration.global.GlobalConfigurationBuilder; //导入依赖的package包/类
private DefaultCacheManager clusteredCacheManager(CacheMode mode, int owners, RulesManager rulesManager) {
ExecutorService executorService = Executors.newFixedThreadPool(4);
HAKieSessionBuilder sessionBuilder = new HAKieSessionBuilder(rulesManager, executorService);
GlobalConfiguration glob = new GlobalConfigurationBuilder().clusteredDefault()
.transport().addProperty("configurationFile", System.getProperty("jgroups.configuration", "jgroups-test-tcp.xml"))
.clusterName("HACEP")
.globalJmxStatistics().allowDuplicateDomains(true).enable()
.serialization()
.addAdvancedExternalizer(new HAKieSession.HASessionExternalizer(sessionBuilder))
.addAdvancedExternalizer(new HAKieSerializedSession.HASerializedSessionExternalizer(sessionBuilder))
.addAdvancedExternalizer(new HAKieSessionDeltaEmpty.HASessionDeltaEmptyExternalizer(sessionBuilder))
.addAdvancedExternalizer(new HAKieSessionDeltaFact.HASessionDeltaFactExternalizer())
.build();
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
configurationBuilder.invocationBatching().enable();
configureCacheMode(configurationBuilder, mode, owners);
org.infinispan.configuration.cache.Configuration loc = extendDefaultConfiguration(configurationBuilder).build();
return new DefaultCacheManager(glob, loc, true);
}
示例3: defaultClusteredCacheManager
import org.infinispan.configuration.global.GlobalConfigurationBuilder; //导入依赖的package包/类
@Produces
@ApplicationScoped
public EmbeddedCacheManager defaultClusteredCacheManager() {
GlobalConfiguration g = new GlobalConfigurationBuilder()
.clusteredDefault()
.transport()
.clusterName(MACHINE_TRANSLATIONS_CLUSTER)
.globalJmxStatistics()
.allowDuplicateDomains(true)
.build();
Configuration cfg = new ConfigurationBuilder()
.clustering()
.cacheMode(CacheMode.DIST_ASYNC)
.eviction()
.strategy(EvictionStrategy.LRU)
.type(EvictionType.COUNT).size(150)
.transaction()
.transactionMode(TransactionMode.TRANSACTIONAL)
.lockingMode(LockingMode.PESSIMISTIC)
.build();
return new DefaultCacheManager(g, cfg);
}
示例4: main
import org.infinispan.configuration.global.GlobalConfigurationBuilder; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// Setup up a clustered cache manager
GlobalConfigurationBuilder global = GlobalConfigurationBuilder.defaultClusteredBuilder();
// Make the default cache a replicated synchronous one
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.clustering().cacheMode(CacheMode.REPL_SYNC);
// Initialize the cache manager
DefaultCacheManager cacheManager = new DefaultCacheManager(global.build(), builder.build());
// Obtain the default cache
Cache<String, String> cache = cacheManager.getCache();
// Store the current node address in some random keys
for(int i=0; i < 10; i++) {
cache.put(UUID.randomUUID().toString(), cacheManager.getNodeAddress());
}
// Display the current cache contents for the whole cluster
cache.entrySet().forEach(entry -> System.out.printf("%s = %s\n", entry.getKey(), entry.getValue()));
// Display the current cache contents for this node
cache.getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP)
.entrySet().forEach(entry -> System.out.printf("%s = %s\n", entry.getKey(), entry.getValue()));
// Stop the cache manager and release all resources
cacheManager.stop();
}
示例5: main
import org.infinispan.configuration.global.GlobalConfigurationBuilder; //导入依赖的package包/类
public static void main(String[] args) {
// Setup up a clustered cache manager
GlobalConfigurationBuilder global = GlobalConfigurationBuilder.defaultClusteredBuilder();
// Make the default cache a distributed one
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.clustering().cacheMode(CacheMode.DIST_SYNC);
// Initialize the cache manager
DefaultCacheManager cacheManager = new DefaultCacheManager(global.build(), builder.build());
// Obtain the default cache
Cache<String, String> cache = cacheManager.getCache();
// Create a distributed executor service using the distributed cache to determine the nodes on which to run
DefaultExecutorService executorService = new DefaultExecutorService(cache);
// Submit a job to all nodes
List<Future<Integer>> results = executorService.submitEverywhere((Callable & Serializable) () -> new Random().nextInt());
// Print out the results
results.forEach(s -> {
try {
System.out.printf("%s\n", s.get(100, TimeUnit.MILLISECONDS));
} catch (Exception e) {
}
});
// Shuts down the cache manager and all associated resources
cacheManager.stop();
System.exit(0);
}
示例6: main
import org.infinispan.configuration.global.GlobalConfigurationBuilder; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// Setup up a clustered cache manager
GlobalConfigurationBuilder global = GlobalConfigurationBuilder.defaultClusteredBuilder();
// Make the default cache a distributed synchronous one
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.clustering().cacheMode(CacheMode.DIST_SYNC);
// Initialize the cache manager
DefaultCacheManager cacheManager = new DefaultCacheManager(global.build(), builder.build());
// Obtain the default cache
Cache<String, String> cache = cacheManager.getCache();
// Store the current node address in some random keys
for(int i=0; i < 10; i++) {
cache.put(UUID.randomUUID().toString(), cacheManager.getNodeAddress());
}
// Display the current cache contents for the whole cluster
cache.entrySet().forEach(entry -> System.out.printf("%s = %s\n", entry.getKey(), entry.getValue()));
// Display the current cache contents for this node
cache.getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP)
.entrySet().forEach(entry -> System.out.printf("%s = %s\n", entry.getKey(), entry.getValue()));
// Stop the cache manager and release all resources
cacheManager.stop();
}
示例7: start
import org.infinispan.configuration.global.GlobalConfigurationBuilder; //导入依赖的package包/类
@Override
public void start() {
createdSessionCount.set(0);
expiredSessionCount.set(0);
// here we create a replicated cache using a cluster with name 'default-cluster'.
// sessions are replicate across all nodes joining the same cluster.
this.cacheManager = new DefaultCacheManager(
GlobalConfigurationBuilder.defaultClusteredBuilder()
.globalJmxStatistics().cacheManagerName(deploymentName)
.transport().nodeName(deploymentName).clusterName("default-cluster")
.build(),
new ConfigurationBuilder()
.clustering()
.cacheMode(CacheMode.REPL_SYNC)
.build()
);
this.sessions = cacheManager.getCache();
startTime = System.currentTimeMillis();
}
示例8: doCreateHttpServerMechanismFactory
import org.infinispan.configuration.global.GlobalConfigurationBuilder; //导入依赖的package包/类
@Override
protected HttpServerAuthenticationMechanismFactory doCreateHttpServerMechanismFactory(Map<String, ?> properties) {
HttpServerAuthenticationMechanismFactory delegate = super.doCreateHttpServerMechanismFactory(properties);
String cacheManagerName = UUID.randomUUID().toString();
EmbeddedCacheManager cacheManager = new DefaultCacheManager(
GlobalConfigurationBuilder.defaultClusteredBuilder()
.globalJmxStatistics().cacheManagerName(cacheManagerName)
.transport().nodeName(cacheManagerName).addProperty(JGroupsTransport.CONFIGURATION_FILE, "fast.xml")
.build(),
new ConfigurationBuilder()
.clustering()
.cacheMode(CacheMode.REPL_SYNC)
.build()
);
Cache<String, SingleSignOnEntry> cache = cacheManager.getCache();
SingleSignOnManager manager = new DefaultSingleSignOnManager(cache, new DefaultSingleSignOnSessionIdentifierFactory(), (id, entry) -> cache.put(id, entry));
SingleSignOnServerMechanismFactory.SingleSignOnConfiguration signOnConfiguration = new SingleSignOnServerMechanismFactory.SingleSignOnConfiguration("JSESSIONSSOID", null, "/", false, false);
SingleSignOnSessionFactory singleSignOnSessionFactory = new DefaultSingleSignOnSessionFactory(manager, this.keyPairSupplier.get());
return new SingleSignOnServerMechanismFactory(delegate, singleSignOnSessionFactory, signOnConfiguration);
}
示例9: createContainerForLucene
import org.infinispan.configuration.global.GlobalConfigurationBuilder; //导入依赖的package包/类
public static DefaultCacheManager createContainerForLucene()
throws Exception {
GlobalConfiguration glob = new GlobalConfigurationBuilder()
.nonClusteredDefault() //Helper method that gets you a default constructed GlobalConfiguration, preconfigured for use in LOCAL mode
.globalJmxStatistics().enable() //This method allows enables the jmx statistics of the global configuration.
.jmxDomain("org.infinispan.trades.annotated." + ++cnt) //prevent collision with non-transactional carmart
.build(); //Builds the GlobalConfiguration object
Configuration loc = new ConfigurationBuilder()
.indexing().enable().addProperty("hibernate.search.default.directory_provider", "filesystem").addProperty("hibernate.search.default.indexBase", "./target/lucene/indexes " + cnt)
.clustering().cacheMode(CacheMode.LOCAL) //Set Cache mode to LOCAL - Data is not replicated.
.transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL)
.eviction().maxEntries(100).strategy(EvictionStrategy.LIRS) //Sets 4 as maximum number of entries in a cache instance and uses the LIRS strategy - an efficient low inter-reference recency set replacement policy to improve buffer cache performance
.persistence().passivation(false).addSingleFileStore().purgeOnStartup(true).location("./target/localcache/indexing/trades" + cnt) //Disable passivation and adds a SingleFileStore that is purged on Startup
.build(); //Builds the Configuration object
DefaultCacheManager container = new DefaultCacheManager(glob, loc, true);
return container;
}
示例10: buildCacheManager
import org.infinispan.configuration.global.GlobalConfigurationBuilder; //导入依赖的package包/类
private DefaultCacheManager buildCacheManager() {
GlobalConfiguration glob = new GlobalConfigurationBuilder().clusteredDefault()
//.transport().addProperty("configurationFile", System.getProperty("playground.jgroups.configuration", "default-jgroups-tcp.xml"))
.transport().clusterName("PLAYGROUND")
.globalJmxStatistics().allowDuplicateDomains(true).enable()
.build();
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
configurationBuilder.jmxStatistics().enable();
configureCacheMode(configurationBuilder);
if (persistence()) {
configureCacheStore(configurationBuilder);
}
Configuration loc = configurationBuilder.transaction().transactionMode(TransactionMode.TRANSACTIONAL).transactionManagerLookup(new DummyTransactionManagerLookup()).build();
return new DefaultCacheManager(glob, loc, true);
}
示例11: buildLocalConfiguration
import org.infinispan.configuration.global.GlobalConfigurationBuilder; //导入依赖的package包/类
/**
* Build a local cache configuration.
* <p/>
* In local cache mode, the cache is not shared among the servers in a cluster. Each machine keeps a local cache.
* This allows quick startups and eliminates network traffic in the cluster, but subsequent requests to different
* cluster members cannot benefit from the cached data.
*/
protected void buildLocalConfiguration() {
GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder()
.classLoader(InfinispanEmbeddedCacheManager.class.getClassLoader())
.globalJmxStatistics()
.jmxDomain("org.apache.marmotta.kiwi")
.allowDuplicateDomains(true)
.build();
defaultConfiguration = new ConfigurationBuilder()
.clustering()
.cacheMode(CacheMode.LOCAL)
.eviction()
.strategy(EvictionStrategy.LIRS)
.maxEntries(100000)
.expiration()
.lifespan(5, TimeUnit.MINUTES)
.maxIdle(1, TimeUnit.MINUTES)
.build();
cacheManager = new DefaultCacheManager(globalConfiguration, defaultConfiguration, true);
log.info("initialised Infinispan local cache manager");
}
示例12: LDCachingInfinispanBackend
import org.infinispan.configuration.global.GlobalConfigurationBuilder; //导入依赖的package包/类
/**
* Create a non-clustered instance of the infinispan cache.
*/
public LDCachingInfinispanBackend() {
globalConfiguration = new GlobalConfigurationBuilder()
.classLoader(LDCachingInfinispanBackend.class.getClassLoader())
.globalJmxStatistics()
.jmxDomain("org.apache.marmotta.ldcache")
.allowDuplicateDomains(true)
.build();
defaultConfiguration = new ConfigurationBuilder()
.clustering()
.cacheMode(CacheMode.LOCAL)
.eviction()
.strategy(EvictionStrategy.LIRS)
.maxEntries(100000)
.expiration()
.lifespan(7, TimeUnit.DAYS)
.maxIdle(1, TimeUnit.DAYS)
.build();
clustered = false;
}
示例13: testConfigBuilder
import org.infinispan.configuration.global.GlobalConfigurationBuilder; //导入依赖的package包/类
public void testConfigBuilder() {
GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().globalJmxStatistics().transport().defaultTransport().build();
Configuration cacheConfig = new ConfigurationBuilder().persistence().addStore(LevelDBStoreConfigurationBuilder.class).location(tmpDataDirectory)
.expiredLocation(tmpExpiredDirectory).implementationType(LevelDBStoreConfiguration.ImplementationType.AUTO).build();
StoreConfiguration cacheLoaderConfig = cacheConfig.persistence().stores().get(0);
assertTrue(cacheLoaderConfig instanceof LevelDBStoreConfiguration);
LevelDBStoreConfiguration leveldbConfig = (LevelDBStoreConfiguration) cacheLoaderConfig;
assertEquals(tmpDataDirectory, leveldbConfig.location());
assertEquals(tmpExpiredDirectory, leveldbConfig.expiredLocation());
EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfig);
cacheManager.defineConfiguration("testCache", cacheConfig);
cacheManager.start();
Cache<String, String> cache = cacheManager.getCache("testCache");
cache.put("hello", "there");
cache.stop();
cacheManager.stop();
}
示例14: testLegacyJavaConfig
import org.infinispan.configuration.global.GlobalConfigurationBuilder; //导入依赖的package包/类
@Test(enabled = false, description = "ISPN-3388")
public void testLegacyJavaConfig() {
GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().globalJmxStatistics().transport().defaultTransport().build();
Configuration cacheConfig = new ConfigurationBuilder().persistence().addStore(LevelDBStoreConfigurationBuilder.class).addProperty("location", tmpDataDirectory)
.addProperty("expiredLocation", tmpExpiredDirectory).addProperty("implementationType", LevelDBStoreConfiguration.ImplementationType.AUTO.toString()).build();
EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfig);
cacheManager.defineConfiguration("testCache", cacheConfig);
cacheManager.start();
Cache<String, String> cache = cacheManager.getCache("testCache");
cache.put("hello", "there legacy java");
cache.stop();
cacheManager.stop();
}
示例15: testConfigBuilder
import org.infinispan.configuration.global.GlobalConfigurationBuilder; //导入依赖的package包/类
public void testConfigBuilder() {
GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().globalJmxStatistics().transport().defaultTransport().build();
Configuration cacheConfig = new ConfigurationBuilder().persistence().addStore(MapDBStoreConfigurationBuilder.class)
.location(tmpDirectory)
.compression(true)
.build();
StoreConfiguration cacheLoaderConfig = cacheConfig.persistence().stores().get(0);
assertTrue(cacheLoaderConfig instanceof MapDBStoreConfiguration);
MapDBStoreConfiguration config = (MapDBStoreConfiguration) cacheLoaderConfig;
assertEquals(true, config.compression());
EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfig);
cacheManager.defineConfiguration("testCache", cacheConfig);
cacheManager.start();
Cache<String, String> cache = cacheManager.getCache("testCache");
cache.put("hello", "there");
cache.stop();
cacheManager.stop();
}