mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-5852: router search in DomainDouterDao using AllFieldsSearch filters few routers due to router_network_ref join. Created a seperate search to list running routers with filters.
Conflicts: engine/schema/src/com/cloud/vm/dao/DomainRouterDao.java
This commit is contained in:
parent
c98ac9aae0
commit
9486a9652e
@ -69,7 +69,7 @@ public interface DomainRouterDao extends GenericDao<DomainRouterVO, Long> {
|
||||
* @param podId id of the pod. null if to get all.
|
||||
* @return list of DomainRouterVO
|
||||
*/
|
||||
public List<DomainRouterVO> listByPodId(Long podId);
|
||||
public List<DomainRouterVO> listRunningByPodId(Long podId);
|
||||
|
||||
/**
|
||||
* list virtual machine routers by pod id. pass in null to get all
|
||||
@ -94,7 +94,7 @@ public interface DomainRouterDao extends GenericDao<DomainRouterVO, Long> {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public List<DomainRouterVO> listByDomain(Long id);
|
||||
public List<DomainRouterVO> listRunningByDomain(Long id);
|
||||
|
||||
List<DomainRouterVO> findBy(long accountId, long dcId, Role role);
|
||||
|
||||
@ -147,5 +147,9 @@ public interface DomainRouterDao extends GenericDao<DomainRouterVO, Long> {
|
||||
*/
|
||||
void removeRouterFromGuestNetwork(long routerId, long guestNetworkId);
|
||||
|
||||
List<DomainRouterVO> listByClusterId(Long clusterId);
|
||||
List<DomainRouterVO> listRunningByClusterId(Long clusterId);
|
||||
|
||||
List<DomainRouterVO> listRunningByAccountId(long accountId);
|
||||
|
||||
List<DomainRouterVO> listRunningByDataCenter(long dcId);
|
||||
}
|
||||
|
||||
@ -54,6 +54,7 @@ import com.cloud.vm.VirtualMachine.State;
|
||||
public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> implements DomainRouterDao {
|
||||
|
||||
protected SearchBuilder<DomainRouterVO> AllFieldsSearch;
|
||||
protected SearchBuilder<DomainRouterVO> RunningSearch;
|
||||
protected SearchBuilder<DomainRouterVO> IdNetworkIdStatesSearch;
|
||||
protected SearchBuilder<DomainRouterVO> HostUpSearch;
|
||||
protected SearchBuilder<DomainRouterVO> StateNetworkTypeSearch;
|
||||
@ -139,10 +140,19 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
|
||||
OutsidePodSearch.done();
|
||||
|
||||
clusterSearch = createSearchBuilder();
|
||||
clusterSearch.and("state", clusterSearch.entity().getState(), Op.EQ);
|
||||
SearchBuilder<HostVO> clusterHost = _hostsDao.createSearchBuilder();
|
||||
clusterHost.and("clusterId", clusterHost.entity().getClusterId(), Op.EQ);
|
||||
clusterSearch.join("host", clusterHost, clusterSearch.entity().getHostId(), clusterHost.entity().getId(), JoinType.INNER);
|
||||
clusterSearch.done();
|
||||
|
||||
RunningSearch = createSearchBuilder();
|
||||
RunningSearch.and("dc", RunningSearch.entity().getDataCenterId(), Op.EQ);
|
||||
RunningSearch.and("account", RunningSearch.entity().getAccountId(), Op.EQ);
|
||||
RunningSearch.and("domainId", RunningSearch.entity().getDomainId(), Op.EQ);
|
||||
RunningSearch.and("state", RunningSearch.entity().getState(), Op.EQ);
|
||||
RunningSearch.and("podId", RunningSearch.entity().getPodIdToDeployIn(), Op.EQ);
|
||||
RunningSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -200,15 +210,17 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DomainRouterVO> listByPodId(Long podId) {
|
||||
SearchCriteria<DomainRouterVO> sc = AllFieldsSearch.create();
|
||||
public List<DomainRouterVO> listRunningByPodId(Long podId) {
|
||||
SearchCriteria<DomainRouterVO> sc = RunningSearch.create();
|
||||
sc.setParameters("state", State.Running);
|
||||
sc.setParameters("podId", podId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DomainRouterVO> listByClusterId(Long clusterId) {
|
||||
public List<DomainRouterVO> listRunningByClusterId(Long clusterId) {
|
||||
SearchCriteria<DomainRouterVO> sc = clusterSearch.create();
|
||||
sc.setParameters("state", State.Running);
|
||||
sc.setJoinParameters("host", "clusterId", clusterId);
|
||||
return listBy(sc);
|
||||
}
|
||||
@ -237,8 +249,9 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DomainRouterVO> listByDomain(Long domainId) {
|
||||
SearchCriteria<DomainRouterVO> sc = AllFieldsSearch.create();
|
||||
public List<DomainRouterVO> listRunningByDomain(Long domainId) {
|
||||
SearchCriteria<DomainRouterVO> sc = RunningSearch.create();
|
||||
sc.setParameters("state", State.Running);
|
||||
sc.setParameters("domainId", domainId);
|
||||
return listBy(sc);
|
||||
}
|
||||
@ -379,4 +392,19 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DomainRouterVO> listRunningByAccountId(long accountId) {
|
||||
SearchCriteria<DomainRouterVO> sc = RunningSearch.create();
|
||||
sc.setParameters("state", State.Running);
|
||||
sc.setParameters("account", accountId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DomainRouterVO> listRunningByDataCenter(long dcId) {
|
||||
SearchCriteria<DomainRouterVO> sc = RunningSearch.create();
|
||||
sc.setParameters("state", State.Running);
|
||||
sc.setParameters("dc", dcId);
|
||||
return listBy(sc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4116,10 +4116,10 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
||||
if(account == null){
|
||||
throw new InvalidParameterValueException("Account :"+accountName+" does not exist in domain: "+domainId);
|
||||
}
|
||||
routers = _routerDao.listBy(account.getId());
|
||||
routers = _routerDao.listRunningByAccountId(account.getId());
|
||||
} else {
|
||||
//List by domainId, account name not specified
|
||||
routers = _routerDao.listByDomain(domainId);
|
||||
routers = _routerDao.listRunningByDomain(domainId);
|
||||
}
|
||||
params++;
|
||||
}
|
||||
@ -4127,19 +4127,19 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
||||
Long clusterId = cmd.getClusterId();
|
||||
if (clusterId != null) {
|
||||
params++;
|
||||
routers = _routerDao.listByClusterId(clusterId);
|
||||
routers = _routerDao.listRunningByClusterId(clusterId);
|
||||
}
|
||||
|
||||
Long podId = cmd.getPodId();
|
||||
if (podId != null) {
|
||||
params++;
|
||||
routers = _routerDao.listByPodId(podId);
|
||||
routers = _routerDao.listRunningByPodId(podId);
|
||||
}
|
||||
|
||||
Long zoneId = cmd.getZoneId();
|
||||
if (zoneId != null) {
|
||||
params++;
|
||||
routers = _routerDao.listByDataCenter(zoneId);
|
||||
routers = _routerDao.listRunningByDataCenter(zoneId);
|
||||
}
|
||||
|
||||
if (params > 1) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user