本文整理汇总了Java中com.hazelcast.config.JoinConfig类的典型用法代码示例。如果您正苦于以下问题:Java JoinConfig类的具体用法?Java JoinConfig怎么用?Java JoinConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JoinConfig类属于com.hazelcast.config包,在下文中一共展示了JoinConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.hazelcast.config.JoinConfig; //导入依赖的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: discoveryStrategyFactoryTest
import com.hazelcast.config.JoinConfig; //导入依赖的package包/类
@Test
public void discoveryStrategyFactoryTest() {
JCloudsDiscoveryStrategyFactory jCloudsDiscoveryStrategyFactory = new JCloudsDiscoveryStrategyFactory();
String xmlFileName = "test-jclouds-config.xml";
InputStream xmlResource = JCloudsDiscoveryFactoryTest.class.getClassLoader().getResourceAsStream(xmlFileName);
Config config = new XmlConfigBuilder(xmlResource).build();
JoinConfig joinConfig = config.getNetworkConfig().getJoin();
DiscoveryConfig discoveryConfig = joinConfig.getDiscoveryConfig();
DiscoveryStrategyConfig providerConfig = discoveryConfig.getDiscoveryStrategyConfigs().iterator().next();
assertEquals(jCloudsDiscoveryStrategyFactory.getDiscoveryStrategyType(), JCloudsDiscoveryStrategy.class);
assertEquals(JCloudsDiscoveryStrategy.class.getName(), providerConfig.getClassName());
assertEquals(jCloudsDiscoveryStrategyFactory.getConfigurationProperties().size(), providerConfig.getProperties().size());
assertTrue(jCloudsDiscoveryStrategyFactory.
newDiscoveryStrategy(null, null, new HashMap<String, Comparable>()) instanceof DiscoveryStrategy);
}
示例3: hazelcastConfig
import com.hazelcast.config.JoinConfig; //导入依赖的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: getConfig
import com.hazelcast.config.JoinConfig; //导入依赖的package包/类
private Config getConfig() {
Config config = new Config();
JoinConfig join = config.getNetworkConfig().getJoin();
join.getTcpIpConfig().setEnabled(true);
join.getTcpIpConfig().setMembers(cacheHosts);
join.getMulticastConfig().setEnabled(false);
join.getAwsConfig().setEnabled(false);
CacheConfig cacheConfig = configProvider.getCacheConfig(cacheHosts);
List<QuorumConfig> quorumConfigs = cacheConfig.getQuorumConfigs();
quorumConfigs.stream().forEach(q -> config.addQuorumConfig(q));
List<MapConfig> mapConfigs = cacheConfig.getMapConfigs();
mapConfigs.stream().forEach(c -> config.addMapConfig(c));
return config;
}
示例5: Transport
import com.hazelcast.config.JoinConfig; //导入依赖的package包/类
/**
* Initializes the {@link HazelcastInstance} for this global runtime instance.
*
* @param runtime
* the global runtime instance
* @param master
* member to connect to or null
* @param localhost
* the preferred ip address of this host or null
* @param compact
* reduce thread creation if set
* @param kryo
* use kryo serialization if set
*/
protected Transport(GlobalRuntimeImpl runtime, String master,
String localhost, boolean compact, boolean kryo) {
this.runtime = runtime;
// config
final Config config = new Config();
config.setProperty("hazelcast.logging.type", "none");
config.setProperty("hazelcast.wait.seconds.before.join", "0");
config.setProperty("hazelcast.socket.connect.timeout.seconds", "1");
config.setProperty("hazelcast.connection.monitor.max.faults", "0");
if (compact) {
config.setProperty("hazelcast.operation.thread.count", "2");
config.setProperty("hazelcast.operation.generic.thread.count", "2");
config.setProperty("hazelcast.io.thread.count", "2");
config.setProperty("hazelcast.event.thread.count", "2");
config.addExecutorConfig(
new ExecutorConfig(ExecutionService.ASYNC_EXECUTOR, 2));
config.addExecutorConfig(
new ExecutorConfig(ExecutionService.SYSTEM_EXECUTOR, 2));
config.addExecutorConfig(
new ExecutorConfig(ExecutionService.SCHEDULED_EXECUTOR, 2));
}
// kryo
if (kryo) {
config.getSerializationConfig().addSerializerConfig(
new SerializerConfig().setTypeClass(SerializableRunnable.class)
.setImplementation(new KryoSerializer()));
}
config.addMapConfig(
new MapConfig(APGAS_FINISH).setInMemoryFormat(InMemoryFormat.OBJECT));
// join config
final JoinConfig join = config.getNetworkConfig().getJoin();
join.getMulticastConfig().setEnabled(false);
join.getTcpIpConfig().setEnabled(true);
if (localhost != null) {
System.setProperty("hazelcast.local.localAddress", localhost);
}
if (master != null) {
join.getTcpIpConfig().addMember(master);
}
config.setInstanceName(APGAS);
hazelcast = Hazelcast.newHazelcastInstance(config);
me = hazelcast.getCluster().getLocalMember();
allMembers = hazelcast.getList(APGAS_PLACES);
allMembers.add(me);
int id = 0;
for (final Member member : allMembers) {
if (member.getUuid().equals(me.getUuid())) {
break;
}
++id;
}
here = id;
executor = hazelcast.getExecutorService(APGAS_EXECUTOR);
}
示例6: parseDiscoveryStrategyConfigPasses
import com.hazelcast.config.JoinConfig; //导入依赖的package包/类
@Test
public void parseDiscoveryStrategyConfigPasses() {
final AwsDiscoveryStrategyFactory factory = new AwsDiscoveryStrategyFactory();
final Config config = createConfig("test-aws-config.xml");
final JoinConfig joinConfig = config.getNetworkConfig().getJoin();
assertFalse(joinConfig.getAwsConfig().isEnabled());
assertFalse(joinConfig.getTcpIpConfig().isEnabled());
assertFalse(joinConfig.getMulticastConfig().isEnabled());
final DiscoveryConfig discoveryConfig = joinConfig.getDiscoveryConfig();
assertTrue(discoveryConfig.isEnabled());
assertEquals(1, discoveryConfig.getDiscoveryStrategyConfigs().size());
final DiscoveryStrategyConfig providerConfig = discoveryConfig.getDiscoveryStrategyConfigs().iterator().next();
final Map<String, Comparable> providerProperties = providerConfig.getProperties();
final Collection<PropertyDefinition> factoryConfigProperties = factory.getConfigurationProperties();
assertEquals(factory.getDiscoveryStrategyType(), AwsDiscoveryStrategy.class);
assertEquals(AwsDiscoveryStrategy.class.getName(), providerConfig.getClassName());
assertEquals(factoryConfigProperties.size(), providerProperties.size());
for (AwsProperties prop : AwsProperties.values()) {
assertTrue(factoryConfigProperties.contains(prop.getDefinition()));
}
assertEquals("test-access-key", providerProperties.get("access-key"));
assertEquals("test-secret-key", providerProperties.get("secret-key"));
assertEquals("test-region", providerProperties.get("region"));
assertEquals("test-iam-role", providerProperties.get("iam-role"));
assertEquals("ec2.test-host-header", providerProperties.get("host-header"));
assertEquals("test-security-group-name", providerProperties.get("security-group-name"));
assertEquals("test-tag-key", providerProperties.get("tag-key"));
assertEquals("test-tag-value", providerProperties.get("tag-value"));
assertEquals("10", providerProperties.get("connection-timeout-seconds"));
assertEquals("5702", providerProperties.get("hz-port"));
}
示例7: HazelcastSessionDao
import com.hazelcast.config.JoinConfig; //导入依赖的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.");
}
示例8: setNetworkJoin
import com.hazelcast.config.JoinConfig; //导入依赖的package包/类
private void setNetworkJoin(JoinConfig join) {
join.getMulticastConfig().setEnabled(false);
AwsConfig aws = join.getAwsConfig();
aws.setEnabled(false);
aws.setAccessKey("AKIAIA2GXRFAH4OTZN4A");
aws.setSecretKey("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");
setTcpIpConfig(join.getTcpIpConfig());
}
示例9: testParsing
import com.hazelcast.config.JoinConfig; //导入依赖的package包/类
@Test
public void testParsing() {
String xmlFileName = "test-jclouds-config.xml";
InputStream xmlResource = JCloudsDiscoveryFactoryTest.class.getClassLoader().getResourceAsStream(xmlFileName);
Config config = new XmlConfigBuilder(xmlResource).build();
JoinConfig joinConfig = config.getNetworkConfig().getJoin();
AwsConfig awsConfig = joinConfig.getAwsConfig();
assertFalse(awsConfig.isEnabled());
TcpIpConfig tcpIpConfig = joinConfig.getTcpIpConfig();
assertFalse(tcpIpConfig.isEnabled());
MulticastConfig multicastConfig = joinConfig.getMulticastConfig();
assertFalse(multicastConfig.isEnabled());
DiscoveryConfig discoveryConfig = joinConfig.getDiscoveryConfig();
assertTrue(discoveryConfig.isEnabled());
assertEquals(1, discoveryConfig.getDiscoveryStrategyConfigs().size());
DiscoveryStrategyConfig providerConfig = discoveryConfig.getDiscoveryStrategyConfigs().iterator().next();
assertEquals(12, providerConfig.getProperties().size());
assertEquals("aws-ec2", providerConfig.getProperties().get("provider"));
assertEquals("test", providerConfig.getProperties().get("identity"));
assertEquals("test", providerConfig.getProperties().get("credential"));
assertEquals("zone1,zone2", providerConfig.getProperties().get("zones"));
assertEquals("region1,region2", providerConfig.getProperties().get("regions"));
assertEquals("zone1,zone2", providerConfig.getProperties().get("zones"));
assertEquals("tag1,tag2", providerConfig.getProperties().get("tag-keys"));
assertEquals("tagvalue1,tagvalue2", providerConfig.getProperties().get("tag-values"));
assertEquals("group", providerConfig.getProperties().get("group"));
assertEquals("5702", providerConfig.getProperties().get("hz-port"));
assertEquals("myfile.json", providerConfig.getProperties().get("credentialPath"));
assertEquals("myRole", providerConfig.getProperties().get("role-name"));
assertEquals("http://foo/bar", providerConfig.getProperties().get("endpoint"));
}
示例10: before
import com.hazelcast.config.JoinConfig; //导入依赖的package包/类
@Before
public void before() throws Exception {
JetConfig config = new JetConfig();
config.getInstanceConfig().setCooperativeThreadCount(PARALLELISM);
Config hazelcastConfig = config.getHazelcastConfig();
final JoinConfig join = hazelcastConfig.getNetworkConfig().getJoin();
join.getMulticastConfig().setEnabled(false);
join.getTcpIpConfig().setEnabled(true).addMember("127.0.0.1");
for (int i = 1; i < NODE_COUNT; i++) {
instance = Jet.newJetInstance(config);
}
logger = instance.getHazelcastInstance().getLoggingService().getLogger(WordCountTest.class);
generateMockInput();
}
示例11: joinConfig
import com.hazelcast.config.JoinConfig; //导入依赖的package包/类
/**
* Only multicast and tcpip are currently supported.
*
* @return JoinConfig
*/
private JoinConfig joinConfig(final com.typesafe.config.Config config) {
final JoinConfig join = new JoinConfig();
join.setTcpIpConfig(tcpIpConfig(config));
join.setMulticastConfig(multicastConfig(config));
return join;
}
示例12: testDataMigration
import com.hazelcast.config.JoinConfig; //导入依赖的package包/类
@Test
@Ignore
public void testDataMigration() throws Exception {
Config shConfig = new Config();
shConfig.getNetworkConfig().setPortAutoIncrement(true);
shConfig.getGroupConfig().setName("schema");
shConfig.getGroupConfig().setPassword("schemapass");
JoinConfig shJoin = shConfig.getNetworkConfig().getJoin();
shJoin.getMulticastConfig().setEnabled(false);
shJoin.getTcpIpConfig().addMember("localhost").setEnabled(true);
shConfig.setProperty("hazelcast.logging.type", "slf4j");
MapConfig mConfig = new MapConfig("test");
mConfig.getMapStoreConfig().setEnabled(true);
mConfig.getMapStoreConfig().setWriteDelaySeconds(10);
mConfig.getMapStoreConfig().setImplementation(new TestCacheStore());
shConfig.addMapConfig(mConfig);
HazelcastInstance node1 = Hazelcast.newHazelcastInstance(shConfig);
populateCache(node1, "test", 1000);
System.out.println("population finished, time to start second node!");
Thread.sleep(50000);
//HazelcastInstance node2 = Hazelcast.newHazelcastInstance(shConfig);
//populateCache(node, "test", 1000);
//System.out.println("Second node started");
//Thread.sleep(5000);
}
示例13: HazelcastSessionDao
import com.hazelcast.config.JoinConfig; //导入依赖的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.");
}
示例14: main
import com.hazelcast.config.JoinConfig; //导入依赖的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();
}));
}
示例15: getConfig
import com.hazelcast.config.JoinConfig; //导入依赖的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;
}