mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-9896: listDedicatedXXX should respect pagination (#2073)
Fixes listDedicatedxxx APIs to respect pagination options.
This commit is contained in:
parent
1ade09575e
commit
92a6bc27ff
@ -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());
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user