本文整理汇总了Java中com.hazelcast.config.NetworkConfig.getJoin方法的典型用法代码示例。如果您正苦于以下问题:Java NetworkConfig.getJoin方法的具体用法?Java NetworkConfig.getJoin怎么用?Java NetworkConfig.getJoin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hazelcast.config.NetworkConfig
的用法示例。
在下文中一共展示了NetworkConfig.getJoin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.hazelcast.config.NetworkConfig; //导入方法依赖的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: start
import com.hazelcast.config.NetworkConfig; //导入方法依赖的package包/类
void start(String... seeds) {
handler = this.new HazelcastListener();
Config hzConfig = new Config();
if (seeds != null) {
NetworkConfig networkConfig = hzConfig.getNetworkConfig();
Join join = networkConfig.getJoin();
join.getMulticastConfig().setEnabled(false);
for(String address : seeds) {
join.getTcpIpConfig().addMember(address);
}
join.getTcpIpConfig().setEnabled(true);
}
hzConfig.getGroupConfig().setName(GROUP_NAME);
this.hz = Hazelcast.newHazelcastInstance(hzConfig);
this.cluster = hz.getCluster();
cluster.addMembershipListener(handler);
getServicesMap().addEntryListener(handler, true);
syncServiceMap(cluster);
}
示例3: startHazelcastServices
import com.hazelcast.config.NetworkConfig; //导入方法依赖的package包/类
private void startHazelcastServices(List<String> registeredServers) throws PEException {
Config cfg = new Config();
cfg.setInstanceName(HAZELCAST_INSTANCE_NAME);
cfg.setProperty("hazelcast.logging.type", "log4j");
GroupConfig group = cfg.getGroupConfig();
group.setName(HAZELCAST_GROUP_NAME);
group.setPassword(HAZELCAST_GROUP_PASSWORD);
NetworkConfig network = cfg.getNetworkConfig();
network.setPortAutoIncrement(false);
network.setPublicAddress(ourClusterAddress.getAddress().getHostAddress());
network.setPort(ourClusterAddress.getPort());
Join join = network.getJoin();
join.getMulticastConfig().setEnabled(false);
for (String serverAddress : registeredServers) {
join.getTcpIpConfig().addMember(serverAddress);
logger.debug("Added member " + serverAddress);
}
join.getTcpIpConfig().setEnabled(true);
MapConfig mc = new MapConfig(GLOBAL_SESS_VAR_MAP_NAME);
mc.setStorageType(StorageType.HEAP);
mc.setTimeToLiveSeconds(0);
mc.setMaxIdleSeconds(0);
MaxSizeConfig msc = new MaxSizeConfig();
msc.setSize(0);
msc.setMaxSizePolicy(MaxSizeConfig.POLICY_CLUSTER_WIDE_MAP_SIZE);
mc.setMaxSizeConfig(msc);
cfg.addMapConfig(mc);
ourHazelcastInstance = Hazelcast.newHazelcastInstance(cfg);
}
示例4: initiateDefaultVariables
import com.hazelcast.config.NetworkConfig; //导入方法依赖的package包/类
/**
* Establishes the values of variables used throughout the app.
**/
private void initiateDefaultVariables()
{
networkFlickEnabled = false;
this.stage = MultiplicityEnvironment.get().getLocalStages().get(0);
this.behaviourMaker = this.stage.getBehaviourMaker();
this.contentFactory = this.stage.getContentFactory();
if (NETWORKING)
{
WebConfigPrefsItem webconfig = new WebConfigPrefsItem();
Config cfg = new Config();
NetworkConfig network = cfg.getNetworkConfig();
String clusterInterface = webconfig.getClusterInterface();
if (!clusterInterface.equals(""))
{
network.getInterfaces().setEnabled(true).addInterface(clusterInterface);
Hazelcast.init(cfg);
}
//Check if webconfig has TCP/IP enabled
if (!webconfig.getJoinModeMulticasting())
{
//Disable multicasting
Join join = network.getJoin();
join.getMulticastConfig().setEnabled( false );
//Add IPs of members to look for, collected from the config
join.getTcpIpConfig().addMember(webconfig.getTcpIPs()).setEnabled( true );
//Increase waiting time to a minute
join.getTcpIpConfig().setConnectionTimeoutSeconds(60);
}
localDevicePosition = SynergyNetPositioning.getLocalDeviceLocationFull();
}
AdditionalItemUtilities.loadAdditionalItems(stage);
}
示例5: init
import com.hazelcast.config.NetworkConfig; //导入方法依赖的package包/类
public void init(Set<HazelcastNode> nodes, String hazelcastName) throws Exception {
// force Hazelcast to use log4j
int hazelcastPort = localNodeConfig.getHazelcastPort();
Config cfg = new Config();
cfg.setProperty(GroupProperty.LOGGING_TYPE.getName(), "log4j");
// disable Hazelcast shutdown hook to allow LuMongo to handle
cfg.setProperty(GroupProperty.SHUTDOWNHOOK_ENABLED.getName(), "false");
cfg.setProperty(GroupProperty.REST_ENABLED.getName(), "false");
cfg.getGroupConfig().setName(hazelcastName);
cfg.getGroupConfig().setPassword(hazelcastName);
cfg.getNetworkConfig().setPortAutoIncrement(false);
cfg.getNetworkConfig().setPort(hazelcastPort);
cfg.setInstanceName("" + hazelcastPort);
cfg.getManagementCenterConfig().setEnabled(false);
NetworkConfig network = cfg.getNetworkConfig();
JoinConfig joinConfig = network.getJoin();
joinConfig.getMulticastConfig().setEnabled(false);
joinConfig.getTcpIpConfig().setEnabled(true);
for (HazelcastNode node : nodes) {
joinConfig.getTcpIpConfig().addMember(node.getAddress() + ":" + node.getHazelcastPort());
}
hazelcastInstance = Hazelcast.newHazelcastInstance(cfg);
self = hazelcastInstance.getCluster().getLocalMember();
hazelcastInstance.getCluster().addMembershipListener(this);
hazelcastInstance.getLifecycleService().addLifecycleListener(this);
log.info("Initialized hazelcast");
Set<Member> members = hazelcastInstance.getCluster().getMembers();
Member firstMember = members.iterator().next();
if (firstMember.equals(self)) {
log.info("Member is owner of cluster");
indexManager.loadIndexes();
}
log.info("Current cluster members: <" + members + ">");
indexManager.openConnections(members);
initLock.writeLock().unlock();
}