You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2013/01/09 05:37:23 UTC

[37/50] [abbrv] git commit: DB view dao cleanup, and introduce global configuration parameter for entity detail batch query size to remove hard-coded VM_DETAILS_BATCH_SIZE.

DB view dao cleanup, and introduce global configuration parameter for
entity detail batch query size to remove hard-coded
VM_DETAILS_BATCH_SIZE.

Signed-off-by: Min Chen <mi...@citrix.com>


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

Branch: refs/heads/master
Commit: 0894822651542560afada3648eb4f9f599fa1415
Parents: a948a89
Author: Min Chen <mi...@citrix.com>
Authored: Mon Jan 7 16:40:31 2013 -0800
Committer: Min Chen <mi...@citrix.com>
Committed: Mon Jan 7 16:40:31 2013 -0800

----------------------------------------------------------------------
 .../com/cloud/api/query/dao/AccountJoinDao.java    |    1 -
 .../cloud/api/query/dao/AccountJoinDaoImpl.java    |   42 ------
 .../com/cloud/api/query/dao/AsyncJobJoinDao.java   |    1 -
 .../cloud/api/query/dao/AsyncJobJoinDaoImpl.java   |   47 -------
 .../api/query/dao/DomainRouterJoinDaoImpl.java     |   50 +++++++-
 .../com/cloud/api/query/dao/HostJoinDaoImpl.java   |   69 ++++++++--
 .../cloud/api/query/dao/InstanceGroupJoinDao.java  |    3 -
 .../api/query/dao/InstanceGroupJoinDaoImpl.java    |   15 --
 .../cloud/api/query/dao/ProjectAccountJoinDao.java |    2 -
 .../api/query/dao/ProjectAccountJoinDaoImpl.java   |   12 +-
 .../query/dao/ProjectInvitationJoinDaoImpl.java    |   12 +-
 .../cloud/api/query/dao/ProjectJoinDaoImpl.java    |   69 ++++++++--
 .../api/query/dao/ResourceTagJoinDaoImpl.java      |   68 ++++++++--
 .../api/query/dao/SecurityGroupJoinDaoImpl.java    |   50 +++++++-
 .../cloud/api/query/dao/UserAccountJoinDao.java    |    2 -
 .../api/query/dao/UserAccountJoinDaoImpl.java      |   15 --
 .../com/cloud/api/query/dao/UserVmJoinDaoImpl.java |   83 ++++++------
 .../com/cloud/api/query/dao/VolumeJoinDaoImpl.java |   52 +++++++-
 server/src/com/cloud/configuration/Config.java     |  101 ++++++++-------
 .../configuration/DefaultComponentLibrary.java     |   27 ++--
 setup/db/db/schema-40to410.sql                     |    1 +
 21 files changed, 427 insertions(+), 295 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/08948226/server/src/com/cloud/api/query/dao/AccountJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/AccountJoinDao.java b/server/src/com/cloud/api/query/dao/AccountJoinDao.java
