当前位置: 首页>>代码示例>>Java>>正文


Java DefaultCacheManager类代码示例

本文整理汇总了Java中org.infinispan.manager.DefaultCacheManager的典型用法代码示例。如果您正苦于以下问题:Java DefaultCacheManager类的具体用法?Java DefaultCacheManager怎么用?Java DefaultCacheManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DefaultCacheManager类属于org.infinispan.manager包,在下文中一共展示了DefaultCacheManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createCacheManager

import org.infinispan.manager.DefaultCacheManager; //导入依赖的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());
}
 
开发者ID:snowdrop,项目名称:spring-data-snowdrop,代码行数:18,代码来源:InfinispanConfiguration.java

示例2: testClusterSize

import org.infinispan.manager.DefaultCacheManager; //导入依赖的package包/类
@Test
public void testClusterSize() {
    System.setProperty("grid.buffer", "10");

    RulesConfigurationTestImpl rulesConfigurationTest = RulesTestBuilder.buildV1();
    RulesManager rulesManager = new RulesManager(rulesConfigurationTest);
    rulesManager.start(null, null, null);

    LOGGER.info("Start test cluster size");
    Cache<Key, HAKieSession> cache1 = startNodes(2, rulesManager).getCache();
    Cache<Key, HAKieSession> cache2 = startNodes(2, rulesManager).getCache();

    assertEquals(2, ((DefaultCacheManager) cache1.getCacheManager()).getClusterSize());
    assertEquals(2, ((DefaultCacheManager) cache2.getCacheManager()).getClusterSize());
    LOGGER.info("End test cluster size");
    rulesManager.stop();
}
 
开发者ID:redhat-italy,项目名称:hacep,代码行数:18,代码来源:ClusterTest.java

示例3: clusteredCacheManager

import org.infinispan.manager.DefaultCacheManager; //导入依赖的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);
}
 
开发者ID:redhat-italy,项目名称:hacep,代码行数:23,代码来源:AbstractClusterTest.java

示例4: defaultClusteredCacheManager

import org.infinispan.manager.DefaultCacheManager; //导入依赖的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);
}
 
开发者ID:zanata,项目名称:zanata-mt,代码行数:23,代码来源:ResourceProducer.java

示例5: embeddedCacheWithFlagsTest

