throw ClusterConfigException
.RACKPOLICY_WITH_NO_MAPPING_INFO_EXIST(ngc.getName());
}
GroupRacks r = policies.getGroupRacks();
GroupRacksType rackType = r.getType();
Set<String> specifiedRacks =
new HashSet<String>(Arrays.asList(r.getRacks()));
if (rackType.equals(GroupRacksType.SAMERACK)
&& specifiedRacks.size() != 1) {
throw ClusterConfigException.MUST_DEFINE_ONE_RACK(ngc.getName());
}
List<String> intersecRacks = new ArrayList<String>();
int intersecHostNum = 0;
int maxIntersecHostNum = 0;
for (RackInfo rackInfo : racksInfo) {
if (specifiedRacks.isEmpty() || specifiedRacks.size() == 0
|| specifiedRacks.contains(rackInfo.getName())) {
intersecHostNum += rackInfo.getHosts().size();
intersecRacks.add(rackInfo.getName());
if (rackInfo.getHosts().size() > maxIntersecHostNum) {
maxIntersecHostNum = rackInfo.getHosts().size();
}
}
}
if (intersecRacks.size() == 0) {
valid = false;
throw ClusterConfigException.NO_VALID_RACK(ngc.getName());
}
if (ngc.calculateHostNum() != null) {
if (rackType.equals(GroupRacksType.ROUNDROBIN)
&& ngc.calculateHostNum() > intersecHostNum) {
valid = false;
throw ClusterConfigException.LACK_PHYSICAL_HOSTS(
ngc.calculateHostNum(), ngc.getName(), intersecHostNum);
} else if (rackType.equals(GroupRacksType.SAMERACK)
&& ngc.calculateHostNum() > maxIntersecHostNum) {
valid = false;
throw ClusterConfigException.LACK_PHYSICAL_HOSTS(
ngc.calculateHostNum(), ngc.getName(),
maxIntersecHostNum);