本文整理匯總了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);
}