org.infinispan.configuration.global.GlobalConfiguration Java Examples
The following examples show how to use
org.infinispan.configuration.global.GlobalConfiguration.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GlobalConfigurerJmxDisabledConfiguration.java From infinispan-spring-boot with Apache License 2.0 | 5 votes |
@Bean public InfinispanGlobalConfigurer globalConfigurer() { return () -> { final GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder() .transport().clusterName(TEST_CLUSTER) .jmx().disable() .build(); return globalConfiguration; }; }
Example #2
Source File: ClusterManager.java From glowroot with Apache License 2.0 | 5 votes |
private ClusterManagerImpl(File confDir, String jgroupsConfigurationFile, Map<String, String> jgroupsProperties) { GlobalConfiguration configuration = new GlobalConfigurationBuilder() .transport() .defaultTransport() .addProperty("configurationFile", getConfigurationFilePropertyValue(confDir, jgroupsConfigurationFile)) .globalJmxStatistics() .enable() .build(); cacheManager = doWithSystemProperties(jgroupsProperties, () -> new DefaultCacheManager(configuration)); executor = MoreExecutors2.newCachedThreadPool("Cluster-Manager-Worker"); }
Example #3
Source File: InfinispanKubernetes.java From infinispan-simple-tutorials with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws UnknownHostException { //Configure Infinispan to use default transport and Kubernetes configuration GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().defaultCacheName("defaultCacheName") .transport() .defaultTransport() .addProperty("configurationFile", "default-configs/default-jgroups-kubernetes.xml") .build(); // We need a distributed cache for the purpose of this demo Configuration cacheConfiguration = new ConfigurationBuilder() .clustering() .cacheMode(CacheMode.REPL_SYNC) .build(); DefaultCacheManager cacheManager = new DefaultCacheManager(globalConfig, cacheConfiguration); cacheManager.defineConfiguration("default", cacheConfiguration); Cache<String, String> cache = cacheManager.getCache("default"); //Each cluster member will update its own entry in the cache String hostname = Inet4Address.getLocalHost().getHostName(); ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); scheduler.scheduleAtFixedRate(() -> { String time = Instant.now().toString(); cache.put(hostname, time); System.out.println("[" + time + "][" + hostname + "] Values from the cache: "); System.out.println(cache.entrySet()); }, 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(); } }
Example #4
Source File: InfinispanEmbeddedAutoConfigurationIntegrationConfigurerTest.java From infinispan-spring-boot with Apache License 2.0 | 5 votes |
@Test public void testWithGlobalConfigurer() { final GlobalConfiguration globalConfiguration = defaultCacheManager.getCacheManagerConfiguration(); assertThat(globalConfiguration.jmx().enabled()).isTrue(); assertThat(globalConfiguration.jmx().domain()).isEqualTo(JMX_TEST_DOMAIN); assertThat(globalConfiguration.transport().clusterName()).isEqualTo(InfinispanCacheTestConfiguration.TEST_CLUSTER); }
Example #5
Source File: InfinispanEmbeddedAutoConfigurationIntegrationTest.java From infinispan-spring-boot with Apache License 2.0 | 5 votes |
@Test public void testDefaultConfigurations() { assertThat(defaultCacheManager.getClusterName()).isEqualTo("default-autoconfigure"); assertThat(defaultCacheManager.getCacheNames()).containsExactly("default"); final Configuration defaultCacheConfiguration = defaultCacheManager.getDefaultCacheConfiguration(); assertThat(defaultCacheConfiguration).isNull(); final GlobalConfiguration globalConfiguration = defaultCacheManager.getCacheManagerConfiguration(); assertThat(globalConfiguration.jmx().enabled()).isTrue(); assertThat(globalConfiguration.jmx().domain()).isEqualTo("org.infinispan"); }
Example #6
Source File: InfinispanCacheTestConfiguration.java From infinispan-spring-boot with Apache License 2.0 | 5 votes |
@Bean public InfinispanGlobalConfigurer globalConfigurer() { return () -> { final GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder() .transport().clusterName(TEST_CLUSTER) .jmx().domain(TEST_GLOBAL_JMX_DOMAIN).enable() .build(); return globalConfiguration; }; }
Example #7
Source File: InfinispanEmbeddedAutoConfigurationPropertiesTest.java From infinispan-spring-boot with Apache License 2.0 | 5 votes |
@Test public void testCacheManagerXmlConfig() { assertThat(defaultCacheManager.getCacheNames()).isEqualTo(Collections.singleton("default-local")); final GlobalConfiguration globalConfiguration = defaultCacheManager.getCacheManagerConfiguration(); assertThat(globalConfiguration.globalJmxStatistics().enabled()).isTrue(); assertThat(globalConfiguration.globalJmxStatistics().domain()).isEqualTo("properties.test.spring.infinispan"); final Configuration defaultCacheConfiguration = defaultCacheManager.getDefaultCacheConfiguration(); assertThat(defaultCacheConfiguration.memory().size()).isEqualTo(2000L); }
Example #8
Source File: AbstractClusterTest.java From hacep with Apache License 2.0 | 5 votes |
private DefaultCacheManager clusteredCacheManager(CacheMode mode, int owners, RulesManager rulesManager, String nodeName, String globalStateLocation) { ExecutorService executorService = Executors.newFixedThreadPool(4); HAKieSessionBuilder sessionBuilder = new HAKieSessionBuilder(rulesManager, executorService); TransportConfigurationBuilder tcb = new GlobalConfigurationBuilder().clusteredDefault() .transport().addProperty("configurationFile", System.getProperty("jgroups.configuration", "jgroups-test-tcp.xml")) .clusterName("HACEP"); if(nodeName != null){ tcb.nodeName(nodeName); } GlobalJmxStatisticsConfigurationBuilder gjscb = tcb.globalJmxStatistics().allowDuplicateDomains(true).enable(); GlobalStateConfigurationBuilder gscb; if(globalStateLocation!=null){ gscb = gjscb.globalState().enable().persistentLocation(globalStateLocation); } else { gscb = gjscb.globalState().disable(); } GlobalConfiguration glob = gscb.serialization() .addAdvancedExternalizer(new HAKieSession.HASessionExternalizer(sessionBuilder)) .addAdvancedExternalizer(new HAKieSerializedSession.HASerializedSessionExternalizer(sessionBuilder)) .addAdvancedExternalizer(new HAKieSessionDeltaEmpty.HASessionDeltaEmptyExternalizer(sessionBuilder)) .addAdvancedExternalizer(new HAKieSessionDeltaFact.HASessionDeltaFactExternalizer(sessionBuilder)) .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); }
Example #9
Source File: DataGridManager.java From hacep with Apache License 2.0 | 5 votes |
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(); } }
Example #10
Source File: DataGridManager.java From hacep with Apache License 2.0 | 4 votes |
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(builder)) .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(); } }
Example #11
Source File: SubstituteDefaultCacheManager.java From camel-quarkus with Apache License 2.0 | 4 votes |
@Substitute public SubstituteDefaultCacheManager(GlobalConfiguration globalConfiguration) { throw new RuntimeException("DefaultCacheManager not supported in native image mode"); }
Example #12
Source File: SubstituteTransactionClasses.java From quarkus with Apache License 2.0 | 4 votes |
@Substitute public void init(GlobalConfiguration globalCfg) { }
Example #13
Source File: SubstituteDefaultCacheManager.java From camel-quarkus with Apache License 2.0 | 4 votes |
@Substitute public SubstituteDefaultCacheManager(GlobalConfiguration globalConfiguration, Configuration defaultConfiguration, boolean start) { throw new RuntimeException("DefaultCacheManager not supported in native image mode"); }
Example #14
Source File: InvalidationMode.java From infinispan-simple-tutorials with Apache License 2.0 | 4 votes |
public static void main(String[] args) { // Create a clustered configuration and a default cache named test GlobalConfiguration global = GlobalConfigurationBuilder.defaultClusteredBuilder().build(); // Create the cache manager DefaultCacheManager cacheManager = new DefaultCacheManager(global); // Clustered mode invalidation sync. Can also be async Configuration config = new ConfigurationBuilder() .clustering().cacheMode(CacheMode.INVALIDATION_SYNC) .build(); // Define a cache configuration cacheManager.defineConfiguration("test", config); // Retrieve the cache Cache<String, String> cache = cacheManager.getCache("test"); Scanner scanner = new Scanner(System.in); String next = ""; // Enter 'q' option to exit while (!next.equals("q")) { System.out.println( "Invalidation mode simple tutorial\n" + "=================================\n" + "`p` to put a key/value \n" + "`pe` to put a key/value for external read \n" + "`r` to remove a key \n" + "`g` to get a key \n" + "`q` to exit \n"); System.out.println("Enter an option: "); next = scanner.next(); switch (next) { case "p": putKeyValue(scanner, cache); break; case "pe": putForExternalReadKeyValue(scanner, cache); break; case "r": removeKey(scanner, cache); break; case "g": getKey(scanner, cache); break; default: } } // Goodbye! System.out.println("Good bye"); // Stop the cache manager cacheManager.stop(); }
Example #15
Source File: SubstituteDefaultCacheManager.java From camel-quarkus with Apache License 2.0 | 4 votes |
@Substitute public SubstituteDefaultCacheManager(GlobalConfiguration globalConfiguration, Configuration defaultConfiguration) { throw new RuntimeException("DefaultCacheManager not supported in native image mode"); }
Example #16
Source File: InfinispanServerClusterConfiguration.java From spring-batch-lightmin with Apache License 2.0 | 4 votes |
@Bean(name = INFINISPAN_DEFAULT_CACHE_MANAGER_NAME) @ConditionalOnMissingBean(SpringEmbeddedCacheManager.class) public SpringEmbeddedCacheManager infinispanCacheManager(final GlobalConfiguration globalConfiguration) { final EmbeddedCacheManager manager = new DefaultCacheManager(globalConfiguration); return new SpringEmbeddedCacheManager(manager); }
Example #17
Source File: InfinispanITConfiguration.java From spring-batch-lightmin with Apache License 2.0 | 4 votes |
@Bean public GlobalConfiguration globalConfiguration() { return new GlobalConfigurationBuilder() .clusteredDefault() .build(); }
Example #18
Source File: InfinispanTest.java From bucket4j with Apache License 2.0 | 4 votes |
private static GlobalConfiguration getGlobalConfiguration() { GlobalConfigurationBuilder globalConfigurationBuilder = GlobalConfigurationBuilder.defaultClusteredBuilder(); globalConfigurationBuilder.serialization().addContextInitializer(new Bucket4jProtobufContextInitializer()); return globalConfigurationBuilder.build(); }
Example #19
Source File: SubstituteDefaultCacheManager.java From camel-quarkus with Apache License 2.0 | 4 votes |
@Substitute public SubstituteDefaultCacheManager(GlobalConfiguration globalConfiguration, boolean start) { throw new RuntimeException("DefaultCacheManager not supported in native image mode"); }
Example #20
Source File: InfinispanDataSourceConnectionFactoryConfigurationBuilder.java From wallride with Apache License 2.0 | 2 votes |
@Override public void validate(GlobalConfiguration globalConfiguration) { }
Example #21
Source File: InfinispanGlobalConfigurer.java From infinispan-spring-boot with Apache License 2.0 | votes |
GlobalConfiguration getGlobalConfiguration();