Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 27 additions & 28 deletions server/src/main/java/com/cloud/server/StatsCollector.java
Original file line number Diff line number Diff line change
Expand Up @@ -684,18 +684,17 @@ protected void runInContext() {
return;
}
// collect the vm disk statistics(total) from hypervisor. added by weizhou, 2013.03.
s_logger.trace("Running VM disk stats ...");
try {
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) {
s_logger.debug("VmDiskStatsTask is running...");
s_logger.debug("VmDiskStatsTask is running...");

SearchCriteria<HostVO> sc = createSearchCriteriaForHostTypeRoutingStateUpAndNotInMaintenance();
sc.addAnd("hypervisorType", SearchCriteria.Op.IN, HypervisorType.KVM, HypervisorType.VMware);
List<HostVO> hosts = _hostDao.search(sc, null);
SearchCriteria<HostVO> sc = createSearchCriteriaForHostTypeRoutingStateUpAndNotInMaintenance();
sc.addAnd("hypervisorType", SearchCriteria.Op.IN, HypervisorType.KVM, HypervisorType.VMware);
List<HostVO> hosts = _hostDao.search(sc, null);

for (HostVO host : hosts) {
for (HostVO host : hosts) {
try {
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) {
List<UserVmVO> vms = _userVmDao.listRunningByHostId(host.getId());
List<Long> vmIds = new ArrayList<Long>();

Expand All @@ -706,7 +705,7 @@ public void doInTransactionWithoutResult(TransactionStatus status) {

HashMap<Long, List<VmDiskStatsEntry>> vmDiskStatsById = _userVmMgr.getVmDiskStatistics(host.getId(), host.getName(), vmIds);
if (vmDiskStatsById == null)
continue;
return;

Set<Long> vmIdSet = vmDiskStatsById.keySet();
for (Long vmId : vmIdSet) {
Expand Down Expand Up @@ -793,10 +792,10 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
}
}
}
}
});
} catch (Exception e) {
s_logger.warn("Error while collecting vm disk stats from hosts", e);
});
} catch (Exception e) {
s_logger.warn(String.format("Error while collecting vm disk stats from host %s : ", host.getName()), e);
}
}
}
}
Expand All @@ -812,16 +811,16 @@ protected void runInContext() {
return;
}
// collect the vm network statistics(total) from hypervisor
try {
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) {
s_logger.debug("VmNetworkStatsTask is running...");
s_logger.debug("VmNetworkStatsTask is running...");

SearchCriteria<HostVO> sc = createSearchCriteriaForHostTypeRoutingStateUpAndNotInMaintenance();
List<HostVO> hosts = _hostDao.search(sc, null);
SearchCriteria<HostVO> sc = createSearchCriteriaForHostTypeRoutingStateUpAndNotInMaintenance();
List<HostVO> hosts = _hostDao.search(sc, null);

for (HostVO host : hosts) {
for (HostVO host : hosts) {
try {
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) {
List<UserVmVO> vms = _userVmDao.listRunningByHostId(host.getId());
List<Long> vmIds = new ArrayList<Long>();

Expand All @@ -832,7 +831,7 @@ public void doInTransactionWithoutResult(TransactionStatus status) {

HashMap<Long, List<VmNetworkStatsEntry>> vmNetworkStatsById = _userVmMgr.getVmNetworkStatistics(host.getId(), host.getName(), vmIds);
if (vmNetworkStatsById == null)
continue;
return;

Set<Long> vmIdSet = vmNetworkStatsById.keySet();
for (Long vmId : vmIdSet) {
Expand Down Expand Up @@ -912,10 +911,10 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
}
}
}
}
});
} catch (Exception e) {
s_logger.warn("Error while collecting vm network stats from hosts", e);
});
} catch (Exception e) {
s_logger.warn(String.format("Error while collecting vm network stats from host %s : ", host.getName()), e);
}
}
}
}
Expand Down