Github user jburwell commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1403#discussion_r63108616
  
    --- 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 --
    
    The DAO calls in the ``for`` loop are concerning from a performance 
perspective (both for the speed of this call and the load placed on the 
database).  Ideally, it would be calculated in a single join.  Would it be 
possible to craft a query across the details for all hosts in a cluster where 
the detail key = "supportsResign" and the value = "true"?


---
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