This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/master by this push:
     new 92a6bc2  CLOUDSTACK-9896: listDedicatedXXX should respect pagination 
(#2073)
92a6bc2 is described below

commit 92a6bc27ff862be72de7f96a2e836d6bb66a353c
Author: Marc-Aurèle Brothier <m...@brothier.org>
AuthorDate: Sun Jan 7 11:13:27 2018 +0100

    CLOUDSTACK-9896: listDedicatedXXX should respect pagination (#2073)
    
    Fixes listDedicatedxxx APIs to respect pagination options.
---
 .../dedicated/DedicatedResourceManagerImpl.java    | 22 +++++++++++++++++-----
 .../src/com/cloud/dc/dao/DedicatedResourceDao.java |  9 +++++----
 .../com/cloud/dc/dao/DedicatedResourceDaoImpl.java | 17 +++++++++--------
 .../deploy/DeploymentPlanningManagerImpl.java      | 13 +++++++------
 4 files changed, 38 insertions(+), 23 deletions(-)

diff --git 
a/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/DedicatedResourceManagerImpl.java
 
b/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/DedicatedResourceManagerImpl.java
index e7a6f35..7cf193d 100644
--- 
a/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/DedicatedResourceManagerImpl.java
+++ 
b/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/DedicatedResourceManagerImpl.java
@@ -73,6 +73,7 @@ import com.cloud.utils.DateUtil;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
 import com.cloud.utils.db.DB;
+import com.cloud.utils.db.Filter;
 import com.cloud.utils.db.Transaction;
 import com.cloud.utils.db.TransactionCallback;
 import com.cloud.utils.db.TransactionCallbackNoReturn;
@@ -816,6 +817,8 @@ public class DedicatedResourceManagerImpl implements 
DedicatedService {
         String accountName = cmd.getAccountName();
         Long accountId = null;
         Long affinityGroupId = cmd.getAffinityGroupId();
+        Long startIndex = cmd.getStartIndex();
+        Long pageSize = cmd.getPageSizeVal();
 
         if (accountName != null) {
             if (domainId != null) {
@@ -827,7 +830,8 @@ public class DedicatedResourceManagerImpl implements 
DedicatedService {
                 throw new InvalidParameterValueException("Please specify the 
domain id of the account: " + accountName);
             }
         }
-        Pair<List<DedicatedResourceVO>, Integer> result = 
_dedicatedDao.searchDedicatedZones(zoneId, domainId, accountId, 
affinityGroupId);
+        Filter searchFilter = new Filter(DedicatedResourceVO.class, "id", 
true, startIndex, pageSize);
+        Pair<List<DedicatedResourceVO>, Integer> result = 
_dedicatedDao.searchDedicatedZones(zoneId, domainId, accountId, 
affinityGroupId, searchFilter);
         return new Pair<List<? extends DedicatedResourceVO>, 
Integer>(result.first(), result.second());
     }
 
@@ -838,6 +842,8 @@ public class DedicatedResourceManagerImpl implements 
DedicatedService {
         String accountName = cmd.getAccountName();
         Long accountId = null;
         Long affinityGroupId = cmd.getAffinityGroupId();
+        Long startIndex = cmd.getStartIndex();
+        Long pageSize = cmd.getPageSizeVal();
 
         if (accountName != null) {
             if (domainId != null) {
@@ -849,7 +855,8 @@ public class DedicatedResourceManagerImpl implements 
DedicatedService {
                 throw new InvalidParameterValueException("Please specify the 
domain id of the account: " + accountName);
             }
         }
-        Pair<List<DedicatedResourceVO>, Integer> result = 
_dedicatedDao.searchDedicatedPods(podId, domainId, accountId, affinityGroupId);
+        Filter searchFilter = new Filter(DedicatedResourceVO.class, "id", 
true, startIndex, pageSize);
+        Pair<List<DedicatedResourceVO>, Integer> result = 
_dedicatedDao.searchDedicatedPods(podId, domainId, accountId, affinityGroupId, 
searchFilter);
         return new Pair<List<? extends DedicatedResourceVO>, 
Integer>(result.first(), result.second());
     }
 
@@ -860,6 +867,8 @@ public class DedicatedResourceManagerImpl implements 
DedicatedService {
         String accountName = cmd.getAccountName();
         Long accountId = null;
         Long affinityGroupId = cmd.getAffinityGroupId();
+        Long startIndex = cmd.getStartIndex();
+        Long pageSize = cmd.getPageSizeVal();
 
         if (accountName != null) {
             if (domainId != null) {
@@ -871,7 +880,8 @@ public class DedicatedResourceManagerImpl implements 
DedicatedService {
                 throw new InvalidParameterValueException("Please specify the 
domain id of the account: " + accountName);
             }
         }
-        Pair<List<DedicatedResourceVO>, Integer> result = 
_dedicatedDao.searchDedicatedClusters(clusterId, domainId, accountId, 
affinityGroupId);
+        Filter searchFilter = new Filter(DedicatedResourceVO.class, "id", 
true, startIndex, pageSize);
+        Pair<List<DedicatedResourceVO>, Integer> result = 
_dedicatedDao.searchDedicatedClusters(clusterId, domainId, accountId, 
affinityGroupId, searchFilter);
         return new Pair<List<? extends DedicatedResourceVO>, 
Integer>(result.first(), result.second());
     }
 
@@ -881,6 +891,8 @@ public class DedicatedResourceManagerImpl implements 
DedicatedService {
         Long domainId = cmd.getDomainId();
         String accountName = cmd.getAccountName();
         Long affinityGroupId = cmd.getAffinityGroupId();
+        Long startIndex = cmd.getStartIndex();
+        Long pageSize = cmd.getPageSizeVal();
 
         Long accountId = null;
         if (accountName != null) {
@@ -893,8 +905,8 @@ public class DedicatedResourceManagerImpl implements 
DedicatedService {
                 throw new InvalidParameterValueException("Please specify the 
domain id of the account: " + accountName);
             }
         }
-
-        Pair<List<DedicatedResourceVO>, Integer> result = 
_dedicatedDao.searchDedicatedHosts(hostId, domainId, accountId, 
affinityGroupId);
+        Filter searchFilter = new Filter(DedicatedResourceVO.class, "id", 
true, startIndex, pageSize);
+        Pair<List<DedicatedResourceVO>, Integer> result = 
_dedicatedDao.searchDedicatedHosts(hostId, domainId, accountId, 
affinityGroupId, searchFilter);
         return new Pair<List<? extends DedicatedResourceVO>, 
Integer>(result.first(), result.second());
     }
 
diff --git a/server/src/com/cloud/dc/dao/DedicatedResourceDao.java 
b/server/src/com/cloud/dc/dao/DedicatedResourceDao.java
index 0876d46..7c41439 100644
--- a/server/src/com/cloud/dc/dao/DedicatedResourceDao.java
+++ b/server/src/com/cloud/dc/dao/DedicatedResourceDao.java
@@ -20,6 +20,7 @@ import java.util.List;
 
 import com.cloud.dc.DedicatedResourceVO;
 import com.cloud.utils.Pair;
+import com.cloud.utils.db.Filter;
 import com.cloud.utils.db.GenericDao;
 
 public interface DedicatedResourceDao extends GenericDao<DedicatedResourceVO, 
Long> {
@@ -32,13 +33,13 @@ public interface DedicatedResourceDao extends 
GenericDao<DedicatedResourceVO, Lo
 
     DedicatedResourceVO findByHostId(Long hostId);
 
-    Pair<List<DedicatedResourceVO>, Integer> searchDedicatedHosts(Long hostId, 
Long domainId, Long accountId, Long affinityGroupId);
+    Pair<List<DedicatedResourceVO>, Integer> searchDedicatedHosts(Long hostId, 
Long domainId, Long accountId, Long affinityGroupId, Filter filter);
 
-    Pair<List<DedicatedResourceVO>, Integer> searchDedicatedClusters(Long 
clusterId, Long domainId, Long accountId, Long affinityGroupId);
+    Pair<List<DedicatedResourceVO>, Integer> searchDedicatedClusters(Long 
clusterId, Long domainId, Long accountId, Long affinityGroupId, Filter filter);
 
-    Pair<List<DedicatedResourceVO>, Integer> searchDedicatedPods(Long podId, 
Long domainId, Long accountId, Long affinityGroupId);
+    Pair<List<DedicatedResourceVO>, Integer> searchDedicatedPods(Long podId, 
Long domainId, Long accountId, Long affinityGroupId, Filter filter);
 
-    Pair<List<DedicatedResourceVO>, Integer> searchDedicatedZones(Long 
dataCenterId, Long domainId, Long accountId, Long affinityGroupId);
+    Pair<List<DedicatedResourceVO>, Integer> searchDedicatedZones(Long 
dataCenterId, Long domainId, Long accountId, Long affinityGroupId, Filter 
filter);
 
     List<DedicatedResourceVO> listByAccountId(Long accountId);
 
diff --git a/server/src/com/cloud/dc/dao/DedicatedResourceDaoImpl.java 
b/server/src/com/cloud/dc/dao/DedicatedResourceDaoImpl.java
index 8f51783..c406755 100644
--- a/server/src/com/cloud/dc/dao/DedicatedResourceDaoImpl.java
+++ b/server/src/com/cloud/dc/dao/DedicatedResourceDaoImpl.java
@@ -19,6 +19,7 @@ package com.cloud.dc.dao;
 import java.util.List;
 
 
+import com.cloud.utils.db.Filter;
 import org.springframework.stereotype.Component;
 
 import com.cloud.dc.DedicatedResourceVO;
@@ -231,7 +232,7 @@ public class DedicatedResourceDaoImpl extends 
GenericDaoBase<DedicatedResourceVO
     }
 
     @Override
-    public Pair<List<DedicatedResourceVO>, Integer> searchDedicatedZones(Long 
dataCenterId, Long domainId, Long accountId, Long affinityGroupId) {
+    public Pair<List<DedicatedResourceVO>, Integer> searchDedicatedZones(Long 
dataCenterId, Long domainId, Long accountId, Long affinityGroupId, Filter 
filter) {
         SearchCriteria<DedicatedResourceVO> sc = ListAllZonesSearch.create();
         if (dataCenterId != null) {
             sc.setParameters("zoneId", dataCenterId);
@@ -247,11 +248,11 @@ public class DedicatedResourceDaoImpl extends 
GenericDaoBase<DedicatedResourceVO
                 sc.setParameters("accountId", (Object)null);
             }
         }
-        return searchAndCount(sc, null);
+        return searchAndCount(sc, filter);
     }
 
     @Override
-    public Pair<List<DedicatedResourceVO>, Integer> searchDedicatedPods(Long 
podId, Long domainId, Long accountId, Long affinityGroupId) {
+    public Pair<List<DedicatedResourceVO>, Integer> searchDedicatedPods(Long 
podId, Long domainId, Long accountId, Long affinityGroupId, Filter filter) {
         SearchCriteria<DedicatedResourceVO> sc = ListAllPodsSearch.create();
         if (podId != null) {
             sc.setParameters("podId", podId);
@@ -267,11 +268,11 @@ public class DedicatedResourceDaoImpl extends 
GenericDaoBase<DedicatedResourceVO
                 sc.setParameters("accountId", (Object)null);
             }
         }
-        return searchAndCount(sc, null);
+        return searchAndCount(sc, filter);
     }
 
     @Override
-    public Pair<List<DedicatedResourceVO>, Integer> 
searchDedicatedClusters(Long clusterId, Long domainId, Long accountId, Long 
affinityGroupId) {
+    public Pair<List<DedicatedResourceVO>, Integer> 
searchDedicatedClusters(Long clusterId, Long domainId, Long accountId, Long 
affinityGroupId, Filter filter) {
         SearchCriteria<DedicatedResourceVO> sc = 
ListAllClustersSearch.create();
         if (clusterId != null) {
             sc.setParameters("clusterId", clusterId);
@@ -288,11 +289,11 @@ public class DedicatedResourceDaoImpl extends 
GenericDaoBase<DedicatedResourceVO
                 sc.setParameters("accountId", (Object)null);
             }
         }
-        return searchAndCount(sc, null);
+        return searchAndCount(sc, filter);
     }
 
     @Override
-    public Pair<List<DedicatedResourceVO>, Integer> searchDedicatedHosts(Long 
hostId, Long domainId, Long accountId, Long affinityGroupId) {
+    public Pair<List<DedicatedResourceVO>, Integer> searchDedicatedHosts(Long 
hostId, Long domainId, Long accountId, Long affinityGroupId, Filter filter) {
         SearchCriteria<DedicatedResourceVO> sc = ListAllHostsSearch.create();
         if (hostId != null) {
             sc.setParameters("hostId", hostId);
@@ -308,7 +309,7 @@ public class DedicatedResourceDaoImpl extends 
GenericDaoBase<DedicatedResourceVO
                 sc.setParameters("accountId", (Object)null);
             }
         }
-        return searchAndCount(sc, null);
+        return searchAndCount(sc, filter);
     }
 
     @Override
diff --git a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java 
b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
index 6cb5381..cc244ce 100644
--- a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
+++ b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
@@ -30,6 +30,7 @@ import java.util.TreeSet;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import com.cloud.utils.db.Filter;
 import com.cloud.utils.fsm.StateMachine2;
 
 import org.apache.log4j.Logger;
@@ -639,21 +640,21 @@ StateListener<State, VirtualMachine.Event, 
VirtualMachine> {
             if (domainGroupMappings == null || domainGroupMappings.isEmpty()) {
                 //The dedicated resource belongs to VM Account ID.
 
-                tempStorage = _dedicatedDao.searchDedicatedPods(null, 
vmDomainId, vmAccountId, null).first();
+                tempStorage = _dedicatedDao.searchDedicatedPods(null, 
vmDomainId, vmAccountId, null, new Filter(DedicatedResourceVO.class, "id", 
true, 0L, 1L)).first();
 
                 for(DedicatedResourceVO vo : tempStorage) {
                     allPodsFromDedicatedID.add(vo.getPodId());
                 }
 
                 tempStorage.clear();
-                tempStorage = _dedicatedDao.searchDedicatedClusters(null, 
vmDomainId, vmAccountId, null).first();
+                tempStorage = _dedicatedDao.searchDedicatedClusters(null, 
vmDomainId, vmAccountId, null, new Filter(DedicatedResourceVO.class, "id", 
true, 0L, 1L)).first();
 
                 for(DedicatedResourceVO vo : tempStorage) {
                     allClustersFromDedicatedID.add(vo.getClusterId());
                 }
 
                 tempStorage.clear();
-                tempStorage = _dedicatedDao.searchDedicatedHosts(null, 
vmDomainId, vmAccountId, null).first();
+                tempStorage = _dedicatedDao.searchDedicatedHosts(null, 
vmDomainId, vmAccountId, null, new Filter(DedicatedResourceVO.class, "id", 
true, 0L, 1L)).first();
 
                 for(DedicatedResourceVO vo : tempStorage) {
                     allHostsFromDedicatedID.add(vo.getHostId());
@@ -667,21 +668,21 @@ StateListener<State, VirtualMachine.Event, 
VirtualMachine> {
             else {
                 //The dedicated resource belongs to VM Domain ID or No 
dedication.
 
-                tempStorage = _dedicatedDao.searchDedicatedPods(null, 
vmDomainId, null, null).first();
+                tempStorage = _dedicatedDao.searchDedicatedPods(null, 
vmDomainId, null, null, new Filter(DedicatedResourceVO.class, "id", true, 0L, 
1L)).first();
 
                 for(DedicatedResourceVO vo : tempStorage) {
                     allPodsFromDedicatedID.add(vo.getPodId());
                 }
 
                 tempStorage.clear();
-                tempStorage = _dedicatedDao.searchDedicatedClusters(null, 
vmDomainId, null, null).first();
+                tempStorage = _dedicatedDao.searchDedicatedClusters(null, 
vmDomainId, null, null, new Filter(DedicatedResourceVO.class, "id", true, 0L, 
1L)).first();
 
                 for(DedicatedResourceVO vo : tempStorage) {
                     allClustersFromDedicatedID.add(vo.getClusterId());
                 }
 
                 tempStorage.clear();
-                tempStorage = _dedicatedDao.searchDedicatedHosts(null, 
vmDomainId, null, null).first();
+                tempStorage = _dedicatedDao.searchDedicatedHosts(null, 
vmDomainId, null, null, new Filter(DedicatedResourceVO.class, "id", true, 0L, 
1L)).first();
 
                 for(DedicatedResourceVO vo : tempStorage) {
                     allHostsFromDedicatedID.add(vo.getHostId());

-- 
To stop receiving notification emails like this one, please contact
['"commits@cloudstack.apache.org" <commits@cloudstack.apache.org>'].

Reply via email to