Gilad Chaplik has uploaded a new change for review.

Change subject: engine: Adding Speed optimization option to the scheduler
......................................................................

engine: Adding Speed optimization option to the scheduler

Add to cluster entity optimization_type field.
this field is a binary representation of cluster optimization possibilities.
The first option is optimize for speed, allows to skip host weighing in case
there are more than configurable amount of pending scheduling
requests.

Bug-Url: https://bugzilla.redhat.com/1014696
Change-Id: I0784f89648093e650be73fcc3d850a4854d53c1a
Reviewed-on: http://gerrit.ovirt.org/#/c/19270/
Signed-off-by: Gilad Chaplik <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SchedulingManager.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDSGroup.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/scheduling/OptimizationType.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAODbFacadeImpl.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java
M 
frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.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/popup/cluster/ClusterPopupView.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.ui.xml
A packaging/dbscripts/upgrade/03_03_1030_add_vds_group_optimization_field.sql
M packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
M packaging/dbscripts/vds_groups_sp.sql
M packaging/etc/engine-config/engine-config.properties
17 files changed, 218 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/73/22173/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SchedulingManager.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SchedulingManager.java
index 6ad748a..f565a4d 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SchedulingManager.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SchedulingManager.java
@@ -13,6 +13,7 @@
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.lang.StringUtils;
@@ -27,6 +28,7 @@
 import org.ovirt.engine.core.common.config.ConfigValues;
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
 import org.ovirt.engine.core.common.scheduling.ClusterPolicy;
+import org.ovirt.engine.core.common.scheduling.OptimizationType;
 import org.ovirt.engine.core.common.scheduling.PolicyUnit;
 import org.ovirt.engine.core.common.utils.Pair;
 import org.ovirt.engine.core.compat.Guid;
@@ -71,7 +73,7 @@
 
     private final Object policyUnitsLock = new Object();
 
-    private final ConcurrentHashMap<Guid, Object> clusterLockMap = new 
ConcurrentHashMap<Guid, Object>();
+    private final ConcurrentHashMap<Guid, Semaphore> clusterLockMap = new 
ConcurrentHashMap<Guid, Semaphore>();
 
     private final VdsFreeMemoryChecker noWaitingMemoryChecker = new 
VdsFreeMemoryChecker(new NonWaitingDelayer());
     private MigrationHandler migrationHandler;
@@ -225,8 +227,9 @@
             List<String> messages,
             VdsFreeMemoryChecker memoryChecker,
             String correlationId) {
-        clusterLockMap.putIfAbsent(cluster.getId(), new Object());
-        synchronized (clusterLockMap.get(cluster.getId())) {
+        clusterLockMap.putIfAbsent(cluster.getId(), new Semaphore(1));
+        try {
+            clusterLockMap.get(cluster.getId()).acquire();
             List<VDS> vdsList = getVdsDAO()
                     .getAllForVdsGroupWithStatus(cluster.getId(), 
VDSStatus.Up);
             updateInitialHostList(vdsList, hostBlackList, true);
@@ -260,7 +263,10 @@
             if (policy.getFunctions() == null || 
policy.getFunctions().isEmpty()) {
                 return vdsList.get(0).getId();
             }
-            Guid bestHost = runFunctions(policy.getFunctions(), vdsList, vm, 
parameters);
+            Guid bestHost = null;
+            if (shouldWeighClusterHosts(cluster, vdsList)) {
+                bestHost = runFunctions(policy.getFunctions(), vdsList, vm, 
parameters);
+            }
             if (bestHost == null && vdsList.size() > 0) {
                 bestHost = vdsList.get(0).getId();
             }
@@ -274,9 +280,40 @@
                         0);
             }
             return bestHost;
+        } catch (InterruptedException e) {
+            log.error("interrupted", e);
+            return null;
+        } finally {
+            clusterLockMap.get(cluster.getId()).release();
         }
     }
 
