shwstppr commented on code in PR #9840:
URL: https://github.com/apache/cloudstack/pull/9840#discussion_r1828876291
##########
engine/schema/src/main/java/com/cloud/host/dao/HostDaoImpl.java:
##########
@@ -1602,4 +1701,75 @@ private String createSqlFindHostToExecuteCommand(boolean
useDisabledHosts) {
}
return String.format(sqlFindHostInZoneToExecuteCommand,
hostResourceStatus);
}
+
+ @Override
+ public boolean isHostUp(long hostId) {
+ GenericSearchBuilder<HostVO, Status> sb =
createSearchBuilder(Status.class);
+ sb.and("id", sb.entity().getId(), Op.EQ);
+ sb.selectFields(sb.entity().getStatus());
+ SearchCriteria<Status> sc = sb.create();
+ List<Status> statuses = customSearch(sc, null);
+ return CollectionUtils.isNotEmpty(statuses) &&
Status.Up.equals(statuses.get(0));
+ }
+
+ @Override
+ public List<Long>
findHostIdsByZoneClusterResourceStateTypeAndHypervisorType(final Long zoneId,
final Long clusterId,
+ final List<ResourceState> resourceStates, final List<Type>
types,
+ final List<Hypervisor.HypervisorType> hypervisorTypes) {
+ GenericSearchBuilder<HostVO, Long> sb =
createSearchBuilder(Long.class);
+ sb.selectFields(sb.entity().getId());
+ sb.and("zoneId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);
+ sb.and("clusterId", sb.entity().getClusterId(), SearchCriteria.Op.EQ);
+ sb.and("resourceState", sb.entity().getResourceState(),
SearchCriteria.Op.IN);
+ sb.and("type", sb.entity().getType(), SearchCriteria.Op.IN);
+ if (CollectionUtils.isNotEmpty(hypervisorTypes)) {
+ sb.and().op(sb.entity().getHypervisorType(),
SearchCriteria.Op.NULL);
+ sb.or("hypervisorTypes", sb.entity().getHypervisorType(),
SearchCriteria.Op.IN);
+ sb.cp();
+ }
+ sb.done();
+ SearchCriteria<Long> sc = sb.create();
+ if (zoneId != null) {
+ sc.setParameters("zoneId", zoneId);
+ }
+ if (clusterId != null) {
+ sc.setParameters("clusterId", clusterId);
+ }
+ if (CollectionUtils.isNotEmpty(hypervisorTypes)) {
+ sc.setParameters("hypervisorTypes", hypervisorTypes.toArray());
+ }
+ sc.setParameters("resourceState", resourceStates.toArray());
+ sc.setParameters("type", types.toArray());
+ return customSearch(sc, null);
+ }
+
+ @Override
+ public List<Long> listAllIds() {
+ return listIdsBy(null, null, null, null, null, null, null);
+ }
+
+ @Override
+ public List<HypervisorType> listDistinctHypervisorTypes(final Long zoneId)
{
+ GenericSearchBuilder<HostVO, HypervisorType> sb =
createSearchBuilder(HypervisorType.class);
Review Comment:
This searchbuilder is used only by this method, would it add any benefit in
adding it as a class object?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]