Search in sources :

Example 86 with JoinConfig

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"));
}
Also used : AwsConfig(com.hazelcast.config.AwsConfig) XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) DiscoveryStrategyConfig(com.hazelcast.config.DiscoveryStrategyConfig) InputStream(java.io.InputStream) AwsConfig(com.hazelcast.config.AwsConfig) DiscoveryStrategyConfig(com.hazelcast.config.DiscoveryStrategyConfig) MulticastConfig(com.hazelcast.config.MulticastConfig) JoinConfig(com.hazelcast.config.JoinConfig) Config(com.hazelcast.config.Config) DiscoveryConfig(com.hazelcast.config.DiscoveryConfig) TcpIpConfig(com.hazelcast.config.TcpIpConfig) InterfacesConfig(com.hazelcast.config.InterfacesConfig) JoinConfig(com.hazelcast.config.JoinConfig) MulticastConfig(com.hazelcast.config.MulticastConfig) TcpIpConfig(com.hazelcast.config.TcpIpConfig) DiscoveryConfig(com.hazelcast.config.DiscoveryConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 87 with JoinConfig

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();
        }
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) DiscoveryStrategyConfig(com.hazelcast.config.DiscoveryStrategyConfig) AwsConfig(com.hazelcast.config.AwsConfig) DiscoveryStrategyConfig(com.hazelcast.config.DiscoveryStrategyConfig) MulticastConfig(com.hazelcast.config.MulticastConfig) JoinConfig(com.hazelcast.config.JoinConfig) Config(com.hazelcast.config.Config) DiscoveryConfig(com.hazelcast.config.DiscoveryConfig) TcpIpConfig(com.hazelcast.config.TcpIpConfig) InterfacesConfig(com.hazelcast.config.InterfacesConfig) JoinConfig(com.hazelcast.config.JoinConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 88 with JoinConfig

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);
}
Also used : DiscoveryStrategyConfig(com.hazelcast.config.DiscoveryStrategyConfig) AwsConfig(com.hazelcast.config.AwsConfig) DiscoveryStrategyConfig(com.hazelcast.config.DiscoveryStrategyConfig) MulticastConfig(com.hazelcast.config.MulticastConfig) JoinConfig(com.hazelcast.config.JoinConfig) Config(com.hazelcast.config.Config) DiscoveryConfig(com.hazelcast.config.DiscoveryConfig) TcpIpConfig(com.hazelcast.config.TcpIpConfig) InterfacesConfig(com.hazelcast.config.InterfacesConfig) JoinConfig(com.hazelcast.config.JoinConfig) DiscoveryConfig(com.hazelcast.config.DiscoveryConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 89 with JoinConfig

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();
}
Also used : JoinConfig(com.hazelcast.config.JoinConfig) Config(com.hazelcast.config.Config) JetConfig(com.hazelcast.jet.config.JetConfig) JoinConfig(com.hazelcast.config.JoinConfig) JetConfig(com.hazelcast.jet.config.JetConfig) Before(org.junit.Before)

Example 90 with JoinConfig

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());
}
Also used : NetworkConfig(com.hazelcast.config.NetworkConfig) JoinConfig(com.hazelcast.config.JoinConfig) SpringManagedContext(com.hazelcast.spring.context.SpringManagedContext) TcpIpConfig(com.hazelcast.config.TcpIpConfig)

Aggregations

JoinConfig (com.hazelcast.config.JoinConfig)90 Config (com.hazelcast.config.Config)64 NetworkConfig (com.hazelcast.config.NetworkConfig)32 Test (org.junit.Test)32 TcpIpConfig (com.hazelcast.config.TcpIpConfig)27 QuickTest (com.hazelcast.test.annotation.QuickTest)20 InterfacesConfig (com.hazelcast.config.InterfacesConfig)18 HazelcastInstance (com.hazelcast.core.HazelcastInstance)18 MulticastConfig (com.hazelcast.config.MulticastConfig)15 PartitionGroupConfig (com.hazelcast.config.PartitionGroupConfig)15 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)13 SlowTest (com.hazelcast.test.annotation.SlowTest)12 DiscoveryStrategyConfig (com.hazelcast.config.DiscoveryStrategyConfig)11 RealmConfig (com.hazelcast.config.security.RealmConfig)11 ClientConfig (com.hazelcast.client.config.ClientConfig)9 ListenerConfig (com.hazelcast.config.ListenerConfig)8 AwsConfig (com.hazelcast.config.AwsConfig)7 MemberAttributeConfig (com.hazelcast.config.MemberAttributeConfig)7 ServerSocketEndpointConfig (com.hazelcast.config.ServerSocketEndpointConfig)6 CountDownLatch (java.util.concurrent.CountDownLatch)6