Search in sources :

Example 1 with SPIAwareMemberGroupFactory

use of com.hazelcast.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);
    // we create this instance in order to fully create Node
    HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(config);
    Node node = TestUtil.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 : DefaultMemberGroup(com.hazelcast.partition.membergroup.DefaultMemberGroup) MemberGroup(com.hazelcast.partition.membergroup.MemberGroup) 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.Node) SPIAwareMemberGroupFactory(com.hazelcast.partition.membergroup.SPIAwareMemberGroupFactory) Member(com.hazelcast.core.Member) MemberGroupFactory(com.hazelcast.partition.membergroup.MemberGroupFactory) SPIAwareMemberGroupFactory(com.hazelcast.partition.membergroup.SPIAwareMemberGroupFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with SPIAwareMemberGroupFactory

use of com.hazelcast.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(TestUtil.getNode(hazelcastInstance).getDiscoveryService());
        Collection<Member> members = createMembers();
        groupFactory.createMemberGroups(members);
    } finally {
        hazelcastInstance.shutdown();
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) SPIAwareMemberGroupFactory(com.hazelcast.partition.membergroup.SPIAwareMemberGroupFactory) Member(com.hazelcast.core.Member) MemberGroupFactory(com.hazelcast.partition.membergroup.MemberGroupFactory) SPIAwareMemberGroupFactory(com.hazelcast.partition.membergroup.SPIAwareMemberGroupFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 Member (com.hazelcast.core.Member)2 MemberGroupFactory (com.hazelcast.partition.membergroup.MemberGroupFactory)2 SPIAwareMemberGroupFactory (com.hazelcast.partition.membergroup.SPIAwareMemberGroupFactory)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2 AwsConfig (com.hazelcast.config.AwsConfig)1 Config (com.hazelcast.config.Config)1 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)1 DiscoveryStrategyConfig (com.hazelcast.config.DiscoveryStrategyConfig)1 InterfacesConfig (com.hazelcast.config.InterfacesConfig)1 JoinConfig (com.hazelcast.config.JoinConfig)1 MulticastConfig (com.hazelcast.config.MulticastConfig)1 TcpIpConfig (com.hazelcast.config.TcpIpConfig)1 Node (com.hazelcast.instance.Node)1 DefaultMemberGroup (com.hazelcast.partition.membergroup.DefaultMemberGroup)1 MemberGroup (com.hazelcast.partition.membergroup.MemberGroup)1