com.hazelcast.config.MaxSizeConfig Java Examples

The following examples show how to use com.hazelcast.config.MaxSizeConfig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MapsConfig.java    From eventapis with Apache License 2.0 6 votes vote down vote up
@Override
public Config configure(Config config) {

    List<MapIndexConfig> indexes = Arrays.asList(
            new MapIndexConfig("startTime", true),
            new MapIndexConfig("operationState", true)
    );
    config.getMapConfig(OPERATIONS_MAP_NAME)
            .setTimeToLiveSeconds(OPERATIONS_MAX_TTL_INSEC)
            .setMapIndexConfigs(indexes);

    config.getMapConfig(OPERATIONS_MAP_HISTORY_NAME)
            .setMapIndexConfigs(indexes)
            .setMaxSizeConfig(new MaxSizeConfig(evictFreePercentage, MaxSizeConfig.MaxSizePolicy.FREE_HEAP_PERCENTAGE))
            .setEvictionPolicy(EvictionPolicy.LRU);
    config.getReplicatedMapConfig(TOPICS_MAP_NAME);

    return config;
}
 
Example #2
Source File: HazelcastOperationMapsConfig.java    From eventapis with Apache License 2.0 6 votes vote down vote up
@Override
public Config configure(Config config) {

    List<MapIndexConfig> indexes = Arrays.asList(
            new MapIndexConfig("spanningServices[any].serviceName", true)
    );

    MapConfig mapConfig = new MapConfig(EVENTS_OPS_MAP_NAME)
            .setMapIndexConfigs(indexes)
            .setMaxSizeConfig(new MaxSizeConfig(evictFreePercentage, MaxSizeConfig.MaxSizePolicy.FREE_HEAP_PERCENTAGE))
            .setEvictionPolicy(EvictionPolicy.LRU)
            .setQuorumName("default")
            .setName(EVENTS_OPS_MAP_NAME);
    config.addMapConfig(mapConfig);
    return config;
}
 
Example #3
Source File: HazelCastConfigration.java    From sctalk with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #4
Source File: CacheConfiguration.java    From flair-engine with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #5
Source File: HazelCastConfigration.java    From jvue-admin with MIT License 5 votes vote down vote up
private MapConfig initializeDefaultMapConfig() {
    MapConfig mapConfig = new MapConfig();
    mapConfig.setBackupCount(1);
    mapConfig.setEvictionPolicy(EvictionPolicy.LRU);
    mapConfig.setMaxSizeConfig(new MaxSizeConfig(0, MaxSizeConfig.MaxSizePolicy.USED_HEAP_SIZE));
    return mapConfig;
}
 
Example #6
Source File: CacheConfiguration.java    From jhipster-microservices-example with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #7
Source File: ServiceCacheConfiguration.java    From iotplatform with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #8
Source File: _CacheConfiguration.java    From jhipster-ribbon-hystrix with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example #9
Source File: DistributedCacheFactory.java    From foxtrot with Apache License 2.0 5 votes vote down vote up
private MapConfig getDefaultMapConfig(CacheConfig cacheConfig) {
    MapConfig mapConfig = new MapConfig(CACHE_NAME_PREFIX + "*");
    mapConfig.setInMemoryFormat(InMemoryFormat.BINARY);
    mapConfig.setBackupCount(0);
    mapConfig.setEvictionPolicy(EvictionPolicy.LRU);

    if(cacheConfig.getMaxIdleSeconds() == 0) {
        mapConfig.setMaxIdleSeconds(DEFAULT_MAX_IDLE_SECONDS);
    } else {
        mapConfig.setMaxIdleSeconds(cacheConfig.getMaxIdleSeconds());
    }

    if(cacheConfig.getTimeToLiveSeconds() == 0) {
        mapConfig.setTimeToLiveSeconds(DEFAULT_TIME_TO_LIVE_SECONDS);
    } else {
        mapConfig.setTimeToLiveSeconds(cacheConfig.getTimeToLiveSeconds());
    }

    MaxSizeConfig maxSizeConfig = new MaxSizeConfig();
    maxSizeConfig.setMaxSizePolicy(MaxSizeConfig.MaxSizePolicy.USED_HEAP_PERCENTAGE);
    if(cacheConfig.getSize() == 0) {
        maxSizeConfig.setSize(DEFAULT_SIZE);
    } else {
        maxSizeConfig.setSize(cacheConfig.getSize());
    }
    mapConfig.setMaxSizeConfig(maxSizeConfig);
    return mapConfig;
}
 
Example #10
Source File: CacheConfiguration.java    From tutorials with MIT License 5 votes vote down vote up
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;
}
 
Example #11
Source File: CacheConfiguration.java    From tutorials with MIT License 5 votes vote down vote up
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;
}
 
Example #12
Source File: CacheConfiguration.java    From tutorials with MIT License 5 votes vote down vote up
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;
}