From fb981be8007e8db1fb92277c48b756da5bf4f5ed Mon Sep 17 00:00:00 2001 From: Nitin Date: Wed, 6 Jul 2011 18:10:25 +0530 Subject: [PATCH] bug 10580: Making necessary changes to stats collection to entertain multiple secondary storage. status 10580: resolved fixed --- .../cloud/agent/api/GetStorageStatsCommand.java | 15 ++++++++++++--- .../resource/NfsSecondaryStorageResource.java | 2 +- server/src/com/cloud/server/StatsCollector.java | 8 ++++++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/api/src/com/cloud/agent/api/GetStorageStatsCommand.java b/api/src/com/cloud/agent/api/GetStorageStatsCommand.java index 3eda95c45ac..1cb3d7c0124 100755 --- a/api/src/com/cloud/agent/api/GetStorageStatsCommand.java +++ b/api/src/com/cloud/agent/api/GetStorageStatsCommand.java @@ -25,9 +25,18 @@ public class GetStorageStatsCommand extends Command { private String id; private String localPath; private StoragePoolType pooltype; + private String secUrl; - public GetStorageStatsCommand() { + public String getSecUrl() { + return secUrl; + } + + public void setSecUrl(String secUrl) { + this.secUrl = secUrl; + } + + public GetStorageStatsCommand() { } public StoragePoolType getPooltype() { @@ -38,8 +47,8 @@ public class GetStorageStatsCommand extends Command { this.pooltype = pooltype; } - public GetStorageStatsCommand(String id) { - this.id = id; + public GetStorageStatsCommand(String secUrl) { + this.secUrl = secUrl; } public GetStorageStatsCommand(String id, StoragePoolType pooltype) { diff --git a/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java b/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java index 04ba5353c63..438ec3f6138 100755 --- a/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java +++ b/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java @@ -305,7 +305,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S } protected GetStorageStatsAnswer execute(final GetStorageStatsCommand cmd) { - String rootDir = getRootDir(cmd.getLocalPath()); + String rootDir = getRootDir(cmd.getSecUrl()); final long usedSize = getUsedSize(rootDir); final long totalSize = getTotalSize(rootDir); if (usedSize == -1 || totalSize == -1) { diff --git a/server/src/com/cloud/server/StatsCollector.java b/server/src/com/cloud/server/StatsCollector.java index cb2ce49a1cd..fbaa4056f7e 100755 --- a/server/src/com/cloud/server/StatsCollector.java +++ b/server/src/com/cloud/server/StatsCollector.java @@ -258,15 +258,19 @@ public class StatsCollector { class StorageCollector implements Runnable { @Override public void run() { - try { + try { + s_logger.debug("StorageCollector is running..."); + List hosts = _hostDao.listSecondaryStorageHosts(); ConcurrentHashMap storageStats = new ConcurrentHashMap(); for (HostVO host : hosts) { GetStorageStatsCommand command = new GetStorageStatsCommand(host.getStorageUrl()); + HostVO ssAhost = _agentMgr.getSSAgent(host); long hostId = host.getId(); - Answer answer = _agentMgr.easySend(hostId, command); + Answer answer = _agentMgr.easySend(ssAhost.getId(), command); if (answer != null && answer.getResult()) { storageStats.put(hostId, (StorageStats)answer); + s_logger.debug("HostId: "+hostId+ " Used: " + ((StorageStats)answer).getByteUsed() + " Total Available: " + ((StorageStats)answer).getCapacityBytes()); //Seems like we have dynamically updated the sec. storage as prev. size and the current do not match if (_storageStats.get(hostId)!=null && _storageStats.get(hostId).getCapacityBytes() != ((StorageStats)answer).getCapacityBytes()){