本文整理汇总了Java中com.hazelcast.config.NetworkConfig类的典型用法代码示例。如果您正苦于以下问题:Java NetworkConfig类的具体用法?Java NetworkConfig怎么用?Java NetworkConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NetworkConfig类属于com.hazelcast.config包,在下文中一共展示了NetworkConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: hazelcastConfig
import com.hazelcast.config.NetworkConfig; //导入依赖的package包/类
@Bean
public Config hazelcastConfig() {
final EntryListenerConfig listener = new EntryListenerConfig();
final Config config = new Config()
.setNetworkConfig(new NetworkConfig()
.setJoin(new JoinConfig()
.setMulticastConfig(new MulticastConfig()
.setEnabled(true))))
.setInstanceName(instanceName)
.setProperty("hazelcast.logging.type", "slf4j")
.addMapConfig(new MapConfig()
.setName(SERVER_STATE)
.setTimeToLiveSeconds(serverStateExpiration)
.setMaxIdleSeconds(serverStateExpiration))
.addMapConfig(new MapConfig()
.setName(CacheNames.NONCE)
.setTimeToLiveSeconds(nonceExpirationInSeconds)
.setMaxIdleSeconds(nonceExpirationInSeconds))
.addMapConfig(new MapConfig()
.setName(CacheNames.JWKS)
.setTimeToLiveSeconds(jwkExpirationInSeconds)
.setMaxIdleSeconds(jwkExpirationInSeconds)
.addEntryListenerConfig(listener));
LOG.debug("hazelcast config={}", config);
return config;
}
示例4: init
import com.hazelcast.config.NetworkConfig; //导入依赖的package包/类
public void init() {
//Specific map time to live
MapConfig myMapConfig = new MapConfig();
myMapConfig.setName("cachetest");
myMapConfig.setTimeToLiveSeconds(10);
//Package config
Config myConfig = new Config();
myConfig.addMapConfig(myMapConfig);
//Symmetric Encryption
SymmetricEncryptionConfig symmetricEncryptionConfig = new SymmetricEncryptionConfig();
symmetricEncryptionConfig.setAlgorithm("DESede");
symmetricEncryptionConfig.setSalt("saltysalt");
symmetricEncryptionConfig.setPassword("lamepassword");
symmetricEncryptionConfig.setIterationCount(1337);
//Weak Network config..
NetworkConfig networkConfig = new NetworkConfig();
networkConfig.setSymmetricEncryptionConfig(symmetricEncryptionConfig);
myConfig.setNetworkConfig(networkConfig);
Hazelcast.init(myConfig);
cacheMap = Hazelcast.getMap("cachetest");
}
示例5: newStandaloneHazelcastInstance
import com.hazelcast.config.NetworkConfig; //导入依赖的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);
}
示例6: main
import com.hazelcast.config.NetworkConfig; //导入依赖的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));
}
示例7: AwsDiscoveryStrategy
import com.hazelcast.config.NetworkConfig; //导入依赖的package包/类
public AwsDiscoveryStrategy(Map<String, Comparable> properties) {
super(LOGGER, properties);
this.port = getOrDefault(PORT.getDefinition(), NetworkConfig.DEFAULT_PORT);
try {
this.aws = new AWSClient(getAwsConfig());
} catch (IllegalArgumentException e) {
throw new InvalidConfigurationException("AWS configuration is not valid", e);
}
}
示例8: buildCluster
import com.hazelcast.config.NetworkConfig; //导入依赖的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];
}
示例9: 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.");
}
示例10: 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());
}
示例11: test_getServicePort_returns_configured_hz_port
import com.hazelcast.config.NetworkConfig; //导入依赖的package包/类
@Test
public void test_getServicePort_returns_configured_hz_port() {
Map<String, Comparable> properties = new HashMap<String, Comparable>();
properties.put("hz-port", 5703);
ComputeServiceBuilder builder = new ComputeServiceBuilder(properties);
assertEquals(builder.getServicePort(), 5703);
assertNotEquals(builder.getServicePort(), NetworkConfig.DEFAULT_PORT);
}
示例12: getServicePort
import com.hazelcast.config.NetworkConfig; //导入依赖的package包/类
protected int getServicePort(Map<String, Object> properties) {
int port = NetworkConfig.DEFAULT_PORT;
if (properties != null) {
String servicePort = (String) properties.get(HAZELCAST_SERVICE_PORT);
if (servicePort != null) {
port = Integer.parseInt(servicePort);
}
}
return port;
}
示例13: buildCluster
import com.hazelcast.config.NetworkConfig; //导入依赖的package包/类
private static HazelcastInstance buildCluster(int memberCount) {
Config config = new Config();
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];
}
示例14: embeddedHazelcast
import com.hazelcast.config.NetworkConfig; //导入依赖的package包/类
@Bean
public HazelcastInstance embeddedHazelcast() {
Config hazelcastConfig = new ClasspathXmlConfig(
"org/springframework/session/hazelcast/config/annotation/web/http/hazelcast-custom-map-name.xml");
NetworkConfig netConfig = new NetworkConfig();
netConfig.setPort(SocketUtils.findAvailableTcpPort());
hazelcastConfig.setNetworkConfig(netConfig);
return Hazelcast.newHazelcastInstance(hazelcastConfig);
}
开发者ID:spring-projects,项目名称:spring-session,代码行数:10,代码来源:HazelcastHttpSessionConfigurationXmlTests.java
示例15: 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.");
}