本文整理汇总了Java中com.hazelcast.config.Config.getNetworkConfig方法的典型用法代码示例。如果您正苦于以下问题:Java Config.getNetworkConfig方法的具体用法?Java Config.getNetworkConfig怎么用?Java Config.getNetworkConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hazelcast.config.Config
的用法示例。
在下文中一共展示了Config.getNetworkConfig方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.hazelcast.config.Config; //导入方法依赖的package包/类
public static void main(String[] args) {
// 创建默认config对象
Config config = new Config();
// 获取network元素<network></network>
NetworkConfig netConfig = config.getNetworkConfig();
System.out.println("Default port:" + netConfig.getPort());
// 设置组网起始监听端口
netConfig.setPort(9701);
System.out.println("Customer port:" + netConfig.getPort());
// 获取join元素<join></join>
JoinConfig joinConfig = netConfig.getJoin();
// 获取multicast元素<multicast></multicast>
MulticastConfig multicastConfig = joinConfig.getMulticastConfig();
// 输出组播协议端口
System.out.println(multicastConfig.getMulticastPort());
// 禁用multicast协议
multicastConfig.setEnabled(false);
// 初始化Hazelcast
Hazelcast.newHazelcastInstance(config);
}
示例2: newStandaloneHazelcastInstance
import com.hazelcast.config.Config; //导入方法依赖的package包/类
static HazelcastInstance newStandaloneHazelcastInstance() {
Config config = new Config();
config.setProperty("hazelcast.logging.type", "slf4j");
config.setProperty("hazelcast.shutdownhook.enabled", "false");
NetworkConfig network = config.getNetworkConfig();
network.getJoin().getTcpIpConfig().setEnabled(false);
network.getJoin().getMulticastConfig().setEnabled(false);
return Hazelcast.newHazelcastInstance(config);
}
示例3: MesosMembershipScheme
import com.hazelcast.config.Config; //导入方法依赖的package包/类
public MesosMembershipScheme(Map<String, Parameter> parameters, String primaryDomain, Config config,
HazelcastInstance primaryHazelcastInstance, List<ClusteringMessage> messageBuffer) {
this.parameters = parameters;
this.primaryHazelcastInstance = primaryHazelcastInstance;
this.messageBuffer = messageBuffer;
this.nwConfig = config.getNetworkConfig();
}
示例4: 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));
}
示例5: buildCluster
import com.hazelcast.config.Config; //导入方法依赖的package包/类
private static HazelcastInstance buildCluster(int memberCount) {
Config config = new XmlConfigBuilder().build();
NetworkConfig networkConfig = config.getNetworkConfig();
networkConfig.getJoin().getMulticastConfig().setEnabled(false);
networkConfig.getJoin().getTcpIpConfig().setEnabled(true);
networkConfig.getJoin().getTcpIpConfig().setMembers(Arrays.asList(new String[] {"127.0.0.1"}));
HazelcastInstance[] hazelcastInstances = new HazelcastInstance[memberCount];
for (int i = 0; i < memberCount; i++) {
hazelcastInstances[i] = Hazelcast.newHazelcastInstance(config);
}
return hazelcastInstances[0];
}