本文整理汇总了Java中org.infinispan.configuration.global.GlobalConfigurationBuilder.build方法的典型用法代码示例。如果您正苦于以下问题:Java GlobalConfigurationBuilder.build方法的具体用法?Java GlobalConfigurationBuilder.build怎么用?Java GlobalConfigurationBuilder.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.infinispan.configuration.global.GlobalConfigurationBuilder
的用法示例。
在下文中一共展示了GlobalConfigurationBuilder.build方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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();
}
示例3: 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);
}
示例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 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();
}
示例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();
// Initialize the cache manager
DefaultCacheManager cacheManager = new DefaultCacheManager(global.build());
ClusterExecutor clusterExecutor = cacheManager.executor();
clusterExecutor.submitConsumer(cm -> new Random().nextInt(), (address, intValue, exception) ->
System.out.printf("%s\n", intValue));
// Shuts down the cache manager and all associated resources
cacheManager.stop();
}
示例6: initialize
import org.infinispan.configuration.global.GlobalConfigurationBuilder; //导入方法依赖的package包/类
public void initialize(Configuration config) {
GlobalConfigurationBuilder global = new GlobalConfigurationBuilder();
global.globalJmxStatistics().allowDuplicateDomains(true);
manager = new DefaultCacheManager(global.build());
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.persistence()
.addStore(SoftIndexFileStoreConfigurationBuilder.class)
.indexLocation(config.getDataDir()+"/index")
.dataLocation(config.getDataDir()+"/data");
manager.defineConfiguration("raccovery-cache", builder.build(global.build()));
cache = manager.getCache("raccovery-cache");
LOG.info("Starting persistence layer");
}
示例7: getManagerWithStandardConfig
import org.infinispan.configuration.global.GlobalConfigurationBuilder; //导入方法依赖的package包/类
/**
* Constructs an {@code EmbeddedCacheManager} using the default Infinispan
* GlobalConfiguration with one modification: duplicate JMX statistics
* domains are allowed.
*
* @return new cache manager
*/
private EmbeddedCacheManager getManagerWithStandardConfig() {
GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder();
gcb.globalJmxStatistics().allowDuplicateDomains(true);
gcb.serialization().addAdvancedExternalizer(new StaticBufferAE());
EmbeddedCacheManager m = new DefaultCacheManager(gcb.build());
log.info("Loaded ISPN cache manager using standard GlobalConfiguration");
log.debug("Standard global configuration: {}",
m.getGlobalComponentRegistry().getGlobalConfiguration());
return m;
}
示例8: init
import org.infinispan.configuration.global.GlobalConfigurationBuilder; //导入方法依赖的package包/类
@Override
public void init() {
//
// Configure and build the cache manager
//
GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder();
gcb.
transport().
defaultTransport().
clusterName(CLUSTER_NAME).
// the jgroups.xml file will be deployed within WEB-INF/classes
addProperty("configurationFile", "jgroups.xml").
globalJmxStatistics().
allowDuplicateDomains(true).
enable();
GlobalConfiguration gc = gcb.build();
this.cacheManager = new DefaultCacheManager(gc);
//
// Configure and build the cache
//
ConfigurationBuilder ccb = new ConfigurationBuilder();
ccb.
clustering().
cacheMode(CacheMode.DIST_SYNC);
Configuration cc = ccb.build();
cacheManager.defineConfiguration(CACHE_NAME, cc);
this.cache = cacheManager.getCache(CACHE_NAME);
log.info(this + " initialized");
}
示例9: init
import org.infinispan.configuration.global.GlobalConfigurationBuilder; //导入方法依赖的package包/类
@Override
public void init() {
//
// Configuration externalization
//
String jdgConfiguration = System.getProperty("playground.jdg.configuration");
log.info("configuring the cache from " + jdgConfiguration);
File jdgConfigurationFile = new File(jdgConfiguration);
if (!jdgConfigurationFile.isFile() || !jdgConfigurationFile.canRead()) {
throw new IllegalStateException(
"the cache configuration file " + jdgConfiguration +
" does not exist or is not readable - was the PoC correctly configured?");
}
//
// Configure and build the cache manager
//
GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder();
gcb.
transport().
defaultTransport().
clusterName(CLUSTER_NAME).
// the configuration file must be placed in $JBOSS_HOME/<profile>/configuration directory
addProperty("configurationFile", jdgConfiguration).
globalJmxStatistics().
allowDuplicateDomains(true).
enable();
GlobalConfiguration gc = gcb.build();
this.cacheManager = new DefaultCacheManager(gc);
//
// Configure and build the cache
//
ConfigurationBuilder ccb = new ConfigurationBuilder();
ccb.
clustering().
cacheMode(CacheMode.DIST_SYNC).
transaction().transactionMode(TransactionMode.TRANSACTIONAL).
transactionManagerLookup(new GenericTransactionManagerLookup()).
lockingMode(LockingMode.PESSIMISTIC).
useSynchronization(true);
Configuration cc = ccb.build();
cacheManager.defineConfiguration(CACHE_NAME, cc);
this.cache = cacheManager.getCache(CACHE_NAME);
log.info(this + " initialized");
}
示例10: 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();
// Create the counter configuration builder
CounterManagerConfigurationBuilder builder = global.addModule(CounterManagerConfigurationBuilder.class);
// Create 3 counters.
// The first counter is bounded to 10 (upper-bound).
builder.addStrongCounter().name("counter-1").upperBound(10).initialValue(1);
// The second counter is unbounded
builder.addStrongCounter().name("counter-2").initialValue(2);
// And finally, the third counter is a weak counter.
builder.addWeakCounter().name("counter-3").initialValue(3);
// Initialize the cache manager
DefaultCacheManager cacheManager = new DefaultCacheManager(global.build());
// Retrieve the CounterManager from the CacheManager. Each CacheManager has it own CounterManager
CounterManager counterManager = EmbeddedCounterManagerFactory.asCounterManager(cacheManager);
// StrongCounter provides the higher consistency. Its value is known during the increment/decrement and it may be bounded.
// Bounded counters are aimed for uses cases where a limit is needed.
StrongCounter counter1 = counterManager.getStrongCounter("counter-1");
// All methods returns a CompletableFuture. So you can do other work while the counter value is being computed.
counter1.getValue().thenAccept(value -> System.out.println("Counter-1 initial value is " + value)).get();
// Try to add more than the upper-bound
counter1.addAndGet(10).handle((value, throwable) -> {
// Value is null since the counter is bounded and we can add 10 to it.
System.out.println("Counter-1 Exception is " + throwable.getMessage());
return 0;
}).get();
// Check the counter value. It should be the upper-bound (10)
counter1.getValue().thenAccept(value -> System.out.println("Counter-1 value is " + value)).get();
//Decrement the value. Should be 9.
counter1.decrementAndGet().handle((value, throwable) -> {
// No exception this time.
System.out.println("Counter-1 new value is " + value);
return value;
}).get();
// Similar to counter-1, counter-2 is a strong counter but it is unbounded. It will never throw the CounterOutOfBoundsException
StrongCounter counter2 = counterManager.getStrongCounter("counter-2");
// All counters allow a listener to be registered.
// The handle can be used to remove the listener
counter2.addListener(event -> System.out
.println("Counter-2 event: oldValue=" + event.getOldValue() + " newValue=" + event.getNewValue()));
// Adding MAX_VALUE won't throws an exception. But the all the increments won't have any effect since we can store
//any value larger the MAX_VALUE
counter2.addAndGet(Long.MAX_VALUE).thenAccept(aLong -> System.out.println("Counter-2 value is " + aLong)).get();
// Conditional operations are allowed in strong counters
counter2.compareAndSet(Long.MAX_VALUE, 0)
.thenAccept(aBoolean -> System.out.println("Counter-2 CAS result is " + aBoolean)).get();
counter2.getValue().thenAccept(value -> System.out.println("Counter-2 value is " + value)).get();
// Reset the counter to its initial value (2)
counter2.reset().get();
counter2.getValue().thenAccept(value -> System.out.println("Counter-2 initial value is " + value)).get();
// Retrieve counter-3
WeakCounter counter3 = counterManager.getWeakCounter("counter-3");
// Weak counter doesn't have its value available during updates. This makes the increment faster than the StrongCounter
// Its value is computed lazily and stored locally.
// Its main use case is for uses-case where faster increments are needed.
counter3.add(5).thenAccept(aVoid -> System.out.println("Adding 5 to counter-3 completed!")).get();
// Check the counter value.
System.out.println("Counter-3 value is " + counter3.getValue());
// Stop the cache manager and release all resources
cacheManager.stop();
}