Java 类com.hazelcast.config.MemberGroupConfig 实例源码

项目:hazelcast-archive    文件:ConfigMemberGroupFactory.java   
public Collection<MemberGroup> createMemberGroups(Collection<MemberImpl> members) {
    final Map<Integer, MemberGroup> memberGroups = new HashMap<Integer, MemberGroup>();
    for (MemberImpl member : members) {
        if (member.isLiteMember()) {
            continue;
        }
        for (Entry<Integer, MemberGroupConfig> groupConfigEntry : memberGroupConfigMap.entrySet()) {
            if (AddressPicker.matchAddress(member.getAddress().getHost(), groupConfigEntry.getValue().getInterfaces())) {
                MemberGroup group = memberGroups.get(groupConfigEntry.getKey());
                if (group == null) {
                    group = new DefaultMemberGroup();
                    memberGroups.put(groupConfigEntry.getKey(), group);
                }
                group.addMember(member);
                break;
            }
        }
    }
    return memberGroups.values();
}
项目:health-and-care-developer-network    文件:ConfigMemberGroupFactory.java   
protected Set<MemberGroup> createInternalMemberGroups(Collection<MemberImpl> members) {
    final Map<Integer, MemberGroup> memberGroups = new HashMap<Integer, MemberGroup>();
    for (MemberImpl member : members) {
        if (member.isLiteMember()) {
            continue;
        }
        for (Entry<Integer, MemberGroupConfig> groupConfigEntry : memberGroupConfigMap.entrySet()) {
            if (AddressUtil.matchAnyInterface(member.getAddress().getHost(), groupConfigEntry.getValue().getInterfaces())) {
                MemberGroup group = memberGroups.get(groupConfigEntry.getKey());
                if (group == null) {
                    group = new DefaultMemberGroup();
                    memberGroups.put(groupConfigEntry.getKey(), group);
                }
                group.addMember(member);
                break;
            }
        }
    }
    return new HashSet<MemberGroup>(memberGroups.values());
}
项目:eet.osslite.cz    文件:HazelcastConfiguration.java   
private void setPartitionGroup(PartitionGroupConfig partitionGroup) {
    partitionGroup.setEnabled(false);
    partitionGroup.setGroupType(MemberGroupType.CUSTOM);

    MemberGroupConfig memberGroupConfig = new MemberGroupConfig();
    memberGroupConfig.addInterface("10.10.0.*").addInterface("10.10.3.*").addInterface("10.10.5.*");
    partitionGroup.addMemberGroupConfig(memberGroupConfig);
}
项目:runrightfast-vertx    文件:TypesafeHazelcastConfig.java   
private PartitionGroupConfig partitionConfig(final com.typesafe.config.Config c) {
    final PartitionGroupConfig partitionGroupConfig = new PartitionGroupConfig();
    partitionGroupConfig.setEnabled(true);
    partitionGroupConfig.setGroupType(ConfigUtils.getString(c, "group-type").map(MemberGroupType::valueOf).orElseThrow(new ConfigurationExceptionSupplier("name is required")));
    if (partitionGroupConfig.getGroupType().equals(CUSTOM)) {
        ConfigUtils.getConfigList(c, "member-group-configs").ifPresent(memberGroupConfigs -> {
            memberGroupConfigs.stream().forEach(memberGroupConfig -> {
                final MemberGroupConfig _memberGroupConfig = new MemberGroupConfig();
                _memberGroupConfig.setInterfaces(ConfigUtils.getStringList(memberGroupConfig, "interfaces").orElseThrow(new ConfigurationExceptionSupplier("no interfaces were defined for the MemberGroupConfig")));
                partitionGroupConfig.addMemberGroupConfig(_memberGroupConfig);
            });
        });
    }
    return partitionGroupConfig;
}
项目:hazelcast-archive    文件:ConfigMemberGroupFactory.java   
public ConfigMemberGroupFactory(Collection<MemberGroupConfig> memberGroupConfigs) {
    super();
    this.memberGroupConfigMap = new LinkedHashMap<Integer, MemberGroupConfig>();
    int key = 0;
    for (MemberGroupConfig groupConfig : memberGroupConfigs) {
        memberGroupConfigMap.put(key++, groupConfig);
    }
}
项目:hazelcast-archive    文件:PartitionStateGeneratorTest.java   
@Test
public void testConfigCustomPartitionStateGenerator() throws Exception {
    PartitionGroupConfig config = new PartitionGroupConfig();
    config.setEnabled(true);
    config.setGroupType(MemberGroupType.CUSTOM);
    config.addMemberGroupConfig(new MemberGroupConfig().addInterface("10.10.0.0").addInterface("10.10.0.2"))
            .addMemberGroupConfig(new MemberGroupConfig().addInterface("10.10.0.3-5"))
            .addMemberGroupConfig(new MemberGroupConfig().addInterface("10.10.0.6").addInterface("10.10.0.7").addInterface("10.10.0.8"))
            .addMemberGroupConfig(new MemberGroupConfig().addInterface("10.10.0.9-100"));
    PartitionStateGenerator generator = PartitionStateGeneratorFactory.newConfigPartitionStateGenerator(config);
    test(generator, new ConfigMemberGroupFactory(config.getMemberGroupConfigs()));
}
项目:health-and-care-developer-network    文件:ConfigMemberGroupFactory.java   
public ConfigMemberGroupFactory(Collection<MemberGroupConfig> memberGroupConfigs) {
    super();
    this.memberGroupConfigMap = new LinkedHashMap<Integer, MemberGroupConfig>();
    int key = 0;
    for (MemberGroupConfig groupConfig : memberGroupConfigs) {
        memberGroupConfigMap.put(key++, groupConfig);
    }
}
项目:health-and-care-developer-network    文件:PartitionStateGeneratorTest.java   
@Test
public void testConfigCustomPartitionStateGenerator() throws Exception {
    PartitionGroupConfig config = new PartitionGroupConfig();
    config.setEnabled(true);
    config.setGroupType(MemberGroupType.CUSTOM);
    config.addMemberGroupConfig(new MemberGroupConfig().addInterface("10.10.0.0").addInterface("10.10.0.2"))
            .addMemberGroupConfig(new MemberGroupConfig().addInterface("10.10.0.3-5"))
            .addMemberGroupConfig(new MemberGroupConfig().addInterface("10.10.0.6").addInterface("10.10.0.7").addInterface("10.10.0.8"))
            .addMemberGroupConfig(new MemberGroupConfig().addInterface("10.10.0.9-100"));
    PartitionStateGenerator generator = PartitionStateGeneratorFactory.newConfigPartitionStateGenerator(config);
    test(generator, new ConfigMemberGroupFactory(config.getMemberGroupConfigs()));
}