本文整理匯總了Java中com.hazelcast.config.MapConfig.setMaxSizeConfig方法的典型用法代碼示例。如果您正苦於以下問題:Java MapConfig.setMaxSizeConfig方法的具體用法?Java MapConfig.setMaxSizeConfig怎麽用?Java MapConfig.setMaxSizeConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.hazelcast.config.MapConfig
的用法示例。
在下文中一共展示了MapConfig.setMaxSizeConfig方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initializeDefaultMapConfig
import com.hazelcast.config.MapConfig; //導入方法依賴的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: addMapConfig
import com.hazelcast.config.MapConfig; //導入方法依賴的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);
}
示例3: setup
import com.hazelcast.config.MapConfig; //導入方法依賴的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;
}
示例4: createCache
import com.hazelcast.config.MapConfig; //導入方法依賴的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);
}
示例5: initializeDefaultMapConfig
import com.hazelcast.config.MapConfig; //導入方法依賴的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: initializeDefaultMapConfig
import com.hazelcast.config.MapConfig; //導入方法依賴的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;
}
示例7: createDeviceCredentialsCacheConfig
import com.hazelcast.config.MapConfig; //導入方法依賴的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;
}
示例8: initializeDefaultMapConfig
import com.hazelcast.config.MapConfig; //導入方法依賴的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;
}
示例9: initializeDefaultMapConfig
import com.hazelcast.config.MapConfig; //導入方法依賴的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
示例10: createBucket
import com.hazelcast.config.MapConfig; //導入方法依賴的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);
}
示例11: initializeDefaultMapConfig
import com.hazelcast.config.MapConfig; //導入方法依賴的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;
}
示例12: startHazelcastServices
import com.hazelcast.config.MapConfig; //導入方法依賴的package包/類
private void startHazelcastServices(List<String> registeredServers) throws PEException {
Config cfg = new Config();
cfg.setInstanceName(HAZELCAST_INSTANCE_NAME);
cfg.setProperty("hazelcast.logging.type", "log4j");
GroupConfig group = cfg.getGroupConfig();
group.setName(HAZELCAST_GROUP_NAME);
group.setPassword(HAZELCAST_GROUP_PASSWORD);
NetworkConfig network = cfg.getNetworkConfig();
network.setPortAutoIncrement(false);
network.setPublicAddress(ourClusterAddress.getAddress().getHostAddress());
network.setPort(ourClusterAddress.getPort());
Join join = network.getJoin();
join.getMulticastConfig().setEnabled(false);
for (String serverAddress : registeredServers) {
join.getTcpIpConfig().addMember(serverAddress);
logger.debug("Added member " + serverAddress);
}
join.getTcpIpConfig().setEnabled(true);
MapConfig mc = new MapConfig(GLOBAL_SESS_VAR_MAP_NAME);
mc.setStorageType(StorageType.HEAP);
mc.setTimeToLiveSeconds(0);
mc.setMaxIdleSeconds(0);
MaxSizeConfig msc = new MaxSizeConfig();
msc.setSize(0);
msc.setMaxSizePolicy(MaxSizeConfig.POLICY_CLUSTER_WIDE_MAP_SIZE);
mc.setMaxSizeConfig(msc);
cfg.addMapConfig(mc);
ourHazelcastInstance = Hazelcast.newHazelcastInstance(cfg);
}
示例13: setupMapConfig
import com.hazelcast.config.MapConfig; //導入方法依賴的package包/類
private void setupMapConfig(String name, int size) {
MapConfig cfg = new MapConfig(NODE_CACHE);
cfg.setMaxSizeConfig(new MaxSizeConfig(size, MaxSizeConfig.MaxSizePolicy.PER_PARTITION));
cfg.setAsyncBackupCount(1);
cfg.setBackupCount(0);
cfg.setEvictionPolicy(MapConfig.EvictionPolicy.LRU);
cfg.setMaxIdleSeconds(600); // 10 minutes
cfg.setTimeToLiveSeconds(3600); // 1 hour
hcConfiguration.addMapConfig(cfg);
}