當前位置: 首頁>>代碼示例>>Java>>正文


Java EmbeddedCacheManager.defineConfiguration方法代碼示例

本文整理匯總了Java中org.infinispan.manager.EmbeddedCacheManager.defineConfiguration方法的典型用法代碼示例。如果您正苦於以下問題:Java EmbeddedCacheManager.defineConfiguration方法的具體用法?Java EmbeddedCacheManager.defineConfiguration怎麽用?Java EmbeddedCacheManager.defineConfiguration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.infinispan.manager.EmbeddedCacheManager的用法示例。


在下文中一共展示了EmbeddedCacheManager.defineConfiguration方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initCacheInfinispan

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
/**
 * Inits the cache infinispan.
 */
private static void initCacheInfinispan() {
	EmbeddedCacheManager manager = new DefaultCacheManager();
	Configuration config = new Configuration().fluent()
	  .eviction()
	    .maxEntries((int)sCacheItemsLimit).strategy(EvictionStrategy.LRU)
	    /*.wakeUpInterval(5000L)*/ // TODO - fix it 
	  .expiration()
	    .maxIdle(120000L)
	    .build();

	manager.defineConfiguration("name", config);
	ispnCache = manager.getCache("name");


}
 
開發者ID:VladRodionov,項目名稱:bigbase,代碼行數:19,代碼來源:PerfTest.java

示例2: create

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
@Override
public BenchmarkCache<Integer, Integer> create(int _maxElements) {
  EmbeddedCacheManager m = getCacheMangaer();
  ConfigurationBuilder cb = new ConfigurationBuilder();

  cb.eviction().maxEntries(_maxElements);
  cb.storeAsBinary().disable();
  if (!withExpiry) {
    cb.expiration().disableReaper().lifespan(-1);
  } else {
    cb.expiration().lifespan(5 * 60, TimeUnit.SECONDS);
  }
  switch (algorithm) {
    case LRU: cb.eviction().strategy(EvictionStrategy.LRU); break;
    case LIRS: cb.eviction().strategy(EvictionStrategy.LIRS); break;
    case UNORDERED: cb.eviction().strategy(EvictionStrategy.UNORDERED); break;
  }
  m.defineConfiguration(CACHE_NAME, cb.build());
  Cache<Integer, Integer> _cache = m.getCache(CACHE_NAME);
  return new MyBenchmarkCache(_cache);
}
 
開發者ID:cache2k,項目名稱:cache2k-benchmark,代碼行數:22,代碼來源:InfinispanCacheFactory.java

示例3: testConfigBuilder

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
public void testConfigBuilder() {
   GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().globalJmxStatistics().transport().defaultTransport().build();

   Configuration cacheConfig = new ConfigurationBuilder().persistence().addStore(LevelDBStoreConfigurationBuilder.class).location(tmpDataDirectory)
         .expiredLocation(tmpExpiredDirectory).implementationType(LevelDBStoreConfiguration.ImplementationType.AUTO).build();

   StoreConfiguration cacheLoaderConfig = cacheConfig.persistence().stores().get(0);
   assertTrue(cacheLoaderConfig instanceof LevelDBStoreConfiguration);
   LevelDBStoreConfiguration leveldbConfig = (LevelDBStoreConfiguration) cacheLoaderConfig;
   assertEquals(tmpDataDirectory, leveldbConfig.location());
   assertEquals(tmpExpiredDirectory, leveldbConfig.expiredLocation());

   EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfig);

   cacheManager.defineConfiguration("testCache", cacheConfig);

   cacheManager.start();
   Cache<String, String> cache = cacheManager.getCache("testCache");

   cache.put("hello", "there");
   cache.stop();
   cacheManager.stop();
}
 
開發者ID:danberindei,項目名稱:infinispan-cachestore-leveldb,代碼行數:24,代碼來源:ConfigurationTest.java

