cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject [23/50] [abbrv] git commit: updated refs/heads/4.2 to a23322b
Date Mon, 26 Aug 2013 23:32:59 GMT
CLOUDSTACK-4350: [Performance Testing] Adding hosts take much longer time than baselines
During host connect multiple listeners gets invoked, one of them is the download listener.
As part of processConnect() method, it checks if templates needs to be downloaded to secondary
store for a particular HV type. As part of that check it computes list of HVs present in the
zone. The earlier logic was to query all hosts (excluding current one) and iterate over them
to
make the list. This is not optimal and is bound to have some latency as the number of hosts
increases.
Optimized the logic by querying the list of HVs from the db. directly instead of iterating
over
all hosts in the zone.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9f9f438a
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9f9f438a
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9f9f438a

Branch: refs/heads/4.2
Commit: 9f9f438ab907d6ce474850e1a2e68137ce6ef68e
Parents: 81d489d
Author: Koushik Das <koushik@apache.org>
Authored: Mon Aug 26 15:54:36 2013 +0530
Committer: Koushik Das <koushik@apache.org>
Committed: Mon Aug 26 15:54:36 2013 +0530

----------------------------------------------------------------------
 .../com/cloud/resource/ResourceManagerImpl.java | 36 ++++++++++++++------
 1 file changed, 26 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f9f438a/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index 2a86ffd..9da8c28 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -32,9 +32,9 @@ import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
 import com.cloud.dc.*;
+
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
-
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.command.admin.cluster.AddClusterCmd;
 import org.apache.cloudstack.api.command.admin.cluster.DeleteClusterCmd;
@@ -48,6 +48,7 @@ import org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd;
 import org.apache.cloudstack.region.dao.RegionDao;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
+
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.AgentManager.TapAgentsAction;
 import com.cloud.agent.api.Answer;
@@ -138,9 +139,11 @@ import com.cloud.utils.UriUtils;
 import com.cloud.utils.component.Manager;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.db.DB;
+import com.cloud.utils.db.GenericSearchBuilder;
 import com.cloud.utils.db.GlobalLock;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Func;
 import com.cloud.utils.db.SearchCriteria.Op;
 import com.cloud.utils.db.SearchCriteria2;
 import com.cloud.utils.db.SearchCriteriaService;
@@ -252,6 +255,8 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
 
     private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION = 30; // seconds
 
+    private GenericSearchBuilder<HostVO, String> _hypervisorsInDC;
+
     private void insertListener(Integer event, ResourceListener listener) {
         List<ResourceListener> lst = _lifeCycleListeners.get(event);
         if (lst == null) {
@@ -1334,6 +1339,15 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
     @Override
     public boolean configure(String name, Map<String, Object> params) throws ConfigurationException
{
         _defaultSystemVMHypervisor = HypervisorType.getType(_configDao.getValue(Config.SystemVMDefaultHypervisor.toString()));
+
+        _hypervisorsInDC = _hostDao.createSearchBuilder(String.class);
+        _hypervisorsInDC.select(null, Func.DISTINCT, _hypervisorsInDC.entity().getHypervisorType());
+        _hypervisorsInDC.and("hypervisorType", _hypervisorsInDC.entity().getHypervisorType(),
SearchCriteria.Op.NNULL);
+        _hypervisorsInDC.and("dataCenter", _hypervisorsInDC.entity().getDataCenterId(), SearchCriteria.Op.EQ);
+        _hypervisorsInDC.and("id", _hypervisorsInDC.entity().getId(), SearchCriteria.Op.NEQ);
+        _hypervisorsInDC.and("type", _hypervisorsInDC.entity().getType(), SearchCriteria.Op.EQ);
+        _hypervisorsInDC.done();
+
         return true;
     }
 
@@ -2386,23 +2400,25 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
 
     @Override
     public List<HypervisorType> listAvailHypervisorInZone(Long hostId, Long zoneId)
{
-        SearchCriteriaService<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
+        SearchCriteria<String> sc = _hypervisorsInDC.create();
         if (zoneId != null) {
-            sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, zoneId);
+            sc.setParameters("dataCenter", zoneId);
         }
         if (hostId != null) {
             // exclude the given host, since we want to check what hypervisor is already
handled
             // in adding this new host
-            sc.addAnd(sc.getEntity().getId(), Op.NEQ, hostId);
+            sc.setParameters("id", hostId);
         }
-        sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.Routing);
-        List<HostVO> hosts = sc.list();
+        sc.setParameters("type", Host.Type.Routing);
 
-        List<HypervisorType> hypers = new ArrayList<HypervisorType>(5);
-        for (HostVO host : hosts) {
-            hypers.add(host.getHypervisorType());
+        // The search is not able to return list of enums, so getting
+        // list of hypervisors as strings and then converting them to enum
+        List<String> hvs = _hostDao.customSearch(sc, null);
+        List<HypervisorType> hypervisors = new ArrayList<HypervisorType>();
+        for (String hv : hvs) {
+            hypervisors.add(HypervisorType.getType(hv));
         }
-        return hypers;
+        return hypervisors;
     }
 
     @Override


Mime
View raw message