+    /**
+     * Checks whether scheduler should weigh hosts/or skip weighing:
+     * * More than one host (it's trivial to weigh a single host).
+     * * optimize for speed is enabled for the cluster, and there are less 
than configurable requests pending (skip
+     * weighing in a loaded setup).
+     *
+     * @param cluster
+     * @param vdsList
+     * @return
+     */
+    protected boolean shouldWeighClusterHosts(VDSGroup cluster, List<VDS> 
vdsList) {
+        Integer threshold = Config.<Integer> 
GetValue(ConfigValues.SpeedOptimizationSchedulingThreshold);
+        // threshold is crossed only when cluster is configured for optimized 
for speed
+        boolean crossedThreshold =
+                OptimizationType.OPTIMIZE_FOR_SPEED == 
cluster.getOptimizationType()
+                        && 
clusterLockMap.get(cluster.getId()).getQueueLength() >
+                        threshold;
+        if (crossedThreshold) {
+            log.infoFormat("Scheduler: skipping whighing hosts in cluster {0}, 
since there are more than {1} parallel requests",
+                    cluster.getName(),
+                    threshold);
+        }
+        return vdsList.size() > 1
+                && !crossedThreshold;
+    }
+
     public boolean canSchedule(VDSGroup cluster,
             VM vm,
             List<Guid> vdsBlackList,
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDSGroup.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDSGroup.java
index 3da0c8e..3326edd 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDSGroup.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDSGroup.java
@@ -6,6 +6,7 @@
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Size;
 
+import org.ovirt.engine.core.common.scheduling.OptimizationType;
 import org.ovirt.engine.core.common.utils.ObjectUtils;
 import org.ovirt.engine.core.common.validation.annotation.ValidI18NName;
 import org.ovirt.engine.core.common.validation.annotation.ValidVdsGroup;
@@ -77,10 +78,13 @@
     private Map<String, String> clusterPolicyProperties;
     private boolean detectEmulatedMachine;
 
+    private OptimizationType optimizationType;
+
     public VDSGroup() {
         migrateOnError = MigrateOnErrorOptions.YES;
         name = "";
         virtService = true;
+        optimizationType = OptimizationType.NONE;
     }
 
     @Override
@@ -274,6 +278,14 @@
         return detectEmulatedMachine;
     }
 
+    public OptimizationType getOptimizationType() {
+        return optimizationType;
+    }
+
+    public void setOptimizationType(OptimizationType optimizationType) {
+        this.optimizationType = optimizationType;
+    }
+
     @Override
     public int hashCode() {
         final int prime = 31;
@@ -298,6 +310,7 @@
         result = prime * result + ((clusterPolicyName == null) ? 0 : 
clusterPolicyName.hashCode());
         result = prime * result + (clusterPolicyProperties == null ? 0 : 
clusterPolicyProperties.hashCode());
         result = prime * result + (enableBallooning ? 1231 : 1237);
+        result = prime * result + ((optimizationType == null) ? 0 : 
optimizationType.hashCode());
         return result;
     }
 
@@ -334,7 +347,8 @@
                 && ObjectUtils.objectsEqual(clusterPolicyName, 
other.clusterPolicyName)
                 && ObjectUtils.objectsEqual(clusterPolicyProperties, 
other.clusterPolicyProperties)
                 && enableBallooning == other.enableBallooning
-                && detectEmulatedMachine == other.detectEmulatedMachine);
+                && detectEmulatedMachine == other.detectEmulatedMachine
+                && optimizationType == other.optimizationType);
     }
 
 }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
index 2aab8f3..fab5b29 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
@@ -1537,6 +1537,10 @@
     @DefaultValueAttribute("true")
     PortMirroringSupported(544),
 
+    @TypeConverterAttribute(Integer.class)
+    @DefaultValueAttribute("10")
+    SpeedOptimizationSchedulingThreshold(545),
+
     Invalid(65535);
 
     private int intValue;
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java
index 40bee48..5ebebb7 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java
@@ -107,7 +107,8 @@
     MaxVmNameLengthNonWindows(ConfigAuthType.User),
     AttestationServer,
     DefaultGeneralTimeZone,
