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


Java MapConfig.setEvictionPolicy方法代碼示例

本文整理匯總了Java中com.hazelcast.config.MapConfig.setEvictionPolicy方法的典型用法代碼示例。如果您正苦於以下問題:Java MapConfig.setEvictionPolicy方法的具體用法?Java MapConfig.setEvictionPolicy怎麽用?Java MapConfig.setEvictionPolicy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.hazelcast.config.MapConfig的用法示例。


在下文中一共展示了MapConfig.setEvictionPolicy方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: ClusterManager

import com.hazelcast.config.MapConfig; //導入方法依賴的package包/類
public ClusterManager(HazelcastConnection connection,
                      List<HealthCheck> healthChecks,
                      HttpConfiguration httpConfiguration) throws Exception {
    this.hazelcastConnection = connection;
    this.healthChecks = healthChecks;
    MapConfig mapConfig = new MapConfig(MAP_NAME);
    mapConfig.setTimeToLiveSeconds(MAP_REFRESH_TIME + 2); //Reduce jitter
    mapConfig.setBackupCount(1);
    mapConfig.setAsyncBackupCount(2);
    mapConfig.setEvictionPolicy(EvictionPolicy.NONE);
    hazelcastConnection.getHazelcastConfig().getMapConfigs().put(MAP_NAME, mapConfig);

    String hostname = Inet4Address.getLocalHost().getCanonicalHostName();
    executor = Executors.newScheduledThreadPool(1);
    clusterMember = new ClusterMember(hostname, httpConfiguration.getPort());
}
 
開發者ID:Flipkart,項目名稱:foxtrot,代碼行數:17,代碼來源:ClusterManager.java

示例4: 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

示例5: hazelCastConfig

import com.hazelcast.config.MapConfig; //導入方法依賴的package包/類
@Bean
public Config hazelCastConfig() {
 
    Config config = new Config();
    config.setInstanceName("hazelcast-packt-cache");
    config.setProperty("hazelcast.jmx", "true");
 
    MapConfig deptCache = new MapConfig();
    deptCache.setTimeToLiveSeconds(20);
    deptCache.setEvictionPolicy(EvictionPolicy.LFU);
   
    config.getMapConfigs().put("hazeldept",deptCache);
    return config;
}
 
開發者ID:PacktPublishing,項目名稱:Spring-5.0-Cookbook,代碼行數:15,代碼來源:CachingConfig.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: cache

import com.hazelcast.config.MapConfig; //導入方法依賴的package包/類
@Bean
public Map<String, Object> cache() {
    Config config = new Config();
    MapConfig mapConfig = new MapConfig();
    mapConfig.setEvictionPercentage(50);
    mapConfig.setEvictionPolicy(EvictionPolicy.LFU);
    mapConfig.setTimeToLiveSeconds(300);
    Map<String, MapConfig> mapConfigMap = new HashMap<>();
    mapConfigMap.put("cache", mapConfig);
    config.setMapConfigs(mapConfigMap);

    HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
    return instance.getMap("cache");
}
 
開發者ID:darylmathison,項目名稱:annotation-implementation-example,代碼行數:15,代碼來源:AppConfig.java

示例12: 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

示例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

示例14: KfkaManagerImpl

import com.hazelcast.config.MapConfig; //導入方法依賴的package包/類
public KfkaManagerImpl(HazelcastInstance hazelcastInstance, KfkaMapStore<? extends KfkaMessage> mapStore, KfkaCounterStore counterStore, KfkaConfig kfkaCfg)
{
    this.kfkaCfg = kfkaCfg;
    
    final MapConfig hzcfg = hazelcastInstance.getConfig().getMapConfig(kfkaCfg.getName());
    hzcfg.setEvictionPolicy(EvictionPolicy.NONE);
    
    final MapStoreConfig mapCfg = hzcfg.getMapStoreConfig();
    mapCfg.setImplementation(mapStore);
    mapCfg.setEnabled(kfkaCfg.isPersistent());
    mapCfg.setWriteBatchSize(kfkaCfg.getBatchSize());
    mapCfg.setWriteDelaySeconds(kfkaCfg.getWriteDelay());
    mapCfg.setInitialLoadMode(kfkaCfg.getInitialLoadMode());
    
    this.mapStore = mapStore;
    this.messages = hazelcastInstance.getMap(kfkaCfg.getName());
    this.counter = hazelcastInstance.getAtomicLong(kfkaCfg.getName());
    
    messages.addIndex("id", true);
    messages.addIndex("timestamp", true);
    
    messages.addEntryListener(new EntryAddedListener<Long, KfkaMessage>()
    {
        @Override
        public void entryAdded(EntryEvent<Long, KfkaMessage> event)
        {
        	logger.debug("Received message for dispatch: {}", event.getValue());
            final Iterator<Entry<KfkaMessageListener, KfkaPredicate>> iter = msgListeners.entrySet().iterator();
            while (iter.hasNext())
            {
            	final Entry<KfkaMessageListener, KfkaPredicate> e = iter.next();
                final KfkaPredicate predicate = e.getValue();
                final KfkaMessage msg = event.getValue();
                
                // Check if message should be included
                if (predicate.toGuavaPredicate().apply(msg))
                {
                    final KfkaMessageListener l = e.getKey();
                    logger.debug("Sending message {} to {}", event.getValue().getId(), e.getKey());
                    l.onMessage(event.getValue());
                }
            }
        }
    }, true);
    
    if (counter.get() == 0)
    {
        final long initialValue = counterStore.latest();
        logger.info("Setting current KFKA message ID counter to {}", initialValue);
        counter.compareAndSet(0, initialValue);
    }
}
 
