當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。