當前位置: 首頁>>代碼示例>>Java>>正文


Java MapConfig.setMaxSizeConfig方法代碼示例

本文整理匯總了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;
}
 
開發者ID:ccfish86,項目名稱:sctalk,代碼行數:27,代碼來源:HazelCastConfigration.java

示例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);
}
 
開發者ID:javanotes,項目名稱:reactive-data,代碼行數:27,代碼來源:HazelcastInstanceProxy.java

示例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;
}
 
開發者ID:Esquive,項目名稱:iticrawler,代碼行數:25,代碼來源:DistMapConfig.java

示例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);
}
 
開發者ID:igniterealtime,項目名稱:Openfire,代碼行數:26,代碼來源:ClusteredCacheFactory.java

示例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;
}
 
開發者ID:xm-online,項目名稱:xm-uaa,代碼行數:30,代碼來源:CacheConfiguration.java

示例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;
}
 
開發者ID:xm-online,項目名稱:xm-gate,代碼行數:30,代碼來源:CacheConfiguration.java

示例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;
}
 
開發者ID:osswangxining,項目名稱:iotplatform,代碼行數:12,代碼來源:ServiceCacheConfiguration.java

示例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;
}
 
開發者ID:xetys,項目名稱:jhipster-ribbon-hystrix,代碼行數:38,代碼來源:_CacheConfiguration.java

示例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);
}
 
開發者ID:ancoron,項目名稱:hazelcast-rest,代碼行數:29,代碼來源:HazelcastMapServlet.java

示例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;
}
 
開發者ID:thpham,項目名稱:ithings-demo,代碼行數:38,代碼來源:CacheConfiguration.java

示例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);
}
 
開發者ID:Tesora,項目名稱:tesora-dve-pub,代碼行數:37,代碼來源:HazelcastCoordinationServices.java

示例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);
}
 
開發者ID:apache,項目名稱:marmotta,代碼行數:12,代碼來源:HazelcastCacheManager.java


注:本文中的com.hazelcast.config.MapConfig.setMaxSizeConfig方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。