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


Java EvictionStrategy类代码示例

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


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

示例1: extendDefaultConfiguration

import org.infinispan.eviction.EvictionStrategy; //导入依赖的package包/类
@Override
    public ConfigurationBuilder extendDefaultConfiguration(ConfigurationBuilder builder) {
        builder
                .persistence()
                .passivation(false)
                .addSingleFileStore()
                .shared(false)
                .preload(true)
                .fetchPersistentState(true)
                .purgeOnStartup(false)
                .location(passivationLocation)
//                .async().enabled(true)
//                .threadPoolSize(5)
                .singleton().enabled(false)
                .eviction()
                .strategy(EvictionStrategy.LRU).type(EvictionType.COUNT).size(1024);
        return builder;
    }
 
开发者ID:redhat-italy,项目名称:hacep,代码行数:19,代码来源:TestPassivation.java

示例2: defaultClusteredCacheManager

import org.infinispan.eviction.EvictionStrategy; //导入依赖的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

示例3: init

import org.infinispan.eviction.EvictionStrategy; //导入依赖的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

示例4: createContainerForLucene

import org.infinispan.eviction.EvictionStrategy; //导入依赖的package包/类
public static DefaultCacheManager createContainerForLucene()
		throws Exception {

    GlobalConfiguration glob = new GlobalConfigurationBuilder()
    .nonClusteredDefault() //Helper method that gets you a default constructed GlobalConfiguration, preconfigured for use in LOCAL mode
    .globalJmxStatistics().enable() //This method allows enables the jmx statistics of the global configuration.
   .jmxDomain("org.infinispan.trades.annotated." + ++cnt)  //prevent collision with non-transactional carmart
    .build(); //Builds  the GlobalConfiguration object
    Configuration loc = new ConfigurationBuilder()
	.indexing().enable().addProperty("hibernate.search.default.directory_provider", "filesystem").addProperty("hibernate.search.default.indexBase", "./target/lucene/indexes " + cnt)
    .clustering().cacheMode(CacheMode.LOCAL) //Set Cache mode to LOCAL - Data is not replicated.
    .transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL)
    .eviction().maxEntries(100).strategy(EvictionStrategy.LIRS) //Sets  4 as maximum number of entries in a cache instance and uses the LIRS strategy - an efficient low inter-reference recency set replacement policy to improve buffer cache performance
    .persistence().passivation(false).addSingleFileStore().purgeOnStartup(true).location("./target/localcache/indexing/trades" + cnt) //Disable passivation and adds a SingleFileStore that is purged on Startup
    .build(); //Builds the Configuration object
	DefaultCacheManager container = new DefaultCacheManager(glob, loc, true);

	return container;
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:20,代码来源:TestInfinispanConnection.java

示例5: initCacheInfinispan

import org.infinispan.eviction.EvictionStrategy; //导入依赖的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

示例6: buildLocalConfiguration

import org.infinispan.eviction.EvictionStrategy; //导入依赖的package包/类
/**
 * Build a local cache configuration.
 * <p/>
 * In local cache mode, the cache is not shared among the servers in a cluster. Each machine keeps a local cache.
 * This allows quick startups and eliminates network traffic in the cluster, but subsequent requests to different
 * cluster members cannot benefit from the cached data.
 */
protected void buildLocalConfiguration() {
    GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder()
            .classLoader(InfinispanEmbeddedCacheManager.class.getClassLoader())
            .globalJmxStatistics()
                .jmxDomain("org.apache.marmotta.kiwi")
                .allowDuplicateDomains(true)
            .build();

    defaultConfiguration = new ConfigurationBuilder()
            .clustering()
                .cacheMode(CacheMode.LOCAL)
            .eviction()
                .strategy(EvictionStrategy.LIRS)
                .maxEntries(100000)
            .expiration()
                .lifespan(5, TimeUnit.MINUTES)
                .maxIdle(1, TimeUnit.MINUTES)
            .build();
    cacheManager = new DefaultCacheManager(globalConfiguration, defaultConfiguration, true);

    log.info("initialised Infinispan local cache manager");
}
 
开发者ID:apache,项目名称:marmotta,代码行数:30,代码来源:InfinispanEmbeddedCacheManager.java

示例7: LDCachingInfinispanBackend

import org.infinispan.eviction.EvictionStrategy; //导入依赖的package包/类
/**
 * Create a non-clustered instance of the infinispan cache.
 */
public LDCachingInfinispanBackend() {
    globalConfiguration = new GlobalConfigurationBuilder()
            .classLoader(LDCachingInfinispanBackend.class.getClassLoader())
            .globalJmxStatistics()
                .jmxDomain("org.apache.marmotta.ldcache")
                .allowDuplicateDomains(true)
            .build();

    defaultConfiguration = new ConfigurationBuilder()
            .clustering()
                .cacheMode(CacheMode.LOCAL)
            .eviction()
                .strategy(EvictionStrategy.LIRS)
                .maxEntries(100000)
            .expiration()
                .lifespan(7, TimeUnit.DAYS)
                .maxIdle(1, TimeUnit.DAYS)
            .build();

    clustered = false;

}
 
