当前位置: 首页>>代码示例>>Java>>正文


Java MapConfig.setMaxIdleSeconds方法代码示例

本文整理汇总了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);
}
 
开发者ID:javanotes,项目名称:reactive-data,代码行数:27,代码来源:HazelcastInstanceProxy.java

示例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);
}
 
开发者ID:Flipkart,项目名称:foxtrot,代码行数:13,代码来源:DistributedCache.java

示例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);
}
 
开发者ID:Tesora,项目名称:tesora-dve-pub,代码行数:37,代码来源:HazelcastCoordinationServices.java

示例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);
}
 
开发者ID:apache,项目名称:marmotta,代码行数:12,代码来源:HazelcastCacheManager.java

示例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);
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:43,代码来源:MemoryLeakTest.java


注:本文中的com.hazelcast.config.MapConfig.setMaxIdleSeconds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。