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


Java Config.getMapConfig方法代码示例

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


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

示例1: correctHazelcastInstanceIsCreated

import com.hazelcast.config.Config; //导入方法依赖的package包/类
@Test
public void correctHazelcastInstanceIsCreated() throws Exception {
    assertNotNull(this.hzInstance);
    final Config config = this.hzInstance.getConfig();
    assertFalse(config.getNetworkConfig().getJoin().getMulticastConfig().isEnabled());
    assertEquals(Arrays.asList("localhost"), config.getNetworkConfig().getJoin().getTcpIpConfig().getMembers());
    assertTrue(config.getNetworkConfig().isPortAutoIncrement());
    assertEquals(5701, config.getNetworkConfig().getPort());

    final MapConfig mapConfig = config.getMapConfig("tickets");
    assertNotNull(mapConfig);
    assertEquals(28800, mapConfig.getMaxIdleSeconds());
    assertEquals(EvictionPolicy.LRU, mapConfig.getEvictionPolicy());
    assertEquals(10, mapConfig.getEvictionPercentage());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:16,代码来源:DefaultHazelcastInstanceConfigurationTests.java

示例2: hazelcastInstanceIsCreatedNormally

import com.hazelcast.config.Config; //导入方法依赖的package包/类
@Test
public void hazelcastInstanceIsCreatedNormally() throws Exception {
    assertNotNull(this.hzInstance);
    final Config config = this.hzInstance.getConfig();
    assertTrue(config.getNetworkConfig().getJoin().getMulticastConfig().isEnabled());
    assertEquals(Arrays.asList("127.0.0.1"), config.getNetworkConfig().getJoin().getTcpIpConfig().getMembers());
    assertFalse(config.getNetworkConfig().isPortAutoIncrement());
    assertEquals(5801, config.getNetworkConfig().getPort());

    final MapConfig mapConfig = config.getMapConfig("tickets-from-external-config");
    assertNotNull(mapConfig);
    assertEquals(20000, mapConfig.getMaxIdleSeconds());
    assertEquals(EvictionPolicy.LFU, mapConfig.getEvictionPolicy());
    assertEquals(99, mapConfig.getEvictionPercentage());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:16,代码来源:ProvidedHazelcastInstanceConfigurationTests.java

示例3: main

import com.hazelcast.config.Config; //导入方法依赖的package包/类
public static void main(String[] args) {
	// 从classpath加载配置文件
	Config config = new ClasspathXmlConfig("xmlconfig/simple-config.xml");
	// 获取网络配置
	NetworkConfig netConfig = config.getNetworkConfig();
	// 获取用户定义的map配置
	MapConfig mapConfigXml = config.getMapConfig("demo.config");
	// 获取系统默认的map配置
	MapConfig mapConfigDefault = config.getMapConfig("default");
	// 输出集群监听的起始端口号
	System.out.println("Current port:" + netConfig.getPort());
	// 输出监听端口的累加号
	System.out.println("Current port count:" + netConfig.getPortCount());
	// 输出自定义map的备份副本个数
	System.out.println("Config map backup count:" + mapConfigXml.getBackupCount());
	// 输出默认map的备份副本个数
	System.out.println("Default map backup count:" + mapConfigDefault.getBackupCount());

	// 测试创建Hazelcast实例并读写测试数据
	HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
	HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config);

	Map<Integer, String> defaultMap1 = instance1.getMap("defaultMap");
	defaultMap1.put(1, "testMap");
	Map<Integer, String> configMap1 = instance1.getMap("configMap");
	configMap1.put(1, "configMap");

	Map<Integer, String> testMap2 = instance2.getMap("defaultMap");
	System.out.println("Default map value:" + testMap2.get(1));
	Map<Integer, String> configMap2 = instance2.getMap("configMap");
	System.out.println("Config map value:" + configMap2.get(1));
}
 
开发者ID:chkui,项目名称:hazelcast-demo,代码行数:33,代码来源:HazelcastConfigSimple.java


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