Search in sources :

Example 1 with MemberGroupConfig

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

the class MemberGroupFactoryTest method createMemberGroupConfigs.

private Collection<MemberGroupConfig> createMemberGroupConfigs() {
    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);
    groupConfigs.add(group3);
    groupConfigs.add(group4);
    return groupConfigs;
}
Also used : MemberGroupConfig(com.hazelcast.config.MemberGroupConfig) HashSet(java.util.HashSet)

Example 2 with MemberGroupConfig

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

the class TestFullApplicationContext method testPartitionGroupConfig.

@Test
public void testPartitionGroupConfig() {
    PartitionGroupConfig pgc = config.getPartitionGroupConfig();
    assertFalse(pgc.isEnabled());
    assertEquals(PartitionGroupConfig.MemberGroupType.CUSTOM, pgc.getGroupType());
    assertEquals(2, pgc.getMemberGroupConfigs().size());
    for (MemberGroupConfig mgc : pgc.getMemberGroupConfigs()) {
        assertEquals(2, mgc.getInterfaces().size());
    }
}
Also used : PartitionGroupConfig(com.hazelcast.config.PartitionGroupConfig) MemberGroupConfig(com.hazelcast.config.MemberGroupConfig) Test(org.junit.Test) QuickTest(com.hazelcast.test.annotation.QuickTest)

Example 3 with MemberGroupConfig

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

the class ConfigMemberGroupFactory method createInternalMemberGroups.

@Override
protected Set<MemberGroup> createInternalMemberGroups(Collection<? extends Member> members) {
    Map<Integer, MemberGroup> memberGroups = new HashMap<Integer, MemberGroup>();
    for (Member member : members) {
        String host = ((MemberImpl) member).getAddress().getHost();
        for (Entry<Integer, MemberGroupConfig> entry : memberGroupConfigMap.entrySet()) {
            Collection<String> interfaces = entry.getValue().getInterfaces();
            boolean match;
            if (AddressUtil.isIpAddress(host)) {
                match = AddressUtil.matchAnyInterface(host, interfaces);
            } else {
                match = AddressUtil.matchAnyDomain(host, interfaces);
            }
            if (match) {
                MemberGroup group = memberGroups.get(entry.getKey());
                if (group == null) {
                    group = new DefaultMemberGroup();
                    memberGroups.put(entry.getKey(), group);
                }
                group.addMember(member);
                break;
            }
        }
    }
    return new HashSet<MemberGroup>(memberGroups.values());
}
Also used : MemberGroup(com.hazelcast.spi.partitiongroup.MemberGroup) MapUtil.createLinkedHashMap(com.hazelcast.internal.util.MapUtil.createLinkedHashMap) HashMap(java.util.HashMap) Member(com.hazelcast.cluster.Member) MemberGroupConfig(com.hazelcast.config.MemberGroupConfig) HashSet(java.util.HashSet)

Example 4 with MemberGroupConfig

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

the class YamlMemberDomConfigProcessor method handleMemberGroup.

@Override
protected void handleMemberGroup(Node node, Config config) {
    for (Node memberGroupNode : childElements(node)) {
        MemberGroupConfig memberGroupConfig = new MemberGroupConfig();
        for (Node interfacesNode : childElements(memberGroupNode)) {
            memberGroupConfig.addInterface(interfacesNode.getNodeValue().trim());
        }
        config.getPartitionGroupConfig().addMemberGroupConfig(memberGroupConfig);
    }
}
Also used : Node(org.w3c.dom.Node) YamlNode(com.hazelcast.internal.yaml.YamlNode) MemberGroupConfig(com.hazelcast.config.MemberGroupConfig)

Example 5 with MemberGroupConfig

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

the class LocalMapStatsMultipleNodeTest method createConfig.

private Config createConfig(String mapName, String[] firstGroup, String[] secondGroup) {
    final MemberGroupConfig firstGroupConfig = createGroupConfig(firstGroup);
    final MemberGroupConfig secondGroupConfig = createGroupConfig(secondGroup);
    Config config = getConfig();
    config.getPartitionGroupConfig().setEnabled(true).setGroupType(PartitionGroupConfig.MemberGroupType.CUSTOM);
    config.getPartitionGroupConfig().addMemberGroupConfig(firstGroupConfig);
    config.getPartitionGroupConfig().addMemberGroupConfig(secondGroupConfig);
    config.getNetworkConfig().getInterfaces().addInterface("127.0.0.*");
    config.getMapConfig(mapName).setBackupCount(2);
    return config;
}
Also used : MapConfig(com.hazelcast.config.MapConfig) EvictionConfig(com.hazelcast.config.EvictionConfig) Config(com.hazelcast.config.Config) MemberGroupConfig(com.hazelcast.config.MemberGroupConfig) PartitionGroupConfig(com.hazelcast.config.PartitionGroupConfig) MemberGroupConfig(com.hazelcast.config.MemberGroupConfig)

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