Roy Golan has uploaded a new change for review.

Change subject: core: add max memory for scheduling VMs as a calculated field 
to VDS
......................................................................

core: add max memory for scheduling VMs as a calculated field to VDS

This new calculated field is mostly to keep the user informed of the
max amount of memory is free to schedule a new VM. The number reflects
the absulute max which the VM scheduler can't exceed and is subjected to
future scheduling policies, which means the actual number can be lower.

The calculation is:

     (getmax_vds_memory_over_commit() * getphysical_mem_mb() / 100.0f)
                        -
     (getmem_commited() + getreserved_mem())

Change-Id: I8cb338f79682bdc550c4cc6e0667ba1fea50a9c6
Signed-off-by: Roy Golan <rgo...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java
M 
backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
M 
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostMapper.java
M 
frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostGeneralModel.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostGeneralView.java
9 files changed, 42 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/25/7825/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
index cc070b9..4f8f3ab 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
@@ -119,8 +119,11 @@
         boolean retVal = false;
         if (curVds.getmem_commited() != null && curVds.getphysical_mem_mb() != 
null && curVds.getreserved_mem() != null) {
             double vdsCurrentMem =
-                    curVds.getmem_commited() + curVds.getpending_vmem_size() + 
curVds.getguest_overhead() + curVds
-                            .getreserved_mem() + vm.getMinAllocatedMem();
+                    curVds.getmem_commited() +
+                            curVds.getpending_vmem_size() +
+                            curVds.getguest_overhead() +
+                            curVds.getreserved_mem() +
+                            vm.getMinAllocatedMem();
             double vdsMemLimit = curVds.getmax_vds_memory_over_commit() * 
curVds.getphysical_mem_mb() / 100.0;
             if (log.isDebugEnabled()) {
                 log.debugFormat("hasMemoryToRunVM: host {0} pending vmem size 
is : {1} MB",
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java
index f355a16..2e2cf95 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java
@@ -590,6 +590,7 @@
 
     public void setmem_commited(Integer value) {
         this.mVdsDynamic.setmem_commited(value);
+        calculateFreeVirtualMemory();
         OnPropertyChanged(new PropertyChangedEventArgs("mem_commited"));
         OnPropertyChanged(new 
PropertyChangedEventArgs("mem_commited_percent"));
     }
@@ -1229,4 +1230,18 @@
     public void setAutoRecoverable(boolean autoRecoverable) {
         mVdsStatic.setAutoRecoverable(autoRecoverable);
     }
+
+    private float maxSchedulingMemory;
+
+    public void calculateFreeVirtualMemory() {
+        if (getmem_commited() != null && getphysical_mem_mb() != null && 
getreserved_mem() != null && getguest_overhead() != null) {
+            maxSchedulingMemory = (getmax_vds_memory_over_commit() * 
getphysical_mem_mb() / 100.0f) -
+                    (getmem_commited() + getreserved_mem());
+        }
+    }
+
+    public float getMaxSchedulingMemory() {
+        return maxSchedulingMemory;
+    }
+
 }
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java
index 467b4f4..d80a9da 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java
@@ -283,6 +283,7 @@
             entity.setOtpValidity(rs.getLong("otp_validity"));
             entity.setVdsSpmPriority(rs.getInt("vds_spm_priority"));
             entity.setAutoRecoverable(rs.getBoolean("recoverable"));
+            entity.calculateFreeVirtualMemory();
             return entity;
         }
     }
diff --git 
a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
 
b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
index 833a672..4e2aa18 100644
--- 
a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
+++ 
b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
@@ -1134,6 +1134,7 @@
           <xs:element name="statistics" type="Statistics" minOccurs="0" 
maxOccurs="1"/>
           <xs:element ref="cpu" minOccurs="0" maxOccurs="1"/>
           <xs:element name="memory" type="xs:long" minOccurs="0"/>
+          <xs:element name="freeMemoryToRunVMs" type="xs:float" minOccurs="0"/>
           <xs:element name="summary" type="VmSummary" minOccurs="0" 
maxOccurs="1"/>
           <xs:element name="override_iptables" type="xs:boolean" minOccurs="0" 
