use of com.hazelcast.config.JoinConfig in project hazelcast by hazelcast.
the class DiscoverySpiTest method testParsing.
@Test
public void testParsing() throws Exception {
String xmlFileName = "test-hazelcast-discovery-spi.xml";
InputStream xmlResource = DiscoverySpiTest.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(3, providerConfig.getProperties().size());
assertEquals("foo", providerConfig.getProperties().get("key-string"));
assertEquals("123", providerConfig.getProperties().get("key-int"));
assertEquals("true", providerConfig.getProperties().get("key-boolean"));
}
use of com.hazelcast.config.JoinConfig in project hazelcast by hazelcast.
the class DiscoverySpiTest method testMemberGroup_givenSPIMemberGroupIsActived_whenInstanceStarting_wontThrowNPE.
@Test
public void testMemberGroup_givenSPIMemberGroupIsActived_whenInstanceStarting_wontThrowNPE() {
// this test has no assert. it's a regression test checking an instance can start when a SPI-driven member group
// strategy is configured. see #11681
Config config = new Config();
config.setProperty(ClusterProperty.DISCOVERY_SPI_ENABLED.getName(), "true");
JoinConfig joinConfig = config.getNetworkConfig().getJoin();
joinConfig.getMulticastConfig().setEnabled(false);
DiscoveryStrategyConfig discoveryStrategyConfig = new DiscoveryStrategyConfig(MetadataProvidingDiscoveryStrategy.class.getName());
joinConfig.getDiscoveryConfig().addDiscoveryStrategyConfig(discoveryStrategyConfig);
config.getPartitionGroupConfig().setGroupType(SPI).setEnabled(true);
HazelcastInstance hazelcastInstance = null;
try {
// check the instance can actually be started
hazelcastInstance = Hazelcast.newHazelcastInstance(config);
} finally {
if (hazelcastInstance != null) {
hazelcastInstance.shutdown();
}
}
}
use of com.hazelcast.config.JoinConfig in project hazelcast by hazelcast.
the class DiscoverySpiTest method givenDiscoveryStrategyFactoryExistOnClassPath_whenTheSameFactoryIsConfiguredExplicitly_thenOnlyOneInstanceOfStrategyIsCreated.
@Test
public void givenDiscoveryStrategyFactoryExistOnClassPath_whenTheSameFactoryIsConfiguredExplicitly_thenOnlyOneInstanceOfStrategyIsCreated() {
// ParametrizedDiscoveryStrategy has a static counter and throws an exception when its instantiated more than
// than once.
Config config = new Config();
config.setProperty(ClusterProperty.DISCOVERY_SPI_ENABLED.getName(), "true");
JoinConfig join = config.getNetworkConfig().getJoin();
join.getMulticastConfig().setEnabled(false);
DiscoveryConfig discoveryConfig = join.getDiscoveryConfig();
DiscoveryStrategyConfig strategyConfig = new DiscoveryStrategyConfig(new ParametrizedDiscoveryStrategyFactory());
strategyConfig.addProperty("bool-property", true);
discoveryConfig.addDiscoveryStrategyConfig(strategyConfig);
// this will fail when the discovery strategy throws an exception
createHazelcastInstance(config);
}
use of com.hazelcast.config.JoinConfig in project hazelcast-jet by hazelcast.
the class WordCountTest method before.
@Before
public void before() {
JetConfig config = new JetConfig();
config.getInstanceConfig().setCooperativeThreadCount(PARALLELISM);
Config hazelcastConfig = config.getHazelcastConfig();
hazelcastConfig.getGroupConfig().setName(randomName());
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();
}
use of com.hazelcast.config.JoinConfig in project hazelcast-jet by hazelcast.
the class TestApplicationContext method assertHazelcastConfig.
private void assertHazelcastConfig(Config cfg) {
assertTrue(cfg.getManagedContext() instanceof SpringManagedContext);
assertEquals("jet-spring", cfg.getGroupConfig().getName());
NetworkConfig networkConfig = cfg.getNetworkConfig();
assertEquals(5707, networkConfig.getPort());
assertFalse(networkConfig.isPortAutoIncrement());
JoinConfig join = networkConfig.getJoin();
assertFalse(join.getMulticastConfig().isEnabled());
TcpIpConfig tcpIpConfig = join.getTcpIpConfig();
assertTrue(tcpIpConfig.isEnabled());
List<String> members = tcpIpConfig.getMembers();
assertEquals(1, members.size());
assertEquals("127.0.0.1:5707", members.get(0));
assertEquals(3, cfg.getMapConfig("map").getBackupCount());
}
Aggregations