本文整理汇总了Java中com.hazelcast.config.MaxSizeConfig类的典型用法代码示例。如果您正苦于以下问题:Java MaxSizeConfig类的具体用法?Java MaxSizeConfig怎么用?Java MaxSizeConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MaxSizeConfig类属于com.hazelcast.config包,在下文中一共展示了MaxSizeConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeDefaultMapConfig
import com.hazelcast.config.MaxSizeConfig; //导入依赖的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.MaxSizeConfig; //导入依赖的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.MaxSizeConfig; //导入依赖的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: setUp
import com.hazelcast.config.MaxSizeConfig; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
mapConfig = mock(MapConfig.class);
when(mapConfig.getMaxSizeConfig()).thenReturn(new MaxSizeConfig(50, MaxSizeConfig.MaxSizePolicy.PER_NODE));
when(mapConfig.getTimeToLiveSeconds()).thenReturn(timeout);
config = mock(Config.class);
when(config.findMapConfig(eq(REGION_NAME))).thenReturn(mapConfig);
Cluster cluster = mock(Cluster.class);
when(cluster.getClusterTime()).thenAnswer(new Answer<Long>() {
@Override
public Long answer(InvocationOnMock invocation) throws Throwable {
return System.currentTimeMillis();
}
});
instance = mock(HazelcastInstance.class);
when(instance.getConfig()).thenReturn(config);
when(instance.getCluster()).thenReturn(cluster);
cache = mock(RegionCache.class);
region = new HazelcastTimestampsRegion<RegionCache>(instance, REGION_NAME, new Properties(), cache);
}
示例5: setUp
import com.hazelcast.config.MaxSizeConfig; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
mapConfig = mock(MapConfig.class);
when(mapConfig.getMaxSizeConfig()).thenReturn(new MaxSizeConfig(maxSize, MaxSizeConfig.MaxSizePolicy.PER_NODE));
when(mapConfig.getTimeToLiveSeconds()).thenReturn(timeout);
config = mock(Config.class);
when(config.findMapConfig(eq(REGION_NAME))).thenReturn(mapConfig);
Cluster cluster = mock(Cluster.class);
when(cluster.getClusterTime()).thenAnswer(new Answer<Long>() {
@Override
public Long answer(InvocationOnMock invocation) throws Throwable {
return System.currentTimeMillis();
}
});
instance = mock(HazelcastInstance.class);
when(instance.getConfig()).thenReturn(config);
when(instance.getCluster()).thenReturn(cluster);
region = new HazelcastQueryResultsRegion(instance, REGION_NAME, new Properties());
}
示例6: setup
import com.hazelcast.config.MaxSizeConfig; //导入依赖的package包/类
public DistMapConfig setup(Config cfg, String name, Object storeImplementation) {
MapConfig mapConfig = new MapConfig();
//TODO: Refactor the config options
mapConfig.setName(name);
mapConfig.setBackupCount(1);
if (storeImplementation != null) {
MaxSizeConfig maxSizeConfig = new MaxSizeConfig();
//todo Refactor this to config
maxSizeConfig.setSize(1000);
MapStoreConfig store = new MapStoreConfig();
store.setImplementation(storeImplementation);
mapConfig.setMaxSizeConfig(maxSizeConfig);
mapConfig.setMapStoreConfig(store);
}
cfg.addMapConfig(mapConfig);
return this;
}
示例7: createCache
import com.hazelcast.config.MaxSizeConfig; //导入依赖的package包/类
public Cache createCache(String name) {
// Check if cluster is being started up
while (state == State.starting) {
// Wait until cluster is fully started (or failed)
try {
Thread.sleep(250);
}
catch (InterruptedException e) {
// Ignore
}
}
if (state == State.stopped) {
throw new IllegalStateException("Cannot create clustered cache when not in a cluster");
}
// Determine the time to live. Note that in Hazelcast 0 means "forever", not -1
final long openfireLifetimeInMilliseconds = CacheFactory.getMaxCacheLifetime(name);
final int hazelcastLifetimeInSeconds = openfireLifetimeInMilliseconds < 0 ? 0 : (int) (openfireLifetimeInMilliseconds / 1000);
// Determine the max cache size. Note that in Hazelcast the max cache size must be positive
final long openfireMaxCacheSize = CacheFactory.getMaxCacheSize(name);
final int hazelcastMaxCacheSize = openfireMaxCacheSize < 0 ? Integer.MAX_VALUE : (int) openfireMaxCacheSize;
final MapConfig mapConfig = hazelcast.getConfig().getMapConfig(name);
mapConfig.setTimeToLiveSeconds(hazelcastLifetimeInSeconds);
mapConfig.setMaxSizeConfig(new MaxSizeConfig(hazelcastMaxCacheSize, MaxSizeConfig.MaxSizePolicy.USED_HEAP_SIZE));
return new ClusteredCache(name, hazelcast.getMap(name), hazelcastLifetimeInSeconds);
}
示例8: initializeDefaultMapConfig
import com.hazelcast.config.MaxSizeConfig; //导入依赖的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;
}
示例9: initializeDefaultMapConfig
import com.hazelcast.config.MaxSizeConfig; //导入依赖的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.MaxSizeConfig; //导入依赖的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.MaxSizeConfig; //导入依赖的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.MaxSizeConfig; //导入依赖的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.MaxSizeConfig; //导入依赖的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.MaxSizeConfig; //导入依赖的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: initializeDefaultMapConfig
import com.hazelcast.config.MaxSizeConfig; //导入依赖的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(MapConfig.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;
}