CLOUDSTACK 711: CPU and RAM overcommit update cluster part

This commit is contained in:
Bharat Kumar 2013-02-22 20:09:50 +05:30 committed by Abhinandan Prateek
parent 54f7933f11
commit 667aa17512
4 changed files with 44 additions and 9 deletions

View File

@ -71,7 +71,7 @@ public interface ResourceService {
boolean deleteCluster(DeleteClusterCmd cmd);
Cluster updateCluster(Cluster cluster, String clusterType, String hypervisor, String allocationState, String managedstate, Float memoryOvercommitRaito, Float cpuOvercommitRatio);
Cluster updateCluster(Cluster cluster, String clusterType, String hypervisor, String allocationState, String managedstate,Float memoryOvercommitRatio, Float cpuOvercommitRatio);
List<? extends Host> discoverHosts(AddHostCmd cmd) throws IllegalArgumentException, DiscoveryException, InvalidParameterValueException;

View File

@ -2921,15 +2921,11 @@ ServerResource {
vm.addComp(guest);
GuestResourceDef grd = new GuestResourceDef();
//check if overcommit should be considered.
if(vmTO.getMinSpeed() == vmTO.getMaxSpeed()){
}
if (vmTO.getMinRam() != vmTO.getMaxRam()){
grd.setMemBalloning(true);
grd.setCurrentMem((int)vmTO.getMinRam()/1024);
grd.setMemorySize((int)vmTO.getMaxRam()/1024);
grd.setMemBalloning(true);
grd.setCurrentMem((int)vmTO.getMinRam()/1024);
grd.setMemorySize((int)vmTO.getMaxRam()/1024);
}
else{
grd.setMemorySize(vmTO.getMaxRam() / 1024);

View File

@ -496,6 +496,17 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
_clusterDetailsDao.persist(cluster_detail_cpu);
_clusterDetailsDao.persist(cluster_detail_ram);
//create a new entry only if the overcommit ratios are greater than 1.
if(cmd.getCpuOvercommitRatio().compareTo(1f) > 0) {
cluster_detail_cpu = new ClusterDetailsVO(clusterId, "cpuOvercommitRatio", Float.toString(cmd.getCpuOvercommitRatio()));
_clusterDetailsDao.persist(cluster_detail_cpu);
}
if(cmd.getMemoryOvercommitRaito().compareTo(1f) > 0) {
cluster_detail_ram = new ClusterDetailsVO(clusterId, "memoryOvercommitRatio", Float.toString(cmd.getMemoryOvercommitRaito()));
_clusterDetailsDao.persist(cluster_detail_ram);
}
boolean success = false;
@ -1065,7 +1076,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
@Override
@DB
public Cluster updateCluster(Cluster clusterToUpdate, String clusterType,
String hypervisor, String allocationState, String managedstate, Float memoryOvercommitRaito, Float cpuOvercommitRatio) {
String hypervisor, String allocationState, String managedstate,Float memoryovercommitratio, Float cpuovercommitratio) {
ClusterVO cluster = (ClusterVO) clusterToUpdate;
// Verify cluster information and update the cluster if needed
@ -1148,6 +1159,31 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
}
}
ClusterDetailsVO memory_detail = _clusterDetailsDao.findDetail(cluster.getId(),"memoryOvercommitRatio");
if( memory_detail == null){
if (memoryovercommitratio.compareTo(1f) > 0){
memory_detail = new ClusterDetailsVO(cluster.getId(),"memoryOvercommitRatio",Float.toString(memoryovercommitratio));
_clusterDetailsDao.persist(memory_detail);
}
}
else {
memory_detail.setValue(Float.toString(memoryovercommitratio));
_clusterDetailsDao.update(memory_detail.getId(),memory_detail);
}
ClusterDetailsVO cpu_detail = _clusterDetailsDao.findDetail(cluster.getId(),"cpuOvercommitRatio");
if( cpu_detail == null){
if (cpuovercommitratio.compareTo(1f) > 0){
cpu_detail = new ClusterDetailsVO(cluster.getId(),"cpuOvercommitRatio",Float.toString(cpuovercommitratio));
_clusterDetailsDao.persist(cpu_detail);
}
}
else {
cpu_detail.setValue(Float.toString(cpuovercommitratio));
_clusterDetailsDao.update(cpu_detail.getId(),cpu_detail);
}
if (doUpdate) {
Transaction txn = Transaction.currentTxn();
try {

View File

@ -54,6 +54,9 @@ import com.cloud.storage.Swift;
import com.cloud.template.VirtualMachineTemplate;
import com.cloud.utils.Pair;
import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.component.Manager;
import com.cloud.utils.fsm.NoTransitionException;
@Local(value = {ResourceManager.class})