示例4: testLegacyJavaConfig

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
@Test(enabled = false, description = "ISPN-3388")
public void testLegacyJavaConfig() {
   GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().globalJmxStatistics().transport().defaultTransport().build();

   Configuration cacheConfig = new ConfigurationBuilder().persistence().addStore(LevelDBStoreConfigurationBuilder.class).addProperty("location", tmpDataDirectory)
         .addProperty("expiredLocation", tmpExpiredDirectory).addProperty("implementationType", LevelDBStoreConfiguration.ImplementationType.AUTO.toString()).build();

   EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfig);

   cacheManager.defineConfiguration("testCache", cacheConfig);

   cacheManager.start();
   Cache<String, String> cache = cacheManager.getCache("testCache");

   cache.put("hello", "there legacy java");
   cache.stop();
   cacheManager.stop();
}
 
開發者ID:danberindei,項目名稱:infinispan-cachestore-leveldb,代碼行數:19,代碼來源:ConfigurationTest.java

示例5: testConfigBuilder

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
public void testConfigBuilder() {
   GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().globalJmxStatistics().transport().defaultTransport().build();

   Configuration cacheConfig = new ConfigurationBuilder().persistence().addStore(MapDBStoreConfigurationBuilder.class)
         .location(tmpDirectory)
         .compression(true)
         .build();

   StoreConfiguration cacheLoaderConfig = cacheConfig.persistence().stores().get(0);
   assertTrue(cacheLoaderConfig instanceof MapDBStoreConfiguration);
   MapDBStoreConfiguration config = (MapDBStoreConfiguration) cacheLoaderConfig;
   assertEquals(true, config.compression());
   
   EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfig);

   cacheManager.defineConfiguration("testCache", cacheConfig);

   cacheManager.start();
   Cache<String, String> cache = cacheManager.getCache("testCache");

   cache.put("hello", "there");
   cache.stop();
   cacheManager.stop();
}
 
開發者ID:saturnism,項目名稱:infinispan-cachestore-mapdb,代碼行數:25,代碼來源:ConfigurationTest.java

示例6: testConfigBuilder

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
public void testConfigBuilder() {
   GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().globalJmxStatistics().transport().defaultTransport().build();

   Configuration cacheConfig = new ConfigurationBuilder().persistence().addStore(OffheapStoreConfigurationBuilder.class)
         .compression(true)
         .build();

   StoreConfiguration cacheLoaderConfig = cacheConfig.persistence().stores().get(0);
   assertTrue(cacheLoaderConfig instanceof OffheapStoreConfiguration);
   OffheapStoreConfiguration config = (OffheapStoreConfiguration) cacheLoaderConfig;
   assertEquals(true, config.compression());
   
   EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfig);

   cacheManager.defineConfiguration("testCache", cacheConfig);

   cacheManager.start();
   Cache<String, String> cache = cacheManager.getCache("testCache");

   cache.put("hello", "there");
   cache.stop();
   cacheManager.stop();
}
 
開發者ID:saturnism,項目名稱:infinispan-cachestore-offheap,代碼行數:24,代碼來源:ConfigurationTest.java

示例7: getCache

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
public static synchronized Cache<String, String> getCache() {
	if (INSTANCE == null) {
		GlobalConfiguration gc = GlobalConfigurationBuilder.defaultClusteredBuilder()
				// Use this line for testing in Kubernetes. But it requires
				// additional configuration:
				// oc policy add-role-to-user view
				// system:serviceaccount:$(oc
				// project -q):default -n $(oc project -q)
				// And setting OPENSHIFT_KUBE_PING_NAMESPACE env variable to
				// your namespace
				.transport().defaultTransport()
				.addProperty("configurationFile", "default-configs/default-jgroups-kubernetes.xml")

				// Or use, multicast stack to simplify local testing:
				// .transport().defaultTransport().addProperty("configurationFile",
				// "default-configs/default-jgroups-udp.xml")
				.build();

		EmbeddedCacheManager manager = new DefaultCacheManager(gc);

		// And here are per-cache configuration, e.g. eviction, replication
		// scheme etc.
		ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
		configurationBuilder.clustering().cacheMode(CacheMode.REPL_ASYNC);
		manager.defineConfiguration("default", configurationBuilder.build());
		INSTANCE = manager.getCache("default");
	}
	return INSTANCE;
}
 
開發者ID:redhat-developer-demos,項目名稱:the-deploy-master,代碼行數:30,代碼來源:CacheInstance.java