-    DefaultWindowsTimeZone
+    DefaultWindowsTimeZone,
+    SpeedOptimizationSchedulingThreshold
     ;
 
     public static enum ConfigAuthType {
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/scheduling/OptimizationType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/scheduling/OptimizationType.java
new file mode 100644
index 0000000..b90cdc8
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/scheduling/OptimizationType.java
@@ -0,0 +1,32 @@
+package org.ovirt.engine.core.common.scheduling;
+
+
+/**
+ * cluster's optimization method,
+ * <p>
+ * none - 0
+ * optimize_for_speed - 1
+ */
+public enum OptimizationType {
+    NONE(0),
+    OPTIMIZE_FOR_SPEED(1);
+
+    private final int value;
+
+    OptimizationType(int value) {
+        this.value = value;
+    }
+
+    public static OptimizationType from(int value) {
+        for (OptimizationType v : values()) {
+            if (v.value == value) {
+                return v;
+            }
+        }
+        return null;
+    }
+
+    public int getValue() {
+        return value;
+    }
+}
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAODbFacadeImpl.java
index 903db0f..77b7e43 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAODbFacadeImpl.java
@@ -8,6 +8,7 @@
 import org.ovirt.engine.core.common.businessentities.ActionGroup;
 import org.ovirt.engine.core.common.businessentities.MigrateOnErrorOptions;
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
+import org.ovirt.engine.core.common.scheduling.OptimizationType;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.compat.Version;
 import org.ovirt.engine.core.dal.dbbroker.DbFacadeUtils;
@@ -170,8 +171,8 @@
                 .addValue("cluster_policy_id", group.getClusterPolicyId())
                 .addValue("cluster_policy_custom_properties",
                                 
SerializationFactory.getSerializer().serialize(group.getClusterPolicyProperties()))
-                .addValue("enable_balloon", group.isEnableBallooning());
-
+                .addValue("enable_balloon", group.isEnableBallooning())
+                .addValue("optimization_type", group.getOptimizationType());
         return parameterSource;
     }
 
@@ -210,7 +211,7 @@
             
entity.setClusterPolicyProperties(SerializationFactory.getDeserializer()
                     
.deserializeOrCreateNew(rs.getString("cluster_policy_custom_properties"), 
LinkedHashMap.class));
             entity.setEnableBallooning(rs.getBoolean("enable_balloon"));
-
+            
entity.setOptimizationType(OptimizationType.from(rs.getInt("optimization_type")));
             return entity;
         }
     }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
index 5f5857b..0768ff1 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
@@ -3322,4 +3322,9 @@
         Integer maxVmNameLengthNonWindows = (Integer) 
AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.MaxVmNameLengthNonWindows);
         return maxVmNameLengthNonWindows == null ? 64 : 
maxVmNameLengthNonWindows;
     }
+
+    public static int getOptimizeSchedulerForSpeedPendingRequests() {
+        return (Integer) 
getConfigValuePreConverted(ConfigurationValues.SpeedOptimizationSchedulingThreshold,
+                getDefaultConfigurationVersion());
+    }
 }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java
index 5e07104..cb9c817 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java
@@ -22,6 +22,7 @@
 import org.ovirt.engine.core.common.queries.VdcQueryReturnValue;
 import org.ovirt.engine.core.common.queries.VdcQueryType;
 import org.ovirt.engine.core.common.scheduling.ClusterPolicy;
+import org.ovirt.engine.core.common.scheduling.OptimizationType;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.compat.StringHelper;
 import org.ovirt.engine.core.compat.Version;
@@ -369,6 +370,9 @@
             clusterModel.getEnableTrustedService().setIsChangable(false);
         }
 
