private static final Logger logger = Logger.getLogger(CommonClusterExpandPolicy.class);
public static void expandGroupInstanceType(NodeGroupEntity ngEntity, NodeGroupCreate group,
Set<String> sharedPattern, Set<String> localPattern, SoftwareManager softwareManager) {
logger.debug("Expand instance type config for group " + ngEntity.getName());
InstanceType instanceType = ngEntity.getNodeType();
int memory = ngEntity.getMemorySize();
int cpu = ngEntity.getCpuNum();
if (instanceType == null && (cpu == 0 || memory == 0)) {
throw ClusterConfigException.INSTANCE_SIZE_NOT_SET(group.getName());
}
if (instanceType == null) {
logger.debug("instance type is not set.");
if (softwareManager.hasMgmtRole(group.getRoles())) {
instanceType = InstanceType.MEDIUM;
} else {
instanceType = InstanceType.SMALL;
}
ngEntity.setNodeType(instanceType);
} else {
logger.debug("instance type is " + instanceType.toString());
}
if (group.getStorage().getSizeGB() <= 0) {
GroupType groupType = null;
if (softwareManager.hasMgmtRole(group.getRoles())) {
groupType = GroupType.MANAGEMENTGROUP;
} else {
groupType = GroupType.WORKGROUP;
}
ngEntity.setStorageSize(ExpandUtils.getStorage(instanceType, groupType));
logger.debug("CommonClusterExpandPolicy::expandGroupInstanceType:storage size is setting to default value: "
+ ngEntity.getStorageSize());
} else {
ngEntity.setStorageSize(group.getStorage().getSizeGB());
}
if (memory == 0) {
ngEntity.setMemorySize(instanceType.getMemoryMB());
}
if (cpu == 0) {
ngEntity.setCpuNum(instanceType.getCpuNum());
}
// storage
logger.debug("storage size is set to : " + ngEntity.getStorageSize());
if (ngEntity.getStorageType() == null) {