本文整理匯總了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];
}