+        clusterModel.getOptimizeForSpeed()
+                .setEntity(OptimizationType.OPTIMIZE_FOR_SPEED == 
cluster.getOptimizationType());
+
         AsyncDataProvider.getAllowClusterWithVirtGlusterEnabled(new 
AsyncQuery(this, new INewAsyncCallback() {
             @Override
             public void onSuccess(Object model, Object returnValue) {
@@ -696,6 +700,8 @@
         cluster.setTrustedService((Boolean) 
model.getEnableTrustedService().getEntity());
         cluster.setClusterPolicyId(((ClusterPolicy) 
model.getClusterPolicy().getSelectedItem()).getId());
         
cluster.setClusterPolicyProperties(KeyValueModel.convertProperties(model.getCustomPropertySheet().getEntity()));
+        cluster.setOptimizationType((Boolean) 
model.getOptimizeForSpeed().getEntity() ?
+                OptimizationType.OPTIMIZE_FOR_SPEED : OptimizationType.NONE);
 
         model.startProgress(null);
 
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java
index a41a690..4e2d6e2 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java
@@ -488,6 +488,26 @@
         this.enableBallooning = enableBallooning;
     }
 
+    private EntityModel optimizeForUtilization;
+
+    public EntityModel getOptimizeForUtilization() {
+        return optimizeForUtilization;
+    }
+
+    public void setOptimizeForUtilization(EntityModel optimizeForUtilization) {
+        this.optimizeForUtilization = optimizeForUtilization;
+    }
+
+    private EntityModel optimizeForSpeed;
+
+    public EntityModel getOptimizeForSpeed() {
+        return optimizeForSpeed;
+    }
+
+    public void setOptimizeForSpeed(EntityModel optimizeForSpeed) {
+        this.optimizeForSpeed = optimizeForSpeed;
+    }
+
     private boolean isGeneralTabValid;
 
     public boolean getIsGeneralTabValid()
@@ -613,6 +633,12 @@
         }
 
         return AsyncDataProvider.getClusterDefaultMemoryOverCommit();
+    }
+
+    public String getSchedulerOptimizationInfoMessage() {
+        return ConstantsManager.getInstance()
+                .getMessages()
+                
.schedulerOptimizationInfo(AsyncDataProvider.getOptimizeSchedulerForSpeedPendingRequests());
     }
 
     public void setMemoryOverCommit(int value)
@@ -802,6 +828,13 @@
         setCountThreadsAsCores(new 
EntityModel(AsyncDataProvider.getClusterDefaultCountThreadsAsCores()));
 
         setVersionSupportsCpuThreads(new EntityModel(true));
+
+        setOptimizeForUtilization(new EntityModel());
+        setOptimizeForSpeed(new EntityModel());
+        getOptimizeForUtilization().setEntity(true);
+        getOptimizeForSpeed().setEntity(false);
+        getOptimizeForUtilization().getEntityChangedEvent().addListener(this);
+        getOptimizeForSpeed().getEntityChangedEvent().addListener(this);
 
         AsyncQuery _asyncQuery = new AsyncQuery();
         _asyncQuery.setModel(this);
@@ -1097,6 +1130,10 @@
                 {
                     getMigrateOnErrorOption_YES().setEntity(false);
                     getMigrateOnErrorOption_NO().setEntity(false);
+                } else if (senderEntityModel == getOptimizeForUtilization()) {
+                    getOptimizeForSpeed().setEntity(false);
+                } else if (senderEntityModel == getOptimizeForSpeed()) {
+                    getOptimizeForUtilization().setEntity(false);
                 }
             }
         }
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java
 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java
index c191590..af82a30 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java
+++ 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java
@@ -306,4 +306,9 @@
 
     @DefaultMessage("No Rebalance ever happened on volume :  {0}")
     String rebalanceStatusConfirmationMessage(String name);
+
+    @DefaultMessage("Optimize scheduling for host weighing (ordering):\n" +
+            "Utilization: include weight modules in shceduling to allow best 
selection\n" +
+            "Speed: skip host weighing in case there are more than {0} pending 
requests")
+    String schedulerOptimizationInfo(int numOfRequests);
 }
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 85fdb69..2c37f96 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
@@ -3312,4 +3312,13 @@
 
     @DefaultStringValue("External Policy Unit")
     String externalPolicyUnit();
