本文整理汇总了Java中com.hazelcast.config.EvictionPolicy类的典型用法代码示例。如果您正苦于以下问题:Java EvictionPolicy类的具体用法?Java EvictionPolicy怎么用?Java EvictionPolicy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EvictionPolicy类属于com.hazelcast.config包,在下文中一共展示了EvictionPolicy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeDefaultMapConfig
import com.hazelcast.config.EvictionPolicy; //导入依赖的package包/类
private MapConfig initializeDefaultMapConfig() {
MapConfig mapConfig = new MapConfig();
/*
* Number of backups. If 1 is set as the backup-count for example, then all entries of the
* map will be copied to another JVM for fail-safety. Valid numbers are 0 (no backup), 1, 2,
* 3.
*/
mapConfig.setBackupCount(1);
/*
* Valid values are: NONE (no eviction), LRU (Least Recently Used), LFU (Least Frequently
* Used). NONE is the default.
*/
mapConfig.setEvictionPolicy(EvictionPolicy.LRU);
/*
* Maximum size of the map. When max size is reached, map is evicted based on the policy
* defined. Any integer between 0 and Integer.MAX_VALUE. 0 means Integer.MAX_VALUE. Default
* is 0.
*/
mapConfig
.setMaxSizeConfig(new MaxSizeConfig(0, MaxSizeConfig.MaxSizePolicy.USED_HEAP_SIZE));
return mapConfig;
}
示例2: createMapConfig
import com.hazelcast.config.EvictionPolicy; //导入依赖的package包/类
private MapConfig createMapConfig(final TicketDefinition definition) {
final HazelcastProperties hz = casProperties.getTicket().getRegistry().getHazelcast();
final HazelcastProperties.Cluster cluster = hz.getCluster();
final EvictionPolicy evictionPolicy = EvictionPolicy.valueOf(cluster.getEvictionPolicy());
LOGGER.debug("Creating Hazelcast map configuration for [{}] with idle timeout [{}] second(s)",
definition.getProperties().getStorageName(), definition.getProperties().getStorageTimeout());
return new MapConfig()
.setName(definition.getProperties().getStorageName())
.setMaxIdleSeconds((int) definition.getProperties().getStorageTimeout())
.setBackupCount(cluster.getBackupCount())
.setAsyncBackupCount(cluster.getAsyncBackupCount())
.setEvictionPolicy(evictionPolicy)
.setMaxSizeConfig(new MaxSizeConfig()
.setMaxSizePolicy(MaxSizeConfig.MaxSizePolicy.valueOf(cluster.getMaxSizePolicy()))
.setSize(cluster.getMaxHeapSizePercentage()));
}
示例3: addMapConfig
import com.hazelcast.config.EvictionPolicy; //导入依赖的package包/类
void addMapConfig(Class<?> c)
{
if(!c.isAnnotationPresent(HzMapConfig.class))
throw new IllegalArgumentException(c+" not annotated with @"+HzMapConfig.class.getSimpleName());
HzMapConfig hc = c.getAnnotation(HzMapConfig.class);
MapConfig mapC = new MapConfig(hc.name());
if(hzConfig.getMapConfigs().containsKey(hc.name()))
{
mapC = hzConfig.getMapConfig(hc.name());
}
mapC.setAsyncBackupCount(hc.asyncBackupCount());
mapC.setBackupCount(hc.backupCount());
mapC.setEvictionPercentage(hc.evictPercentage());
mapC.setEvictionPolicy(EvictionPolicy.valueOf(hc.evictPolicy()));
mapC.setInMemoryFormat(InMemoryFormat.valueOf(hc.inMemoryFormat()));
mapC.setMaxIdleSeconds(hc.idleSeconds());
mapC.setMergePolicy(hc.evictPolicy());
mapC.setMinEvictionCheckMillis(hc.evictCheckMillis());
mapC.setTimeToLiveSeconds(hc.ttlSeconds());
mapC.setMaxSizeConfig(new MaxSizeConfig(hc.maxSize(), MaxSizePolicy.valueOf(hc.maxSizePolicy())));
mapC.setStatisticsEnabled(hc.statisticsOn());
hzConfig.getMapConfigs().put(mapC.getName(), mapC);
}
示例4: ClusterManager
import com.hazelcast.config.EvictionPolicy; //导入依赖的package包/类
public ClusterManager(HazelcastConnection connection,
List<HealthCheck> healthChecks,
HttpConfiguration httpConfiguration) throws Exception {
this.hazelcastConnection = connection;
this.healthChecks = healthChecks;
MapConfig mapConfig = new MapConfig(MAP_NAME);
mapConfig.setTimeToLiveSeconds(MAP_REFRESH_TIME + 2); //Reduce jitter
mapConfig.setBackupCount(1);
mapConfig.setAsyncBackupCount(2);
mapConfig.setEvictionPolicy(EvictionPolicy.NONE);
hazelcastConnection.getHazelcastConfig().getMapConfigs().put(MAP_NAME, mapConfig);
String hostname = Inet4Address.getLocalHost().getCanonicalHostName();
executor = Executors.newScheduledThreadPool(1);
clusterMember = new ClusterMember(hostname, httpConfiguration.getPort());
}
示例5: initializeDefaultMapConfig
import com.hazelcast.config.EvictionPolicy; //导入依赖的package包/类
private MapConfig initializeDefaultMapConfig() {
MapConfig mapConfig = new MapConfig();
/*
Number of backups. If 1 is set as the backup-count for example,
then all entries of the map will be copied to another JVM for
fail-safety. Valid numbers are 0 (no backup), 1, 2, 3.
*/
mapConfig.setBackupCount(0);
/*
Valid values are:
NONE (no eviction),
LRU (Least Recently Used),
LFU (Least Frequently Used).
NONE is the default.
*/
mapConfig.setEvictionPolicy(EvictionPolicy.LRU);
/*
Maximum size of the map. When max size is reached,
map is evicted based on the policy defined.
Any integer between 0 and Integer.MAX_VALUE. 0 means
Integer.MAX_VALUE. Default is 0.
*/
mapConfig.setMaxSizeConfig(new MaxSizeConfig(0, MaxSizeConfig.MaxSizePolicy.USED_HEAP_SIZE));
return mapConfig;
}
示例6: hazelCastConfig
import com.hazelcast.config.EvictionPolicy; //导入依赖的package包/类
@Bean
public Config hazelCastConfig() {
Config config = new Config();
config.setInstanceName("hazelcast-packt-cache");
config.setProperty("hazelcast.jmx", "true");
MapConfig deptCache = new MapConfig();
deptCache.setTimeToLiveSeconds(20);
deptCache.setEvictionPolicy(EvictionPolicy.LFU);
config.getMapConfigs().put("hazeldept",deptCache);
return config;
}
示例7: correctHazelcastInstanceIsCreated
import com.hazelcast.config.EvictionPolicy; //导入依赖的package包/类
@Test
public void correctHazelcastInstanceIsCreated() throws Exception {
assertNotNull(this.hzInstance);
final Config config = this.hzInstance.getConfig();
assertFalse(config.getNetworkConfig().getJoin().getMulticastConfig().isEnabled());
assertEquals(Arrays.asList("localhost"), config.getNetworkConfig().getJoin().getTcpIpConfig().getMembers());
assertTrue(config.getNetworkConfig().isPortAutoIncrement());
assertEquals(5701, config.getNetworkConfig().getPort());
final MapConfig mapConfig = config.getMapConfig("tickets");
assertNotNull(mapConfig);
assertEquals(28800, mapConfig.getMaxIdleSeconds());
assertEquals(EvictionPolicy.LRU, mapConfig.getEvictionPolicy());
assertEquals(10, mapConfig.getEvictionPercentage());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:16,代码来源:DefaultHazelcastInstanceConfigurationTests.java
示例8: hazelcastInstanceIsCreatedNormally
import com.hazelcast.config.EvictionPolicy; //导入依赖的package包/类
@Test
public void hazelcastInstanceIsCreatedNormally() throws Exception {
assertNotNull(this.hzInstance);
final Config config = this.hzInstance.getConfig();
assertTrue(config.getNetworkConfig().getJoin().getMulticastConfig().isEnabled());
assertEquals(Arrays.asList("127.0.0.1"), config.getNetworkConfig().getJoin().getTcpIpConfig().getMembers());
assertFalse(config.getNetworkConfig().isPortAutoIncrement());
assertEquals(5801, config.getNetworkConfig().getPort());
final MapConfig mapConfig = config.getMapConfig("tickets-from-external-config");
assertNotNull(mapConfig);
assertEquals(20000, mapConfig.getMaxIdleSeconds());
assertEquals(EvictionPolicy.LFU, mapConfig.getEvictionPolicy());
assertEquals(99, mapConfig.getEvictionPercentage());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:16,代码来源:ProvidedHazelcastInstanceConfigurationTests.java
示例9: initializeDefaultMapConfig
import com.hazelcast.config.EvictionPolicy; //导入依赖的package包/类
private static MapConfig initializeDefaultMapConfig() {
MapConfig mapConfig = new MapConfig();
/*
Number of backups. If 1 is set as the backup-count for example,
then all entries of the map will be copied to another JVM for
fail-safety. Valid numbers are 0 (no backup), 1, 2, 3.
*/
mapConfig.setBackupCount(0);
/*
Valid values are:
NONE (no eviction),
LRU (Least Recently Used),
LFU (Least Frequently Used).
NONE is the default.
*/
mapConfig.setEvictionPolicy(EvictionPolicy.LRU);
/*
Maximum size of the map. When max size is reached,
map is evicted based on the policy defined.
Any integer between 0 and Integer.MAX_VALUE. 0 means
Integer.MAX_VALUE. Default is 0.
*/
mapConfig.setMaxSizeConfig(new MaxSizeConfig(0, MaxSizeConfig.MaxSizePolicy.USED_HEAP_SIZE));
return mapConfig;
}
示例10: createDeviceCredentialsCacheConfig
import com.hazelcast.config.EvictionPolicy; //导入依赖的package包/类
private MapConfig createDeviceCredentialsCacheConfig() {
MapConfig deviceCredentialsCacheConfig = new MapConfig(CacheConstants.DEVICE_CREDENTIALS_CACHE);
deviceCredentialsCacheConfig.setTimeToLiveSeconds(cacheDeviceCredentialsTTL);
deviceCredentialsCacheConfig.setEvictionPolicy(EvictionPolicy.LRU);
deviceCredentialsCacheConfig.setMaxSizeConfig(
new MaxSizeConfig(
cacheDeviceCredentialsMaxSizeSize,
MaxSizeConfig.MaxSizePolicy.valueOf(cacheDeviceCredentialsMaxSizePolicy))
);
return deviceCredentialsCacheConfig;
}
示例11: initializeDefaultMapConfig
import com.hazelcast.config.EvictionPolicy; //导入依赖的package包/类
private MapConfig initializeDefaultMapConfig() {
MapConfig mapConfig = new MapConfig();
/*
Number of backups. If 1 is set as the backup-count for example,
then all entries of the map will be copied to another JVM for
fail-safety. Valid numbers are 0 (no backup), 1, 2, 3.
*/
mapConfig.setBackupCount(0);
/*
Valid values are:
NONE (no eviction),
LRU (Least Recently Used),
LFU (Least Frequently Used).
NONE is the default.
*/
mapConfig.setEvictionPolicy(EvictionPolicy.LRU);
/*
Maximum size of the map. When max size is reached,
map is evicted based on the policy defined.
Any integer between 0 and Integer.MAX_VALUE. 0 means
Integer.MAX_VALUE. Default is 0.
*/
mapConfig.setMaxSizeConfig(new MaxSizeConfig(0, MaxSizeConfig.MaxSizePolicy.USED_HEAP_SIZE));
/*
When max. size is reached, specified percentage of
the map will be evicted. Any integer between 0 and 100.
If 25 is set for example, 25% of the entries will
get evicted.
*/
mapConfig.setEvictionPercentage(25);
return mapConfig;
}
示例12: initializeDefaultMapConfig
import com.hazelcast.config.EvictionPolicy; //导入依赖的package包/类
private MapConfig initializeDefaultMapConfig() {
MapConfig mapConfig = new MapConfig();
/*
Number of backups. If 1 is set as the backup-count for example,
then all entries of the map will be copied to another JVM for
fail-safety. Valid numbers are 0 (no backup), 1, 2, 3.
*/
mapConfig.setBackupCount(1);
/*
Valid values are:
NONE (no eviction),
LRU (Least Recently Used),
LFU (Least Frequently Used).
NONE is the default.
*/
mapConfig.setEvictionPolicy(EvictionPolicy.LRU);
/*
Maximum size of the map. When max size is reached,
map is evicted based on the policy defined.
Any integer between 0 and Integer.MAX_VALUE. 0 means
Integer.MAX_VALUE. Default is 0.
*/
mapConfig.setMaxSizeConfig(new MaxSizeConfig(0, MaxSizeConfig.MaxSizePolicy.USED_HEAP_SIZE));
/*
When max. size is reached, specified percentage of
the map will be evicted. Any integer between 0 and 100.
If 25 is set for example, 25% of the entries will
get evicted.
*/
mapConfig.setEvictionPercentage(25);
return mapConfig;
}
开发者ID:francescou,项目名称:hazelcast-shell-spring-boot-starter,代码行数:38,代码来源:HazelcastTestConfiguration.java
示例13: createBucket
import com.hazelcast.config.EvictionPolicy; //导入依赖的package包/类
public void createBucket(String map, int ttl, int backups, int mib)
throws IOException
{
if (bucketCreation.containsKey(map)) {
throw new FileAlreadyExistsException(null, null,
"Bucket already exists: " + map);
}
Map<String, MapConfig> mapConfigs = hazelcast.getConfig()
.getMapConfigs();
MapConfig config = new MapConfig(map);
config.setTimeToLiveSeconds(ttl);
config.setEvictionPolicy(EvictionPolicy.LRU);
config.setInMemoryFormat(InMemoryFormat.BINARY);
config.setBackupCount(backups);
int nodes = hazelcast.getCluster().getMembers().size();
MaxSizeConfig max = new MaxSizeConfig(mib / nodes,
MaxSizeConfig.MaxSizePolicy.USED_HEAP_SIZE);
config.setMaxSizeConfig(max);
mapConfigs.put(map, config);
// pre-fill local map configuration timestamp...
bucketCreation.putIfAbsent(map, System.currentTimeMillis());
// this should always be the first call to the map...
hazelcast.getMap(map);
}
示例14: setCacheConfig
import com.hazelcast.config.EvictionPolicy; //导入依赖的package包/类
private void setCacheConfig(Config config, String name, int timeToLive) {
HotRestartConfig hotRestart = new HotRestartConfig();
hotRestart.setEnabled(true);
config.getMapConfig(name)//
.setTimeToLiveSeconds(timeToLive)//
.setMaxIdleSeconds(timeToLive)//
.setEvictionPolicy(EvictionPolicy.LRU)//
.setMaxSizeConfig(new MaxSizeConfig(5000, MaxSizePolicy.PER_NODE))//
.setBackupCount(1)//
.setHotRestartConfig(hotRestart)//
.setInMemoryFormat(InMemoryFormat.BINARY)//
.setStatisticsEnabled(true)//
// .setWanReplicationRef(null)//
;
}
示例15: cache
import com.hazelcast.config.EvictionPolicy; //导入依赖的package包/类
@Bean
public Map<String, Object> cache() {
Config config = new Config();
MapConfig mapConfig = new MapConfig();
mapConfig.setEvictionPercentage(50);
mapConfig.setEvictionPolicy(EvictionPolicy.LFU);
mapConfig.setTimeToLiveSeconds(300);
Map<String, MapConfig> mapConfigMap = new HashMap<>();
mapConfigMap.put("cache", mapConfig);
config.setMapConfigs(mapConfigMap);
HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
return instance.getMap("cache");
}