本文整理汇总了Java中com.hazelcast.config.NetworkConfig.setJoin方法的典型用法代码示例。如果您正苦于以下问题:Java NetworkConfig.setJoin方法的具体用法?Java NetworkConfig.setJoin怎么用?Java NetworkConfig.setJoin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hazelcast.config.NetworkConfig
的用法示例。
在下文中一共展示了NetworkConfig.setJoin方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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.");
}
示例3: 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();
}));
}
示例4: 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;
}
示例5: newInstance
import com.hazelcast.config.NetworkConfig; //导入方法依赖的package包/类
public HazelcastInstance newInstance() {
String name = NAME.get();
String password = PASS.get();
if (StringUtils.isBlank(name)) {
name = hazelcastDao.getGroupName();
}
if (StringUtils.isBlank(password)) {
password = hazelcastDao.getGroupPassword();
}
Config config = new Config();
if (JMX.get()) {
config.setProperty("hazelcast.jmx", "true");
}
config.setProperty("hazelcast.logging.type", LOGGING.get());
config.setProperty("hazelcast.discovery.enabled", "true");
GroupConfig groupConfig = new GroupConfig();
groupConfig.setName(name);
groupConfig.setPassword(password);
config.setGroupConfig(groupConfig);
DiscoveryStrategyConfig dsc = new DiscoveryStrategyConfig(dbDiscoveryFactory);
DiscoveryConfig dc = new DiscoveryConfig();
dc.setDiscoveryStrategyConfigs(Arrays.asList(dsc));
JoinConfig joinConfig = new JoinConfig();
joinConfig.setDiscoveryConfig(dc);
joinConfig.getTcpIpConfig().setEnabled(false);
joinConfig.getMulticastConfig().setEnabled(false);
joinConfig.getAwsConfig().setEnabled(false);
NetworkConfig nc = new NetworkConfig();
nc.setPort(DBDiscovery.DEFAULT_PORT.get());
nc.setJoin(joinConfig);
nc.setPublicAddress(dbDiscovery.getLocalConfig().getAdvertiseAddress());
config.setNetworkConfig(nc);
HazelcastInstance hi = Hazelcast.newHazelcastInstance(config);
while (!hi.getPartitionService().isClusterSafe()) {
log.info("Waiting for cluster to be in a steady state");
try {
Thread.sleep(2000L);
} catch (InterruptedException e) {
throw new IllegalStateException("Waiting for cluster to be in a steady state", e);
}
}
return hi;
}
示例6: 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");
}