+
+    @DefaultStringValue("Optimize for Utilization")
+    String optimizeForUtilizationLabel();
+
+    @DefaultStringValue("Optimize for Speed")
+    String optimizeForSpeedLabel();
+
+    @DefaultStringValue("Scheduler Optimization")
+    String schedulerOptimizationPanelLabel();
 }
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java
index 2f994c9..ce11562 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java
@@ -36,6 +36,7 @@
 import com.google.gwt.editor.client.SimpleBeanEditorDriver;
 import com.google.gwt.event.shared.EventBus;
 import com.google.gwt.resources.client.CssResource;
+import com.google.gwt.safehtml.shared.SafeHtmlUtils;
 import com.google.gwt.uibinder.client.UiBinder;
 import com.google.gwt.uibinder.client.UiField;
 import com.google.gwt.user.client.ui.FlowPanel;
@@ -247,6 +248,23 @@
     @WithElementId
     EntityModelCheckBoxEditor enableBallooning;
 
+    @UiField
+    @Ignore
+    Label schedulerOptimizationPanelTitle;
+
+    @UiField(provided = true)
+    InfoIcon schedulerOptimizationInfoIcon;
+
+    @UiField(provided = true)
+    @Path(value = "optimizeForUtilization.entity")
+    @WithElementId
+    EntityModelRadioButtonEditor optimizeForUtilizationEditor;
+
+    @UiField(provided = true)
+    @Path(value = "optimizeForSpeed.entity")
+    @WithElementId
+    EntityModelRadioButtonEditor optimizeForSpeedEditor;
+
     private final Driver driver = GWT.create(Driver.class);
 
     private final ApplicationMessages messages;
@@ -325,6 +343,10 @@
         
clusterPolicyEditor.setLabel(constants.clusterPolicySelectPolicyLabel());
 
         enableBallooning.setLabel(constants.enableBallooningLabel());
+
+        
schedulerOptimizationPanelTitle.setText(constants.schedulerOptimizationPanelLabel());
+        
optimizeForUtilizationEditor.setLabel(constants.optimizeForUtilizationLabel());
+        optimizeForSpeedEditor.setLabel(constants.optimizeForSpeedLabel());
     }
 
     private void initRadioButtonEditors() {
@@ -339,6 +361,9 @@
         migrateOnErrorOption_YESEditor = new 
EntityModelRadioButtonEditor("2"); //$NON-NLS-1$
         migrateOnErrorOption_HA_ONLYEditor = new 
EntityModelRadioButtonEditor("2"); //$NON-NLS-1$
         migrateOnErrorOption_NOEditor = new EntityModelRadioButtonEditor("2"); 
//$NON-NLS-1$
+
+        optimizeForUtilizationEditor = new EntityModelRadioButtonEditor("3"); 
//$NON-NLS-1$
+        optimizeForSpeedEditor = new EntityModelRadioButtonEditor("3"); 
//$NON-NLS-1$
     }
 
     private void initListBoxEditors() {
@@ -382,6 +407,7 @@
 
         enableBallooning = new EntityModelCheckBoxEditor(Align.RIGHT);
         enableBallooning.getContentWidgetContainer().setWidth("350px"); 
//$NON-NLS-1$
+
     }
 
     private void initInfoIcons(ApplicationResources resources, 
ApplicationConstants constants, ApplicationTemplates templates)
@@ -389,6 +415,7 @@
         memoryOptimizationInfo = new 
InfoIcon(templates.italicFixedWidth("465px", 
constants.clusterPopupMemoryOptimizationInfo()), resources); //$NON-NLS-1$
 
         cpuThreadsInfo = new InfoIcon(templates.italicFixedWidth("600px", 
constants.clusterPopupCpuThreadsInfo()), resources); //$NON-NLS-1$
+        schedulerOptimizationInfoIcon = new 
InfoIcon(SafeHtmlUtils.EMPTY_SAFE_HTML, resources);
     }
 
     private void applyModeCustomizations() {
@@ -473,6 +500,11 @@
                 
customPropertiesSheetEditor.edit(object.getCustomPropertySheet());
             }
         });
