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


Java MaxSizeConfig类代码示例

本文整理汇总了Java中com.hazelcast.config.MaxSizeConfig的典型用法代码示例。如果您正苦于以下问题:Java MaxSizeConfig类的具体用法?Java MaxSizeConfig怎么用?Java MaxSizeConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MaxSizeConfig类属于com.hazelcast.config包,在下文中一共展示了MaxSizeConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initializeDefaultMapConfig

import com.hazelcast.config.MaxSizeConfig; //导入依赖的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: createMapConfig

import com.hazelcast.config.MaxSizeConfig; //导入依赖的package包/类
private MapConfig createMapConfig(final TicketDefinition definition) {
    final HazelcastProperties hz = casProperties.getTicket().getRegistry().getHazelcast();
    final HazelcastProperties.Cluster cluster = hz.getCluster();
    final EvictionPolicy evictionPolicy = EvictionPolicy.valueOf(cluster.getEvictionPolicy());

    LOGGER.debug("Creating Hazelcast map configuration for [{}] with idle timeout [{}] second(s)",
            definition.getProperties().getStorageName(), definition.getProperties().getStorageTimeout());

    return new MapConfig()
            .setName(definition.getProperties().getStorageName())
            .setMaxIdleSeconds((int) definition.getProperties().getStorageTimeout())
            .setBackupCount(cluster.getBackupCount())
            .setAsyncBackupCount(cluster.getAsyncBackupCount())
            .setEvictionPolicy(evictionPolicy)
            .setMaxSizeConfig(new MaxSizeConfig()
                    .setMaxSizePolicy(MaxSizeConfig.MaxSizePolicy.valueOf(cluster.getMaxSizePolicy()))
                    .setSize(cluster.getMaxHeapSizePercentage()));
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:19,代码来源:HazelcastTicketRegistryConfiguration.java

示例3: addMapConfig

import com.hazelcast.config.MaxSizeConfig; //导入依赖的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

示例4: setUp

import com.hazelcast.config.MaxSizeConfig; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    mapConfig = mock(MapConfig.class);
    when(mapConfig.getMaxSizeConfig()).thenReturn(new MaxSizeConfig(50, MaxSizeConfig.MaxSizePolicy.PER_NODE));
    when(mapConfig.getTimeToLiveSeconds()).thenReturn(timeout);

    config = mock(Config.class);
    when(config.findMapConfig(eq(REGION_NAME))).thenReturn(mapConfig);

    Cluster cluster = mock(Cluster.class);
    when(cluster.getClusterTime()).thenAnswer(new Answer<Long>() {
        @Override
        public Long answer(InvocationOnMock invocation) throws Throwable {
            return System.currentTimeMillis();
        }
    });

    instance = mock(HazelcastInstance.class);
    when(instance.getConfig()).thenReturn(config);
    when(instance.getCluster()).thenReturn(cluster);

    cache = mock(RegionCache.class);

    region = new HazelcastTimestampsRegion<RegionCache>(instance, REGION_NAME, new Properties(), cache);
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate5,代码行数:26,代码来源:HazelcastTimestampsRegionTest.java

示例5: setUp

import com.hazelcast.config.MaxSizeConfig; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    mapConfig = mock(MapConfig.class);
    when(mapConfig.getMaxSizeConfig()).thenReturn(new MaxSizeConfig(maxSize, MaxSizeConfig.MaxSizePolicy.PER_NODE));
    when(mapConfig.getTimeToLiveSeconds()).thenReturn(timeout);

    config = mock(Config.class);
    when(config.findMapConfig(eq(REGION_NAME))).thenReturn(mapConfig);

    Cluster cluster = mock(Cluster.class);
    when(cluster.getClusterTime()).thenAnswer(new Answer<Long>() {
        @Override
        public Long answer(InvocationOnMock invocation) throws Throwable {
            return System.currentTimeMillis();
        }
    });

    instance = mock(HazelcastInstance.class);
    when(instance.getConfig()).thenReturn(config);
    when(instance.getCluster()).thenReturn(cluster);

    region = new HazelcastQueryResultsRegion(instance, REGION_NAME, new Properties());
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate5,代码行数:24,代码来源:HazelcastQueryResultsRegionTest.java

示例6: setup

import com.hazelcast.config.MaxSizeConfig; //导入依赖的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

示例7: createCache

import com.hazelcast.config.MaxSizeConfig; //导入依赖的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

示例8: initializeDefaultMapConfig

import com.hazelcast.config.MaxSizeConfig; //导入依赖的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

示例9: initializeDefaultMapConfig

import com.hazelcast.config.MaxSizeConfig; //导入依赖的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

示例10: createDeviceCredentialsCacheConfig

import com.hazelcast.config.MaxSizeConfig; //导入依赖的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

示例11: initializeDefaultMapConfig

import com.hazelcast.config.MaxSizeConfig; //导入依赖的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

示例12: initializeDefaultMapConfig

import com.hazelcast.config.MaxSizeConfig; //导入依赖的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

示例13: createBucket

import com.hazelcast.config.MaxSizeConfig; //导入依赖的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

示例14: setCacheConfig

import com.hazelcast.config.MaxSizeConfig; //导入依赖的package包/类
private void setCacheConfig(Config config, String name, int timeToLive) {
	HotRestartConfig hotRestart = new HotRestartConfig();
	hotRestart.setEnabled(true);
	config.getMapConfig(name)//
			.setTimeToLiveSeconds(timeToLive)//
			.setMaxIdleSeconds(timeToLive)//
			.setEvictionPolicy(EvictionPolicy.LRU)//
			.setMaxSizeConfig(new MaxSizeConfig(5000, MaxSizePolicy.PER_NODE))//
			.setBackupCount(1)//
			.setHotRestartConfig(hotRestart)//
			.setInMemoryFormat(InMemoryFormat.BINARY)//
			.setStatisticsEnabled(true)//
	// .setWanReplicationRef(null)//
	;
}
 
开发者ID:eetlite,项目名称:eet.osslite.cz,代码行数:16,代码来源:HazelcastConfiguration.java

示例15: initializeDefaultMapConfig

import com.hazelcast.config.MaxSizeConfig; //导入依赖的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


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