当前位置: 首页>>代码示例>>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;未经允许,请勿转载。