+
+        schedulerOptimizationInfoIcon.setText(SafeHtmlUtils.fromTrustedString(
+                templates.italicFixedWidth("350px", //$NON-NLS-1$
+                object.getSchedulerOptimizationInfoMessage()).asString()
+                        .replaceAll("(\r\n|\n)", "<br />"))); //$NON-NLS-1$ 
//$NON-NLS-2$
     }
 
     private void optimizationForServerFormatter(ClusterModel object) {
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.ui.xml
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.ui.xml
index 461122f..830e64e 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.ui.xml
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.ui.xml
@@ -33,7 +33,9 @@
                .label {
                        width: 100%;
                }
-
+               .radioButtonLabel {
+                       width: 200px;
+               }
                .radioButtonsTabContent {
                        margin-top: 10px;
                }
@@ -220,6 +222,14 @@
                                                                <g:ScrollPanel 
height="100px">
                                                                        
<k:KeyValueWidget ui:field="customPropertiesSheetEditor" />
                                                                </g:ScrollPanel>
+                                                               <g:FlowPanel>
+                                                                       
<g:Label ui:field="schedulerOptimizationPanelTitle" 
addStyleNames="{style.panelTitle}" />
+                                                                       
<g:HorizontalPanel>
+                                                                               
<e:EntityModelRadioButtonEditor ui:field="optimizeForUtilizationEditor" 
addStyleNames="{style.radioButtonLabel}" />
+                                                                               
<e:EntityModelRadioButtonEditor ui:field="optimizeForSpeedEditor" 
addStyleNames="{style.radioButtonLabel}" />
+                                                                               
<d:InfoIcon ui:field="schedulerOptimizationInfoIcon" 
addStyleNames="{style.panelInfo}" />
+                                                                       
</g:HorizontalPanel>
+                                                               </g:FlowPanel>
                                                                <g:FlowPanel 
ui:field="additionPropsPanel" addStyleNames="{style.nestedSubsequentPanel}">
                                                                        
<g:Label ui:field="additionPropsPanelTitle" addStyleNames="{style.panelTitle}" 
/>
                                                                        
<e:EntityModelCheckBoxEditor ui:field="enableTrustedServiceEditor" />
diff --git 
a/packaging/dbscripts/upgrade/03_03_1030_add_vds_group_optimization_field.sql 
b/packaging/dbscripts/upgrade/03_03_1030_add_vds_group_optimization_field.sql
new file mode 100644
index 0000000..8c51955
--- /dev/null
+++ 
b/packaging/dbscripts/upgrade/03_03_1030_add_vds_group_optimization_field.sql
@@ -0,0 +1,5 @@
+-- Since we will have more than one optimization type, defining an integer
+-- for defining cluster optimization:
+-- 0 is none.
+-- 1 is optimize for speed.
+select fn_db_add_column('vds_groups', 'optimization_type', 'smallint default 
0');
diff --git a/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql 
b/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
index 10691ba..8545283 100644
--- a/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
+++ b/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
@@ -385,6 +385,7 @@
 select fn_db_add_config_value('MTUOverrideSupported','true','3.3');
 select fn_db_add_config_value('PortMirroringSupported','false','3.0');
 select fn_db_add_config_value('PortMirroringSupported','false','3.1');
+select 
fn_db_add_config_value('SpeedOptimizationSchedulingThreshold','10','general');
 --Handling Organization Name
 select fn_db_add_config_value('OrganizationName','oVirt','general');
 select fn_db_add_config_value('OriginType','OVIRT','general');
diff --git a/packaging/dbscripts/vds_groups_sp.sql 
b/packaging/dbscripts/vds_groups_sp.sql
index 7d47129..2d58d08 100644
--- a/packaging/dbscripts/vds_groups_sp.sql
+++ b/packaging/dbscripts/vds_groups_sp.sql
@@ -27,15 +27,16 @@
        v_trusted_service BOOLEAN,
         v_cluster_policy_id UUID,
         v_cluster_policy_custom_properties text,
-       v_enable_balloon BOOLEAN)
+       v_enable_balloon BOOLEAN,
+       v_optimization_type SMALLINT)
 RETURNS VOID
    AS $procedure$
 BEGIN
       INSERT INTO vds_groups(vds_group_id,description, name, 
free_text_comment, cpu_name, storage_pool_id,  max_vds_memory_over_commit, 
count_threads_as_cores, compatibility_version,
         transparent_hugepages, migrate_on_error, virt_service, 
gluster_service, tunnel_migration, emulated_machine, detect_emulated_machine, 
trusted_service, cluster_policy_id,
-        cluster_policy_custom_properties, enable_balloon)
+        cluster_policy_custom_properties, enable_balloon, optimization_type)
        VALUES(v_vds_group_id,v_description, v_name, v_free_text_comment, 
v_cpu_name, v_storage_pool_id,  v_max_vds_memory_over_commit, 
v_count_threads_as_cores, v_compatibility_version,
-    v_transparent_hugepages, v_migrate_on_error, v_virt_service, 
v_gluster_service, v_tunnel_migration, v_emulated_machine, 
v_detect_emulated_machine, v_trusted_service, v_cluster_policy_id, 
v_cluster_policy_custom_properties, v_enable_balloon);
+    v_transparent_hugepages, v_migrate_on_error, v_virt_service, 
v_gluster_service, v_tunnel_migration, v_emulated_machine, 
v_detect_emulated_machine, v_trusted_service, v_cluster_policy_id, 
v_cluster_policy_custom_properties, v_enable_balloon, v_optimization_type);
 END; $procedure$
 LANGUAGE plpgsql;
 
