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


Java MapConfig類代碼示例

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


MapConfig類屬於com.hazelcast.config包,在下文中一共展示了MapConfig類的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: testThreeArgConstructorRegistersTopicListener

import com.hazelcast.config.MapConfig; //導入依賴的package包/類
@Test
public void testThreeArgConstructorRegistersTopicListener() {
    MapConfig mapConfig = mock(MapConfig.class);

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

    ITopic<Object> topic = mock(ITopic.class);
    when(topic.addMessageListener(isNotNull(MessageListener.class))).thenReturn("ignored");

    HazelcastInstance instance = mock(HazelcastInstance.class);
    when(instance.getConfig()).thenReturn(config);
    when(instance.getTopic(eq(CACHE_NAME))).thenReturn(topic);

    new LocalRegionCache(CACHE_NAME, instance, null);
    verify(config).findMapConfig(eq(CACHE_NAME));
    verify(instance).getConfig();
    verify(instance).getTopic(eq(CACHE_NAME));
    verify(topic).addMessageListener(isNotNull(MessageListener.class));
}
 
開發者ID:hazelcast,項目名稱:hazelcast-hibernate5,代碼行數:21,代碼來源:LocalRegionCacheTest.java

示例3: createMapConfig

import com.hazelcast.config.MapConfig; //導入依賴的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

示例4: init

import com.hazelcast.config.MapConfig; //導入依賴的package包/類
@PostConstruct
public void init() {
	Config config = this.hazelcastInstance.getConfig();
	String mapName = this.sessionProperties.getMapName();
	MapConfig mapConfig = config.getMapConfigOrNull(mapName);

	if (mapConfig == null) {
		// @formatter:off
		MapAttributeConfig principalNameAttributeConfig = new MapAttributeConfig()
				.setName(HazelcastSessionRepository.PRINCIPAL_NAME_ATTRIBUTE)
				.setExtractor(PrincipalNameExtractor.class.getName());
		// @formatter:on

		MapIndexConfig principalNameIndexConfig = new MapIndexConfig(
				HazelcastSessionRepository.PRINCIPAL_NAME_ATTRIBUTE, false);

		// @formatter:off
		mapConfig = new MapConfig(mapName)
				.addMapAttributeConfig(principalNameAttributeConfig)
				.addMapIndexConfig(principalNameIndexConfig);
		// @formatter:on

		config.addMapConfig(mapConfig);
	}
}
 
開發者ID:vpavic,項目名稱:simple-openid-provider,代碼行數:26,代碼來源:SessionConfiguration.java

示例5: HazelcastLockMemory

import com.hazelcast.config.MapConfig; //導入依賴的package包/類
public HazelcastLockMemory(IMap<String, LockValue> locksMap) {
	super();
	this.locksMap = locksMap;
	
	LOG.info("HazelcastLockMemory ----- MAP_ID: " + locksMap.getId());
	LOG.info("HazelcastLockMemory ----- MAP_NAME: " + locksMap.getName());
	LOG.info("HazelcastLockMemory ----- MAP_STRING: " + locksMap.toString());
	LOG.info("HazelcastLockMemory ----- MAP_INSTANCE_TYPE: " + locksMap.getInstanceType());
	
	MapConfig mapConf = Hazelcast.getConfig().getMapConfig(DistributedMapNames.MAP.LOCK_MEMORY_LOCKS_MAP.toString());
	
	MapStoreConfig mapStoreConf = mapConf.getMapStoreConfig();
	
	if(mapStoreConf == null){
		LOG.info("HazelcastLockMemory ----- MAPSTORE NULL");	
	}else{
		LOG.info("HazelcastLockMemory ----- MAPSTORE IMPL: " + mapStoreConf.getImplementation());
	}
	
	
}
 
開發者ID:gerritjvv,項目名稱:bigstreams,代碼行數:22,代碼來源:HazelcastLockMemory.java

示例6: HazelcastFileTrackerStorage

import com.hazelcast.config.MapConfig; //導入依賴的package包/類
/**
 * Requires a hazelcast map.
 * 
 * @param fileTrackerMemory
 * @param logTypeSet
 *            stores the log types
 * @param agentSet
 */
public HazelcastFileTrackerStorage(
		IMap<FileTrackingStatusKey, FileTrackingStatus> fileTrackerMemory,
		IMap<String, LogTypeContact> logTypeSet, IMap<String, AgentContact> agentSet) {

	this.fileTrackerMemoryMap = fileTrackerMemory;
	this.logTypeSet = logTypeSet;
	this.agentSet = agentSet;

	MapConfig mapConf = Hazelcast.getConfig().getMapConfig(
			DistributedMapNames.MAP.FILE_TRACKER_MAP.toString());

	MapStoreConfig mapStoreConf = mapConf.getMapStoreConfig();

	if (mapStoreConf == null) {
		LOG.info("HazelcastFileTrackerStorage ----- MAPSTORE NULL");
	} else {
		LOG.info("HazelcastFileTrackerStorage ----- MAPSTORE IMPL: "
				+ mapStoreConf.getImplementation());
	}

}
 
開發者ID:gerritjvv,項目名稱:bigstreams,代碼行數:30,代碼來源:HazelcastFileTrackerStorage.java

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

示例8: setUp

import com.hazelcast.config.MapConfig; //導入依賴的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

示例9: setUp

import com.hazelcast.config.MapConfig; //導入依賴的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

示例10: testQueryCacheCleanup

