Search in sources :

Example 1 with SPIAwareMemberGroupFactory

use of com.hazelcast.internal.partition.membergroup.SPIAwareMemberGroupFactory in project hazelcast by hazelcast.

the class DiscoverySpiTest method testSPIAwareMemberGroupFactoryCreateMemberGroups.

@Test
public void testSPIAwareMemberGroupFactoryCreateMemberGroups() throws Exception {
    String xmlFileName = "test-hazelcast-discovery-spi-metadata.xml";
    Config config = getDiscoverySPIConfig(xmlFileName, false);
    // we create this instance in order to fully create Node
    HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(config);
    Node node = getNode(hazelcastInstance);
    assertNotNull(node);
    MemberGroupFactory groupFactory = new SPIAwareMemberGroupFactory(node.getDiscoveryService());
    Collection<Member> members = createMembers();
    Collection<MemberGroup> memberGroups = groupFactory.createMemberGroups(members);
    assertEquals("Member Groups: " + String.valueOf(memberGroups), 2, memberGroups.size());
    for (MemberGroup memberGroup : memberGroups) {
        assertEquals("Member Group: " + String.valueOf(memberGroup), 2, memberGroup.size());
    }
    hazelcastInstance.shutdown();
}
Also used : MemberGroup(com.hazelcast.spi.partitiongroup.MemberGroup) DefaultMemberGroup(com.hazelcast.internal.partition.membergroup.DefaultMemberGroup) HazelcastInstance(com.hazelcast.core.HazelcastInstance) 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) Node(com.hazelcast.instance.impl.Node) Accessors.getNode(com.hazelcast.test.Accessors.getNode) SPIAwareMemberGroupFactory(com.hazelcast.internal.partition.membergroup.SPIAwareMemberGroupFactory) Member(com.hazelcast.cluster.Member) SPIAwareMemberGroupFactory(com.hazelcast.internal.partition.membergroup.SPIAwareMemberGroupFactory) MemberGroupFactory(com.hazelcast.internal.partition.membergroup.MemberGroupFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with SPIAwareMemberGroupFactory

use of com.hazelcast.internal.partition.membergroup.SPIAwareMemberGroupFactory in project hazelcast by hazelcast.

the class DiscoverySpiTest method testSPIAwareMemberGroupFactoryCreateMemberGroups_withDeprecated.

@Test
public void testSPIAwareMemberGroupFactoryCreateMemberGroups_withDeprecated() throws Exception {
    String xmlFileName = "test-hazelcast-discovery-spi-metadata.xml";
    Config config = getDiscoverySPIConfig(xmlFileName, true);
    // we create this instance in order to fully create Node
    HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(config);
    Node node = getNode(hazelcastInstance);
    assertNotNull(node);
    MemberGroupFactory groupFactory = new SPIAwareMemberGroupFactory(node.getDiscoveryService());
    Collection<Member> members = createMembers();
    Collection<MemberGroup> memberGroups = groupFactory.createMemberGroups(members);
    assertEquals("Member Groups: " + String.valueOf(memberGroups), 2, memberGroups.size());
    for (MemberGroup memberGroup : memberGroups) {
        assertEquals("Member Group: " + String.valueOf(memberGroup), 2, memberGroup.size());
    }
    hazelcastInstance.shutdown();
}
Also used : MemberGroup(com.hazelcast.spi.partitiongroup.MemberGroup) DefaultMemberGroup(com.hazelcast.internal.partition.membergroup.DefaultMemberGroup) HazelcastInstance(com.hazelcast.core.HazelcastInstance) 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) Node(com.hazelcast.instance.impl.Node) Accessors.getNode(com.hazelcast.test.Accessors.getNode) SPIAwareMemberGroupFactory(com.hazelcast.internal.partition.membergroup.SPIAwareMemberGroupFactory) Member(com.hazelcast.cluster.Member) SPIAwareMemberGroupFactory(com.hazelcast.internal.partition.membergroup.SPIAwareMemberGroupFactory) MemberGroupFactory(com.hazelcast.internal.partition.membergroup.MemberGroupFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with SPIAwareMemberGroupFactory

use of com.hazelcast.internal.partition.membergroup.SPIAwareMemberGroupFactory in project hazelcast by hazelcast.

the class DiscoverySpiTest method testSPIAwareMemberGroupFactoryInvalidConfig.

@Test(expected = RuntimeException.class)
public void testSPIAwareMemberGroupFactoryInvalidConfig() throws Exception {
    HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance();
    try {
        MemberGroupFactory groupFactory = new SPIAwareMemberGroupFactory(getNode(hazelcastInstance).getDiscoveryService());
        Collection<Member> members = createMembers();
        groupFactory.createMemberGroups(members);
    } finally {
        hazelcastInstance.shutdown();
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) SPIAwareMemberGroupFactory(com.hazelcast.internal.partition.membergroup.SPIAwareMemberGroupFactory) Member(com.hazelcast.cluster.Member) SPIAwareMemberGroupFactory(com.hazelcast.internal.partition.membergroup.SPIAwareMemberGroupFactory) MemberGroupFactory(com.hazelcast.internal.partition.membergroup.MemberGroupFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

Member (com.hazelcast.cluster.Member)3 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 MemberGroupFactory (com.hazelcast.internal.partition.membergroup.MemberGroupFactory)3 SPIAwareMemberGroupFactory (com.hazelcast.internal.partition.membergroup.SPIAwareMemberGroupFactory)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 Test (org.junit.Test)3 AwsConfig (com.hazelcast.config.AwsConfig)2 Config (com.hazelcast.config.Config)2 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)2 DiscoveryStrategyConfig (com.hazelcast.config.DiscoveryStrategyConfig)2 InterfacesConfig (com.hazelcast.config.InterfacesConfig)2 JoinConfig (com.hazelcast.config.JoinConfig)2 MulticastConfig (com.hazelcast.config.MulticastConfig)2 TcpIpConfig (com.hazelcast.config.TcpIpConfig)2 Node (com.hazelcast.instance.impl.Node)2 DefaultMemberGroup (com.hazelcast.internal.partition.membergroup.DefaultMemberGroup)2 MemberGroup (com.hazelcast.spi.partitiongroup.MemberGroup)2 Accessors.getNode (com.hazelcast.test.Accessors.getNode)2