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

项目: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    文件:PartitionStateGeneratorFactory.java   
public static MemberGroupFactory newMemberGroupFactory(PartitionGroupConfig partitionGroupConfig) {
    if (partitionGroupConfig == null || !partitionGroupConfig.isEnabled()) {
        return new SingleMemberGroupFactory();
    }
    switch (partitionGroupConfig.getGroupType()) {
        case HOST_AWARE:
            return new HostAwareMemberGroupFactory();
        case CUSTOM:
            return new ConfigMemberGroupFactory(partitionGroupConfig.getMemberGroupConfigs());
        default:
            return new SingleMemberGroupFactory();
    }
}
项目: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()));
}
项目:hazelcast-archive    文件:PartitionStateGeneratorTest.java   
@Test
public void testXmlPartitionGroupConfig() {
    Config config = new ClasspathXmlConfig("hazelcast-fullconfig.xml");
    PartitionGroupConfig partitionGroupConfig = config.getPartitionGroupConfig();
    Assert.assertFalse(partitionGroupConfig.isEnabled());
    Assert.assertEquals(MemberGroupType.CUSTOM, partitionGroupConfig.getGroupType());
    Assert.assertEquals(2, partitionGroupConfig.getMemberGroupConfigs().size());
}
项目:health-and-care-developer-network    文件:PartitionStateGeneratorFactory.java   
public static MemberGroupFactory newMemberGroupFactory(PartitionGroupConfig partitionGroupConfig) {
    if (partitionGroupConfig == null || !partitionGroupConfig.isEnabled()) {
        return new SingleMemberGroupFactory();
    }
    switch (partitionGroupConfig.getGroupType()) {
        case HOST_AWARE:
            return new HostAwareMemberGroupFactory();
        case CUSTOM:
            return new ConfigMemberGroupFactory(partitionGroupConfig.getMemberGroupConfigs());
        default:
            return new SingleMemberGroupFactory();
    }
}
项目: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()));
}
项目:health-and-care-developer-network    文件:PartitionStateGeneratorTest.java   
@Test
public void testXmlPartitionGroupConfig() {
    Config config = new ClasspathXmlConfig("hazelcast-fullconfig.xml");
    PartitionGroupConfig partitionGroupConfig = config.getPartitionGroupConfig();
    Assert.assertFalse(partitionGroupConfig.isEnabled());
    Assert.assertEquals(MemberGroupType.CUSTOM, partitionGroupConfig.getGroupType());
    Assert.assertEquals(2, partitionGroupConfig.getMemberGroupConfigs().size());
}
项目:hazelcast-archive    文件:PartitionStateGeneratorFactory.java   
public static PartitionStateGenerator newConfigPartitionStateGenerator(PartitionGroupConfig partitionGroupConfig) {
    return newCustomPartitionStateGenerator(newMemberGroupFactory(partitionGroupConfig));
}
项目:health-and-care-developer-network    文件:PartitionStateGeneratorFactory.java   
public static PartitionStateGenerator newConfigPartitionStateGenerator(PartitionGroupConfig partitionGroupConfig) {
    return newCustomPartitionStateGenerator(newMemberGroupFactory(partitionGroupConfig));
}