This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch 4.19
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.19 by this push:
     new 813d53d031a Sync the pool stats in DB with the actual stats from stats 
collector (#8686)
813d53d031a is described below

commit 813d53d031a0b2a9b551b27e1ba17ae96f32f277
Author: Suresh Kumar Anaparti <suresh.anapa...@shapeblue.com>
AuthorDate: Thu Feb 29 15:26:32 2024 +0530

    Sync the pool stats in DB with the actual stats from stats collector (#8686)
---
 server/src/main/java/com/cloud/server/StatsCollector.java | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/server/src/main/java/com/cloud/server/StatsCollector.java 
b/server/src/main/java/com/cloud/server/StatsCollector.java
index 96eeb5bc33c..2467416155a 100644
--- a/server/src/main/java/com/cloud/server/StatsCollector.java
+++ b/server/src/main/java/com/cloud/server/StatsCollector.java
@@ -1712,17 +1712,21 @@ public class StatsCollector extends ManagerBase 
implements ComponentMethodInterc
                             storagePoolStats.put(pool.getId(), 
(StorageStats)answer);
 
                             boolean poolNeedsUpdating = false;
+                            long capacityBytes = 
((StorageStats)answer).getCapacityBytes();
+                            long usedBytes = 
((StorageStats)answer).getByteUsed();
                             // Seems like we have dynamically updated the pool 
size since the prev. size and the current do not match
-                            if (_storagePoolStats.get(poolId) != null && 
_storagePoolStats.get(poolId).getCapacityBytes() != 
((StorageStats)answer).getCapacityBytes()) {
-                                if (((StorageStats)answer).getCapacityBytes() 
> 0) {
-                                    
pool.setCapacityBytes(((StorageStats)answer).getCapacityBytes());
+                            if ((_storagePoolStats.get(poolId) != null && 
_storagePoolStats.get(poolId).getCapacityBytes() != capacityBytes)
+                                    || pool.getCapacityBytes() != 
capacityBytes) {
+                                if (capacityBytes > 0) {
+                                    pool.setCapacityBytes(capacityBytes);
                                     poolNeedsUpdating = true;
                                 } else {
                                     LOGGER.warn("Not setting capacity bytes, 
received " + ((StorageStats)answer).getCapacityBytes()  + " capacity for pool 
ID " + poolId);
                                 }
                             }
-                            if (pool.getUsedBytes() != 
((StorageStats)answer).getByteUsed() && 
(pool.getStorageProviderName().equalsIgnoreCase(DataStoreProvider.DEFAULT_PRIMARY)
 || _storageManager.canPoolProvideStorageStats(pool))) {
-                                pool.setUsedBytes(((StorageStats) 
answer).getByteUsed());
+                            if (((_storagePoolStats.get(poolId) != null && 
_storagePoolStats.get(poolId).getByteUsed() != usedBytes)
+                                    || pool.getUsedBytes() != usedBytes) && 
(pool.getStorageProviderName().equalsIgnoreCase(DataStoreProvider.DEFAULT_PRIMARY)
 || _storageManager.canPoolProvideStorageStats(pool))) {
+                                pool.setUsedBytes(usedBytes);
                                 poolNeedsUpdating = true;
                             }
                             if (poolNeedsUpdating) {

Reply via email to