Search in sources :

Example 21 with MemberGroup

use of com.hazelcast.spi.partitiongroup.MemberGroup in project hazelcast by hazelcast.

the class MemberGroupFactoryTest method testConfigMemberGroupFactoryCreateMemberGroups_withNonMatchingMembers.

/**
 * When there is a matching {@link MemberGroupConfig} for a {@link Member}, it will be assigned to a {@link MemberGroup}.
 * <p>
 * In this test half of the members will have a matching configuration, so there will be 2 groups with 2 members each.
 */
@Test
public void testConfigMemberGroupFactoryCreateMemberGroups_withNonMatchingMembers() {
    Collection<Member> members = createMembers();
    Collection<MemberGroupConfig> groupConfigs = createMemberGroupConfigs(false);
    MemberGroupFactory groupFactory = new ConfigMemberGroupFactory(groupConfigs);
    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());
    }
}
Also used : MemberGroup(com.hazelcast.spi.partitiongroup.MemberGroup) Member(com.hazelcast.cluster.Member) MemberGroupConfig(com.hazelcast.config.MemberGroupConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 22 with MemberGroup

use of com.hazelcast.spi.partitiongroup.MemberGroup in project hazelcast by hazelcast.

the class MemberGroupFactoryTest method testZoneMetadataAwareMemberGroupFactoryCreateMemberGroups.

@Test
public void testZoneMetadataAwareMemberGroupFactoryCreateMemberGroups() {
    MemberGroupFactory groupFactory = new ZoneAwareMemberGroupFactory();
    Collection<Member> members = createMembersWithZoneAwareMetadata();
    Collection<MemberGroup> memberGroups = groupFactory.createMemberGroups(members);
    assertEquals("Member Groups: " + String.valueOf(memberGroups), 3, memberGroups.size());
    for (MemberGroup memberGroup : memberGroups) {
        assertEquals("Member Group: " + String.valueOf(memberGroup), 1, memberGroup.size());
    }
}
Also used : MemberGroup(com.hazelcast.spi.partitiongroup.MemberGroup) Member(com.hazelcast.cluster.Member) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 23 with MemberGroup

use of com.hazelcast.spi.partitiongroup.MemberGroup 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)

Aggregations

MemberGroup (com.hazelcast.spi.partitiongroup.MemberGroup)23 Member (com.hazelcast.cluster.Member)20 QuickTest (com.hazelcast.test.annotation.QuickTest)10 Test (org.junit.Test)10 DefaultMemberGroup (com.hazelcast.internal.partition.membergroup.DefaultMemberGroup)6 MemberGroupFactory (com.hazelcast.internal.partition.membergroup.MemberGroupFactory)5 HashSet (java.util.HashSet)5 PartitionReplica (com.hazelcast.internal.partition.PartitionReplica)4 Address (com.hazelcast.cluster.Address)3 MemberImpl (com.hazelcast.cluster.impl.MemberImpl)3 MemberGroupConfig (com.hazelcast.config.MemberGroupConfig)3 Node (com.hazelcast.instance.impl.Node)3 Collection (java.util.Collection)3 ClusterState (com.hazelcast.cluster.ClusterState)2 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