index 037e444..5485f09 100644
--- a/server/src/com/cloud/api/query/dao/AccountJoinDao.java
+++ b/server/src/com/cloud/api/query/dao/AccountJoinDao.java
@@ -29,5 +29,4 @@ public interface AccountJoinDao extends GenericDao<AccountJoinVO, Long> {
 
     AccountJoinVO newAccountView(Account vol);
 
-    List<AccountJoinVO> searchByIds(Long... ids);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/08948226/server/src/com/cloud/api/query/dao/AccountJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/AccountJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/AccountJoinDaoImpl.java
index 2b18a80..6268724 100644
--- a/server/src/com/cloud/api/query/dao/AccountJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/AccountJoinDaoImpl.java
@@ -16,8 +16,6 @@
 // under the License.
 package com.cloud.api.query.dao;
 
-import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 import javax.ejb.Local;
@@ -25,55 +23,26 @@ import javax.ejb.Local;
 import org.apache.log4j.Logger;
 
 import com.cloud.api.ApiDBUtils;
-import com.cloud.api.ApiResponseHelper;
 import com.cloud.api.query.ViewResponseHelper;
 import com.cloud.api.query.vo.AccountJoinVO;
-import com.cloud.api.query.vo.InstanceGroupJoinVO;
-import com.cloud.api.query.vo.ResourceTagJoinVO;
 import com.cloud.api.query.vo.UserAccountJoinVO;
-import com.cloud.api.query.vo.UserVmJoinVO;
-import com.cloud.api.query.vo.VolumeJoinVO;
 import com.cloud.configuration.Resource.ResourceType;
-import com.cloud.dc.DataCenter;
-import com.cloud.domain.Domain;
-
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.AccountResponse;
-import org.apache.cloudstack.api.response.ListResponse;
 import org.apache.cloudstack.api.response.UserResponse;
-import org.apache.cloudstack.api.response.VolumeResponse;
-
-import com.cloud.offering.ServiceOffering;
-import com.cloud.server.Criteria;
-import com.cloud.storage.Storage;
-import com.cloud.storage.VMTemplateHostVO;
-import com.cloud.storage.Volume;
-import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-import com.cloud.user.UserStatisticsVO;
-import com.cloud.user.UserVO;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
-import com.cloud.vm.VirtualMachine.State;
 
 
 @Local(value={AccountJoinDao.class})
 public class AccountJoinDaoImpl extends GenericDaoBase<AccountJoinVO, Long> implements AccountJoinDao {
     public static final Logger s_logger = Logger.getLogger(AccountJoinDaoImpl.class);
 
-    private SearchBuilder<AccountJoinVO> acctSearch;
-
     private SearchBuilder<AccountJoinVO> acctIdSearch;
 
     protected AccountJoinDaoImpl() {
 
-        acctSearch = createSearchBuilder();
-        acctSearch.and("idIN", acctSearch.entity().getId(), SearchCriteria.Op.IN);
-        acctSearch.done();
-
         acctIdSearch = createSearchBuilder();
         acctIdSearch.and("id", acctIdSearch.entity().getId(), SearchCriteria.Op.EQ);
         acctIdSearch.done();
@@ -213,15 +182,4 @@ public class AccountJoinDaoImpl extends GenericDaoBase<AccountJoinVO, Long> impl
     }
 
 
-
-
-    @Override
-    public List<AccountJoinVO> searchByIds(Long... ids) {
-        SearchCriteria<AccountJoinVO> sc = acctSearch.create();
-        sc.setParameters("idIN", ids);
-        return searchIncludingRemoved(sc, null, null, false);
-    }
-
-
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/08948226/server/src/com/cloud/api/query/dao/AsyncJobJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/AsyncJobJoinDao.java b/server/src/com/cloud/api/query/dao/AsyncJobJoinDao.java
index 59fcc87..f7a2c8c 100644
--- a/server/src/com/cloud/api/query/dao/AsyncJobJoinDao.java
+++ b/server/src/com/cloud/api/query/dao/AsyncJobJoinDao.java
@@ -30,5 +30,4 @@ public interface AsyncJobJoinDao extends GenericDao<AsyncJobJoinVO, Long> {
 
     AsyncJobJoinVO newAsyncJobView(AsyncJob vol);
 
-    List<AsyncJobJoinVO> searchByIds(Long... ids);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/08948226/server/src/com/cloud/api/query/dao/AsyncJobJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/AsyncJobJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/AsyncJobJoinDaoImpl.java
index c0c827b..bf1d15c 100644
--- a/server/src/com/cloud/api/query/dao/AsyncJobJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/AsyncJobJoinDaoImpl.java
@@ -16,71 +16,32 @@
 // under the License.
 package com.cloud.api.query.dao;
 
-import java.util.ArrayList;
 import java.util.Date;
-import java.util.Iterator;
 import java.util.List;
 
 import javax.ejb.Local;
 
 import org.apache.log4j.Logger;
 
-import com.cloud.api.ApiDBUtils;
-import com.cloud.api.ApiResponseHelper;
 import com.cloud.api.ApiSerializerHelper;
 import com.cloud.api.SerializationContext;
-import com.cloud.api.query.ViewResponseHelper;
-import com.cloud.api.query.vo.AccountJoinVO;
 import com.cloud.api.query.vo.AsyncJobJoinVO;
-import com.cloud.api.query.vo.InstanceGroupJoinVO;
-import com.cloud.api.query.vo.ResourceTagJoinVO;
-import com.cloud.api.query.vo.UserAccountJoinVO;
-import com.cloud.api.query.vo.UserVmJoinVO;
-import com.cloud.api.query.vo.VolumeJoinVO;
 import com.cloud.async.AsyncJob;
-import com.cloud.configuration.Resource.ResourceType;
-import com.cloud.dc.DataCenter;
-import com.cloud.domain.Domain;
-
-import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.ResponseObject;
-import org.apache.cloudstack.api.ServerApiException;
-import org.apache.cloudstack.api.response.AccountResponse;
 import org.apache.cloudstack.api.response.AsyncJobResponse;
-import org.apache.cloudstack.api.response.ListResponse;
-import org.apache.cloudstack.api.response.UserResponse;
-import org.apache.cloudstack.api.response.VolumeResponse;
-
-import com.cloud.offering.ServiceOffering;
-import com.cloud.server.Criteria;
-import com.cloud.storage.Storage;
-import com.cloud.storage.VMTemplateHostVO;
-import com.cloud.storage.Volume;
-import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
-import com.cloud.user.Account;
-import com.cloud.user.User;
-import com.cloud.user.UserContext;
-import com.cloud.user.UserStatisticsVO;
-import com.cloud.user.UserVO;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
-import com.cloud.vm.VirtualMachine.State;
 
 
 @Local(value={AsyncJobJoinDao.class})
 public class AsyncJobJoinDaoImpl extends GenericDaoBase<AsyncJobJoinVO, Long> implements AsyncJobJoinDao {
     public static final Logger s_logger = Logger.getLogger(AsyncJobJoinDaoImpl.class);
 
-    private SearchBuilder<AsyncJobJoinVO> jobSearch;
-
     private SearchBuilder<AsyncJobJoinVO> jobIdSearch;
 
     protected AsyncJobJoinDaoImpl() {
 
-        jobSearch = createSearchBuilder();
-        jobSearch.and("idIN", jobSearch.entity().getId(), SearchCriteria.Op.IN);
-        jobSearch.done();
 
         jobIdSearch = createSearchBuilder();
         jobIdSearch.and("id", jobIdSearch.entity().getId(), SearchCriteria.Op.EQ);
@@ -149,13 +110,5 @@ public class AsyncJobJoinDaoImpl extends GenericDaoBase<AsyncJobJoinVO, Long> im
 
 
 
-    @Override
-    public List<AsyncJobJoinVO> searchByIds(Long... ids) {
-        SearchCriteria<AsyncJobJoinVO> sc = jobSearch.create();
-        sc.setParameters("idIN", ids);
-        return searchIncludingRemoved(sc, null, null, false);
-    }
-
-
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/08948226/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java
index 9feb131..94736cd 100644
--- a/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java
@@ -25,12 +25,14 @@ import org.apache.log4j.Logger;
 
 import com.cloud.api.ApiResponseHelper;
 import com.cloud.api.query.vo.DomainRouterJoinVO;
+import com.cloud.configuration.dao.ConfigurationDao;
 
 import org.apache.cloudstack.api.response.DomainRouterResponse;
 import org.apache.cloudstack.api.response.NicResponse;
 import com.cloud.network.Networks.TrafficType;
 import com.cloud.network.router.VirtualRouter;
 import com.cloud.user.Account;
+import com.cloud.utils.component.Inject;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
@@ -40,6 +42,9 @@ import com.cloud.utils.db.SearchCriteria;
 public class DomainRouterJoinDaoImpl extends GenericDaoBase<DomainRouterJoinVO, Long> implements DomainRouterJoinDao {
     public static final Logger s_logger = Logger.getLogger(DomainRouterJoinDaoImpl.class);
 
+    @Inject
+    private ConfigurationDao  _configDao;
+
     private SearchBuilder<DomainRouterJoinVO> vrSearch;
 
     private SearchBuilder<DomainRouterJoinVO> vrIdSearch;
@@ -189,10 +194,47 @@ public class DomainRouterJoinDaoImpl extends GenericDaoBase<DomainRouterJoinVO,
 
 
     @Override
-    public List<DomainRouterJoinVO> searchByIds(Long... ids) {
-        SearchCriteria<DomainRouterJoinVO> sc = vrSearch.create();
-        sc.setParameters("idIN", ids);
-        return searchIncludingRemoved(sc, null, null, false);
+    public List<DomainRouterJoinVO> searchByIds(Long... vrIds) {
+        // set detail batch query size
+        int DETAILS_BATCH_SIZE = 2000;
+        String batchCfg = _configDao.getValue("detail.batch.query.size");
+        if ( batchCfg != null ){
+            DETAILS_BATCH_SIZE = Integer.parseInt(batchCfg);
+        }
+        // query details by batches
+        List<DomainRouterJoinVO> uvList = new ArrayList<DomainRouterJoinVO>();
+        // query details by batches
+        int curr_index = 0;
+        if ( vrIds.length > DETAILS_BATCH_SIZE ){
+            while ( (curr_index + DETAILS_BATCH_SIZE ) <= vrIds.length ) {
+                Long[] ids = new Long[DETAILS_BATCH_SIZE];
+                for (int k = 0, j = curr_index; j < curr_index + DETAILS_BATCH_SIZE; j++, k++) {
+                    ids[k] = vrIds[j];
+                }
+                SearchCriteria<DomainRouterJoinVO> sc = vrSearch.create();
+                sc.setParameters("idIN", ids);
+                List<DomainRouterJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
+                if (vms != null) {
+                    uvList.addAll(vms);
+                }
+                curr_index += DETAILS_BATCH_SIZE;
+            }
+        }
+        if (curr_index < vrIds.length) {
+            int batch_size = (vrIds.length - curr_index);
+            // set the ids value
+            Long[] ids = new Long[batch_size];
+            for (int k = 0, j = curr_index; j < curr_index + batch_size; j++, k++) {
+                ids[k] = vrIds[j];
+            }
+            SearchCriteria<DomainRouterJoinVO> sc = vrSearch.create();
+            sc.setParameters("idIN", ids);
+            List<DomainRouterJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
+            if (vms != null) {
+                uvList.addAll(vms);
+            }
+        }
+        return uvList;
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/08948226/server/src/com/cloud/api/query/dao/HostJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/HostJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/HostJoinDaoImpl.java
index 723a01d..e842383 100644
--- a/server/src/com/cloud/api/query/dao/HostJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/HostJoinDaoImpl.java
@@ -17,6 +17,7 @@
 package com.cloud.api.query.dao;
 
 import java.text.DecimalFormat;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.EnumSet;
 import java.util.Iterator;
@@ -29,12 +30,14 @@ import org.apache.log4j.Logger;
 
 import com.cloud.api.ApiDBUtils;
 import com.cloud.api.query.vo.HostJoinVO;
+import com.cloud.configuration.dao.ConfigurationDao;
 import com.cloud.host.Host;
 import com.cloud.host.HostStats;
 
 import org.apache.cloudstack.api.ApiConstants.HostDetails;
 import org.apache.cloudstack.api.response.HostResponse;
 import com.cloud.storage.StorageStats;
+import com.cloud.utils.component.Inject;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
@@ -44,20 +47,23 @@ import com.cloud.utils.db.SearchCriteria;
 public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements HostJoinDao {
     public static final Logger s_logger = Logger.getLogger(HostJoinDaoImpl.class);
 
-    private SearchBuilder<HostJoinVO> vrSearch;
+    @Inject
+    private ConfigurationDao  _configDao;
 
-    private SearchBuilder<HostJoinVO> vrIdSearch;
+    private SearchBuilder<HostJoinVO> hostSearch;
+
+    private SearchBuilder<HostJoinVO> hostIdSearch;
 
 
     protected HostJoinDaoImpl() {
 
-        vrSearch = createSearchBuilder();
-        vrSearch.and("idIN", vrSearch.entity().getId(), SearchCriteria.Op.IN);
-        vrSearch.done();
+        hostSearch = createSearchBuilder();
+        hostSearch.and("idIN", hostSearch.entity().getId(), SearchCriteria.Op.IN);
+        hostSearch.done();
 
-        vrIdSearch = createSearchBuilder();
-        vrIdSearch.and("id", vrIdSearch.entity().getId(), SearchCriteria.Op.EQ);
-        vrIdSearch.done();
+        hostIdSearch = createSearchBuilder();
+        hostIdSearch.and("id", hostIdSearch.entity().getId(), SearchCriteria.Op.EQ);
+        hostIdSearch.done();
 
         this._count = "select count(distinct id) from host_view WHERE ";
     }
@@ -206,7 +212,7 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
 
     @Override
     public List<HostJoinVO> newHostView(Host host) {
-        SearchCriteria<HostJoinVO> sc = vrIdSearch.create();
+        SearchCriteria<HostJoinVO> sc = hostIdSearch.create();
         sc.setParameters("id", host.getId());
         return searchIncludingRemoved(sc, null, null, false);
 
@@ -215,10 +221,47 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
 
 
     @Override
-    public List<HostJoinVO> searchByIds(Long... ids) {
-        SearchCriteria<HostJoinVO> sc = vrSearch.create();
-        sc.setParameters("idIN", ids);
-        return searchIncludingRemoved(sc, null, null, false);
+    public List<HostJoinVO> searchByIds(Long... hostIds) {
+        // set detail batch query size
+        int DETAILS_BATCH_SIZE = 2000;
+        String batchCfg = _configDao.getValue("detail.batch.query.size");
+        if ( batchCfg != null ){
+            DETAILS_BATCH_SIZE = Integer.parseInt(batchCfg);
+        }
+        // query details by batches
+        List<HostJoinVO> uvList = new ArrayList<HostJoinVO>();
+        // query details by batches
+        int curr_index = 0;
+        if ( hostIds.length > DETAILS_BATCH_SIZE ){
+            while ( (curr_index + DETAILS_BATCH_SIZE ) <= hostIds.length ) {
+                Long[] ids = new Long[DETAILS_BATCH_SIZE];
+                for (int k = 0, j = curr_index; j < curr_index + DETAILS_BATCH_SIZE; j++, k++) {
+                    ids[k] = hostIds[j];
+                }
+                SearchCriteria<HostJoinVO> sc = hostSearch.create();
+                sc.setParameters("idIN", ids);
+                List<HostJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
+                if (vms != null) {
+                    uvList.addAll(vms);
+                }
+                curr_index += DETAILS_BATCH_SIZE;
+            }
+        }
+        if (curr_index < hostIds.length) {
+            int batch_size = (hostIds.length - curr_index);
+            // set the ids value
+            Long[] ids = new Long[batch_size];
+            for (int k = 0, j = curr_index; j < curr_index + batch_size; j++, k++) {
+                ids[k] = hostIds[j];
+            }
+            SearchCriteria<HostJoinVO> sc = hostSearch.create();
+            sc.setParameters("idIN", ids);
+            List<HostJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
+            if (vms != null) {
+                uvList.addAll(vms);
+            }
+        }
+        return uvList;
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/08948226/server/src/com/cloud/api/query/dao/InstanceGroupJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/InstanceGroupJoinDao.java b/server/src/com/cloud/api/query/dao/InstanceGroupJoinDao.java
index 79e5728..78ceab1 100644
--- a/server/src/com/cloud/api/query/dao/InstanceGroupJoinDao.java
+++ b/server/src/com/cloud/api/query/dao/InstanceGroupJoinDao.java
@@ -16,8 +16,6 @@
 // under the License.
 package com.cloud.api.query.dao;
 
-import java.util.List;
-
 import org.apache.cloudstack.api.response.InstanceGroupResponse;
 
 import com.cloud.api.query.vo.InstanceGroupJoinVO;
@@ -30,6 +28,5 @@ public interface InstanceGroupJoinDao extends GenericDao<InstanceGroupJoinVO, Lo
 
     InstanceGroupJoinVO newInstanceGroupView(InstanceGroup group);
 
-    List<InstanceGroupJoinVO> searchByIds(Long... ids);
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/08948226/server/src/com/cloud/api/query/dao/InstanceGroupJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/InstanceGroupJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/InstanceGroupJoinDaoImpl.java
index 8374605..f83ef6c 100644
--- a/server/src/com/cloud/api/query/dao/InstanceGroupJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/InstanceGroupJoinDaoImpl.java
@@ -37,17 +37,11 @@ import com.cloud.vm.InstanceGroup;
 public class InstanceGroupJoinDaoImpl extends GenericDaoBase<InstanceGroupJoinVO, Long> implements InstanceGroupJoinDao {
     public static final Logger s_logger = Logger.getLogger(InstanceGroupJoinDaoImpl.class);
 
-    private SearchBuilder<InstanceGroupJoinVO> vrSearch;
-
     private SearchBuilder<InstanceGroupJoinVO> vrIdSearch;
 
 
     protected InstanceGroupJoinDaoImpl() {
 
-        vrSearch = createSearchBuilder();
-        vrSearch.and("idIN", vrSearch.entity().getId(), SearchCriteria.Op.IN);
-        vrSearch.done();
-
         vrIdSearch = createSearchBuilder();
         vrIdSearch.and("id", vrIdSearch.entity().getId(), SearchCriteria.Op.EQ);
         vrIdSearch.done();
@@ -84,14 +78,5 @@ public class InstanceGroupJoinDaoImpl extends GenericDaoBase<InstanceGroupJoinVO
 
 
 
-    @Override
-    public List<InstanceGroupJoinVO> searchByIds(Long... ids) {
-        SearchCriteria<InstanceGroupJoinVO> sc = vrSearch.create();
-        sc.setParameters("idIN", ids);
-        return searchIncludingRemoved(sc, null, null, false);
-    }
-
-
-
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/08948226/server/src/com/cloud/api/query/dao/ProjectAccountJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/ProjectAccountJoinDao.java b/server/src/com/cloud/api/query/dao/ProjectAccountJoinDao.java
index a653ddd..d8fa0f8 100644
--- a/server/src/com/cloud/api/query/dao/ProjectAccountJoinDao.java
+++ b/server/src/com/cloud/api/query/dao/ProjectAccountJoinDao.java
@@ -16,8 +16,6 @@
 // under the License.
 package com.cloud.api.query.dao;
 
-import java.util.List;
-
 import org.apache.cloudstack.api.response.ProjectAccountResponse;
 
 import com.cloud.api.query.vo.ProjectAccountJoinVO;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/08948226/server/src/com/cloud/api/query/dao/ProjectAccountJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/ProjectAccountJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/ProjectAccountJoinDaoImpl.java
index 59eeb46..f808da0 100644
--- a/server/src/com/cloud/api/query/dao/ProjectAccountJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/ProjectAccountJoinDaoImpl.java
@@ -35,14 +35,14 @@ public class ProjectAccountJoinDaoImpl extends GenericDaoBase<ProjectAccountJoin
     public static final Logger s_logger = Logger.getLogger(ProjectAccountJoinDaoImpl.class);
 
 
-    private SearchBuilder<ProjectAccountJoinVO> vrIdSearch;
+    private SearchBuilder<ProjectAccountJoinVO> paIdSearch;
 
     protected ProjectAccountJoinDaoImpl() {
 
-        vrIdSearch = createSearchBuilder();
-        vrIdSearch.and("accountId", vrIdSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
-        vrIdSearch.and("projectId", vrIdSearch.entity().getProjectId(), SearchCriteria.Op.EQ);
-        vrIdSearch.done();
+        paIdSearch = createSearchBuilder();
+        paIdSearch.and("accountId", paIdSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
+        paIdSearch.and("projectId", paIdSearch.entity().getProjectId(), SearchCriteria.Op.EQ);
+        paIdSearch.done();
 
         this._count = "select count(distinct id) from project_account_view WHERE ";
     }
@@ -74,7 +74,7 @@ public class ProjectAccountJoinDaoImpl extends GenericDaoBase<ProjectAccountJoin
 
     @Override
     public ProjectAccountJoinVO newProjectAccountView(ProjectAccount proj) {
-        SearchCriteria<ProjectAccountJoinVO> sc = vrIdSearch.create();
+        SearchCriteria<ProjectAccountJoinVO> sc = paIdSearch.create();
         sc.setParameters("accountId", proj.getAccountId());
         sc.setParameters("projectId", proj.getProjectId());
         List<ProjectAccountJoinVO> grps = searchIncludingRemoved(sc, null, null, false);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/08948226/server/src/com/cloud/api/query/dao/ProjectInvitationJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/ProjectInvitationJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/ProjectInvitationJoinDaoImpl.java
index 4173861..ebf64d1 100644
--- a/server/src/com/cloud/api/query/dao/ProjectInvitationJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/ProjectInvitationJoinDaoImpl.java
@@ -24,10 +24,8 @@ import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.response.ProjectInvitationResponse;
 
-import com.cloud.api.ApiDBUtils;
 import com.cloud.api.query.vo.ProjectInvitationJoinVO;
 import com.cloud.projects.ProjectInvitation;
-import com.cloud.user.Account;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
@@ -37,13 +35,13 @@ public class ProjectInvitationJoinDaoImpl extends GenericDaoBase<ProjectInvitati
     public static final Logger s_logger = Logger.getLogger(ProjectInvitationJoinDaoImpl.class);
 
 
-    private SearchBuilder<ProjectInvitationJoinVO> vrIdSearch;
+    private SearchBuilder<ProjectInvitationJoinVO> piIdSearch;
 
     protected ProjectInvitationJoinDaoImpl() {
 
-        vrIdSearch = createSearchBuilder();
-        vrIdSearch.and("id", vrIdSearch.entity().getId(), SearchCriteria.Op.EQ);
-        vrIdSearch.done();
+        piIdSearch = createSearchBuilder();
+        piIdSearch.and("id", piIdSearch.entity().getId(), SearchCriteria.Op.EQ);
+        piIdSearch.done();
 
         this._count = "select count(distinct id) from project_invitation_view WHERE ";
     }
@@ -75,7 +73,7 @@ public class ProjectInvitationJoinDaoImpl extends GenericDaoBase<ProjectInvitati
 
     @Override
     public ProjectInvitationJoinVO newProjectInvitationView(ProjectInvitation proj) {
-        SearchCriteria<ProjectInvitationJoinVO> sc = vrIdSearch.create();
+        SearchCriteria<ProjectInvitationJoinVO> sc = piIdSearch.create();
         sc.setParameters("id", proj.getId());
         List<ProjectInvitationJoinVO> grps = searchIncludingRemoved(sc, null, null, false);
         assert grps != null && grps.size() == 1 : "No project invitation found for id  " + proj.getId();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/08948226/server/src/com/cloud/api/query/dao/ProjectJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/ProjectJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/ProjectJoinDaoImpl.java
index 3663e07..15bff36 100644
--- a/server/src/com/cloud/api/query/dao/ProjectJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/ProjectJoinDaoImpl.java
@@ -16,6 +16,7 @@
 // under the License.
 package com.cloud.api.query.dao;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import javax.ejb.Local;
@@ -25,9 +26,11 @@ import org.apache.log4j.Logger;
 import com.cloud.api.ApiDBUtils;
 import com.cloud.api.query.vo.ProjectJoinVO;
 import com.cloud.api.query.vo.ResourceTagJoinVO;
+import com.cloud.configuration.dao.ConfigurationDao;
 
 import org.apache.cloudstack.api.response.ProjectResponse;
 import com.cloud.projects.Project;
+import com.cloud.utils.component.Inject;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
@@ -36,19 +39,22 @@ import com.cloud.utils.db.SearchCriteria;
 public class ProjectJoinDaoImpl extends GenericDaoBase<ProjectJoinVO, Long> implements ProjectJoinDao {
     public static final Logger s_logger = Logger.getLogger(ProjectJoinDaoImpl.class);
 
-    private SearchBuilder<ProjectJoinVO> vrSearch;
+    @Inject
+    private ConfigurationDao  _configDao;
 
-    private SearchBuilder<ProjectJoinVO> vrIdSearch;
+    private SearchBuilder<ProjectJoinVO> prjSearch;
+
+    private SearchBuilder<ProjectJoinVO> prjIdSearch;
 
     protected ProjectJoinDaoImpl() {
 
-        vrSearch = createSearchBuilder();
-        vrSearch.and("idIN", vrSearch.entity().getId(), SearchCriteria.Op.IN);
-        vrSearch.done();
+        prjSearch = createSearchBuilder();
+        prjSearch.and("idIN", prjSearch.entity().getId(), SearchCriteria.Op.IN);
+        prjSearch.done();
 
-        vrIdSearch = createSearchBuilder();
-        vrIdSearch.and("id", vrIdSearch.entity().getId(), SearchCriteria.Op.EQ);
-        vrIdSearch.done();
+        prjIdSearch = createSearchBuilder();
+        prjIdSearch.and("id", prjIdSearch.entity().getId(), SearchCriteria.Op.EQ);
+        prjIdSearch.done();
 
         this._count = "select count(distinct id) from project_view WHERE ";
     }
@@ -95,16 +101,53 @@ public class ProjectJoinDaoImpl extends GenericDaoBase<ProjectJoinVO, Long> impl
 
     @Override
     public List<ProjectJoinVO> newProjectView(Project proj) {
-        SearchCriteria<ProjectJoinVO> sc = vrIdSearch.create();
+        SearchCriteria<ProjectJoinVO> sc = prjIdSearch.create();
         sc.setParameters("id", proj.getId());
         return searchIncludingRemoved(sc, null, null, false);
     }
 
     @Override
-    public List<ProjectJoinVO> searchByIds(Long... ids) {
-        SearchCriteria<ProjectJoinVO> sc = vrSearch.create();
-        sc.setParameters("idIN", ids);
-        return searchIncludingRemoved(sc, null, null, false);
+    public List<ProjectJoinVO> searchByIds(Long... prjIds) {
+        // set detail batch query size
+        int DETAILS_BATCH_SIZE = 2000;
+        String batchCfg = _configDao.getValue("detail.batch.query.size");
+        if ( batchCfg != null ){
+            DETAILS_BATCH_SIZE = Integer.parseInt(batchCfg);
+        }
+        // query details by batches
+        List<ProjectJoinVO> uvList = new ArrayList<ProjectJoinVO>();
+        // query details by batches
+        int curr_index = 0;
+        if ( prjIds.length > DETAILS_BATCH_SIZE ){
+            while ( (curr_index + DETAILS_BATCH_SIZE ) <= prjIds.length ) {
+                Long[] ids = new Long[DETAILS_BATCH_SIZE];
+                for (int k = 0, j = curr_index; j < curr_index + DETAILS_BATCH_SIZE; j++, k++) {
+                    ids[k] = prjIds[j];
+                }
+                SearchCriteria<ProjectJoinVO> sc = prjSearch.create();
+                sc.setParameters("idIN", ids);
+                List<ProjectJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
+                if (vms != null) {
+                    uvList.addAll(vms);
+                }
+                curr_index += DETAILS_BATCH_SIZE;
+            }
+        }
+        if (curr_index < prjIds.length) {
+            int batch_size = (prjIds.length - curr_index);
+            // set the ids value
+            Long[] ids = new Long[batch_size];
+            for (int k = 0, j = curr_index; j < curr_index + batch_size; j++, k++) {
+                ids[k] = prjIds[j];
+            }
+            SearchCriteria<ProjectJoinVO> sc = prjSearch.create();
+            sc.setParameters("idIN", ids);
+            List<ProjectJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
+            if (vms != null) {
+                uvList.addAll(vms);
+            }
+        }
+        return uvList;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/08948226/server/src/com/cloud/api/query/dao/ResourceTagJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/ResourceTagJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/ResourceTagJoinDaoImpl.java
index badf457..5adee9e 100644
--- a/server/src/com/cloud/api/query/dao/ResourceTagJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/ResourceTagJoinDaoImpl.java
@@ -25,9 +25,11 @@ import org.apache.log4j.Logger;
 
 import com.cloud.api.ApiResponseHelper;
 import com.cloud.api.query.vo.ResourceTagJoinVO;
+import com.cloud.configuration.dao.ConfigurationDao;
 
 import org.apache.cloudstack.api.response.ResourceTagResponse;
 import com.cloud.server.ResourceTag;
+import com.cloud.utils.component.Inject;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
@@ -37,19 +39,22 @@ import com.cloud.utils.db.SearchCriteria;
 public class ResourceTagJoinDaoImpl extends GenericDaoBase<ResourceTagJoinVO, Long> implements ResourceTagJoinDao {
     public static final Logger s_logger = Logger.getLogger(ResourceTagJoinDaoImpl.class);
 
-    private SearchBuilder<ResourceTagJoinVO> vrSearch;
+    @Inject
+    private ConfigurationDao  _configDao;
 
-    private SearchBuilder<ResourceTagJoinVO> vrIdSearch;
+    private SearchBuilder<ResourceTagJoinVO> tagSearch;
+
+    private SearchBuilder<ResourceTagJoinVO> tagIdSearch;
 
     protected ResourceTagJoinDaoImpl() {
 
-        vrSearch = createSearchBuilder();
-        vrSearch.and("idIN", vrSearch.entity().getId(), SearchCriteria.Op.IN);
-        vrSearch.done();
+        tagSearch = createSearchBuilder();
+        tagSearch.and("idIN", tagSearch.entity().getId(), SearchCriteria.Op.IN);
+        tagSearch.done();
 
-        vrIdSearch = createSearchBuilder();
-        vrIdSearch.and("id", vrIdSearch.entity().getId(), SearchCriteria.Op.EQ);
-        vrIdSearch.done();
+        tagIdSearch = createSearchBuilder();
+        tagIdSearch.and("id", tagIdSearch.entity().getId(), SearchCriteria.Op.EQ);
+        tagIdSearch.done();
 
         this._count = "select count(distinct id) from resource_tag_view WHERE ";
     }
@@ -83,17 +88,54 @@ public class ResourceTagJoinDaoImpl extends GenericDaoBase<ResourceTagJoinVO, Lo
 
 
     @Override
-    public List<ResourceTagJoinVO> searchByIds(Long... ids) {
-        SearchCriteria<ResourceTagJoinVO> sc = vrSearch.create();
-        sc.setParameters("idIN", ids);
-        return searchIncludingRemoved(sc, null, null, false);
+    public List<ResourceTagJoinVO> searchByIds(Long... tagIds) {
+        // set detail batch query size
+        int DETAILS_BATCH_SIZE = 2000;
+        String batchCfg = _configDao.getValue("detail.batch.query.size");
+        if ( batchCfg != null ){
+            DETAILS_BATCH_SIZE = Integer.parseInt(batchCfg);
+        }
+        // query details by batches
+        List<ResourceTagJoinVO> uvList = new ArrayList<ResourceTagJoinVO>();
+        // query details by batches
+        int curr_index = 0;
+        if ( tagIds.length > DETAILS_BATCH_SIZE ){
+            while ( (curr_index + DETAILS_BATCH_SIZE ) <= tagIds.length ) {
+                Long[] ids = new Long[DETAILS_BATCH_SIZE];
+                for (int k = 0, j = curr_index; j < curr_index + DETAILS_BATCH_SIZE; j++, k++) {
+                    ids[k] = tagIds[j];
+                }
+                SearchCriteria<ResourceTagJoinVO> sc = tagSearch.create();
+                sc.setParameters("idIN", ids);
+                List<ResourceTagJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
+                if (vms != null) {
+                    uvList.addAll(vms);
+                }
+                curr_index += DETAILS_BATCH_SIZE;
+            }
+        }
+        if (curr_index < tagIds.length) {
+            int batch_size = (tagIds.length - curr_index);
+            // set the ids value
+            Long[] ids = new Long[batch_size];
+            for (int k = 0, j = curr_index; j < curr_index + batch_size; j++, k++) {
+                ids[k] = tagIds[j];
+            }
+            SearchCriteria<ResourceTagJoinVO> sc = tagSearch.create();
+            sc.setParameters("idIN", ids);
+            List<ResourceTagJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
+            if (vms != null) {
+                uvList.addAll(vms);
+            }
+        }
+        return uvList;
     }
 
 
     @Override
     public ResourceTagJoinVO newResourceTagView(ResourceTag vr) {
 
-        SearchCriteria<ResourceTagJoinVO> sc = vrIdSearch.create();
+        SearchCriteria<ResourceTagJoinVO> sc = tagIdSearch.create();
         sc.setParameters("id", vr.getId());
         List<ResourceTagJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
         assert vms != null && vms.size() == 1 : "No tag found for tag id " + vr.getId();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/08948226/server/src/com/cloud/api/query/dao/SecurityGroupJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/SecurityGroupJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/SecurityGroupJoinDaoImpl.java
index 57cbf47..c35c4aa 100644
--- a/server/src/com/cloud/api/query/dao/SecurityGroupJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/SecurityGroupJoinDaoImpl.java
@@ -27,12 +27,14 @@ import com.cloud.api.ApiDBUtils;
 import com.cloud.api.ApiResponseHelper;
 import com.cloud.api.query.vo.ResourceTagJoinVO;
 import com.cloud.api.query.vo.SecurityGroupJoinVO;
+import com.cloud.configuration.dao.ConfigurationDao;
 
 import org.apache.cloudstack.api.response.SecurityGroupResponse;
 import org.apache.cloudstack.api.response.SecurityGroupRuleResponse;
 import com.cloud.network.security.SecurityGroup;
 import com.cloud.network.security.SecurityRule.SecurityRuleType;
 import com.cloud.user.Account;
+import com.cloud.utils.component.Inject;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
@@ -41,6 +43,9 @@ import com.cloud.utils.db.SearchCriteria;
 public class SecurityGroupJoinDaoImpl extends GenericDaoBase<SecurityGroupJoinVO, Long> implements SecurityGroupJoinDao {
     public static final Logger s_logger = Logger.getLogger(SecurityGroupJoinDaoImpl.class);
 
+    @Inject
+    private ConfigurationDao  _configDao;
+
     private SearchBuilder<SecurityGroupJoinVO> sgSearch;
 
     private SearchBuilder<SecurityGroupJoinVO> sgIdSearch;
@@ -175,9 +180,46 @@ public class SecurityGroupJoinDaoImpl extends GenericDaoBase<SecurityGroupJoinVO
     }
 
     @Override
-    public List<SecurityGroupJoinVO> searchByIds(Long... ids) {
-        SearchCriteria<SecurityGroupJoinVO> sc = sgSearch.create();
-        sc.setParameters("idIN", ids);
-        return searchIncludingRemoved(sc, null, null, false);
+    public List<SecurityGroupJoinVO> searchByIds(Long... sgIds) {
+        // set detail batch query size
+        int DETAILS_BATCH_SIZE = 2000;
+        String batchCfg = _configDao.getValue("detail.batch.query.size");
+        if ( batchCfg != null ){
+            DETAILS_BATCH_SIZE = Integer.parseInt(batchCfg);
+        }
+        // query details by batches
+        List<SecurityGroupJoinVO> uvList = new ArrayList<SecurityGroupJoinVO>();
+        // query details by batches
+        int curr_index = 0;
+        if ( sgIds.length > DETAILS_BATCH_SIZE ){
+            while ( (curr_index + DETAILS_BATCH_SIZE ) <= sgIds.length ) {
+                Long[] ids = new Long[DETAILS_BATCH_SIZE];
+                for (int k = 0, j = curr_index; j < curr_index + DETAILS_BATCH_SIZE; j++, k++) {
+                    ids[k] = sgIds[j];
+                }
+                SearchCriteria<SecurityGroupJoinVO> sc = sgSearch.create();
+                sc.setParameters("idIN", ids);
+                List<SecurityGroupJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
+                if (vms != null) {
+                    uvList.addAll(vms);
+                }
+                curr_index += DETAILS_BATCH_SIZE;
+            }
+        }
+        if (curr_index < sgIds.length) {
+            int batch_size = (sgIds.length - curr_index);
+            // set the ids value
+            Long[] ids = new Long[batch_size];
+            for (int k = 0, j = curr_index; j < curr_index + batch_size; j++, k++) {
+                ids[k] = sgIds[j];
+            }
+            SearchCriteria<SecurityGroupJoinVO> sc = sgSearch.create();
+            sc.setParameters("idIN", ids);
+            List<SecurityGroupJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
+            if (vms != null) {
+                uvList.addAll(vms);
+            }
+        }
+        return uvList;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/08948226/server/src/com/cloud/api/query/dao/UserAccountJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/UserAccountJoinDao.java b/server/src/com/cloud/api/query/dao/UserAccountJoinDao.java
index 50f221e..b48f192 100644
--- a/server/src/com/cloud/api/query/dao/UserAccountJoinDao.java
+++ b/server/src/com/cloud/api/query/dao/UserAccountJoinDao.java
@@ -33,8 +33,6 @@ public interface UserAccountJoinDao extends GenericDao<UserAccountJoinVO, Long>
 
     UserAccountJoinVO newUserView(UserAccount usr);
 
-    List<UserAccountJoinVO> searchByIds(Long... ids);
-
     List<UserAccountJoinVO> searchByAccountId(Long accountId);
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/08948226/server/src/com/cloud/api/query/dao/UserAccountJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/UserAccountJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/UserAccountJoinDaoImpl.java
index 767f190..b1f5dca 100644
--- a/server/src/com/cloud/api/query/dao/UserAccountJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/UserAccountJoinDaoImpl.java
@@ -43,7 +43,6 @@ import com.cloud.vm.InstanceGroup;
 public class UserAccountJoinDaoImpl extends GenericDaoBase<UserAccountJoinVO, Long> implements UserAccountJoinDao {
     public static final Logger s_logger = Logger.getLogger(UserAccountJoinDaoImpl.class);
 
-    private SearchBuilder<UserAccountJoinVO> vrSearch;
 
     private SearchBuilder<UserAccountJoinVO> vrIdSearch;
 
@@ -52,10 +51,6 @@ public class UserAccountJoinDaoImpl extends GenericDaoBase<UserAccountJoinVO, Lo
 
     protected UserAccountJoinDaoImpl() {
 
-        vrSearch = createSearchBuilder();
-        vrSearch.and("idIN", vrSearch.entity().getId(), SearchCriteria.Op.IN);
-        vrSearch.done();
-
         vrIdSearch = createSearchBuilder();
         vrIdSearch.and("id", vrIdSearch.entity().getId(), SearchCriteria.Op.EQ);
         vrIdSearch.done();
@@ -121,16 +116,6 @@ public class UserAccountJoinDaoImpl extends GenericDaoBase<UserAccountJoinVO, Lo
     }
 
 
-
-    @Override
-    public List<UserAccountJoinVO> searchByIds(Long... ids) {
-        SearchCriteria<UserAccountJoinVO> sc = vrSearch.create();
-        sc.setParameters("idIN", ids);
-        return searchIncludingRemoved(sc, null, null, false);
-    }
-
-
-
     @Override
     public List<UserAccountJoinVO> searchByAccountId(Long accountId) {
         SearchCriteria<UserAccountJoinVO> sc = vrAcctIdSearch.create();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/08948226/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
index c134284..3310518 100644
--- a/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
@@ -21,6 +21,7 @@ import java.util.ArrayList;
 import java.util.EnumSet;
 import java.util.Hashtable;
 import java.util.List;
+import java.util.Set;
 
 import javax.ejb.Local;
 
@@ -29,6 +30,7 @@ import org.apache.log4j.Logger;
 import com.cloud.api.ApiDBUtils;
 import com.cloud.api.query.vo.ResourceTagJoinVO;
 import com.cloud.api.query.vo.UserVmJoinVO;
+import com.cloud.configuration.dao.ConfigurationDao;
 
 import org.apache.cloudstack.api.ApiConstants.VMDetails;
 import org.apache.cloudstack.api.response.NicResponse;
@@ -36,6 +38,8 @@ import org.apache.cloudstack.api.response.SecurityGroupResponse;
 import org.apache.cloudstack.api.response.UserVmResponse;
 import com.cloud.user.Account;
 import com.cloud.uservm.UserVm;
+import com.cloud.utils.component.ComponentLocator;
+import com.cloud.utils.component.Inject;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
@@ -46,7 +50,8 @@ import com.cloud.vm.VmStats;
 public class UserVmJoinDaoImpl extends GenericDaoBase<UserVmJoinVO, Long> implements UserVmJoinDao {
     public static final Logger s_logger = Logger.getLogger(UserVmJoinDaoImpl.class);
 
-    private static final int VM_DETAILS_BATCH_SIZE=100;
+    @Inject
+    private ConfigurationDao  _configDao;
 
     private SearchBuilder<UserVmJoinVO> VmDetailSearch;
 
@@ -57,6 +62,8 @@ public class UserVmJoinDaoImpl extends GenericDaoBase<UserVmJoinVO, Long> implem
         VmDetailSearch.done();
 
         this._count = "select count(distinct id) from user_vm_view WHERE ";
+
+
     }
 
     public UserVmResponse newUserVmResponse(String objectName, UserVmJoinVO userVm, EnumSet<VMDetails> details, Account caller) {
@@ -265,64 +272,60 @@ public class UserVmJoinDaoImpl extends GenericDaoBase<UserVmJoinVO, Long> implem
 
     @Override
     public List<UserVmJoinVO> searchByIds(Long... vmIds) {
-        SearchCriteria<UserVmJoinVO> sc = VmDetailSearch.create();
-        sc.setParameters("idIN", vmIds);
-        return searchIncludingRemoved(sc, null, null, false);
-    }
-
-    @Override
-    public List<UserVmJoinVO> newUserVmView(UserVm... userVms) {
-
-        int curr_index = 0;
-
-        Hashtable<Long, UserVm> userVmDataHash = new Hashtable<Long, UserVm>();
-        for (UserVm vm : userVms){
-            if ( !userVmDataHash.containsKey(vm.getId())){
-                userVmDataHash.put(vm.getId(), vm);
-            }
+        // set detail batch query size
+        int DETAILS_BATCH_SIZE = 2000;
+        String batchCfg = _configDao.getValue("detail.batch.query.size");
+        if ( batchCfg != null ){
+            DETAILS_BATCH_SIZE = Integer.parseInt(batchCfg);
         }
-
+        // query details by batches
         List<UserVmJoinVO> uvList = new ArrayList<UserVmJoinVO>();
-        List<Long> userVmIdList = new ArrayList(userVmDataHash.keySet());
-         if (userVmIdList.size() > VM_DETAILS_BATCH_SIZE) {
-            while ((curr_index + VM_DETAILS_BATCH_SIZE) <= userVmIdList.size()) {
-                // set current ids
-                Long[] vmIds = new Long[VM_DETAILS_BATCH_SIZE];
-                for (int k = 0, j = curr_index; j < curr_index + VM_DETAILS_BATCH_SIZE; j++, k++) {
-                    vmIds[k] = userVmIdList.get(j);
+        // query details by batches
+        int curr_index = 0;
+        if ( vmIds.length > DETAILS_BATCH_SIZE ){
+            while ( (curr_index + DETAILS_BATCH_SIZE ) <= vmIds.length ) {
+                Long[] ids = new Long[DETAILS_BATCH_SIZE];
+                for (int k = 0, j = curr_index; j < curr_index + DETAILS_BATCH_SIZE; j++, k++) {
+                    ids[k] = vmIds[j];
                 }
                 SearchCriteria<UserVmJoinVO> sc = VmDetailSearch.create();
-                sc.setParameters("idIN", vmIds);
+                sc.setParameters("idIN", ids);
                 List<UserVmJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
                 if (vms != null) {
-                    for (UserVmJoinVO uvm : vms) {
-                        uvList.add(uvm);
-                    }
+                    uvList.addAll(vms);
                 }
-                curr_index += VM_DETAILS_BATCH_SIZE;
+                curr_index += DETAILS_BATCH_SIZE;
             }
         }
-
-        if (curr_index < userVmIdList.size()) {
-            int batch_size = (userVmIdList.size() - curr_index);
+        if (curr_index < vmIds.length) {
+            int batch_size = (vmIds.length - curr_index);
             // set the ids value
-            Long[] vmIds = new Long[batch_size];
+            Long[] ids = new Long[batch_size];
             for (int k = 0, j = curr_index; j < curr_index + batch_size; j++, k++) {
-                vmIds[k] = userVmIdList.get(j);
+                ids[k] = vmIds[j];
             }
             SearchCriteria<UserVmJoinVO> sc = VmDetailSearch.create();
-            sc.setParameters("idIN", vmIds);
+            sc.setParameters("idIN", ids);
             List<UserVmJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
             if (vms != null) {
-                for (UserVmJoinVO uvm : vms) {
-                    UserVm vm = userVmDataHash.get(uvm.getId());
-                    assert vm != null : "We should not find details of vm not in the passed UserVm list";
-                    uvList.add(uvm);
-                }
+                uvList.addAll(vms);
             }
         }
         return uvList;
+    }
+
+    @Override
+    public List<UserVmJoinVO> newUserVmView(UserVm... userVms) {
+
+        Hashtable<Long, UserVm> userVmDataHash = new Hashtable<Long, UserVm>();
+        for (UserVm vm : userVms){
+            if ( !userVmDataHash.containsKey(vm.getId())){
+                userVmDataHash.put(vm.getId(), vm);
+            }
+        }
 
+        Set<Long> vmIdSet = userVmDataHash.keySet();
+        return searchByIds(vmIdSet.toArray(new Long[vmIdSet.size()]));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/08948226/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
index c6bc7b5..35ba2eb 100644
--- a/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
@@ -16,6 +16,7 @@
 // under the License.
 package com.cloud.api.query.dao;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import javax.ejb.Local;
@@ -26,6 +27,8 @@ import com.cloud.api.ApiDBUtils;
 import com.cloud.api.ApiResponseHelper;
 import com.cloud.api.query.vo.ResourceTagJoinVO;
 import com.cloud.api.query.vo.VolumeJoinVO;
+import com.cloud.configuration.dao.ConfigurationDao;
+
 import org.apache.cloudstack.api.response.VolumeResponse;
 
 import com.cloud.offering.ServiceOffering;
@@ -35,6 +38,7 @@ import com.cloud.storage.Volume;
 import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
 import com.cloud.user.Account;
 import com.cloud.user.UserContext;
+import com.cloud.utils.component.Inject;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
@@ -44,6 +48,9 @@ import com.cloud.utils.db.SearchCriteria;
 public class VolumeJoinDaoImpl extends GenericDaoBase<VolumeJoinVO, Long> implements VolumeJoinDao {
     public static final Logger s_logger = Logger.getLogger(VolumeJoinDaoImpl.class);
 
+    @Inject
+    private ConfigurationDao  _configDao;
+
     private SearchBuilder<VolumeJoinVO> volSearch;
 
     private SearchBuilder<VolumeJoinVO> volIdSearch;
@@ -224,10 +231,47 @@ public class VolumeJoinDaoImpl extends GenericDaoBase<VolumeJoinVO, Long> implem
 
 
     @Override
-    public List<VolumeJoinVO> searchByIds(Long... ids) {
-        SearchCriteria<VolumeJoinVO> sc = volSearch.create();
-        sc.setParameters("idIN", ids);
-        return searchIncludingRemoved(sc, null, null, false);
+    public List<VolumeJoinVO> searchByIds(Long... volIds) {
+        // set detail batch query size
+        int DETAILS_BATCH_SIZE = 2000;
+        String batchCfg = _configDao.getValue("detail.batch.query.size");
+        if ( batchCfg != null ){
+            DETAILS_BATCH_SIZE = Integer.parseInt(batchCfg);
+        }
+        // query details by batches
+        List<VolumeJoinVO> uvList = new ArrayList<VolumeJoinVO>();
+        // query details by batches
+        int curr_index = 0;
+        if ( volIds.length > DETAILS_BATCH_SIZE ){
+            while ( (curr_index + DETAILS_BATCH_SIZE ) <= volIds.length ) {
+                Long[] ids = new Long[DETAILS_BATCH_SIZE];
+                for (int k = 0, j = curr_index; j < curr_index + DETAILS_BATCH_SIZE; j++, k++) {
+                    ids[k] = volIds[j];
+                }
+                SearchCriteria<VolumeJoinVO> sc = volSearch.create();
+                sc.setParameters("idIN", ids);
+                List<VolumeJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
+                if (vms != null) {
+                    uvList.addAll(vms);
+                }
+                curr_index += DETAILS_BATCH_SIZE;
+            }
+        }
+        if (curr_index < volIds.length) {
+            int batch_size = (volIds.length - curr_index);
+            // set the ids value
+            Long[] ids = new Long[batch_size];
+            for (int k = 0, j = curr_index; j < curr_index + batch_size; j++, k++) {
+                ids[k] = volIds[j];
+            }
+            SearchCriteria<VolumeJoinVO> sc = volSearch.create();
+            sc.setParameters("idIN", ids);
+            List<VolumeJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
+            if (vms != null) {
+                uvList.addAll(vms);
+            }
+        }
+        return uvList;
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/08948226/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java
index 92313ea..b91fbdd 100755
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -35,15 +35,15 @@ import com.cloud.template.TemplateManager;
 import com.cloud.vm.UserVmManager;
 
 public enum Config {
-	
+
 	// Alert
-	
+
 	AlertEmailAddresses("Alert", ManagementServer.class, String.class, "alert.email.addresses", null, "Comma separated list of email addresses used for sending alerts.", null),
 	AlertEmailSender("Alert", ManagementServer.class, String.class, "alert.email.sender", null, "Sender of alert email (will be in the From header of the email).", null),
 	AlertSMTPHost("Alert", ManagementServer.class, String.class, "alert.smtp.host", null, "SMTP hostname used for sending out email alerts.", null),
 	AlertSMTPPassword("Secure", ManagementServer.class, String.class, "alert.smtp.password", null, "Password for SMTP authentication (applies only if alert.smtp.useAuth is true).", null),
 	AlertSMTPPort("Alert", ManagementServer.class, Integer.class, "alert.smtp.port", "465", "Port the SMTP server is listening on.", null),
-	AlertSMTPUseAuth("Alert", ManagementServer.class, String.class, "alert.smtp.useAuth", null, "If true, use SMTP authentication when sending emails.", null),	
+	AlertSMTPUseAuth("Alert", ManagementServer.class, String.class, "alert.smtp.useAuth", null, "If true, use SMTP authentication when sending emails.", null),
 	AlertSMTPUsername("Alert", ManagementServer.class, String.class, "alert.smtp.username", null, "Username for SMTP authentication (applies only if alert.smtp.useAuth is true).", null),
 	AlertWait("Alert", AgentManager.class, Integer.class, "alert.wait", null, "Seconds to wait before alerting on a disconnected agent", null),
 	CapacityCheckPeriod("Alert", ManagementServer.class, Integer.class, "capacity.check.period", "300000", "The interval in milliseconds between capacity checks", null),
@@ -62,9 +62,9 @@ public enum Config {
 	CPUCapacityDisableThreshold("Alert", ManagementServer.class, Float.class, "cluster.cpu.allocated.capacity.disablethreshold", "0.85", "Percentage (as a value between 0 and 1) of cpu utilization above which allocators will disable using the cluster for low cpu available. Keep the corresponding notification threshold lower than this to be notified beforehand.", null),
 	MemoryCapacityDisableThreshold("Alert", ManagementServer.class, Float.class, "cluster.memory.allocated.capacity.disablethreshold", "0.85", "Percentage (as a value between 0 and 1) of memory utilization above which allocators will disable using the cluster for low memory available. Keep the corresponding notification threshold lower than this to be notified beforehand.", null),
 
-	
+
 	// Storage
-	
+
 	StorageOverprovisioningFactor("Storage", StoragePoolAllocator.class, String.class, "storage.overprovisioning.factor", "2", "Used for storage overprovisioning calculation; available storage will be (actualStorageSize * storage.overprovisioning.factor)", null),
 	StorageStatsInterval("Storage", ManagementServer.class, String.class, "storage.stats.interval", "60000", "The interval (in milliseconds) when storage stats (per host) are retrieved from agents.", null),
 	MaxVolumeSize("Storage", ManagementServer.class, Integer.class, "storage.max.volume.size", "2000", "The maximum size for a volume (in GB).", null),
@@ -84,9 +84,9 @@ public enum Config {
 	NetworkLBHaproxyStatsVisbility("Network", ManagementServer.class, String.class, "network.loadbalancer.haproxy.stats.visibility", "global", "Load Balancer(haproxy) stats visibilty, the value can be one of the following six parameters : global,guest-network,link-local,disabled,all,default", null),
 	NetworkLBHaproxyStatsUri("Network", ManagementServer.class, String.class, "network.loadbalancer.haproxy.stats.uri","/admin?stats","Load Balancer(haproxy) uri.",null),
 	NetworkLBHaproxyStatsAuth("Secure", ManagementServer.class, String.class, "network.loadbalancer.haproxy.stats.auth","admin1:AdMiN123","Load Balancer(haproxy) authetication string in the format username:password",null),
-	NetworkLBHaproxyStatsPort("Network", ManagementServer.class, String.class, "network.loadbalancer.haproxy.stats.port","8081","Load Balancer(haproxy) stats port number.",null),		
+	NetworkLBHaproxyStatsPort("Network", ManagementServer.class, String.class, "network.loadbalancer.haproxy.stats.port","8081","Load Balancer(haproxy) stats port number.",null),
 	NetworkRouterRpFilter("Network", ManagementServer.class, Integer.class, "network.disable.rpfilter", "true", "disable rp_filter on Domain Router VM public interfaces.", null),
-    
+
 	GuestVlanBits("Network", ManagementServer.class, Integer.class, "guest.vlan.bits", "12", "The number of bits to reserve for the VLAN identifier in the guest subnet.", null),
 	//MulticastThrottlingRate("Network", ManagementServer.class, Integer.class, "multicast.throttling.rate", "10", "Default multicast rate in megabits per second allowed.", null),
 	NetworkThrottlingRate("Network", ManagementServer.class, Integer.class, "network.throttling.rate", "200", "Default data transfer rate in megabits per second allowed in network.", null),
@@ -102,18 +102,18 @@ public enum Config {
 	SecurityGroupWorkerThreads("Network", ManagementServer.class, Integer.class, "network.securitygroups.workers.pool.size", "50", "Number of worker threads processing the security group update work queue", null),
 	SecurityGroupWorkGlobalLockTimeout("Network", ManagementServer.class, Integer.class, "network.securitygroups.work.lock.timeout", "300", "Lock wait timeout (seconds) while updating the security group work queue", null),
 	SecurityGroupWorkPerAgentMaxQueueSize("Network", ManagementServer.class, Integer.class, "network.securitygroups.work.per.agent.queue.size", "100", "The number of outstanding security group work items that can be queued to a host. If exceeded, work items will get dropped to conserve memory. Security Group Sync will take care of ensuring that the host gets updated eventually", null),
-	
+
 	SecurityGroupDefaultAdding("Network", ManagementServer.class, Boolean.class, "network.securitygroups.defaultadding", "true", "If true, the user VM would be added to the default security group by default", null),
-	
+
 	GuestOSNeedGatewayOnNonDefaultNetwork("Network", NetworkManager.class, String.class, "network.dhcp.nondefaultnetwork.setgateway.guestos", "Windows", "The guest OS's name start with this fields would result in DHCP server response gateway information even when the network it's on is not default network. Names are separated by comma.", null),
-	
+
 	//VPN
 	RemoteAccessVpnPskLength("Network", AgentManager.class, Integer.class, "remote.access.vpn.psk.length", "24", "The length of the ipsec preshared key (minimum 8, maximum 256)", null),
 	RemoteAccessVpnClientIpRange("Network", AgentManager.class, String.class, "remote.access.vpn.client.iprange", "10.1.2.1-10.1.2.8", "The range of ips to be allocated to remote access vpn clients. The first ip in the range is used by the VPN server", null),
-	RemoteAccessVpnUserLimit("Network", AgentManager.class, String.class, "remote.access.vpn.user.limit", "8", "The maximum number of VPN users that can be created per account", null),	
+	RemoteAccessVpnUserLimit("Network", AgentManager.class, String.class, "remote.access.vpn.user.limit", "8", "The maximum number of VPN users that can be created per account", null),
 	Site2SiteVpnConnectionPerVpnGatewayLimit("Network", ManagementServer.class, Integer.class, "site2site.vpn.vpngateway.connection.limit", "4", "The maximum number of VPN connection per VPN gateway", null),
 	Site2SiteVpnSubnetsPerCustomerGatewayLimit("Network", ManagementServer.class, Integer.class, "site2site.vpn.customergateway.subnets.limit", "10", "The maximum number of subnets per customer gateway", null),
-	
+
 	// Console Proxy
 	ConsoleProxyCapacityStandby("Console Proxy", AgentManager.class, String.class, "consoleproxy.capacity.standby", "10", "The minimal number of console proxy viewer sessions that system is able to serve immediately(standby capacity)", null),
 	ConsoleProxyCapacityScanInterval("Console Proxy", AgentManager.class, String.class, "consoleproxy.capacityscan.interval", "30000", "The time interval(in millisecond) to scan whether or not system needs more console proxy to ensure minimal standby capacity", null),
@@ -125,11 +125,11 @@ public enum Config {
 	ConsoleProxySessionTimeout("Console Proxy", AgentManager.class, Integer.class, "consoleproxy.session.timeout", "300000", "Timeout(in milliseconds) that console proxy tries to maintain a viewer session before it times out the session for no activity", null),
 	ConsoleProxyDisableRpFilter("Console Proxy", AgentManager.class, Integer.class, "consoleproxy.disable.rpfilter", "true", "disable rp_filter on console proxy VM public interface", null),
     ConsoleProxyLaunchMax("Console Proxy", AgentManager.class, Integer.class, "consoleproxy.launch.max", "10", "maximum number of console proxy instances per zone can be launched", null),
-    ConsoleProxyManagementState("Console Proxy", AgentManager.class, String.class, "consoleproxy.management.state", com.cloud.consoleproxy.ConsoleProxyManagementState.Auto.toString(), 
+    ConsoleProxyManagementState("Console Proxy", AgentManager.class, String.class, "consoleproxy.management.state", com.cloud.consoleproxy.ConsoleProxyManagementState.Auto.toString(),
 		"console proxy service management state", null),
-    ConsoleProxyManagementLastState("Console Proxy", AgentManager.class, String.class, "consoleproxy.management.state.last", com.cloud.consoleproxy.ConsoleProxyManagementState.Auto.toString(), 
+    ConsoleProxyManagementLastState("Console Proxy", AgentManager.class, String.class, "consoleproxy.management.state.last", com.cloud.consoleproxy.ConsoleProxyManagementState.Auto.toString(),
 		"last console proxy service management state", null),
-	
+
 	// Snapshots
     SnapshotHourlyMax("Snapshots", SnapshotManager.class, Integer.class, "snapshot.max.hourly", "8", "Maximum hourly snapshots for a volume", null),
     SnapshotDailyMax("Snapshots", SnapshotManager.class, Integer.class, "snapshot.max.daily", "8", "Maximum daily snapshots for a volume", null),
@@ -137,7 +137,7 @@ public enum Config {
     SnapshotMonthlyMax("Snapshots", SnapshotManager.class, Integer.class, "snapshot.max.monthly", "8", "Maximum monthly snapshots for a volume", null),
     SnapshotPollInterval("Snapshots", SnapshotManager.class, Integer.class, "snapshot.poll.interval", "300", "The time interval in seconds when the management server polls for snapshots to be scheduled.", null),
     SnapshotDeltaMax("Snapshots", SnapshotManager.class, Integer.class, "snapshot.delta.max", "16", "max delta snapshots between two full snapshots.", null),
-    
+
 	// Advanced
     JobExpireMinutes("Advanced", ManagementServer.class, String.class, "job.expire.minutes", "1440", "Time (in minutes) for async-jobs to be kept in system", null),
     JobCancelThresholdMinutes("Advanced", ManagementServer.class, String.class, "job.cancel.threshold.minutes", "60", "Time (in minutes) for async-jobs to be forcely cancelled if it has been in process for long", null),
@@ -165,7 +165,7 @@ public enum Config {
 	RouterCpuMHz("Advanced", NetworkManager.class, Integer.class, "router.cpu.mhz", String.valueOf(VpcVirtualNetworkApplianceManager.DEFAULT_ROUTER_CPU_MHZ), "Default CPU speed (MHz) for router VM.", null),
 	RestartRetryInterval("Advanced", HighAvailabilityManager.class, Integer.class, "restart.retry.interval", "600", "Time (in seconds) between retries to restart a vm", null),
 	RouterStatsInterval("Advanced", NetworkManager.class, Integer.class, "router.stats.interval", "300", "Interval (in seconds) to report router statistics.", null),
-	ExternalNetworkStatsInterval("Advanced", NetworkManager.class, Integer.class, "external.network.stats.interval", "300", "Interval (in seconds) to report external network statistics.", null),	
+	ExternalNetworkStatsInterval("Advanced", NetworkManager.class, Integer.class, "external.network.stats.interval", "300", "Interval (in seconds) to report external network statistics.", null),
 	RouterCheckInterval("Advanced", NetworkManager.class, Integer.class, "router.check.interval", "30", "Interval (in seconds) to report redundant router status.", null),
 	RouterCheckPoolSize("Advanced", NetworkManager.class, Integer.class, "router.check.poolsize", "10", "Numbers of threads using to check redundant router status.", null),
 	RouterTemplateId("Advanced", NetworkManager.class, Long.class, "router.template.id", "1", "Default ID for template.", null),
@@ -197,23 +197,23 @@ public enum Config {
 	MaxTemplateAndIsoSize("Advanced",  ManagementServer.class, Long.class, "max.template.iso.size", "50", "The maximum size for a downloaded template or ISO (in GB).", null),
 	SecStorageAllowedInternalDownloadSites("Advanced", ManagementServer.class, String.class, "secstorage.allowed.internal.sites", null, "Comma separated list of cidrs internal to the datacenter that can host template download servers, please note 0.0.0.0 is not a valid site", null),
 	SecStorageEncryptCopy("Advanced", ManagementServer.class, Boolean.class, "secstorage.encrypt.copy", "false", "Use SSL method used to encrypt copy traffic between zones", "true,false"),
-	SecStorageSecureCopyCert("Advanced", ManagementServer.class, String.class, "secstorage.ssl.cert.domain", "realhostip.com", "SSL certificate used to encrypt copy traffic between zones", null),	
+	SecStorageSecureCopyCert("Advanced", ManagementServer.class, String.class, "secstorage.ssl.cert.domain", "realhostip.com", "SSL certificate used to encrypt copy traffic between zones", null),
 	SecStorageCapacityStandby("Advanced", AgentManager.class, Integer.class, "secstorage.capacity.standby", "10", "The minimal number of command execution sessions that system is able to serve immediately(standby capacity)", null),
 	SecStorageSessionMax("Advanced", AgentManager.class, Integer.class, "secstorage.session.max", "50", "The max number of command execution sessions that a SSVM can handle", null),
 	SecStorageCmdExecutionTimeMax("Advanced", AgentManager.class, Integer.class, "secstorage.cmd.execution.time.max", "30", "The max command execution time in minute", null),
 	SecStorageProxy("Advanced", AgentManager.class, String.class, "secstorage.proxy", null, "http proxy used by ssvm, in http://username:password@proxyserver:port format", null),
-	
+
 
 	DirectAttachNetworkEnabled("Advanced", ManagementServer.class, Boolean.class, "direct.attach.network.externalIpAllocator.enabled", "false", "Direct-attach VMs using external DHCP server", "true,false"),
 	DirectAttachNetworkExternalAPIURL("Advanced", ManagementServer.class, String.class, "direct.attach.network.externalIpAllocator.url", null, "Direct-attach VMs using external DHCP server (API url)", null),
 	CheckPodCIDRs("Advanced", ManagementServer.class, String.class, "check.pod.cidrs", "true", "If true, different pods must belong to different CIDR subnets.", "true,false"),
 	NetworkGcWait("Advanced", ManagementServer.class, Integer.class, "network.gc.wait", "600", "Time (in seconds) to wait before shutting down a network that's not in used", null),
-	NetworkGcInterval("Advanced", ManagementServer.class, Integer.class, "network.gc.interval", "600", "Seconds to wait before checking for networks to shutdown", null),	
+	NetworkGcInterval("Advanced", ManagementServer.class, Integer.class, "network.gc.interval", "600", "Seconds to wait before checking for networks to shutdown", null),
 	CapacitySkipcountingHours("Advanced", ManagementServer.class, Integer.class, "capacity.skipcounting.hours", "3600", "Time (in seconds) to wait before release VM's cpu and memory when VM in stopped state", null),
 	VmStatsInterval("Advanced", ManagementServer.class, Integer.class, "vm.stats.interval", "60000", "The interval (in milliseconds) when vm stats are retrieved from agents.", null),
 	VmTransitionWaitInterval("Advanced", ManagementServer.class, Integer.class, "vm.tranisition.wait.interval", "3600", "Time (in seconds) to wait before taking over a VM in transition state", null),
 	VmDestroyForcestop("Advanced", ManagementServer.class, Boolean.class, "vm.destroy.forcestop", "false", "On destroy, force-stop takes this value ", null),
-	
+
 	ControlCidr("Advanced", ManagementServer.class, String.class, "control.cidr", "169.254.0.0/16", "Changes the cidr for the control network traffic.  Defaults to using link local.  Must be unique within pods", null),
 	ControlGateway("Advanced", ManagementServer.class, String.class, "control.gateway", "169.254.0.1", "gateway for the control network traffic", null),
 	HostCapacityTypeToOrderClusters("Advanced", ManagementServer.class, String.class, "host.capacityType.to.order.clusters", "CPU", "The host capacity type (CPU or RAM) is used by deployment planner to order clusters during VM resource allocation", "CPU,RAM"),
@@ -236,7 +236,7 @@ public enum Config {
     OvmPublicNetwork("Hidden", ManagementServer.class, String.class, "ovm.public.network.device", null, "Specify the public bridge on host for public network", null),
     OvmPrivateNetwork("Hidden", ManagementServer.class, String.class, "ovm.private.network.device", null, "Specify the private bridge on host for private network", null),
     OvmGuestNetwork("Hidden", ManagementServer.class, String.class, "ovm.guest.network.device", null, "Specify the private bridge on host for private network", null),
-    
+
 	// XenServer
     XenPublicNetwork("Hidden", ManagementServer.class, String.class, "xen.public.network.device", null, "[ONLY IF THE PUBLIC NETWORK IS ON A DEDICATED NIC]:The network name label of the physical device dedicated to the public network on a XenServer host", null),
     XenStorageNetwork1("Hidden", ManagementServer.class, String.class, "xen.storage.network.device1", null, "Specify when there are storage networks", null),
@@ -247,7 +247,7 @@ public enum Config {
     XenBondStorageNic("Advanced", ManagementServer.class, String.class, "xen.bond.storage.nics", null, "Attempt to bond the two networks if found", null),
     XenHeartBeatInterval("Advanced", ManagementServer.class, Integer.class, "xen.heartbeat.interval", "60", "heartbeat to use when implementing XenServer Self Fencing", null),
     XenGuestNetwork("Hidden", ManagementServer.class, String.class, "xen.guest.network.device", null, "Specify for guest network name label", null),
-    
+
     // VMware
     VmwarePrivateNetworkVSwitch("Hidden", ManagementServer.class, String.class, "vmware.private.vswitch", null, "Specify the vSwitch on host for private network", null),
     VmwarePublicNetworkVSwitch("Hidden", ManagementServer.class, String.class, "vmware.public.vswitch", null, "Specify the vSwitch on host for public network", null),
@@ -264,7 +264,7 @@ public enum Config {
     VmwareRootDiskControllerType("Advanced", ManagementServer.class, String.class, "vmware.root.disk.controller", "ide", "Specify the default disk controller for root volumes, valid values are scsi, ide", null),
     VmwareSystemVmNicDeviceType("Advanced", ManagementServer.class, String.class, "vmware.systemvm.nic.device.type", "E1000", "Specify the default network device type for system VMs, valid values are E1000, PCNet32, Vmxnet2, Vmxnet3", null),
     VmwareRecycleHungWorker("Advanced", ManagementServer.class, Boolean.class, "vmware.recycle.hung.wokervm", "false", "Specify whether or not to recycle hung worker VMs", null),
-    
+
     // KVM
     KvmPublicNetwork("Hidden", ManagementServer.class, String.class, "kvm.public.network.device", null, "Specify the public bridge on host for public network", null),
     KvmPrivateNetwork("Hidden", ManagementServer.class, String.class, "kvm.private.network.device", null, "Specify the private bridge on host for private network", null),
@@ -279,7 +279,7 @@ public enum Config {
     UsageAggregationTimezone("Usage", ManagementServer.class, String.class, "usage.aggregation.timezone", "GMT", "The timezone to use for usage stats aggregation", null),
     TrafficSentinelIncludeZones("Usage", ManagementServer.class, Integer.class, "traffic.sentinel.include.zones", "EXTERNAL", "Traffic going into specified list of zones is metered. For metering all traffic leave this parameter empty", null),
     TrafficSentinelExcludeZones("Usage", ManagementServer.class, Integer.class, "traffic.sentinel.exclude.zones", "", "Traffic going into specified list of zones is not metered.", null),
-    
+
 	// Hidden
 	UseSecondaryStorageVm("Hidden", ManagementServer.class, Boolean.class, "secondary.storage.vm", "false", "Deploys a VM per zone to manage secondary storage if true, otherwise secondary storage is mounted on management server", null),
     CreatePoolsInPod("Hidden", ManagementServer.class, Boolean.class, "xen.create.pools.in.pod", "false", "Should we automatically add XenServers into pools that are inside a Pod", null),
@@ -295,12 +295,12 @@ public enum Config {
 	VmOpCleanupInterval("Advanced", ManagementServer.class, Long.class, "vm.op.cleanup.interval", "86400", "Interval to run the thread that cleans up the vm operations (in seconds)", "Seconds"),
 	VmOpCleanupWait("Advanced", ManagementServer.class, Long.class, "vm.op.cleanup.wait", "3600", "Time (in seconds) to wait before cleanuping up any vm work items", "Seconds"),
 	VmOpCancelInterval("Advanced", ManagementServer.class, Long.class, "vm.op.cancel.interval", "3600", "Time (in seconds) to wait before cancelling a operation", "Seconds"),
-	
-	
+
+
 	DefaultPageSize("Advanced", ManagementServer.class, Long.class, "default.page.size", "500", "Default page size for API list* commands", null),
-	
+
 	TaskCleanupRetryInterval("Advanced", ManagementServer.class, Integer.class, "task.cleanup.retry.interval", "600", "Time (in seconds) to wait before retrying cleanup of tasks if the cleanup failed previously.  0 means to never retry.", "Seconds"),
-	
+
 	// Account Default Limits
 	DefaultMaxAccountUserVms("Account Defaults", ManagementServer.class, Long.class, "max.account.user.vms", "20", "The default maximum number of user VMs that can be deployed for an account", null),
 	DefaultMaxAccountPublicIPs("Account Defaults", ManagementServer.class, Long.class, "max.account.public.ips", "20", "The default maximum number of public IPs that can be consumed by an account", null),
@@ -310,10 +310,10 @@ public enum Config {
 	DefaultMaxAccountNetworks("Account Defaults", ManagementServer.class, Long.class, "max.account.networks", "20", "The default maximum number of networks that can be created for an account", null),
 	DefaultMaxAccountVpcs("Account Defaults", ManagementServer.class, Long.class, "max.account.vpcs", "20", "The default maximum number of vpcs that can be created for an account", null),
 
-	
+
 	ResourceCountCheckInterval("Advanced", ManagementServer.class, Long.class, "resourcecount.check.interval", "0", "Time (in seconds) to wait before retrying resource count check task. Default is 0 which is to never run the task", "Seconds"),
 	DirectAgentLoadSize("Advanced", ManagementServer.class, Integer.class, "direct.agent.load.size", "16", "The number of direct agents to load each time", null),
-	
+
 	//disabling lb as cluster sync does not work with distributed cluster
 	AgentLbEnable("Advanced", ManagementServer.class, Boolean.class, "agent.lb.enabled", "false", "If agent load balancing enabled in cluster setup", null),
 	SubDomainNetworkAccess("Advanced", NetworkManager.class, Boolean.class, "allow.subdomain.network.access", "true", "Allow subdomains to use networks dedicated to their parent domain(s)", null),
@@ -323,9 +323,9 @@ public enum Config {
 
 	ClusterMessageTimeOutSeconds("Advanced", ManagementServer.class, Integer.class, "cluster.message.timeout.seconds", "300", "Time (in seconds) to wait before a inter-management server message post times out.", null),
 	AgentLoadThreshold("Advanced", ManagementServer.class, Float.class, "agent.load.threshold", "0.7", "Percentage (as a value between 0 and 1) of connected agents after which agent load balancing will start happening", null),
-	
+
 	JavaScriptDefaultContentType("Advanced", ManagementServer.class, String.class, "json.content.type", "text/javascript", "Http response content type for .js files (default is text/javascript)", null),
-	
+
 	DefaultMaxProjectUserVms("Project Defaults", ManagementServer.class, Long.class, "max.project.user.vms", "20", "The default maximum number of user VMs that can be deployed for a project", null),
     DefaultMaxProjectPublicIPs("Project Defaults", ManagementServer.class, Long.class, "max.project.public.ips", "20", "The default maximum number of public IPs that can be consumed by a project", null),
     DefaultMaxProjectTemplates("Project Defaults", ManagementServer.class, Long.class, "max.project.templates", "20", "The default maximum number of templates that can be deployed for a project", null),
@@ -333,11 +333,11 @@ public enum Config {
     DefaultMaxProjectVolumes("Project Defaults", ManagementServer.class, Long.class, "max.project.volumes", "20", "The default maximum number of volumes that can be created for a project", null),
     DefaultMaxProjectNetworks("Project Defaults", ManagementServer.class, Long.class, "max.project.networks", "20", "The default maximum number of networks that can be created for a project", null),
     DefaultMaxProjectVpcs("Project Defaults", ManagementServer.class, Long.class, "max.project.vpcs", "20", "The default maximum number of vpcs that can be created for a project", null),
-	
+
     ProjectInviteRequired("Project Defaults", ManagementServer.class, Boolean.class, "project.invite.required", "false", "If invitation confirmation is required when add account to project. Default value is false", null),
     ProjectInvitationExpirationTime("Project Defaults", ManagementServer.class, Long.class, "project.invite.timeout", "86400", "Invitation expiration time (in seconds). Default is 1 day - 86400 seconds", null),
     AllowUserToCreateProject("Project Defaults", ManagementServer.class, Long.class, "allow.user.create.projects", "true", "If regular user can create a project; true by default", null),
-    
+
     ProjectEmailSender("Project Defaults", ManagementServer.class, String.class, "project.email.sender", null, "Sender of project invitation email (will be in the From header of the email)", null),
     ProjectSMTPHost("Project Defaults", ManagementServer.class, String.class, "project.smtp.host", null, "SMTP hostname used for sending out email project invitations", null),
     ProjectSMTPPassword("Secure", ManagementServer.class, String.class, "project.smtp.password", null, "Password for SMTP authentication (applies only if project.smtp.useAuth is true)", null),
@@ -355,11 +355,12 @@ public enum Config {
 	HaTag("Advanced", ManagementServer.class, String.class, "ha.tag", null, "HA tag defining that the host marked with this tag can be used for HA purposes only", null),
 	VpcCleanupInterval("Advanced", ManagementServer.class, Integer.class, "vpc.cleanup.interval", "3600", "The interval (in seconds) between cleanup for Inactive VPCs", null),
     VpcMaxNetworks("Advanced", ManagementServer.class, Integer.class, "vpc.max.networks", "3", "Maximum number of networks per vpc", null),
-    
+    DetailBatchQuerySize("Advanced", ManagementServer.class, Integer.class, "detail.batch.query.size", "2000", "Default entity detail batch query size for listing", null),
+
 	ConcurrentSnapshotsThresholdPerHost("Advanced", ManagementServer.class, Long.class, "concurrent.snapshots.threshold.perhost",
 	                null, "Limits number of snapshots that can be handled by the host concurrently; default is NULL - unlimited", null);
-	
-	
+
+
 	private final String _category;
 	private final Class<?> _componentClass;
 	private final Class<?> _type;
@@ -384,7 +385,7 @@ public enum Config {
     	_configs.put("Account Defaults", new ArrayList<Config>());
     	_configs.put("Project Defaults", new ArrayList<Config>());
     	_configs.put("Secure", new ArrayList<Config>());
-    	
+
     	// Add values into HashMap
         for (Config c : Config.values()) {
         	String category = c.getCategory();
@@ -393,7 +394,7 @@ public enum Config {
         	_configs.put(category, currentConfigs);
         }
     }
-    
+
     private Config(String category, Class<?> componentClass, Class<?> type, String name, String defaultValue, String description, String range) {
     	_category = category;
     	_componentClass = componentClass;
@@ -403,15 +404,15 @@ public enum Config {
     	_description = description;
     	_range = range;
     }
-    
+
     public String getCategory() {
     	return _category;
     }
-    
+
     public String key() {
         return _name;
     }
-    
+
     public String getDescription() {
         return _description;
     }
@@ -427,7 +428,7 @@ public enum Config {
     public Class<?> getComponentClass() {
         return _componentClass;
     }
-    
+
     public String getComponent() {
     	if (_componentClass == ManagementServer.class) {
             return "management-server";
@@ -453,16 +454,16 @@ public enum Config {
     public String getRange() {
         return _range;
     }
-    
+
     @Override
 	public String toString() {
         return _name;
     }
-    
+
     public static List<Config> getConfigs(String category) {
     	return _configs.get(category);
     }
-    
+
     public static Config getConfig(String name) {
     	List<String> categories = getCategories();
     	for (String category : categories) {
@@ -473,10 +474,10 @@ public enum Config {
                 }
     		}
     	}
-    	
+
     	return null;
     }
-    
+
     public static List<String> getCategories() {
     	Object[] keys = _configs.keySet().toArray();
     	List<String> categories = new ArrayList<String>();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/08948226/server/src/com/cloud/configuration/DefaultComponentLibrary.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/DefaultComponentLibrary.java b/server/src/com/cloud/configuration/DefaultComponentLibrary.java
index 2fbe758..8d8ee9a 100755
--- a/server/src/com/cloud/configuration/DefaultComponentLibrary.java
+++ b/server/src/com/cloud/configuration/DefaultComponentLibrary.java
@@ -235,19 +235,6 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com
         addDao("HostDao", HostDaoImpl.class);
         addDao("VMInstanceDao", VMInstanceDaoImpl.class);
         addDao("UserVmDao", UserVmDaoImpl.class);
-        addDao("UserVmJoinDao", UserVmJoinDaoImpl.class);
-        addDao("DomainRouterJoinDao", DomainRouterJoinDaoImpl.class);
-        addDao("SecurityGroupJoinDao", SecurityGroupJoinDaoImpl.class);
-        addDao("ResourceTagJoinDao", ResourceTagJoinDaoImpl.class);
-        addDao("EventJoinDao", EventJoinDaoImpl.class);
-        addDao("UserAccountJoinDao", UserAccountJoinDaoImpl.class);
-        addDao("ProjectJoinDao", ProjectJoinDaoImpl.class);
-        addDao("ProjectAccountJoinDao", ProjectAccountJoinDaoImpl.class);
-        addDao("ProjectInvitationJoinDao", ProjectInvitationJoinDaoImpl.class);
-        addDao("HostJoinDao", HostJoinDaoImpl.class);
-        addDao("VolumeJoinDao", VolumeJoinDaoImpl.class);
-        addDao("AccountJoinDao", AccountJoinDaoImpl.class);
-        addDao("AsyncJobJoinDao", AsyncJobJoinDaoImpl.class);
         ComponentInfo<? extends GenericDao<?, ? extends Serializable>> info = addDao("ServiceOfferingDao", ServiceOfferingDaoImpl.class);
         info.addParameter("cache.size", "50");
         info.addParameter("cache.time.to.live", "600");
@@ -387,6 +374,20 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com
         addDao("Site2SiteVpnGatewayDao", Site2SiteVpnGatewayDaoImpl.class);
         addDao("Site2SiteCustomerGatewayDao", Site2SiteCustomerGatewayDaoImpl.class);
         addDao("Site2SiteVpnConnnectionDao", Site2SiteVpnConnectionDaoImpl.class);
+
+        addDao("UserVmJoinDao", UserVmJoinDaoImpl.class);
+        addDao("DomainRouterJoinDao", DomainRouterJoinDaoImpl.class);
+        addDao("SecurityGroupJoinDao", SecurityGroupJoinDaoImpl.class);
+        addDao("ResourceTagJoinDao", ResourceTagJoinDaoImpl.class);
+        addDao("EventJoinDao", EventJoinDaoImpl.class);
+        addDao("UserAccountJoinDao", UserAccountJoinDaoImpl.class);
+        addDao("ProjectJoinDao", ProjectJoinDaoImpl.class);
+        addDao("ProjectAccountJoinDao", ProjectAccountJoinDaoImpl.class);
+        addDao("ProjectInvitationJoinDao", ProjectInvitationJoinDaoImpl.class);
+        addDao("HostJoinDao", HostJoinDaoImpl.class);
+        addDao("VolumeJoinDao", VolumeJoinDaoImpl.class);
+        addDao("AccountJoinDao", AccountJoinDaoImpl.class);
+        addDao("AsyncJobJoinDao", AsyncJobJoinDaoImpl.class);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/08948226/setup/db/db/schema-40to410.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-40to410.sql b/setup/db/db/schema-40to410.sql
index 6437052..1142320 100644
--- a/setup/db/db/schema-40to410.sql
+++ b/setup/db/db/schema-40to410.sql
@@ -140,6 +140,7 @@ UPDATE `cloud`.`autoscale_policies` set uuid=id WHERE uuid is NULL;
 UPDATE `cloud`.`counter` set uuid=id WHERE uuid is NULL;
 UPDATE `cloud`.`conditions` set uuid=id WHERE uuid is NULL;
 
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', '"detail.batch.query.size"', '2000', 'Default entity detail batch query size for listing');
 
 --- DB views for list api ---
 DROP VIEW IF EXISTS `cloud`.`user_vm_view`;