示例8: infinispanCacheManager

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
@Bean(destroyMethod = "stop")
@ConditionalOnMissingBean
public EmbeddedCacheManager infinispanCacheManager() throws IOException {
	EmbeddedCacheManager cacheManager = createEmbeddedCacheManager();
	List<String> cacheNames = this.cacheProperties.getCacheNames();
	if (!CollectionUtils.isEmpty(cacheNames)) {
		for (String cacheName : cacheNames) {
			cacheManager.defineConfiguration(cacheName,
					getDefaultCacheConfiguration());
		}
	}
	return cacheManager;
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:14,代碼來源:InfinispanCacheConfiguration.java

示例9: createCache

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
@Override
public ConcurrentMap<?, ?> createCache(String containerName,
        String cacheName, Set<cacheMode> cMode) throws CacheExistException,
        CacheConfigException {
    EmbeddedCacheManager manager = this.cm;
    Cache<Object,Object> c;
    String realCacheName = "{" + containerName + "}_{" + cacheName + "}";
    if (manager == null) {
        return null;
    }

    if (manager.cacheExists(realCacheName)) {
        throw new CacheExistException();
    }

    // Sanity check to avoid contrasting parameters
    if (cMode.containsAll(EnumSet.of(
            IClusterServices.cacheMode.NON_TRANSACTIONAL,
            IClusterServices.cacheMode.TRANSACTIONAL))) {
        throw new CacheConfigException();
    }

    if (cMode.contains(IClusterServices.cacheMode.NON_TRANSACTIONAL)) {
        c = manager.getCache(realCacheName);
        return c;
    } else if (cMode.contains(IClusterServices.cacheMode.TRANSACTIONAL)) {
        Configuration rc = manager
                .getCacheConfiguration("transactional-type");
        manager.defineConfiguration(realCacheName, rc);
        c = manager.getCache(realCacheName);
        return c;
    }
    return null;
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:35,代碼來源:ClusterManager.java

示例10: cacheManager

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
static EmbeddedCacheManager cacheManager(String cacheName, Configuration configuration) {
    EmbeddedCacheManager manager = cacheManager();
    manager.defineConfiguration(cacheName, configuration);
    return manager;
}
 
開發者ID:kazuhira-r,項目名稱:spring-session-infinispan,代碼行數:6,代碼來源:EmbeddedCacheUtils.java

示例11: initCacheInfinispanKoda

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
/**
	 * Inits the cache infinispan.
	 *
	 * @throws NativeMemoryException the native memory exception
	 * @throws KodaException the koda exception
	 */
//	private static void initCacheInfinispanKoda() {
//		LOG.info("Initializing ISPN - Koda ...");
//		EmbeddedCacheManager manager = new DefaultCacheManager();
//		
//		KodaCacheStoreConfig cfg = new KodaCacheStoreConfig();
//		cfg.setBucketNumber(N);
//		cfg.setCacheNamespace("ns");
//		cfg.setEvictionPolicy("LRU");
//		cfg.setMaxMemory(sMemoryLimit);
//		cfg.setDefaultExpireTimeout(6000);
//		cfg.setKeyClass(ByteArrayWritable.class);
//		cfg.setValueClass(ByteArrayWritable.class);
//		
//		Configuration config = new Configuration().fluent()
//		  .eviction()
//		    .maxEntries(20).strategy(EvictionStrategy.LRU)
//		    .wakeUpInterval(5000L)
//		  .expiration()
//		    .maxIdle(120000L)
//		    .loaders()
//		    	.shared(false).passivation(false).preload(false)
//		    .addCacheLoader(
//		    		cfg
//		    )/*.locking().useLockStriping(true).concurrencyLevel(256)*/.build();
//
//		manager.defineConfiguration("name", config);
//		ispnCacheKoda  = manager.getCache("name");
//		List<CommandInterceptor> chain = ispnCacheKoda.getAdvancedCache().getInterceptorChain();
//		//ispnCacheKoda.getAdvancedCache().addInterceptor( new KodaInterceptor(), chain.size()-1);
//		mCache = getISPNOffHeapCache();
//
//	}

	private static void initCacheInfinispanKoda() throws NativeMemoryException, KodaException {
		LOG.info("Initializing ISPN - Koda ...");
		initCacheKoda();
		OffHeapDataContainer dc = new OffHeapDataContainer(mCache);		
		EmbeddedCacheManager manager = new DefaultCacheManager();						
		Configuration config = new Configuration().fluent().
									dataContainer().
										dataContainer(dc).			    
											build();

		manager.defineConfiguration("name", config);
		ispnCacheKoda  = manager.getCache("name");

//		org.infinispan.Cache<byte[], byte[]> cache = ispnCacheKoda;
		
LOG.info("Done");
	}
 
開發者ID:VladRodionov,項目名稱:bigbase,代碼行數:57,代碼來源:PerfTest.java

示例12: buildServer

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
private static HotRodServer buildServer(int port) {
    HotRodServer hotRodServer = new HotRodServer() {
        @Override
        public ConfigurationBuilder createTopologyCacheConfig(long distSyncTimeout) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
            }

            ConfigurationBuilder c = super.createTopologyCacheConfig(distSyncTimeout);
            c.transaction().syncCommitPhase(false).syncRollbackPhase(false);
            return c;
        }
    };

    HotRodServerConfiguration hotrodConfig = new HotRodServerConfigurationBuilder()
            .host("127.0.0.1")
            .port(port)
            .proxyHost("127.0.0.1")
            .proxyPort(port)
            .topologyStateTransfer(false)
            .defaultCacheName(BasicCacheContainer.DEFAULT_CACHE_NAME)
            .recvBufSize(4096)
            .sendBufSize(4096)
                    //.idleTimeout(0)
            .workerThreads(2)
            .build(true);


    GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder()
            .classLoader(InfinispanEmbeddedCacheManager.class.getClassLoader())
            .globalJmxStatistics()
            .jmxDomain("org.apache.marmotta.kiwi")
            .allowDuplicateDomains(true)
            .build();

    Configuration defaultConfiguration = new ConfigurationBuilder()
            .clustering()
            .cacheMode(CacheMode.LOCAL)
            .sync()
            .dataContainer()
            .keyEquivalence(ByteArrayEquivalence.INSTANCE)
            .valueEquivalence(ByteArrayEquivalence.INSTANCE)
            .build();

    EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfiguration, defaultConfiguration, true);
    cacheManager.defineConfiguration(CacheManager.NODE_CACHE, defaultConfiguration);
    cacheManager.defineConfiguration(CacheManager.TRIPLE_CACHE, defaultConfiguration);
    cacheManager.defineConfiguration(CacheManager.URI_CACHE, defaultConfiguration);
    cacheManager.defineConfiguration(CacheManager.BNODE_CACHE, defaultConfiguration);
    cacheManager.defineConfiguration(CacheManager.LITERAL_CACHE, defaultConfiguration);
    cacheManager.defineConfiguration(CacheManager.NS_PREFIX_CACHE, defaultConfiguration);
    cacheManager.defineConfiguration(CacheManager.NS_URI_CACHE, defaultConfiguration);
    cacheManager.defineConfiguration(CacheManager.REGISTRY_CACHE, defaultConfiguration);
    cacheManager.getCache(CacheManager.NODE_CACHE, true);
    cacheManager.getCache(CacheManager.TRIPLE_CACHE, true);
    cacheManager.getCache(CacheManager.URI_CACHE, true);
    cacheManager.getCache(CacheManager.BNODE_CACHE, true);
    cacheManager.getCache(CacheManager.LITERAL_CACHE, true);
    cacheManager.getCache(CacheManager.NS_PREFIX_CACHE, true);
    cacheManager.getCache(CacheManager.NS_URI_CACHE, true);
    cacheManager.getCache(CacheManager.REGISTRY_CACHE, true);

    hotRodServer.start(hotrodConfig, cacheManager);

    return hotRodServer;
}
 
開發者ID:apache,項目名稱:marmotta,代碼行數:68,代碼來源:HotRodServerRule.java


注:本文中的org.infinispan.manager.EmbeddedCacheManager.defineConfiguration方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。