GutoVeronezi commented on a change in pull request #4871:
URL: https://github.com/apache/cloudstack/pull/4871#discussion_r601759823
##########
File path:
engine/schema/src/main/java/com/cloud/storage/dao/StoragePoolHostDaoImpl.java
##########
@@ -121,6 +123,33 @@ public StoragePoolHostVO findByPoolHost(long poolId, long
hostId) {
return result;
}
+ @Override
+ public List<Long> findHostsConnectedToPools(List<Long> poolIds) {
+ List<Long> hosts = new ArrayList<Long>();
+ if (poolIds == null || poolIds.isEmpty()) {
+ return hosts;
+ }
+
+ String poolIdsInStr = poolIds.stream().map(poolId ->
String.valueOf(poolId)).collect(Collectors.joining(",", "(", ")"));
+ String sql = HOSTS_FOR_POOLS_SEARCH.replace("(?)", poolIdsInStr);
+
+ TransactionLegacy txn = TransactionLegacy.currentTxn();
+ try(PreparedStatement pstmt = txn.prepareStatement(sql);) {
+ try(ResultSet rs = pstmt.executeQuery();) {
+ while (rs.next()) {
+ long hostId = rs.getLong(1); // host_id column
+ hosts.add(hostId);
+ }
+ } catch (SQLException e) {
+ s_logger.warn("findHostsConnectedToPools:Exception: ", e);
Review comment:
Suggestion:
We could improve logging here, like:
```java
s_logger.warn(String.format("Unable to retrieve hosts from pools [%s] due to
[%s].", poolIdsInStr, e.getMessage()), e);
```
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]