From 17e4e7014fed8bd010c7858e5bd086c4f479ba1f Mon Sep 17 00:00:00 2001 From: Nitin Date: Thu, 7 Jul 2011 13:45:40 +0530 Subject: [PATCH] bug 10602: Fix NPE in StatsCollector - ssvm might not be up so check for that. status 10602: resolved fixed --- .../src/com/cloud/server/StatsCollector.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/server/src/com/cloud/server/StatsCollector.java b/server/src/com/cloud/server/StatsCollector.java index fb9a0104c87..6561567da83 100755 --- a/server/src/com/cloud/server/StatsCollector.java +++ b/server/src/com/cloud/server/StatsCollector.java @@ -259,21 +259,26 @@ public class StatsCollector { @Override public void run() { try { - s_logger.debug("StorageCollector is running..."); + if (s_logger.isDebugEnabled()) { + s_logger.debug("StorageCollector is running..."); + } List hosts = _hostDao.listSecondaryStorageHosts(); - ConcurrentHashMap storageStats = new ConcurrentHashMap(); + ConcurrentHashMap storageStats = new ConcurrentHashMap(); + for (HostVO host : hosts) { GetStorageStatsCommand command = new GetStorageStatsCommand(host.getStorageUrl()); - HostVO ssAhost = _agentMgr.getSSAgent(host); - if (ssAhost == null) { - return; - } + HostVO ssAhost = _agentMgr.getSSAgent(host); + if( ssAhost == null ) { + s_logger.warn("There is no secondary storage VM for secondary storage host " + host.getName()); + continue; + } + long hostId = host.getId(); 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()); + s_logger.trace("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()){