Tal Nisan has uploaded a new change for review.

Change subject: webadmin: Added sorting of hosts by SPM priority upon activating
......................................................................

webadmin: Added sorting of hosts by SPM priority upon activating

When sending a multiple activate host command the list of the hosts is not
oredered by SPM priority and that can cause a scenario in which no SPM is
elected, multiple hosts are activated one after another and the first one
is selected as an SPM regardless of the SPM priority of the rest.
In order to avoid this scenario, the list is sorted by SPM priority prior
to running the multiple actions

Change-Id: Ie1b3f564491372c8934451c774127ae29e1ac879
Bug-Url: https://bugzilla.redhat.com/998997
Signed-off-by: Tal Nisan <tni...@redhat.com>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Linq.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java
2 files changed, 17 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/92/19092/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Linq.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Linq.java
index b787281..db01230 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Linq.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Linq.java
@@ -74,6 +74,18 @@
         }
     }
 
+    public static class VdsSPMPriorityComparer implements Comparator<VDS>, 
Serializable {
+        private static final long serialVersionUID = 1114793850392069219L;
+
+        @Override
+        public int compare(VDS vds1, VDS vds2)
+        {
+            return (vds1.getVdsSpmPriority() < vds2.getVdsSpmPriority()) ? 1
+                    : ((vds1.getVdsSpmPriority() == vds2.getVdsSpmPriority()) 
? 0 : -1);
+
+        }
+    }
+
     public static class DiskImageByLastModifiedComparer implements 
Comparator<DiskImage>, Serializable
     {
 
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java
index f625447..e89a393 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java
@@ -2,6 +2,7 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -1098,9 +1099,11 @@
     public void activate()
     {
         ArrayList<VdcActionParametersBase> list = new 
ArrayList<VdcActionParametersBase>();
-        for (Object item : getSelectedItems())
+
+        Collections.sort((List<VDS>) getSelectedItems(), new 
Linq.VdsSPMPriorityComparer());
+
+        for (VDS vds : (List<VDS>) getSelectedItems())
         {
-            VDS vds = (VDS) item;
             list.add(new VdsActionParameters(vds.getId()));
         }
 


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

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

Reply via email to