@@ -62,7 +63,8 @@
        v_trusted_service BOOLEAN,
         v_cluster_policy_id UUID,
         v_cluster_policy_custom_properties text,
-       v_enable_balloon BOOLEAN)
+       v_enable_balloon BOOLEAN,
+       v_optimization_type SMALLINT)
 RETURNS VOID
 
        --The [vds_groups] table doesn't have a timestamp column. Optimistic 
concurrency logic cannot be generated
@@ -77,7 +79,7 @@
       migrate_on_error = v_migrate_on_error,
       virt_service = v_virt_service, gluster_service = v_gluster_service, 
tunnel_migration = v_tunnel_migration,
       emulated_machine = v_emulated_machine, detect_emulated_machine = 
v_detect_emulated_machine, trusted_service = v_trusted_service, 
cluster_policy_id = v_cluster_policy_id,
-      cluster_policy_custom_properties = v_cluster_policy_custom_properties, 
enable_balloon = v_enable_balloon
+      cluster_policy_custom_properties = v_cluster_policy_custom_properties, 
enable_balloon = v_enable_balloon, optimization_type = v_optimization_type
       WHERE vds_group_id = v_vds_group_id;
 END; $procedure$
 LANGUAGE plpgsql;
diff --git a/packaging/etc/engine-config/engine-config.properties 
b/packaging/etc/engine-config/engine-config.properties
index 8aa2136..c4b71ff 100644
--- a/packaging/etc/engine-config/engine-config.properties
+++ b/packaging/etc/engine-config/engine-config.properties
@@ -342,3 +342,5 @@
 DwhHeartBeatInterval.type=Integer
 UseFqdnForRdpIfAvailable.type=Boolean
 UseFqdnForRdpIfAvailable.description="If this option is enabled, the RDP 
console will use the FQDN, which is reported by the Guest Agent, if it is 
available and use this to establish the RDP connection."
+SpeedOptimizationSchedulingThreshold.description="Skip Host weights if there 
are more than X requests pending for scheduling (in case cluster is configured 
as optimize for speed)."
+SpeedOptimizationSchedulingThreshold.type=Integer


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0784f89648093e650be73fcc3d850a4854d53c1a
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.3
Gerrit-Owner: Gilad Chaplik <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to