mirror of https://github.com/apache/cloudstack.git
bug 10580: Making necessary changes to stats collection to entertain multiple secondary storage.
status 10580: resolved fixed
This commit is contained in:
parent
2aa1f3e596
commit
fb981be800
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -258,15 +258,19 @@ public class StatsCollector {
|
|||
class StorageCollector implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
try {
|
||||
s_logger.debug("StorageCollector is running...");
|
||||
|
||||
List<HostVO> hosts = _hostDao.listSecondaryStorageHosts();
|
||||
ConcurrentHashMap<Long, StorageStats> storageStats = new ConcurrentHashMap<Long, StorageStats>();
|
||||
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()){
|
||||
|
|
|
|||
Loading…
Reference in New Issue