本文整理汇总了Java中com.hazelcast.config.MapConfig.setMaxIdleSeconds方法的典型用法代码示例。如果您正苦于以下问题:Java MapConfig.setMaxIdleSeconds方法的具体用法?Java MapConfig.setMaxIdleSeconds怎么用?Java MapConfig.setMaxIdleSeconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hazelcast.config.MapConfig
的用法示例。
在下文中一共展示了MapConfig.setMaxIdleSeconds方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: setupConfig
import com.hazelcast.config.MapConfig; //导入方法依赖的package包/类
public static void setupConfig(HazelcastConnection hazelcastConnection) {
MapConfig mapConfig = hazelcastConnection.getHazelcastConfig().getMapConfig(NAME_PREFIX + "*");
mapConfig.setInMemoryFormat(InMemoryFormat.BINARY);
mapConfig.setTimeToLiveSeconds(10);
mapConfig.setMaxIdleSeconds(10);
mapConfig.setBackupCount(0);
NearCacheConfig nearCacheConfig = new NearCacheConfig();
nearCacheConfig.setTimeToLiveSeconds(10);
nearCacheConfig.setInvalidateOnChange(true);
nearCacheConfig.setMaxIdleSeconds(10);
mapConfig.setNearCacheConfig(nearCacheConfig);
}
示例3: 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);
}
示例4: 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);
}
示例5: testMaxIdleAndMemoryLeak
import com.hazelcast.config.MapConfig; //导入方法依赖的package包/类
@Test
public void testMaxIdleAndMemoryLeak() throws Exception {
Runtime.getRuntime().gc();
long usedMemoryInit = getUsedMemoryAsMB();
Config config = new XmlConfigBuilder().build();
MapConfig mapConfig = config.getMapConfig("default");
mapConfig.setMaxIdleSeconds(15);
final HazelcastInstance h1 = Hazelcast.newHazelcastInstance(config);
final HazelcastInstance h2 = Hazelcast.newHazelcastInstance(config);
final HazelcastInstance h3 = Hazelcast.newHazelcastInstance(config);
final HazelcastInstance h4 = Hazelcast.newHazelcastInstance(config);
final HazelcastInstance[] instances = new HazelcastInstance[4];
instances[0] = h1;
instances[1] = h2;
instances[2] = h3;
instances[3] = h4;
IMap map1 = h1.getMap("default");
final int size = 10000;
for (int i = 0; i < size; i++) {
map1.put(i, new byte[10000]);
}
long usedMemoryStart = getUsedMemoryAsMB();
assertTrue("UsedMemoryStart: " + usedMemoryStart, usedMemoryStart > 200);
final ExecutorService es = Executors.newFixedThreadPool(4);
final CountDownLatch latch = new CountDownLatch(4);
for (int a = 0; a < 4; a++) {
final int t = a;
es.execute(new Runnable() {
public void run() {
for (int i = 0; i < size; i++) {
instances[t].getMap("default").get(i);
}
latch.countDown();
}
});
}
assertTrue(latch.await(20, TimeUnit.SECONDS));
es.shutdown();
assertTrue(es.awaitTermination(5, TimeUnit.SECONDS));
assertTrue(waitForCleanup(200, instances));
waitForGC(25 + usedMemoryInit, 200);
}