开发者ID:apache,项目名称:marmotta,代码行数:26,代码来源:LDCachingInfinispanBackend.java

示例8: create

import org.infinispan.eviction.EvictionStrategy; //导入依赖的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

示例9: cacheManager

import org.infinispan.eviction.EvictionStrategy; //导入依赖的package包/类
@Override
@Bean
public CacheManager cacheManager() {

	return new SpringEmbeddedCacheManager(
			new DefaultCacheManager(
				new ConfigurationBuilder()
					.eviction()
						.maxEntries(20000)
						.strategy(EvictionStrategy.LIRS)
					.expiration()
						.wakeUpInterval(5000L)
						.maxIdle(120000L)
		           .build()
				)
			);
}
 
开发者ID:hantsy,项目名称:spring4-sandbox,代码行数:18,代码来源:InfinispanEmbeddedCacheConfig.java

示例10: main

import org.infinispan.eviction.EvictionStrategy; //导入依赖的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();
	}

}
 
开发者ID:PacktPublishing,项目名称:JBoss-Developers-Guide,代码行数:39,代码来源:EvictionDemo.java

示例11: initInfinispan

import org.infinispan.eviction.EvictionStrategy; //导入依赖的package包/类
protected void initInfinispan() {
	long startTime = System.nanoTime();
	if (this.cacheManager == null) {
		Configuration defaultConfiguration = new ConfigurationBuilder().simpleCache(true).eviction()
				.strategy(EvictionStrategy.LRU).type(EvictionType.COUNT).size(1000l).expiration()
				.lifespan(60, TimeUnit.MINUTES).maxIdle(30, TimeUnit.MINUTES).build();
		this.cacheManager = new DefaultCacheManager(defaultConfiguration);
		LOGGER.info("Infinispan initialization took: [{}] ms!!", TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime));
	}
}
 
开发者ID:AdeptJ,项目名称:adeptj-modules,代码行数:11,代码来源:InfinispanCacheProvider.java

示例12: testCacheManagerXmlConfig

import org.infinispan.eviction.EvictionStrategy; //导入依赖的package包/类
@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.eviction().maxEntries()).isEqualTo(2000L);
    assertThat(defaultCacheConfiguration.eviction().strategy()).isEqualTo(EvictionStrategy.LIRS);
    assertThat(defaultCacheConfiguration.eviction().threadPolicy()).isEqualTo(EvictionThreadPolicy.PIGGYBACK);
    assertThat(defaultCacheConfiguration.storeAsBinary().storeKeysAsBinary()).isTrue();
    assertThat(defaultCacheConfiguration.storeAsBinary().storeValuesAsBinary()).isTrue();
}
 
开发者ID:infinispan,项目名称:infinispan-spring-boot,代码行数:16,代码来源:InfinispanEmbeddedAutoConfigurationPropertiesTest.java

示例13: cacheConfigurer

import org.infinispan.eviction.EvictionStrategy; //导入依赖的package包/类
@Bean
public InfinispanCacheConfigurer cacheConfigurer() {
    return cacheManager -> {
        final org.infinispan.configuration.cache.Configuration testCache =
                new ConfigurationBuilder().simpleCache(true)
                                          .eviction().size(1000L).strategy(EvictionStrategy.LRU)
                                          .jmxStatistics().enable()
                                          .build();

        cacheManager.defineConfiguration(TEST_CACHE_NAME, testCache);
    };
}
 
开发者ID:infinispan,项目名称:infinispan-spring-boot,代码行数:13,代码来源:InfinispanCacheTestConfiguration.java

示例14: testWithCacheConfigurer

import org.infinispan.eviction.EvictionStrategy; //导入依赖的package包/类
@Test
public void testWithCacheConfigurer() {
   assertThat(defaultCacheManager.getCacheNames()).isEqualTo(
         Collections.singleton(InfinispanCacheTestConfiguration.TEST_CACHE_NAME));

   final Configuration testCacheConfiguration = defaultCacheManager.getCacheConfiguration(InfinispanCacheTestConfiguration.TEST_CACHE_NAME);
   assertThat(testCacheConfiguration.jmxStatistics().enabled()).isTrue();
   assertThat(testCacheConfiguration.eviction().size()).isEqualTo(1000L);
   assertThat(testCacheConfiguration.eviction().strategy()).isEqualTo(EvictionStrategy.LRU);
}
 
开发者ID:infinispan,项目名称:infinispan-spring-boot,代码行数:11,代码来源:InfinispanEmbeddedAutoConfigurationIntegrationConfigurerTest.java

示例15: main

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


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