maxOccurs="1"/>
           <!-- when installing a host, optionally reboot the host -->
diff --git 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostMapper.java
 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostMapper.java
index 9866398..30de7ed 100644
--- 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostMapper.java
+++ 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostMapper.java
@@ -170,6 +170,7 @@
             model.setType(type != null ? type.value() : null);
         }
         model.setMemory(entity.getphysical_mem_mb()==null ? 0 : 
entity.getphysical_mem_mb()*BYTES_IN_MEGABYTE);
+        model.setFreeMemoryToRunVMs(entity.getMaxSchedulingMemory());
         return model;
     }
 
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml
 
b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml
index 8d08e3b..4e685dd 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml
@@ -149,9 +149,12 @@
                <include name="common/businessentities/FileRepoMetaData.java" />
                <include name="common/businessentities/RepoFileMetaData.java" />
                <include name="common/businessentities/FileTypeExtension.java" 
/>
+               <include 
name="common/businessentities/HostFreeGuestMemoryCalculator.java" />
+               <include 
name="common/businessentities/SimpleHostFreeGuestMemoryCalculator.java" />
+
 
                <include name="common/job/*.java" />
-               
+
                <!-- Quota -->
                <include name="common/businessentities/Quota.java"/>
                <include 
name="common/businessentities/QuotaEnforcementTypeEnum.java"/>
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostGeneralModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostGeneralModel.java
index b9cb57b..a86ae8f 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostGeneralModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostGeneralModel.java
@@ -475,6 +475,12 @@
         }
     }
 
+    private Float maxSchedulingMemory;
+
+    public Float getMaxSchedulingMemory() {
+        return maxSchedulingMemory;
+    }
+
     private boolean hasAnyAlert;
 
     public boolean getHasAnyAlert()
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
index 078075f..73a6ff0 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
@@ -1040,6 +1040,9 @@
     @DefaultStringValue("Swap Size")
     String swapSizeHostGeneral();
 
+    @DefaultStringValue("Max free Memory for scheduling new VMs")
+    String maxSchedulingMemory();
+
     @DefaultStringValue("Shared Memory")
     String sharedMemHostGeneral();
 
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostGeneralView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostGeneralView.java
index 107c23b..558b077 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostGeneralView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostGeneralView.java
@@ -69,6 +69,7 @@
     MemorySizeLabel<Long> swapTotal;
     MemorySizeLabel<Long> usedSwap;
     MemorySizeLabel<Long> swapFree;
+    MemorySizeLabel<Float> maxSchedulingMemory;
 
     @Ignore
     DetailsLabel<ArrayList<ValueLabel<Integer>>, Integer> 
physicalMemoryDetails =
@@ -140,6 +141,7 @@
         formItems.add(new FormItem(constants.physMemHostGeneral(), 
physicalMemoryDetails, 0, 2));
         formItems.add(new FormItem(constants.swapSizeHostGeneral(), 
swapSizeDetails, 1, 2));
         formItems.add(new FormItem(constants.sharedMemHostGeneral(), 
sharedMemory, 2, 2));
+        formItems.add(new FormItem(constants.maxSchedulingMemory(), 
maxSchedulingMemory, 3, 2));
 
         applyModeCustomizations(formItems);
 
@@ -176,6 +178,8 @@
         this.swapTotal = new MemorySizeLabel<Long>(constants);
         this.usedSwap = new MemorySizeLabel<Long>(constants);
         this.swapFree = new MemorySizeLabel<Long>(constants);
+
+        this.maxSchedulingMemory = new MemorySizeLabel<Float>(constants);
     }
 
     @SuppressWarnings("unchecked")
@@ -194,6 +198,8 @@
         physicalMemoryDetails.setValue(physicalMemoryDetailsArray);
         swapSizeDetails.setValue(swapSizeDetailsArray);
 
+        maxSchedulingMemory.setValue(selectedItem.getMaxSchedulingMemory());
+
         formBuilder.showForm(getDetailModel());
     }
 


--
To view, visit http://gerrit.ovirt.org/7825
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8cb338f79682bdc550c4cc6e0667ba1fea50a9c6
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Roy Golan <rgo...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to