import com.hazelcast.config.MapConfig; //導入依賴的package包/類
@Test
public void testQueryCacheCleanup() {

    MapConfig mapConfig = getHazelcastInstance(sf).getConfig().getMapConfig("org.hibernate.cache.*");
    final float baseEvictionRate = 0.2f;
    final int numberOfEntities = 100;
    final int defaultCleanupPeriod = 60;
    final int maxSize = mapConfig.getMaxSizeConfig().getSize();
    final int evictedItemCount = numberOfEntities - maxSize + (int) (maxSize * baseEvictionRate);
    insertDummyEntities(numberOfEntities);
    for (int i = 0; i < numberOfEntities; i++) {
        executeQuery(sf, i);
    }

    HazelcastQueryResultsRegion queryRegion = ((HazelcastQueryResultsRegion) (((SessionFactoryImpl) sf).getQueryCache()).getRegion());
    assertEquals(numberOfEntities, queryRegion.getCache().size());
    sleep(defaultCleanupPeriod);

    assertEquals(numberOfEntities - evictedItemCount, queryRegion.getCache().size());
}
 
開發者ID:hazelcast,項目名稱:hazelcast-hibernate5,代碼行數:21,代碼來源:RegionFactoryDefaultSlowTest.java

示例11: testQueryCacheCleanup

import com.hazelcast.config.MapConfig; //導入依賴的package包/類
@Test
public void testQueryCacheCleanup() {
    MapConfig mapConfig = getHazelcastInstance(sf).getConfig().getMapConfig("org.hibernate.cache.*");
    final float baseEvictionRate = 0.2f;
    final int numberOfEntities = 100;
    final int defaultCleanupPeriod = 60;
    final int maxSize = mapConfig.getMaxSizeConfig().getSize();
    final int evictedItemCount = numberOfEntities - maxSize + (int) (maxSize * baseEvictionRate);
    insertDummyEntities(numberOfEntities);
    sleep(1);
    for (int i = 0; i < numberOfEntities; i++) {
        executeQuery(sf, i);
    }

    HazelcastQueryResultsRegion queryRegion = ((HazelcastQueryResultsRegion) (((SessionFactoryImpl) sf).getQueryCache()).getRegion());
    assertEquals(numberOfEntities, queryRegion.getCache().size());
    sleep(defaultCleanupPeriod);

    assertEquals(numberOfEntities - evictedItemCount, queryRegion.getCache().size());
}
 
開發者ID:hazelcast,項目名稱:hazelcast-hibernate,代碼行數:21,代碼來源:RegionFactoryDefaultSlowTest.java

示例12: configureJetService

import com.hazelcast.config.MapConfig; //導入依賴的package包/類
static void configureJetService(JetConfig jetConfig) {
    if (!(jetConfig.getHazelcastConfig().getConfigPatternMatcher() instanceof MatchingPointConfigPatternMatcher)) {
        throw new UnsupportedOperationException("Custom config pattern matcher is not supported in Jet");
    }

    jetConfig.getHazelcastConfig().getServicesConfig()
             .addServiceConfig(new ServiceConfig().setEnabled(true)
                                                  .setName(JetService.SERVICE_NAME)
                                                  .setClassName(JetService.class.getName())
                                                  .setConfigObject(jetConfig));

    jetConfig.getHazelcastConfig().addMapConfig(new MapConfig(INTERNAL_JET_OBJECTS_PREFIX + "*")
             .setBackupCount(jetConfig.getInstanceConfig().getBackupCount())
             .setStatisticsEnabled(false)
             .setMergePolicy(IgnoreMergingEntryMapMergePolicy.class.getName()));
}
 
開發者ID:hazelcast,項目名稱:hazelcast-jet,代碼行數:17,代碼來源:Jet.java

示例13: when_defaultMapConfig_then_notUsed

import com.hazelcast.config.MapConfig; //導入依賴的package包/類
@Test
public void when_defaultMapConfig_then_notUsed() {
    // When
    JetConfig config = new JetConfig();
    config.getHazelcastConfig().getMapConfig("default")
            .setTimeToLiveSeconds(MapConfig.DEFAULT_TTL_SECONDS + 1);
    JetInstance instance = createJetMember(config);

    try {
        // Then
        int actualTTL = instance.getConfig().getHazelcastConfig().findMapConfig(INTERNAL_JET_OBJECTS_PREFIX + "fooMap")
                                .getTimeToLiveSeconds();
        assertEquals(MapConfig.DEFAULT_TTL_SECONDS, actualTTL);
    } finally {
        shutdownFactory();
    }
}
 
開發者ID:hazelcast,項目名稱:hazelcast-jet,代碼行數:18,代碼來源:JetTest.java

示例14: setup

import com.hazelcast.config.MapConfig; //導入依賴的package包/類
@Before
public void setup() {
    factory = new JetTestInstanceFactory();

    JetConfig config = new JetConfig();
    config.getInstanceConfig().setCooperativeThreadCount(LOCAL_PARALLELISM);

    // force snapshots to fail by adding a failing map store configuration for snapshot data maps
    MapConfig mapConfig = new MapConfig(SnapshotRepository.SNAPSHOT_DATA_NAME_PREFIX + '*');
    MapStoreConfig mapStoreConfig = mapConfig.getMapStoreConfig();
    mapStoreConfig.setEnabled(true);
    mapStoreConfig.setImplementation(new FailingMapStore());
    config.getHazelcastConfig().addMapConfig(mapConfig);

    JetInstance[] instances = factory.newMembers(config, 2);
    instance1 = instances[0];
}
 
開發者ID:hazelcast,項目名稱:hazelcast-jet,代碼行數:18,代碼來源:SnapshotFailureTest.java

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


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