import org.infinispan.manager.DefaultCacheManager; //导入依赖的package包/类
@Test
public void embeddedCacheWithFlagsTest() throws Exception {
    InfinispanConfiguration configuration = new InfinispanConfiguration();
    configuration.setHost("localhost");
    configuration.setCacheName("misc_cache");
    configuration.setCacheContainer(new DefaultCacheManager(true));
    configuration.setFlags(
        org.infinispan.context.Flag.SKIP_CACHE_LOAD,
        org.infinispan.context.Flag.SKIP_CACHE_STORE
    );

    InfinispanManager manager = new InfinispanManager(configuration);
    manager.start();

    BasicCache<Object, Object> cache = manager.getCache();
    assertNotNull(cache);
    assertTrue(cache instanceof DecoratedCache);

    DecoratedCache<Object, Object> decoratedCache = (DecoratedCache<Object, Object>)cache;
    assertTrue(decoratedCache.getFlags().contains(org.infinispan.context.Flag.SKIP_CACHE_LOAD));
    assertTrue(decoratedCache.getFlags().contains(org.infinispan.context.Flag.SKIP_CACHE_STORE));

    manager.getCacheContainer().stop();
    manager.stop();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:InfinispanConfigurationTestIT.java

示例6: main

import org.infinispan.manager.DefaultCacheManager; //导入依赖的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();
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:25,代码来源:InfinispanQuery.java

示例7: main

import org.infinispan.manager.DefaultCacheManager; //导入依赖的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();
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:23,代码来源:InfinispanReplicated.java

示例8: main

import org.infinispan.manager.DefaultCacheManager; //导入依赖的package包/类
public static void main(String[] args) {
   // Construct a simple local cache manager with default configuration
   DefaultCacheManager cacheManager = new DefaultCacheManager();
   // Define local cache configuration
   cacheManager.defineConfiguration("local", new ConfigurationBuilder().build());
   // Obtain the local cache
   Cache<String, String> cache = cacheManager.getCache("local");
   // Store some values
   int range = 10;
   IntStream.range(0, range).boxed().forEach(i -> cache.put(i + "-key", i + "-value"));
   // Map and reduce the keys
   int result = cache.keySet().stream()
      .map((Serializable & Function<String, Integer>) e -> Integer.valueOf(e.substring(0, e.indexOf("-"))))
           .collect(CacheCollectors.serializableCollector(() -> Collectors.summingInt(i -> i.intValue())));
   System.out.printf("Result = %d\n", result);
   // Stop the cache manager and release all resources
   cacheManager.stop();
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:19,代码来源:InfinispanStreams.java

示例9: main

import org.infinispan.manager.DefaultCacheManager; //导入依赖的package包/类
public static void main(String[] args) {
   // Construct a simple local cache manager with default configuration
   DefaultCacheManager cacheManager = new DefaultCacheManager();
   // Define local cache configuration
   cacheManager.defineConfiguration("local", new ConfigurationBuilder().build());
   // Obtain the local cache
   Cache<String, String> cache = cacheManager.getCache("local");
   // Register a listener
   cache.addListener(new MyListener());
   // Store some values
   cache.put("key1", "value1");
   cache.put("key2", "value2");
   cache.put("key1", "newValue");
   // Stop the cache manager and release all resources
   cacheManager.stop();
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:17,代码来源:InfinispanListen.java

示例10: main

import org.infinispan.manager.DefaultCacheManager; //导入依赖的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);
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:26,代码来源:InfinispanDistExec.java

示例11: main

import org.infinispan.manager.DefaultCacheManager; //导入依赖的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();
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:23,代码来源:InfinispanDistributed.java

示例12: infinispanClusterService

import org.infinispan.manager.DefaultCacheManager; //导入依赖的package包/类
@Bean(destroyMethod = "stop")
public IInfinispanClusterService infinispanClusterService(IPropertyService propertyService, IRolesProvider rolesProvider,
		IActionFactory springActionFactory, IInfinispanClusterCheckerService infinispanClusterCheckerService,
		EntityManagerFactory entityManagerFactory) {
	if (propertyService.get(JpaMoreInfinispanPropertyIds.INFINISPAN_ENABLED)) {
		String nodeName = propertyService.get(JpaMoreInfinispanPropertyIds.INFINISPAN_NODE_NAME);
		Properties properties = new Properties();
		for (String key : propertyService.get(JpaMoreInfinispanPropertyIds.INFINISPAN_TRANSPORT_PROPERTIES)) {
			properties.put(key, propertyService.getAsString(JpaMoreInfinispanPropertyIds.transportProperty(key)));
		}
		GlobalConfiguration globalConfiguration =
				new GlobalDefaultReplicatedTransientConfigurationBuilder(properties).nodeName(nodeName).build();
		org.infinispan.configuration.cache.Configuration configuration =
				new DefaultReplicatedTransientConfigurationBuilder().build();
		EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfiguration, configuration, false);
		
		InfinispanClusterServiceImpl cluster =
				new InfinispanClusterServiceImpl(nodeName, cacheManager, rolesProvider, springActionFactory,
						infinispanClusterCheckerService);
		cluster.init();
		return cluster;
	} else {
		return null;
	}
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:26,代码来源:JpaMoreInfinispanConfig.java

示例13: MetadataManager

import org.infinispan.manager.DefaultCacheManager; //导入依赖的package包/类
public MetadataManager(DefaultCacheManager cacheManager){
   Configuration cacheConfiguration = cacheManager.getCacheConfiguration(Support.AVRO_METADATA_CACHE_NAME);
   if (cacheConfiguration == null) {
      ConfigurationBuilder cfg = new ConfigurationBuilder();
      CacheMode cacheMode =
            cacheManager.getDefaultCacheConfiguration().clustering().cacheMode().equals(CacheMode.LOCAL)
                  ? CacheMode.LOCAL : CacheMode.REPL_SYNC;
      cfg
            .transaction().lockingMode(LockingMode.PESSIMISTIC).syncCommitPhase(true).syncRollbackPhase(true)
            .persistence().addSingleFileStore().location(System.getProperty("java.io.tmpdir") + "/" + cacheManager.getNodeAddress()) // mandatory
            .locking().isolationLevel(IsolationLevel.READ_COMMITTED).useLockStriping(false)
            .clustering().cacheMode(cacheMode)
            .stateTransfer().fetchInMemoryState(true)
            .dataContainer().keyEquivalence(new ByteArrayEquivalence()); // for HotRod compatibility
      if (cacheMode.equals(CacheMode.REPL_SYNC)) cfg.clustering().stateTransfer().awaitInitialTransfer(true);
      cacheManager.defineConfiguration(Support.AVRO_METADATA_CACHE_NAME, cfg.build());
      this.cacheManager = cacheManager;
      this.marshaller= Externalizer.getInstance();
      this.knownSchemas = new ConcurrentHashMap<>();
      knownSchemas.put(Request.getClassSchema().getFullName(), Request.getClassSchema());
      knownSchemas.put(Response.getClassSchema().getFullName(), Response.getClassSchema());
   }
}
 
开发者ID:leads-project,项目名称:infinispan-avro,代码行数:24,代码来源:MetadataManager.java

示例14: init

import org.infinispan.manager.DefaultCacheManager; //导入依赖的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);


    }
 
开发者ID:sumanthn,项目名称:hashaggregator,代码行数:24,代码来源:CacheStore.java

示例15: start

import org.infinispan.manager.DefaultCacheManager; //导入依赖的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();
}
 
开发者ID:wildfly-security,项目名称:elytron-web,代码行数:20,代码来源:InfinispanSessionManager.java


注:本文中的org.infinispan.manager.DefaultCacheManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。