當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。