harikrishna-patnala commented on a change in pull request #4871:
URL: https://github.com/apache/cloudstack/pull/4871#discussion_r603033548



##########
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:
       Updated it accordingly

##########
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);
+            }
+        } catch (Exception e) {
+            s_logger.warn("findHostsConnectedToPools:Exception: ", e);

Review comment:
       Updated it accordingly

##########
File path: server/src/main/java/com/cloud/storage/StorageManagerImpl.java
##########
@@ -1633,6 +1640,223 @@ public PrimaryDataStoreInfo 
cancelPrimaryStorageForMaintenance(CancelPrimaryStor
         return 
(PrimaryDataStoreInfo)_dataStoreMgr.getDataStore(primaryStorage.getId(), 
DataStoreRole.Primary);
     }
 
+    @Override
+    @ActionEvent(eventType = EventTypes.EVENT_SYNC_STORAGE_POOL, 
eventDescription = "synchronising storage pool with management server", async = 
true)
+    public StoragePool syncStoragePool(SyncStoragePoolCmd cmd) {
+        Long poolId = cmd.getPoolId();
+        StoragePoolVO pool = _storagePoolDao.findById(poolId);
+
+        if (pool == null) {
+            String msg = "Unable to obtain lock on the storage pool record 
while syncing storage pool with management server";

Review comment:
       added pool id.




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


Reply via email to