本文整理汇总了Java中org.infinispan.eviction.EvictionType类的典型用法代码示例。如果您正苦于以下问题:Java EvictionType类的具体用法?Java EvictionType怎么用?Java EvictionType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EvictionType类属于org.infinispan.eviction包,在下文中一共展示了EvictionType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extendDefaultConfiguration
import org.infinispan.eviction.EvictionType; //导入依赖的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;
}
示例2: defaultClusteredCacheManager
import org.infinispan.eviction.EvictionType; //导入依赖的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);
}
示例3: main
import org.infinispan.eviction.EvictionType; //导入依赖的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();
}
}
示例4: initInfinispan
import org.infinispan.eviction.EvictionType; //导入依赖的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));
}
}
示例5: before
import org.infinispan.eviction.EvictionType; //导入依赖的package包/类
@Override
protected void before() throws Throwable {
EmbeddedCacheManager manager = new DefaultCacheManager(
new GlobalConfigurationBuilder().nonClusteredDefault().build(),
new ConfigurationBuilder()
.memory().evictionType(EvictionType.COUNT).size(100)
.build()
);
caches = manager;
}
示例6: testConfiguration
import org.infinispan.eviction.EvictionType; //导入依赖的package包/类
@Test
public void testConfiguration() {
assertThat(manager.getCacheNames()).contains("base-cache", "small-cache", "large-cache");
assertThat(manager.getCacheConfiguration("base-cache").memory().size()).isEqualTo(500L);
assertThat(manager.getCacheConfiguration("base-cache").memory().evictionType()).isEqualTo(EvictionType.COUNT);
assertThat(manager.getCacheConfiguration("small-cache").memory().size()).isEqualTo(1000L);
assertThat(manager.getCacheConfiguration("small-cache").memory().evictionType()).isEqualTo(EvictionType.MEMORY);
assertThat(manager.getCacheConfiguration("large-cache").memory().size()).isEqualTo(2000L);
assertThat(manager.getCacheConfiguration("large-cache").memory().evictionType()).isEqualTo(EvictionType.COUNT);
}
开发者ID:infinispan,项目名称:infinispan-spring-boot,代码行数:11,代码来源:InfinispanEmbeddedAutoConfigurationIntegrationConfigurationTest.java
示例7: smallCache
import org.infinispan.eviction.EvictionType; //导入依赖的package包/类
@Bean(name = "base-cache")
public org.infinispan.configuration.cache.Configuration smallCache() {
return new ConfigurationBuilder()
.simpleCache(true)
.memory().size(500L)
.memory().evictionType(EvictionType.COUNT)
.build();
}
开发者ID:infinispan,项目名称:infinispan-spring-boot,代码行数:9,代码来源:InfinispanCacheConfigurationBaseTestConfiguration.java
示例8: smallCache
import org.infinispan.eviction.EvictionType; //导入依赖的package包/类
@Bean(name = "small-cache")
public org.infinispan.configuration.cache.Configuration smallCache() {
return new ConfigurationBuilder()
.read(baseCache)
.memory().size(1000L)
.memory().evictionType(EvictionType.MEMORY)
.build();
}
开发者ID:infinispan,项目名称:infinispan-spring-boot,代码行数:9,代码来源:InfinispanCacheConfigurationTestConfiguration.java
示例9: testConfiguration
import org.infinispan.eviction.EvictionType; //导入依赖的package包/类
@Test
public void testConfiguration() {
assertThat(manager.getCacheManagerConfiguration().transport().clusterName()).isEqualTo(CLUSTER_NAME);
assertThat(manager.getDefaultCacheConfiguration().memory().evictionType()).isEqualTo(EvictionType.COUNT);
assertThat(manager.getCacheNames()).contains("small-cache");
assertThat(manager.getCacheConfiguration("small-cache").memory().size()).isEqualTo(1000L);
assertThat(manager.getCacheConfiguration("small-cache").memory().evictionType()).isEqualTo(EvictionType.MEMORY);
}
开发者ID:infinispan,项目名称:infinispan-spring-boot,代码行数:10,代码来源:InfinispanEmbeddedAutoConfigurationCustomizerIntegrationTest.java
示例10: smallCache
import org.infinispan.eviction.EvictionType; //导入依赖的package包/类
@Bean(name = "small-cache")
public org.infinispan.configuration.cache.Configuration smallCache() {
return new ConfigurationBuilder()
.simpleCache(true)
.memory().size(1000L)
.memory().evictionType(EvictionType.MEMORY)
.build();
}
开发者ID:infinispan,项目名称:infinispan-spring-boot,代码行数:9,代码来源:InfinispanEmbeddedAutoConfigurationCustomizerIntegrationTest.java
示例11: configureCacheStore
import org.infinispan.eviction.EvictionType; //导入依赖的package包/类
private void configureCacheStore(ConfigurationBuilder configurationBuilder) {
configurationBuilder
.persistence()
.passivation(isPassivated())
.addSingleFileStore()
.shared(false)
.location(location())
.eviction()
.strategy(EvictionStrategy.LRU).type(EvictionType.COUNT).size(evictionSize())
.build();
}
示例12: createCacheConfiguration
import org.infinispan.eviction.EvictionType; //导入依赖的package包/类
protected Configuration createCacheConfiguration(int cacheCount, int lifespanSeconds) {
return new ConfigurationBuilder()
.eviction().type(EvictionType.COUNT).size(cacheCount).
eviction().expiration().lifespan(lifespanSeconds, TimeUnit.SECONDS)
.build();
}
示例13: start
import org.infinispan.eviction.EvictionType; //导入依赖的package包/类
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())
.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();
}
}
示例14: configurationCustomizer
import org.infinispan.eviction.EvictionType; //导入依赖的package包/类
@Bean
public InfinispanConfigurationCustomizer configurationCustomizer() {
return builder -> {
builder.memory().evictionType(EvictionType.COUNT);
};
}
开发者ID:infinispan,项目名称:infinispan-spring-boot,代码行数:7,代码来源:InfinispanEmbeddedAutoConfigurationCustomizerIntegrationTest.java
示例15: cacheConfigurer
import org.infinispan.eviction.EvictionType; //导入依赖的package包/类
/**
* Initialize cache configuration for Hibernate L2 cache and Spring Cache.
* <p>
* There are three different modes: local, distributed and replicated, and L2 cache options are pre-configured.
*
* <p>
* It supports both jCache and Spring cache abstractions.
* <p>
* Usage:
* <ol>
* <li>
* jCache:
* <pre class="code">@CacheResult(cacheName="dist-app-data") </pre>
* - for creating a distributed cache. In a similar way other cache names and options can be used
* </li>
* <li>
* Spring Cache:
* <pre class="code">@Cacheable(value = "repl-app-data") </pre>
* - for creating a replicated cache. In a similar way other cache names and options can be used
* </li>
* <li>
* Cache manager can also be injected through DI/CDI and data can be manipulated using Infinispan APIs,
* <pre class="code">
* @Autowired (or) @Inject
* private EmbeddedCacheManager cacheManager;
*
* void cacheSample(){
* cacheManager.getCache("dist-app-data").put("hi", "there");
* }
* </pre>
* </li>
* </ol>
*
*/
@Bean
public InfinispanCacheConfigurer cacheConfigurer(JHipsterProperties jHipsterProperties) {
log.info("Defining {} configuration", "app-data for local, replicated and distributed modes");
final JHipsterProperties.Cache.Infinispan cacheInfo = jHipsterProperties.getCache().getInfinispan();
return manager -> {
// initialize application cache
manager.defineConfiguration("local-app-data", new ConfigurationBuilder().clustering().cacheMode(CacheMode.LOCAL)
.jmxStatistics().enabled(cacheInfo.isStatsEnabled())
.eviction().type(EvictionType.COUNT).size(cacheInfo.getLocal().getMaxEntries()).expiration()
.lifespan(cacheInfo.getLocal().getTimeToLiveSeconds(), TimeUnit.MINUTES).build());
manager.defineConfiguration("dist-app-data", new ConfigurationBuilder()
.clustering().cacheMode(CacheMode.DIST_SYNC).hash().numOwners(cacheInfo.getDistributed().getInstanceCount())
.jmxStatistics().enabled(cacheInfo.isStatsEnabled()).eviction()
.type(EvictionType.COUNT).size(cacheInfo.getDistributed().getMaxEntries()).expiration().lifespan(cacheInfo.getDistributed()
.getTimeToLiveSeconds(), TimeUnit.MINUTES).build());
manager.defineConfiguration("repl-app-data", new ConfigurationBuilder().clustering().cacheMode(CacheMode.REPL_SYNC)
.jmxStatistics().enabled(cacheInfo.isStatsEnabled())
.eviction().type(EvictionType.COUNT).size(cacheInfo.getReplicated()
.getMaxEntries()).expiration().lifespan(cacheInfo.getReplicated().getTimeToLiveSeconds(), TimeUnit.MINUTES).build());
// initialize Hibernate L2 cache
manager.defineConfiguration("entity", new ConfigurationBuilder().clustering().cacheMode(CacheMode.INVALIDATION_SYNC)
.jmxStatistics().enabled(cacheInfo.isStatsEnabled())
.locking().concurrencyLevel(1000).lockAcquisitionTimeout(15000).build());
manager.defineConfiguration("replicated-entity", new ConfigurationBuilder().clustering().cacheMode(CacheMode.REPL_SYNC)
.jmxStatistics().enabled(cacheInfo.isStatsEnabled())
.locking().concurrencyLevel(1000).lockAcquisitionTimeout(15000).build());
manager.defineConfiguration("local-query", new ConfigurationBuilder().clustering().cacheMode(CacheMode.LOCAL)
.jmxStatistics().enabled(cacheInfo.isStatsEnabled())
.locking().concurrencyLevel(1000).lockAcquisitionTimeout(15000).build());
manager.defineConfiguration("replicated-query", new ConfigurationBuilder().clustering().cacheMode(CacheMode.REPL_ASYNC)
.jmxStatistics().enabled(cacheInfo.isStatsEnabled())
.locking().concurrencyLevel(1000).lockAcquisitionTimeout(15000).build());
manager.defineConfiguration("timestamps", new ConfigurationBuilder().clustering().cacheMode(CacheMode.REPL_ASYNC)
.jmxStatistics().enabled(cacheInfo.isStatsEnabled())
.locking().concurrencyLevel(1000).lockAcquisitionTimeout(15000).build());
manager.defineConfiguration("pending-puts", new ConfigurationBuilder().clustering().cacheMode(CacheMode.LOCAL)
.jmxStatistics().enabled(cacheInfo.isStatsEnabled())
.simpleCache(true).transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL).expiration().maxIdle(60000).build());
setCacheManager(manager);
};
}