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


Java NetworkConfig.getJoin方法代码示例

本文整理汇总了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);
}
 
开发者ID:chkui,项目名称:hazelcast-demo,代码行数:24,代码来源:HazelcastConfigRuntimeModify.java

示例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);
}
 
开发者ID:mcaprari,项目名称:spino,代码行数:22,代码来源:SpinoHazelcastImpl.java

示例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);
}
 
开发者ID:Tesora,项目名称:tesora-dve-pub,代码行数:37,代码来源:HazelcastCoordinationServices.java

示例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);
}
 
开发者ID:synergynet,项目名称:synergynet3.1,代码行数:47,代码来源:SynergyNetApp.java

示例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();

	}
 
开发者ID:lumongo,项目名称:lumongo,代码行数:52,代码来源:HazelcastManager.java


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