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


Java MapConfig.setBackupCount方法代碼示例

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


在下文中一共展示了MapConfig.setBackupCount方法的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: 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: createConfig

import com.hazelcast.config.MapConfig; //導入方法依賴的package包/類
private static Config createConfig(String name) {
    Config config = new Config(name);

    ExecutorConfig executorConfig = config.getExecutorConfig(EXECUTOR_NAME);
    executorConfig.setPoolSize(10);
    executorConfig.setQueueCapacity(10000);

    // map without backup

    MapConfig mapConfig1 = config.getMapConfig(MAP1_NAME);
    mapConfig1.setBackupCount(0);

    MapConfig mapConfig2 = config.getMapConfig(MAP2_NAME);
    mapConfig2.setBackupCount(0);

    return config;
}
 
開發者ID:romario13,項目名稱:hz-executor,代碼行數:18,代碼來源:Test7.java

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

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

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

示例8: getMap

import com.hazelcast.config.MapConfig; //導入方法依賴的package包/類
private IMap<String, Long> getMap(String key, int longestDuration) {
    MapConfig mapConfig = hz.getConfig().getMapConfig(key);
    mapConfig.setTimeToLiveSeconds(longestDuration);
    mapConfig.setAsyncBackupCount(1);
    mapConfig.setBackupCount(0);
    return hz.getMap(key);
}
 
開發者ID:mokies,項目名稱:ratelimitj,代碼行數:8,代碼來源:HazelcastSlidingWindowRequestRateLimiter.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(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

示例10: initializeClusteredSession

import com.hazelcast.config.MapConfig; //導入方法依賴的package包/類
private MapConfig initializeClusteredSession(JHipsterProperties jHipsterProperties) {
    MapConfig mapConfig = new MapConfig();

    mapConfig.setBackupCount(jHipsterProperties.getCache().getHazelcast().getBackupCount());
    mapConfig.setTimeToLiveSeconds(jHipsterProperties.getCache().getTimeToLiveSeconds());
    return mapConfig;
}
 
開發者ID:xetys,項目名稱:jhipster-ribbon-hystrix,代碼行數:8,代碼來源:_CacheConfiguration.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(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

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

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

示例14: initializeClusteredSession

import com.hazelcast.config.MapConfig; //導入方法依賴的package包/類
private MapConfig initializeClusteredSession() {
    MapConfig mapConfig = new MapConfig();

    mapConfig.setBackupCount(env.getProperty("cache.hazelcast.backupCount", Integer.class, 1));
    mapConfig.setTimeToLiveSeconds(env.getProperty("cache.timeToLiveSeconds", Integer.class, 3600));
    return mapConfig;
}
 
開發者ID:thpham,項目名稱:ithings-demo,代碼行數:8,代碼來源:CacheConfiguration.java

示例15: testBackupCountTwo

import com.hazelcast.config.MapConfig; //導入方法依賴的package包/類
@Test(timeout = 160000)
public void testBackupCountTwo() throws Exception {
    Config config = new Config();
    config.getProperties().put(GroupProperties.PROP_PARTITION_MIGRATION_INTERVAL, "0");
    MapConfig mapConfig = config.getMapConfig("default");
    mapConfig.setBackupCount(2);
    HazelcastInstance h1 = Hazelcast.newHazelcastInstance(config);
    HazelcastInstance h2 = Hazelcast.newHazelcastInstance(config);
    IMap map1 = h1.getMap("default");
    IMap map2 = h2.getMap("default");
    int size = 10000;
    for (int i = 0; i < size; i++) {
        map1.put(i, i);
    }
    assertEquals(size, getTotalOwnedEntryCount(map1, map2));
    assertEquals(size, getTotalBackupEntryCount(map1, map2));
    HazelcastInstance h3 = Hazelcast.newHazelcastInstance(config);
    IMap map3 = h3.getMap("default");
    Thread.sleep(3000);
    assertEquals(size, getTotalOwnedEntryCount(map1, map2, map3));
    assertEquals(2 * size, getTotalBackupEntryCount(map1, map2, map3));
    HazelcastInstance h4 = Hazelcast.newHazelcastInstance(config);
    IMap map4 = h4.getMap("default");
    Thread.sleep(3000);
    assertEquals(size, getTotalOwnedEntryCount(map1, map2, map3, map4));
    assertEquals(2 * size, getTotalBackupEntryCount(map1, map2, map3, map4));
}
 
開發者ID:mdogan,項目名稱:hazelcast-archive,代碼行數:28,代碼來源:ClusterBackupTest.java


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