mirror of https://github.com/apache/cloudstack.git
server: count hosts than get all hosts in capacity scans
This refactors hotspot code to fetch just the count of hosts than all the host VOs for a zone, during capacity scans for systemvms. This reduces CPU and DB load, in really large (10k+ hosts) env. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
2a48d71909
commit
c01aad6ba8
|
|
@ -41,6 +41,8 @@ public interface HostDao extends GenericDao<HostVO, Long>, StateDao<Status, Stat
|
|||
|
||||
Integer countAllByTypeInZone(long zoneId, final Host.Type type);
|
||||
|
||||
Integer countUpAndEnabledHostsInZone(long zoneId);
|
||||
|
||||
/**
|
||||
* Mark all hosts associated with a certain management server
|
||||
* as disconnected.
|
||||
|
|
|
|||
|
|
@ -481,6 +481,15 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
return getCount(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer countUpAndEnabledHostsInZone(long zoneId) {
|
||||
SearchCriteria<HostVO> sc = HostTypeCountSearch.create();
|
||||
sc.setParameters("type", Type.Routing);
|
||||
sc.setParameters("resourceState", ResourceState.Enabled);
|
||||
sc.setParameters("dc", zoneId);
|
||||
return getCount(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listByDataCenterId(long id) {
|
||||
return listByDataCenterIdAndState(id, ResourceState.Enabled);
|
||||
|
|
|
|||
|
|
@ -864,8 +864,8 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
|
|||
}
|
||||
|
||||
public boolean isZoneReady(Map<Long, ZoneHostInfo> zoneHostInfoMap, long dataCenterId) {
|
||||
List <HostVO> hosts = hostDao.listByDataCenterId(dataCenterId);
|
||||
if (CollectionUtils.isEmpty(hosts)) {
|
||||
Integer totalUpAndEnabledHosts = hostDao.countUpAndEnabledHostsInZone(dataCenterId);
|
||||
if (totalUpAndEnabledHosts != null && totalUpAndEnabledHosts < 1) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Zone " + dataCenterId + " has no host available which is enabled and in Up state");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -796,8 +796,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
|
|||
}
|
||||
|
||||
public boolean isZoneReady(Map<Long, ZoneHostInfo> zoneHostInfoMap, long dataCenterId) {
|
||||
List <HostVO> hosts = _hostDao.listByDataCenterId(dataCenterId);
|
||||
if (CollectionUtils.isEmpty(hosts)) {
|
||||
Integer totalUpAndEnabledHosts = _hostDao.countUpAndEnabledHostsInZone(dataCenterId);
|
||||
if (totalUpAndEnabledHosts != null && totalUpAndEnabledHosts < 1) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Zone " + dataCenterId + " has no host available which is enabled and in Up state");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue