dhslove commented on a change in pull request #5862:
URL: https://github.com/apache/cloudstack/pull/5862#discussion_r795031914



##########
File path: 
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java
##########
@@ -35,121 +35,221 @@
 public class KVMHAMonitor extends KVMHABase implements Runnable {
 
     private static final Logger s_logger = 
Logger.getLogger(KVMHAMonitor.class);
-    private final Map<String, NfsStoragePool> storagePool = new 
ConcurrentHashMap<>();
+    private final Map<String, NfsStoragePool> nfsstoragePool = new 
ConcurrentHashMap<>();
+    private final Map<String, RbdStoragePool> rbdstoragePool = new 
ConcurrentHashMap<>();
     private final boolean rebootHostAndAlertManagementOnHeartbeatTimeout;
 
     private final String hostPrivateIp;
 
-    public KVMHAMonitor(NfsStoragePool pool, String host, String scriptPath) {
+    public KVMHAMonitor(NfsStoragePool pool, RbdStoragePool rbdpool, String 
host, String scriptPath, String scriptPathRbd) {
         if (pool != null) {
-            storagePool.put(pool._poolUUID, pool);
+            nfsstoragePool.put(pool._poolUUID, pool);
+        }else if (rbdpool != null) {
+            rbdstoragePool.put(rbdpool._poolUUID, rbdpool);
         }
+        configureHeartBeatPath(scriptPath, scriptPathRbd);
         hostPrivateIp = host;
-        configureHeartBeatPath(scriptPath);
-
         _heartBeatUpdateTimeout = 
AgentPropertiesFileHandler.getPropertyValue(AgentProperties.HEARTBEAT_UPDATE_TIMEOUT);
         rebootHostAndAlertManagementOnHeartbeatTimeout = 
AgentPropertiesFileHandler.getPropertyValue(AgentProperties.REBOOT_HOST_AND_ALERT_MANAGEMENT_ON_HEARTBEAT_TIMEOUT);
     }
 
-    private static synchronized void configureHeartBeatPath(String scriptPath) 
{
+    private static synchronized void configureHeartBeatPath(String scriptPath, 
String scriptPathRbd) {
         KVMHABase.s_heartBeatPath = scriptPath;
+        KVMHABase.s_heartBeatPathRbd = scriptPathRbd;
     }
 
     public void addStoragePool(NfsStoragePool pool) {
-        synchronized (storagePool) {
-            storagePool.put(pool._poolUUID, pool);
+        synchronized (nfsstoragePool) {
+            nfsstoragePool.put(pool._poolUUID, pool);
+        }
+    }
+
+    public void addStoragePool(RbdStoragePool pool) {
+        synchronized (rbdstoragePool) {
+            rbdstoragePool.put(pool._poolUUID, pool);
         }
     }
 
     public void removeStoragePool(String uuid) {
-        synchronized (storagePool) {
-            NfsStoragePool pool = storagePool.get(uuid);
+        synchronized (nfsstoragePool) {
+            NfsStoragePool pool = nfsstoragePool.get(uuid);
             if (pool != null) {
                 Script.runSimpleBashScript("umount " + pool._mountDestPath);
-                storagePool.remove(uuid);
+                nfsstoragePool.remove(uuid);
+            }
+        }
+    }
+
+    public void removeRbdStoragePool(String uuid) {
+        synchronized (rbdstoragePool) {
+            RbdStoragePool pool = rbdstoragePool.get(uuid);
+            if (pool != null) {
+                Script.runSimpleBashScript("umount " + pool._mountDestPath);
+                rbdstoragePool.remove(uuid);
             }
         }
     }
 
     public List<NfsStoragePool> getStoragePools() {
-        synchronized (storagePool) {
-            return new ArrayList<>(storagePool.values());
+        synchronized (nfsstoragePool) {
+            return new ArrayList<>(nfsstoragePool.values());
+        }
+    }
+
+    public List<RbdStoragePool> getRbdStoragePools() {
+        synchronized (rbdstoragePool) {
+            return new ArrayList<>(rbdstoragePool.values());
         }
     }
 
     public NfsStoragePool getStoragePool(String uuid) {
-        synchronized (storagePool) {
-            return storagePool.get(uuid);
+        synchronized (nfsstoragePool) {
+            return nfsstoragePool.get(uuid);
+        }
+    }
+
+    public RbdStoragePool getRbdStoragePool(String uuid) {
+        synchronized (rbdstoragePool) {
+            return rbdstoragePool.get(uuid);
         }
     }
 
     protected void runHeartBeat() {
-        synchronized (storagePool) {
-            Set<String> removedPools = new HashSet<>();
-            for (String uuid : storagePool.keySet()) {
-                NfsStoragePool primaryStoragePool = storagePool.get(uuid);
-                StoragePool storage;
-                try {
-                    Connect conn = LibvirtConnection.getConnection();
-                    storage = conn.storagePoolLookupByUUIDString(uuid);
-                    if (storage == null || storage.getInfo().state != 
StoragePoolState.VIR_STORAGE_POOL_RUNNING) {
-                        if (storage == null) {
-                            s_logger.debug(String.format("Libvirt storage pool 
[%s] not found, removing from HA list.", uuid));
-                        } else {
-                            s_logger.debug(String.format("Libvirt storage pool 
[%s] found, but not running, removing from HA list.", uuid));
+        if(nfsstoragePool != null && !nfsstoragePool.isEmpty()) {

Review comment:
       @GutoVeronezi   I modified the code as you requested.




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


Reply via email to