Moti Asayag has uploaded a new change for review.

Change subject: engine: Use VdsDao for fetching hosts in NetworkClusterHelper
......................................................................

engine: Use VdsDao for fetching hosts in NetworkClusterHelper

Instead of using the search engine for fetching host
internally, a direct use of the VdsDao is done.

In addition, skip DB call for the hosts if the network
is not required.

Change-Id: Icf6574700974b800d96627da9439d7793b7d31b2
Signed-off-by: Moti Asayag <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/cluster/NetworkClusterHelper.java
1 file changed, 3 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/46/22046/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/cluster/NetworkClusterHelper.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/cluster/NetworkClusterHelper.java
index 296ae55..3753934 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/cluster/NetworkClusterHelper.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/cluster/NetworkClusterHelper.java
@@ -5,16 +5,13 @@
 import org.apache.commons.lang.StringUtils;
 import org.ovirt.engine.core.bll.Backend;
 import org.ovirt.engine.core.common.businessentities.VDS;
-import org.ovirt.engine.core.common.businessentities.VDSGroup;
 import org.ovirt.engine.core.common.businessentities.VDSStatus;
 import org.ovirt.engine.core.common.businessentities.network.Network;
 import org.ovirt.engine.core.common.businessentities.network.NetworkCluster;
 import org.ovirt.engine.core.common.businessentities.network.NetworkClusterId;
 import org.ovirt.engine.core.common.businessentities.network.NetworkStatus;
 import 
org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface;
-import org.ovirt.engine.core.common.interfaces.SearchType;
 import org.ovirt.engine.core.common.queries.IdQueryParameters;
-import org.ovirt.engine.core.common.queries.SearchParameters;
 import org.ovirt.engine.core.common.queries.VdcQueryType;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.dal.dbbroker.DbFacade;
@@ -36,24 +33,16 @@
      * @param net
      *            The network itself.
      */
-    @SuppressWarnings("unchecked")
     public static void setStatus(Guid vdsGroupId, final Network net) {
         NetworkStatus status = NetworkStatus.OPERATIONAL;
         NetworkCluster networkCluster =
                 DbFacade.getInstance().getNetworkClusterDao().get(new 
NetworkClusterId(vdsGroupId, net.getId()));
 
         if (networkCluster != null) {
-            VDSGroup vdsGroup = 
DbFacade.getInstance().getVdsGroupDao().get(vdsGroupId);
-
-            // Search all vds in cluster that have the specify network, if not 
the
-            // network is not active
-            SearchParameters searchParams = new SearchParameters("hosts: 
cluster = "
-                    + vdsGroup.getName(), SearchType.VDS);
-            searchParams.setMaxCount(Integer.MAX_VALUE);
-            List<VDS> vdsList = Backend.getInstance()
-                    .runInternalQuery(VdcQueryType.Search, 
searchParams).getReturnValue();
 
             if (networkCluster.isRequired()) {
+                // Search all vds in cluster that have the specified network, 
if not the network is not active
+                List<VDS> vdsList = 
DbFacade.getInstance().getVdsDao().getAllForVdsGroup(vdsGroupId);
                 for (VDS vds : vdsList) {
                     if (vds.getStatus() != VDSStatus.Up) {
                         continue;
@@ -67,6 +56,7 @@
                             return StringUtils.equals(i.getNetworkName(), 
net.getName());
                         }
                     });
+
                     if (iface == null) {
                         status = NetworkStatus.NON_OPERATIONAL;
                         break;


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

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

Reply via email to