本文整理匯總了Java中org.infinispan.configuration.cache.ConfigurationBuilder.build方法的典型用法代碼示例。如果您正苦於以下問題:Java ConfigurationBuilder.build方法的具體用法?Java ConfigurationBuilder.build怎麽用?Java ConfigurationBuilder.build使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.infinispan.configuration.cache.ConfigurationBuilder
的用法示例。
在下文中一共展示了ConfigurationBuilder.build方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createCacheManager
import org.infinispan.configuration.cache.ConfigurationBuilder; //導入方法依賴的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.cache.ConfigurationBuilder; //導入方法依賴的package包/類
public static void main(String[] args) {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.indexing().index(Index.ALL)
.addProperty("default.directory_provider", "ram")
.addProperty("lucene_version", "LUCENE_CURRENT");
// Construct a simple local cache manager with default configuration
DefaultCacheManager cacheManager = new DefaultCacheManager(builder.build());
// Obtain the default cache
Cache<String, Person> cache = cacheManager.getCache();
// Store some entries
cache.put("person1", new Person("William", "Shakespeare"));
cache.put("person2", new Person("William", "Wordsworth"));
cache.put("person3", new Person("John", "Milton"));
// Obtain a query factory for the cache
QueryFactory queryFactory = Search.getQueryFactory(cache);
// Construct a query
Query query = queryFactory.from(Person.class).having("name").eq("William").toBuilder().build();
// Execute the query
List<Person> matches = query.list();
// List the results
matches.forEach(person -> System.out.printf("Match: %s", person));
// Stop the cache manager and release all resources
cacheManager.stop();
}
示例3: main
import org.infinispan.configuration.cache.ConfigurationBuilder; //導入方法依賴的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();
}
示例4: main
import org.infinispan.configuration.cache.ConfigurationBuilder; //導入方法依賴的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);
}
示例5: main
import org.infinispan.configuration.cache.ConfigurationBuilder; //導入方法依賴的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();
}
示例6: init
import org.infinispan.configuration.cache.ConfigurationBuilder; //導入方法依賴的package包/類
public synchronized void init() {
ConfigurationBuilder cfgBuilder = new ConfigurationBuilder();
//ALERT CHANGING CONF HERE
// cfgBuilder.persistence().passivation(true).addSingleFileStore().purgeOnStartup(true).location("/tmp/cachefiles/").create();
cfgBuilder.eviction().strategy(EvictionStrategy.LRU).maxEntries(10)
.persistence()
.passivation(false).addSingleFileStore()
.fetchPersistentState(true)
.ignoreModifications(false)
.purgeOnStartup(true).
location("/tmp/cachefiles/").
create();
//cfgBuilder.eviction().create();
Configuration configuration = cfgBuilder.build();
manager = new DefaultCacheManager(configuration);
manager.defineConfiguration("Cache1",configuration);
}
示例7: main
import org.infinispan.configuration.cache.ConfigurationBuilder; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException, InterruptedException {
//Configuration
ConfigurationBuilder builder = new ConfigurationBuilder();
builder
.eviction()
.strategy(EvictionStrategy.LRU)
.type(EvictionType.COUNT)
.size(3)
;
// Initialize the cache manager
DefaultCacheManager cacheManager = new DefaultCacheManager(builder.build());
// Obtain the default cache
Cache<Long, MoneyTransfert> cache = cacheManager.getCache("beosbank-dist");
// Obtain the remote cache
cache.addListener(new DatagridListener());
// Create a Money Transfer Object from XML Message using BeaoIO API
try {
BeosBankCacheUtils.loadEntries(cache,inputFileNames);
// Inspect the cache .
System.out.println(cache.size());
System.out.println(cache.get(3l));
//Current node content
cache.getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP)
.entrySet().forEach(entry -> System.out.printf("%s = %s\n", entry.getKey(), entry.getValue().getDescription()));
// Stop the cache
cache.stop();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例8: startCacheInfo
import org.infinispan.configuration.cache.ConfigurationBuilder; //導入方法依賴的package包/類
public void startCacheInfo(String nodeName) {
if (startedCacheInfo.compareAndSet(false, true)) {
GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder().clusteredDefault()
.transport().addProperty("configurationFile", System.getProperty("jgroups.configuration.info", "jgroups-tcp-info.xml"))
.clusterName("HACEPINFO").nodeName(nodeName+"INFO")
.globalJmxStatistics().allowDuplicateDomains(true).enable()
.serialization()
.build();
ConfigurationBuilder commonConfigurationBuilder = new ConfigurationBuilder();
commonConfigurationBuilder.clustering().cacheMode(CacheMode.REPL_SYNC);
Configuration commonConfiguration = commonConfigurationBuilder.build();
this.managerCacheInfo = new DefaultCacheManager(globalConfiguration, commonConfiguration, false);
ConfigurationBuilder replicatedInfos = new ConfigurationBuilder();
replicatedInfos.clustering().cacheMode(CacheMode.REPL_SYNC);
if (persistence()) {
replicatedInfos
.persistence()
.passivation(false)
.addSingleFileStore()
.shared(false)
.preload(true)
.fetchPersistentState(true)
.purgeOnStartup(false)
.location(location())
.async().threadPoolSize(threadPoolSize()).enabled(false)
.singleton().enabled(false);
}
this.managerCacheInfo.defineConfiguration(REPLICATED_CACHE_NAME, replicatedInfos.build());
this.managerCacheInfo.start();
}
}
示例9: main
import org.infinispan.configuration.cache.ConfigurationBuilder; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
// Define the default cache to be transactional
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.transaction().transactionMode(TransactionMode.TRANSACTIONAL);
// Construct a local cache manager using the configuration we have defined
DefaultCacheManager cacheManager = new DefaultCacheManager(builder.build());
// Obtain the default cache
Cache<String, String> cache = cacheManager.getCache();
// Obtain the transaction manager
TransactionManager transactionManager = cache.getAdvancedCache().getTransactionManager();
// Perform some operations within a transaction and commit it
transactionManager.begin();
cache.put("key1", "value1");
cache.put("key2", "value2");
transactionManager.commit();
// Display the current cache contents
System.out.printf("key1 = %s\nkey2 = %s\n", cache.get("key1"), cache.get("key2"));
// Perform some operations within a transaction and roll it back
transactionManager.begin();
cache.put("key1", "value3");
cache.put("key2", "value4");
transactionManager.rollback();
// Display the current cache contents
System.out.printf("key1 = %s\nkey2 = %s\n", cache.get("key1"), cache.get("key2"));
// Stop the cache manager and release all resources
cacheManager.stop();
}
示例10: main
import org.infinispan.configuration.cache.ConfigurationBuilder; //導入方法依賴的package包/類
public static void main(String[] args) throws UnknownHostException {
//Configure Infinispan to use default transport and Kubernetes configuration
GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().transport()
.defaultTransport()
.addProperty("configurationFile", "default-configs/default-jgroups-kubernetes.xml")
.build();
//Each node generates events, so we don't want to consume all memory available.
//Let's limit number of entries to 100 and use sync mode
ConfigurationBuilder cacheConfiguration = new ConfigurationBuilder();
cacheConfiguration.clustering().cacheMode(CacheMode.DIST_SYNC);
cacheConfiguration.eviction().strategy(EvictionStrategy.LRU).size(100);
DefaultCacheManager cacheManager = new DefaultCacheManager(globalConfig, cacheConfiguration.build());
Cache<String, String> cache = cacheManager.getCache();
cache.addListener(new MyListener());
//Each cluster member will update its own entry in the cache
String hostname = Inet4Address.getLocalHost().getHostName();
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
scheduler.scheduleAtFixedRate(() -> cache.put(hostname, Instant.now().toString()), 0, 2, TimeUnit.SECONDS);
try {
//This container will operate for an hour and then it will die
TimeUnit.HOURS.sleep(1);
} catch (InterruptedException e) {
scheduler.shutdown();
cacheManager.stop();
}
}
示例11: main
import org.infinispan.configuration.cache.ConfigurationBuilder; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException, InterruptedException {
//Configuration
ConfigurationBuilder builder = new ConfigurationBuilder();
builder
.expiration()
.maxIdle(3l, TimeUnit.SECONDS)
.lifespan(5l, TimeUnit.SECONDS);
// Initialize the cache manager
DefaultCacheManager cacheManager = new DefaultCacheManager(builder.build());
// Obtain the default cache
Cache<Long, MoneyTransfert> cache = cacheManager.getCache("beosbank-dist");
// Obtain the remote cache
cache.addListener(new DatagridListener());
// Create a Money Transfer Object from XML Message using BeaoIO API
try {
BeosBankCacheUtils.loadEntries(cache,inputFileNames);
// Inspect the cache .
System.out.println(cache.size());
Thread.sleep(2000);
cache.get(5l);
System.out.println("Cache content after 2 sec");
//Current node content
printCacheContent(cache);
Thread.sleep(1000);
System.out.println("Cache content after 3 sec");
printCacheContent(cache);
Thread.sleep(3000);
System.out.println("Cache content after 6 sec");
printCacheContent(cache);
// Stop the cache
cache.stop();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例12: start
import org.infinispan.configuration.cache.ConfigurationBuilder; //導入方法依賴的package包/類
public void start(HAKieSessionBuilder builder, String nodeName) {
if (started.compareAndSet(false, true)) {
GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder().clusteredDefault()
.transport().addProperty("configurationFile", System.getProperty("jgroups.configuration", "jgroups-tcp.xml"))
.clusterName("HACEP").nodeName(nodeName)
.globalJmxStatistics().allowDuplicateDomains(true).enable()
.serialization()
.addAdvancedExternalizer(new HAKieSession.HASessionExternalizer(builder))
.addAdvancedExternalizer(new HAKieSerializedSession.HASerializedSessionExternalizer(builder))
.addAdvancedExternalizer(new HAKieSessionDeltaEmpty.HASessionDeltaEmptyExternalizer(builder))
.addAdvancedExternalizer(new HAKieSessionDeltaFact.HASessionDeltaFactExternalizer())
.build();
ConfigurationBuilder commonConfigurationBuilder = new ConfigurationBuilder();
CacheMode cacheMode = getCacheMode();
if (cacheMode.isDistributed()) {
commonConfigurationBuilder
.clustering().cacheMode(cacheMode)
.hash().numOwners(getNumOwners())
.groups().enabled();
} else {
commonConfigurationBuilder.clustering().cacheMode(cacheMode);
}
Configuration commonConfiguration = commonConfigurationBuilder.build();
this.manager = new DefaultCacheManager(globalConfiguration, commonConfiguration, false);
ConfigurationBuilder factCacheConfigurationBuilder = new ConfigurationBuilder().read(commonConfiguration);
factCacheConfigurationBuilder
.expiration()
.maxIdle(factsExpiration(), TimeUnit.MILLISECONDS);
ConfigurationBuilder sessionCacheConfigurationBuilder = new ConfigurationBuilder().read(commonConfiguration);
if (persistence()) {
sessionCacheConfigurationBuilder
.persistence()
.passivation(isPassivated())
.addSingleFileStore()
.shared(shared())
.preload(preload())
.fetchPersistentState(fetchPersistentState())
.purgeOnStartup(purgeOnStartup())
.location(location())
.async().threadPoolSize(threadPoolSize()).enabled(false)
.singleton().enabled(false)
.eviction()
.strategy(EvictionStrategy.LRU).type(EvictionType.COUNT).size(evictionSize());
}
this.manager.defineConfiguration(FACT_CACHE_NAME, factCacheConfigurationBuilder.build());
this.manager.defineConfiguration(SESSION_CACHE_NAME, sessionCacheConfigurationBuilder.build());
this.manager.start();
}
}
示例13: init
import org.infinispan.configuration.cache.ConfigurationBuilder; //導入方法依賴的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");
}
示例14: init
import org.infinispan.configuration.cache.ConfigurationBuilder; //導入方法依賴的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");
}