mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK 711: CPU and RAM overcommit update cluster part
This commit is contained in:
parent
54f7933f11
commit
667aa17512
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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})
|
||||
|
|
|
|||
Loading…
Reference in New Issue