mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
Fix the annoying NPE in StatsCollector
This commit is contained in:
parent
b828af8f58
commit
497e586329
@ -339,32 +339,34 @@ public class StatsCollector {
|
||||
}
|
||||
ConcurrentHashMap<Long, VolumeStats> volumeStats = new ConcurrentHashMap<Long, VolumeStats>();
|
||||
for (Iterator<Long> iter = commandsByPool.keySet().iterator(); iter.hasNext();) {
|
||||
Long poolId = iter.next();
|
||||
List<VolumeCommand> commandsList = commandsByPool.get(poolId);
|
||||
|
||||
long[] volumeIdArray = new long[commandsList.size()];
|
||||
Commands commands = new Commands(OnError.Continue);
|
||||
for (int i = 0; i < commandsList.size(); i++) {
|
||||
VolumeCommand vCommand = commandsList.get(i);
|
||||
volumeIdArray[i] = vCommand.volumeId;
|
||||
commands.addCommand(vCommand.command);
|
||||
}
|
||||
|
||||
List<StoragePoolHostVO> poolhosts = _storagePoolHostDao.listByPoolId(poolId);
|
||||
for(StoragePoolHostVO poolhost : poolhosts) {
|
||||
Answer[] answers = _agentMgr.send(poolhost.getHostId(), commands);
|
||||
if (answers != null) {
|
||||
long totalBytes = 0L;
|
||||
for (int i = 0; i < answers.length; i++) {
|
||||
if (answers[i].getResult()) {
|
||||
VolumeStats vStats = (VolumeStats)answers[i];
|
||||
volumeStats.put(volumeIdArray[i], vStats);
|
||||
totalBytes += vStats.getBytesUsed();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
Long poolId = iter.next();
|
||||
if(poolId != null) {
|
||||
List<VolumeCommand> commandsList = commandsByPool.get(poolId);
|
||||
|
||||
long[] volumeIdArray = new long[commandsList.size()];
|
||||
Commands commands = new Commands(OnError.Continue);
|
||||
for (int i = 0; i < commandsList.size(); i++) {
|
||||
VolumeCommand vCommand = commandsList.get(i);
|
||||
volumeIdArray[i] = vCommand.volumeId;
|
||||
commands.addCommand(vCommand.command);
|
||||
}
|
||||
|
||||
List<StoragePoolHostVO> poolhosts = _storagePoolHostDao.listByPoolId(poolId);
|
||||
for(StoragePoolHostVO poolhost : poolhosts) {
|
||||
Answer[] answers = _agentMgr.send(poolhost.getHostId(), commands);
|
||||
if (answers != null) {
|
||||
long totalBytes = 0L;
|
||||
for (int i = 0; i < answers.length; i++) {
|
||||
if (answers[i].getResult()) {
|
||||
VolumeStats vStats = (VolumeStats)answers[i];
|
||||
volumeStats.put(volumeIdArray[i], vStats);
|
||||
totalBytes += vStats.getBytesUsed();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We replace the existing volumeStats so that it does not grow with no bounds
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user