*/
single = false;
if (groups.containsKey(referredGroup.getName())) {
groups.get(referredGroup.getName()).addNodeGroup(nodeGroup);
} else {
VirtualGroup vGroup = new VirtualGroup(this.cluster);
vGroup.addNodeGroup(nodeGroup);
vGroup.addNodeGroup(referredGroup);
groups.put(referredGroup.getName(), vGroup);
}
}
}
if (single) {
VirtualGroup vGroup = new VirtualGroup(this.cluster);
vGroup.addNodeGroup(nodeGroup);
groups.put(nodeGroup.getName(), vGroup);
}
}
/*
* mark the groups that are referenced by others. they should be placed first
* Note that the group association policy has the assumption that:
* 1. only one level of reference, i.e., if A is referred by B,
* B cannot be referred by others
* 2. not allow the reference to multiple groups, i.e., if A refers to B,
* A cannot refer to any others
*/
for (NodeGroupCreate nodeGroup : cluster.getNodeGroups()) {
if (nodeGroup.getReferredGroup() != null) {
AuAssert.check(groups.containsKey(nodeGroup.getReferredGroup()));
groups.get(nodeGroup.getReferredGroup()).setReferred(true);
if (groups.containsKey(nodeGroup.getName())) {
groups.get(nodeGroup.getName()).setReferToGroup(
nodeGroup.getReferredGroup());
if (nodeGroup.isStrictReferred()) {
groups.get(nodeGroup.getName()).setStrictAssociated(true);
}
}
}
}
List<VirtualGroup> vGroups = new ArrayList<VirtualGroup>(groups.values());
// process the instance_per_host policy
for (VirtualGroup vGroup : vGroups) {
vGroup.setvNodes(getVirtualNodes(vGroup, existedNodes));
}
return vGroups;
}