Search in sources :

Example 11 with MemberGroupConfig

use of com.hazelcast.config.MemberGroupConfig 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 12 with MemberGroupConfig

use of com.hazelcast.config.MemberGroupConfig in project hazelcast by hazelcast.

the class MemberGroupFactoryTest method createMemberGroupConfigs.

private Collection<MemberGroupConfig> createMemberGroupConfigs(boolean addHostnameConfigs) {
    Collection<MemberGroupConfig> groupConfigs = new HashSet<MemberGroupConfig>();
    MemberGroupConfig group1 = new MemberGroupConfig();
    group1.addInterface("192.168.*.*");
    MemberGroupConfig group2 = new MemberGroupConfig();
    group2.addInterface("172.16.*.*");
    MemberGroupConfig group3 = new MemberGroupConfig();
    group3.addInterface("*.hazelcast.com");
    MemberGroupConfig group4 = new MemberGroupConfig();
    group4.addInterface("www.hazelcast.org");
    groupConfigs.add(group1);
    groupConfigs.add(group2);
    if (addHostnameConfigs) {
        groupConfigs.add(group3);
        groupConfigs.add(group4);
    }
    return groupConfigs;
}
Also used : MemberGroupConfig(com.hazelcast.config.MemberGroupConfig) HashSet(java.util.HashSet)

Aggregations

MemberGroupConfig (com.hazelcast.config.MemberGroupConfig)12 PartitionGroupConfig (com.hazelcast.config.PartitionGroupConfig)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 HashSet (java.util.HashSet)4 Test (org.junit.Test)4 Member (com.hazelcast.cluster.Member)3 MemberGroup (com.hazelcast.spi.partitiongroup.MemberGroup)3 Config (com.hazelcast.config.Config)2 HashMap (java.util.HashMap)2 Node (org.w3c.dom.Node)2 EvictionConfig (com.hazelcast.config.EvictionConfig)1 MapConfig (com.hazelcast.config.MapConfig)1 Member (com.hazelcast.core.Member)1 ConfigMemberGroupFactory (com.hazelcast.internal.partition.membergroup.ConfigMemberGroupFactory)1 MapUtil.createLinkedHashMap (com.hazelcast.internal.util.MapUtil.createLinkedHashMap)1 YamlNode (com.hazelcast.internal.yaml.YamlNode)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 LinkedHashMap (java.util.LinkedHashMap)1