[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-9896?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16315144#comment-16315144
 ] 

ASF GitHub Bot commented on CLOUDSTACK-9896:
--------------------------------------------

rhtyd closed pull request #2073: CLOUDSTACK-9896: API: listDedicatedXXX should 
respect pagination
URL: https://github.com/apache/cloudstack/pull/2073
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 e7a6f35dce2..7cf193d49be 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.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 DedicateHostResponse 
createDedicateHostResponse(DedicatedResources resour
         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 DedicateHostResponse 
createDedicateHostResponse(DedicatedResources resour
                 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 DedicateHostResponse 
createDedicateHostResponse(DedicatedResources resour
         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 DedicateHostResponse 
createDedicateHostResponse(DedicatedResources resour
                 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 DedicateHostResponse 
createDedicateHostResponse(DedicatedResources resour
         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 DedicateHostResponse 
createDedicateHostResponse(DedicatedResources resour
                 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 DedicateHostResponse 
createDedicateHostResponse(DedicatedResources resour
         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 DedicateHostResponse 
createDedicateHostResponse(DedicatedResources resour
                 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 0876d462bb1..7c41439b1ec 100644
--- a/server/src/com/cloud/dc/dao/DedicatedResourceDao.java
+++ b/server/src/com/cloud/dc/dao/DedicatedResourceDao.java
@@ -20,6 +20,7 @@
 
 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 @@
 
     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 8f51783c8b0..c406755f994 100644
--- a/server/src/com/cloud/dc/dao/DedicatedResourceDaoImpl.java
+++ b/server/src/com/cloud/dc/dao/DedicatedResourceDaoImpl.java
@@ -19,6 +19,7 @@
 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 DedicatedResourceVO findByHostId(Long hostId) {
     }
 
     @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 DedicatedResourceVO findByHostId(Long hostId) {
                 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 DedicatedResourceVO findByHostId(Long hostId) {
                 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 DedicatedResourceVO findByHostId(Long hostId) {
                 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 DedicatedResourceVO findByHostId(Long hostId) {
                 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 6cb5381894a..cc244ce41ba 100644
--- a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
+++ b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
@@ -30,6 +30,7 @@
 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 @@ private void 
checkForNonDedicatedResources(VirtualMachineProfile vmProfile, Data
             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 @@ private void 
checkForNonDedicatedResources(VirtualMachineProfile vmProfile, Data
             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());


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> ListDedicatedXXX doesn't respect pagination
> -------------------------------------------
>
>                 Key: CLOUDSTACK-9896
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9896
>             Project: CloudStack
>          Issue Type: Bug
>      Security Level: Public(Anyone can view this level - this is the 
> default.) 
>          Components: API
>            Reporter: Marc-Aurèle Brothier
>            Assignee: Marc-Aurèle Brothier
>            Priority: Minor
>
> The listDedicatedZones, listDedicatedPods, listDedicatedClusters, 
> listDedicatedHosts are not using the pagination filter to return the results.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to