開發者ID:ethlo,項目名稱:kfka,代碼行數:53,代碼來源:KfkaManagerImpl.java

示例15: HazelcastCache

import com.hazelcast.config.MapConfig; //導入方法依賴的package包/類
private HazelcastCache() {
    final AppConfig config = AppConfig.getInstance();
    final Map<String, MapConfig> mapconfigs = new HashMap<>();
    GroupConfig groupconfig = new GroupConfig();
    groupconfig.setName(config.getString("cluster.name", "gw2live"));
    groupconfig.setPassword(config.getString("cluster.password", "gw2live"));
    final MapConfig mapconfig = new MapConfig();
    mapconfig.getMaxSizeConfig().setMaxSizePolicy(MaxSizePolicy.PER_PARTITION);
    mapconfig.getMaxSizeConfig().setSize(0);
    mapconfig.setEvictionPolicy(MapConfig.DEFAULT_EVICTION_POLICY);
    mapconfig.setBackupCount(1);
    mapconfigs.put("*-cache", mapconfig);
    final NetworkConfig nwconfig = new NetworkConfig();
    if(config.containsKey("cluster.interface")) {
        final InterfacesConfig interfaces = new InterfacesConfig();
        interfaces.addInterface(config.getString("cluster.interface"));
        interfaces.setEnabled(true);
        nwconfig.setInterfaces(interfaces);
    }
    nwconfig.setPort(config.getInteger("cluster.port", 5801));
    nwconfig.setPortAutoIncrement(true);
    final MulticastConfig mcconfig = new MulticastConfig();
    mcconfig.setEnabled(true);
    mcconfig.setMulticastGroup(config.getString("cluster.multicast.group", "224.2.2.3"));
    mcconfig.setMulticastPort(config.getInteger("cluster.multicast.port", 58011));
    mcconfig.setMulticastTimeToLive(MulticastConfig.DEFAULT_MULTICAST_TTL);
    mcconfig.setMulticastTimeoutSeconds(MulticastConfig.DEFAULT_MULTICAST_TIMEOUT_SECONDS);
    final JoinConfig join = new JoinConfig();
    join.setMulticastConfig(mcconfig);
    nwconfig.setJoin(join);
    final ExecutorConfig execconfig = new ExecutorConfig();
    execconfig.setName("default");
    execconfig.setPoolSize(4);
    execconfig.setQueueCapacity(100);
    final Map<String, ExecutorConfig> execmap = new HashMap<>();
    execmap.put("default", execconfig);
    final Config hconfig = new Config();
    hconfig.setInstanceName("gw2live");
    hconfig.setGroupConfig(groupconfig);
    hconfig.setMapConfigs(mapconfigs);
    hconfig.setNetworkConfig(nwconfig);
    hconfig.setExecutorConfigs(execmap);
    hconfig.setProperty("hazelcast.shutdownhook.enabled", "false");
    hconfig.setProperty("hazelcast.wait.seconds.before.join", "0");
    hconfig.setProperty("hazelcast.rest.enabled", "false");
    hconfig.setProperty("hazelcast.memcache.enabled", "false");
    hconfig.setProperty("hazelcast.mancenter.enabled", "false");
    hconfig.setProperty("hazelcast.logging.type", "none");
    cache = Hazelcast.newHazelcastInstance(hconfig);

    LOG.debug("Hazelcast initialized");
}
 
開發者ID:zyclonite,項目名稱:gw2live,代碼行數:53,代碼來源:HazelcastCache.java


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