本文整理汇总了Java中com.hazelcast.config.NetworkConfig.setPortAutoIncrement方法的典型用法代码示例。如果您正苦于以下问题:Java NetworkConfig.setPortAutoIncrement方法的具体用法?Java NetworkConfig.setPortAutoIncrement怎么用?Java NetworkConfig.setPortAutoIncrement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hazelcast.config.NetworkConfig
的用法示例。
在下文中一共展示了NetworkConfig.setPortAutoIncrement方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: HazelcastSessionDao
import com.hazelcast.config.NetworkConfig; //导入方法依赖的package包/类
public HazelcastSessionDao() {
log.info("Initializing Hazelcast Shiro session persistence..");
// configure Hazelcast instance
final Config cfg = new Config();
cfg.setInstanceName(hcInstanceName);
// group configuration
cfg.setGroupConfig(new GroupConfig(HC_GROUP_NAME, HC_GROUP_PASSWORD));
// network configuration initialization
final NetworkConfig netCfg = new NetworkConfig();
netCfg.setPortAutoIncrement(true);
netCfg.setPort(HC_PORT);
// multicast
final MulticastConfig mcCfg = new MulticastConfig();
mcCfg.setEnabled(false);
mcCfg.setMulticastGroup(HC_MULTICAST_GROUP);
mcCfg.setMulticastPort(HC_MULTICAST_PORT);
// tcp
final TcpIpConfig tcpCfg = new TcpIpConfig();
tcpCfg.addMember("127.0.0.1");
tcpCfg.setEnabled(false);
// network join configuration
final JoinConfig joinCfg = new JoinConfig();
joinCfg.setMulticastConfig(mcCfg);
joinCfg.setTcpIpConfig(tcpCfg);
netCfg.setJoin(joinCfg);
// ssl
netCfg.setSSLConfig(new SSLConfig().setEnabled(false));
// get map
map = Hazelcast.newHazelcastInstance(cfg).getMap(HC_MAP);
log.info("Hazelcast Shiro session persistence initialized.");
}
示例2: setNetwork
import com.hazelcast.config.NetworkConfig; //导入方法依赖的package包/类
private void setNetwork(NetworkConfig network) {
// network.setPublicAddress("11.22.33.44");
network.setPort(port);
network.setPortAutoIncrement(true);
network.setPortCount(100);
network.addOutboundPortDefinition("35000-35100");
// InterfacesConfig interfaces=new InterfacesConfig();
// interfaces.getInterfaces();
// network.setInterfaces(interfaces);
network.getInterfaces().setEnabled(true);
network.getInterfaces().addInterface("*.*.*.*");
network.setSSLConfig(getSslConfig());
setNetworkJoin(network.getJoin());
}
示例3: HazelcastSessionDao
import com.hazelcast.config.NetworkConfig; //导入方法依赖的package包/类
public HazelcastSessionDao() {
log.info("Initializating Hazelcast Shiro session persistence..");
// configure Hazelcast instance
hcInstanceName = UUID.randomUUID().toString();
Config cfg = new Config();
cfg.setInstanceName(hcInstanceName);
// group configuration
cfg.setGroupConfig(new GroupConfig(HC_GROUP_NAME, HC_GROUP_PASSWORD));
// network configuration initialization
NetworkConfig netCfg = new NetworkConfig();
netCfg.setPortAutoIncrement(true);
netCfg.setPort(HC_PORT);
// multicast
MulticastConfig mcCfg = new MulticastConfig();
mcCfg.setEnabled(true);
mcCfg.setMulticastGroup(HC_MULTICAST_GROUP);
mcCfg.setMulticastPort(HC_MULTICAST_PORT);
// tcp
TcpIpConfig tcpCfg = new TcpIpConfig();
tcpCfg.setEnabled(false);
// network join configuration
JoinConfig joinCfg = new JoinConfig();
joinCfg.setMulticastConfig(mcCfg);
joinCfg.setTcpIpConfig(tcpCfg);
netCfg.setJoin(joinCfg);
// ssl
netCfg.setSSLConfig(new SSLConfig().setEnabled(false));
// get map
map = Hazelcast.newHazelcastInstance(cfg).getMap(HC_MAP);
log.info("Hazelcast Shiro session persistence initialized.");
}
示例4: 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);
}
示例5: createConfig
import com.hazelcast.config.NetworkConfig; //导入方法依赖的package包/类
private String createConfig() {
Config memberConfig = options.memberConfig;
if (memberConfig == null) {
return null;
}
memberConfig.getGroupConfig().setName("workers");
memberConfig.setProperty("hazelcast.phone.home.enabled", "false");
NetworkConfig networkConfig = memberConfig.getNetworkConfig();
networkConfig.setPortAutoIncrement(true);
networkConfig.setPort(PORT);
networkConfig.setPortCount(PORT_COUNT);
networkConfig.getJoin().getMulticastConfig().setEnabled(false);
networkConfig.getJoin().getTcpIpConfig().setEnabled(true);
ConfigXmlGenerator generator = new ConfigXmlGenerator(true);
String configString = generator.generate(memberConfig);
if (networkConfig.getJoin().getTcpIpConfig().getMembers().isEmpty()) {
configString = configString.replace("<member-list/>", "<!--MEMBERS-->");
}
configString = fixGroup(configString);
System.out.println("HZ Configuration:\n" + configString);
return configString;
}
示例6: buildConfig
import com.hazelcast.config.NetworkConfig; //导入方法依赖的package包/类
private static Config buildConfig(boolean multicastEnabled) {
Config c = new Config();
c.getGroupConfig().setName("group").setPassword("pass");
c.setProperty(GroupProperties.PROP_MERGE_FIRST_RUN_DELAY_SECONDS, "10");
c.setProperty(GroupProperties.PROP_MERGE_NEXT_RUN_DELAY_SECONDS, "5");
c.setProperty(GroupProperties.PROP_MAX_NO_HEARTBEAT_SECONDS, "10");
c.setProperty(GroupProperties.PROP_MASTER_CONFIRMATION_INTERVAL_SECONDS, "2");
c.setProperty(GroupProperties.PROP_MAX_NO_MASTER_CONFIRMATION_SECONDS, "10");
c.setProperty(GroupProperties.PROP_MEMBER_LIST_PUBLISH_INTERVAL_SECONDS, "10");
final NetworkConfig networkConfig = c.getNetworkConfig();
networkConfig.getJoin().getMulticastConfig().setEnabled(multicastEnabled);
networkConfig.getJoin().getTcpIpConfig().setEnabled(!multicastEnabled);
networkConfig.setPortAutoIncrement(false);
return c;
}
开发者ID:health-and-care-developer-network,项目名称:health-and-care-developer-network,代码行数:16,代码来源:MemberListTest.java
示例7: buildConfig
import com.hazelcast.config.NetworkConfig; //导入方法依赖的package包/类
private static Config buildConfig(boolean multicastEnabled) {
Config c = new Config();
c.getGroupConfig().setName("group").setPassword("pass");
c.setProperty(GroupProperties.PROP_MERGE_FIRST_RUN_DELAY_SECONDS, "10");
c.setProperty(GroupProperties.PROP_MERGE_NEXT_RUN_DELAY_SECONDS, "5");
final NetworkConfig networkConfig = c.getNetworkConfig();
networkConfig.getJoin().getMulticastConfig().setEnabled(multicastEnabled);
networkConfig.getJoin().getTcpIpConfig().setEnabled(!multicastEnabled);
networkConfig.setPortAutoIncrement(false);
return c;
}
开发者ID:health-and-care-developer-network,项目名称:health-and-care-developer-network,代码行数:12,代码来源:SplitBrainHandlerTest.java
示例8: main
import com.hazelcast.config.NetworkConfig; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
final Config cfg = new Config();
cfg.setInstanceName(UUID.randomUUID().toString());
final Properties props = new Properties();
props.put("hazelcast.rest.enabled", false);
props.put("hazelcast.logging.type", "slf4j");
props.put("hazelcast.connect.all.wait.seconds", 45);
props.put("hazelcast.operation.call.timeout.millis", 30000);
// group configuration
cfg.setGroupConfig(new GroupConfig(args[0],
args[1]));
// network configuration initialization
final NetworkConfig netCfg = new NetworkConfig();
netCfg.setPortAutoIncrement(true);
netCfg.setPort(5701);
// multicast
final MulticastConfig mcCfg = new MulticastConfig();
mcCfg.setEnabled(false);
// tcp
final TcpIpConfig tcpCfg = new TcpIpConfig();
tcpCfg.addMember("127.0.0.1");
tcpCfg.setEnabled(true);
// network join configuration
final JoinConfig joinCfg = new JoinConfig();
joinCfg.setMulticastConfig(mcCfg);
joinCfg.setTcpIpConfig(tcpCfg);
netCfg.setJoin(joinCfg);
// ssl
netCfg.setSSLConfig(new SSLConfig().setEnabled(false));
// creating cassandra client
final CassandraClient dao = new CassandraClient();
dao.initialize(args[2]);
final HazelcastMapStore mapStore = new HazelcastMapStore(User.class);
mapStore.setDao(dao);
// Adding mapstore
final MapConfig mapCfg = cfg.getMapConfig("cassandra-map-store");
final MapStoreConfig mapStoreCfg = new MapStoreConfig();
mapStoreCfg.setImplementation(mapStore);
mapStoreCfg.setWriteDelaySeconds(1);
// to load all map at same time
mapStoreCfg.setInitialLoadMode(MapStoreConfig.InitialLoadMode.EAGER);
mapCfg.setMapStoreConfig(mapStoreCfg);
cfg.addMapConfig(mapCfg);
HazelcastInstance instance = Hazelcast.newHazelcastInstance(cfg);
// TERM signal processing
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
Hazelcast.shutdownAll();
}));
}
示例9: getConfig
import com.hazelcast.config.NetworkConfig; //导入方法依赖的package包/类
public Config getConfig() {
final Config cfg = new Config();
cfg.setInstanceName(instanceName);
final Properties props = new Properties();
props.put("hazelcast.rest.enabled", false);
props.put("hazelcast.logging.type", "slf4j");
props.put("hazelcast.connect.all.wait.seconds", 45);
props.put("hazelcast.operation.call.timeout.millis", 30000);
// group configuration
cfg.setGroupConfig(new GroupConfig(Constants.HC_GROUP_NAME,
Constants.HC_GROUP_PASSWORD));
// network configuration initialization
final NetworkConfig netCfg = new NetworkConfig();
netCfg.setPortAutoIncrement(true);
netCfg.setPort(Constants.HC_PORT);
// multicast
final MulticastConfig mcCfg = new MulticastConfig();
mcCfg.setEnabled(false);
// tcp
final TcpIpConfig tcpCfg = new TcpIpConfig();
tcpCfg.addMember("127.0.0.1");
tcpCfg.setEnabled(true);
// network join configuration
final JoinConfig joinCfg = new JoinConfig();
joinCfg.setMulticastConfig(mcCfg);
joinCfg.setTcpIpConfig(tcpCfg);
netCfg.setJoin(joinCfg);
// ssl
netCfg.setSSLConfig(new SSLConfig().setEnabled(false));
// Adding mapstore
final MapConfig mapCfg = cfg.getMapConfig(storeType);
final MapStoreConfig mapStoreCfg = new MapStoreConfig();
mapStoreCfg.setImplementation(store);
mapStoreCfg.setWriteDelaySeconds(1);
// to load all map at same time
mapStoreCfg.setInitialLoadMode(MapStoreConfig.InitialLoadMode.EAGER);
mapCfg.setMapStoreConfig(mapStoreCfg);
cfg.addMapConfig(mapCfg);
return cfg;
}
示例10: HazelcastCache
import com.hazelcast.config.NetworkConfig; //导入方法依赖的package包/类
private HazelcastCache() {
final AppConfig config = AppConfig.getInstance();
final Map<String, MapConfig> mapconfigs = new HashMap<>();
GroupConfig groupconfig = new GroupConfig();
groupconfig.setName(config.getString("cluster.name", "gw2live"));
groupconfig.setPassword(config.getString("cluster.password", "gw2live"));
final MapConfig mapconfig = new MapConfig();
mapconfig.getMaxSizeConfig().setMaxSizePolicy(MaxSizePolicy.PER_PARTITION);
mapconfig.getMaxSizeConfig().setSize(0);
mapconfig.setEvictionPolicy(MapConfig.DEFAULT_EVICTION_POLICY);
mapconfig.setBackupCount(1);
mapconfigs.put("*-cache", mapconfig);
final NetworkConfig nwconfig = new NetworkConfig();
if(config.containsKey("cluster.interface")) {
final InterfacesConfig interfaces = new InterfacesConfig();
interfaces.addInterface(config.getString("cluster.interface"));
interfaces.setEnabled(true);
nwconfig.setInterfaces(interfaces);
}
nwconfig.setPort(config.getInteger("cluster.port", 5801));
nwconfig.setPortAutoIncrement(true);
final MulticastConfig mcconfig = new MulticastConfig();
mcconfig.setEnabled(true);
mcconfig.setMulticastGroup(config.getString("cluster.multicast.group", "224.2.2.3"));
mcconfig.setMulticastPort(config.getInteger("cluster.multicast.port", 58011));
mcconfig.setMulticastTimeToLive(MulticastConfig.DEFAULT_MULTICAST_TTL);
mcconfig.setMulticastTimeoutSeconds(MulticastConfig.DEFAULT_MULTICAST_TIMEOUT_SECONDS);
final JoinConfig join = new JoinConfig();
join.setMulticastConfig(mcconfig);
nwconfig.setJoin(join);
final ExecutorConfig execconfig = new ExecutorConfig();
execconfig.setName("default");
execconfig.setPoolSize(4);
execconfig.setQueueCapacity(100);
final Map<String, ExecutorConfig> execmap = new HashMap<>();
execmap.put("default", execconfig);
final Config hconfig = new Config();
hconfig.setInstanceName("gw2live");
hconfig.setGroupConfig(groupconfig);
hconfig.setMapConfigs(mapconfigs);
hconfig.setNetworkConfig(nwconfig);
hconfig.setExecutorConfigs(execmap);
hconfig.setProperty("hazelcast.shutdownhook.enabled", "false");
hconfig.setProperty("hazelcast.wait.seconds.before.join", "0");
hconfig.setProperty("hazelcast.rest.enabled", "false");
hconfig.setProperty("hazelcast.memcache.enabled", "false");
hconfig.setProperty("hazelcast.mancenter.enabled", "false");
hconfig.setProperty("hazelcast.logging.type", "none");
cache = Hazelcast.newHazelcastInstance(hconfig);
LOG.debug("Hazelcast initialized");
}