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); }
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; }
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(); } }
@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())); }
@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()); }
public static PartitionStateGenerator newConfigPartitionStateGenerator(PartitionGroupConfig partitionGroupConfig) { return newCustomPartitionStateGenerator(newMemberGroupFactory(partitionGroupConfig)); }