Github user mike-tutkowski commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1403#discussion_r63138267
  
    --- Diff: engine/schema/src/com/cloud/dc/dao/ClusterDaoImpl.java ---
    @@ -260,4 +268,41 @@ public boolean remove(Long id) {
             sc.setParameters("dataCenterId", zoneId);
             return customSearch(sc, null);
         }
    +
    +    @Override
    +    public boolean computeWhetherClusterSupportsResigning(long clusterId) {
    +        ClusterVO cluster = findById(clusterId);
    +
    +        if (cluster == null || cluster.getAllocationState() != 
Grouping.AllocationState.Enabled) {
    +            return false;
    +        }
    +
    +        List<HostVO> hosts = hostDao.findByClusterId(clusterId);
    +
    +        if (hosts == null) {
    +            return false;
    +        }
    +
    +        for (HostVO host : hosts) {
    +            if (host == null) {
    +                return false;
    +            }
    +
    +            DetailVO hostDetail = hostDetailsDao.findDetail(host.getId(), 
"supportsResign");
    +
    +            if (hostDetail == null) {
    +                return false;
    +            }
    +
    +            String value = hostDetail.getValue();
    +
    +            Boolean booleanValue = Boolean.valueOf(value);
    +
    +            if (booleanValue == false) {
    +                return false;
    +            }
    +        }
    +
    +        return true;
    +    }
    --- End diff --
    
    See what you think...I just added a method on the HostDetailsDao to return 
a Map where the key is the ID of the host and the value is true or false (you 
pass in the "name" field you are interested in).
    
    This way we just do one query and then look up the results in the map each 
time through the "for" loop.
    
    If we want to do a join of the host, host_details, and cluster tables 
(which, I believe, would be necessary to reduce the results coming back from 
the DB), perhaps you know of somewhere in our codebase where we do some similar 
action? Thanks


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to