mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge branch '4.13' into 4.14
This commit is contained in:
commit
46ead2df71
@ -282,10 +282,7 @@ public class ViewResponseHelper {
|
|||||||
vrDataList.put(vr.getId(), vrData);
|
vrDataList.put(vr.getId(), vrData);
|
||||||
|
|
||||||
VolumeStats vs = null;
|
VolumeStats vs = null;
|
||||||
if (vr.getFormat() == ImageFormat.QCOW2) {
|
if (vr.getFormat() == ImageFormat.VHD || vr.getFormat() == ImageFormat.QCOW2) {
|
||||||
vs = ApiDBUtils.getVolumeStatistics(vrData.getId());
|
|
||||||
}
|
|
||||||
else if (vr.getFormat() == ImageFormat.VHD){
|
|
||||||
vs = ApiDBUtils.getVolumeStatistics(vrData.getPath());
|
vs = ApiDBUtils.getVolumeStatistics(vrData.getPath());
|
||||||
}
|
}
|
||||||
else if (vr.getFormat() == ImageFormat.OVA) {
|
else if (vr.getFormat() == ImageFormat.OVA) {
|
||||||
|
|||||||
@ -928,13 +928,8 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
|
|||||||
|
|
||||||
for (StoragePoolVO pool : pools) {
|
for (StoragePoolVO pool : pools) {
|
||||||
List<VolumeVO> volumes = _volsDao.findByPoolId(pool.getId(), null);
|
List<VolumeVO> volumes = _volsDao.findByPoolId(pool.getId(), null);
|
||||||
List<String> volumeLocators = new ArrayList<String>();
|
|
||||||
for (VolumeVO volume : volumes) {
|
for (VolumeVO volume : volumes) {
|
||||||
if (volume.getFormat() == ImageFormat.QCOW2 || volume.getFormat() == ImageFormat.VHD) {
|
if (volume.getFormat() != ImageFormat.QCOW2 && volume.getFormat() != ImageFormat.VHD && volume.getFormat() != ImageFormat.OVA) {
|
||||||
volumeLocators.add(volume.getPath());
|
|
||||||
} else if (volume.getFormat() == ImageFormat.OVA) {
|
|
||||||
volumeLocators.add(volume.getChainInfo());
|
|
||||||
} else {
|
|
||||||
s_logger.warn("Volume stats not implemented for this format type " + volume.getFormat());
|
s_logger.warn("Volume stats not implemented for this format type " + volume.getFormat());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -943,15 +938,14 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
|
|||||||
Map<String, VolumeStatsEntry> volumeStatsByUuid;
|
Map<String, VolumeStatsEntry> volumeStatsByUuid;
|
||||||
if (pool.getScope() == ScopeType.ZONE) {
|
if (pool.getScope() == ScopeType.ZONE) {
|
||||||
volumeStatsByUuid = new HashMap<>();
|
volumeStatsByUuid = new HashMap<>();
|
||||||
for (final Cluster cluster : _clusterDao.listByZoneId(pool.getDataCenterId())) {
|
for (final Cluster cluster : _clusterDao.listClustersByDcId(pool.getDataCenterId())) {
|
||||||
final Map<String, VolumeStatsEntry> volumeStatsForCluster = _userVmMgr.getVolumeStatistics(cluster.getId(), pool.getUuid(), pool.getPoolType(),
|
final Map<String, VolumeStatsEntry> volumeStatsForCluster = _userVmMgr.getVolumeStatistics(cluster.getId(), pool.getUuid(), pool.getPoolType(), StatsTimeout.value());
|
||||||
volumeLocators, StatsTimeout.value());
|
|
||||||
if (volumeStatsForCluster != null) {
|
if (volumeStatsForCluster != null) {
|
||||||
volumeStatsByUuid.putAll(volumeStatsForCluster);
|
volumeStatsByUuid.putAll(volumeStatsForCluster);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
volumeStatsByUuid = _userVmMgr.getVolumeStatistics(pool.getClusterId(), pool.getUuid(), pool.getPoolType(), volumeLocators, StatsTimeout.value());
|
volumeStatsByUuid = _userVmMgr.getVolumeStatistics(pool.getClusterId(), pool.getUuid(), pool.getPoolType(), StatsTimeout.value());
|
||||||
}
|
}
|
||||||
if (volumeStatsByUuid != null) {
|
if (volumeStatsByUuid != null) {
|
||||||
for (final Map.Entry<String, VolumeStatsEntry> entry : volumeStatsByUuid.entrySet()) {
|
for (final Map.Entry<String, VolumeStatsEntry> entry : volumeStatsByUuid.entrySet()) {
|
||||||
|
|||||||
@ -86,7 +86,7 @@ public interface UserVmManager extends UserVmService {
|
|||||||
|
|
||||||
HashMap<Long, List<VmDiskStatsEntry>> getVmDiskStatistics(long hostId, String hostName, List<Long> vmIds);
|
HashMap<Long, List<VmDiskStatsEntry>> getVmDiskStatistics(long hostId, String hostName, List<Long> vmIds);
|
||||||
|
|
||||||
HashMap<String, VolumeStatsEntry> getVolumeStatistics(long clusterId, String poolUuid, StoragePoolType poolType, List<String> volumeLocator, int timout);
|
HashMap<String, VolumeStatsEntry> getVolumeStatistics(long clusterId, String poolUuid, StoragePoolType poolType, int timout);
|
||||||
|
|
||||||
boolean deleteVmGroup(long groupId);
|
boolean deleteVmGroup(long groupId);
|
||||||
|
|
||||||
|
|||||||
@ -29,6 +29,7 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@ -102,6 +103,7 @@ import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
|||||||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
|
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
|
||||||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
|
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.collections.MapUtils;
|
import org.apache.commons.collections.MapUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
@ -1914,25 +1916,22 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HashMap<String, VolumeStatsEntry> getVolumeStatistics(long clusterId, String poolUuid, StoragePoolType poolType, List<String> volumeLocators, int timeout) {
|
public HashMap<String, VolumeStatsEntry> getVolumeStatistics(long clusterId, String poolUuid, StoragePoolType poolType, int timeout) {
|
||||||
List<HostVO> neighbors = _resourceMgr.listHostsInClusterByStatus(clusterId, Status.Up);
|
List<HostVO> neighbors = _resourceMgr.listHostsInClusterByStatus(clusterId, Status.Up);
|
||||||
StoragePoolVO storagePool = _storagePoolDao.findPoolByUUID(poolUuid);
|
StoragePoolVO storagePool = _storagePoolDao.findPoolByUUID(poolUuid);
|
||||||
|
HashMap<String, VolumeStatsEntry> volumeStatsByUuid = new HashMap<>();
|
||||||
|
|
||||||
for (HostVO neighbor : neighbors) {
|
for (HostVO neighbor : neighbors) {
|
||||||
// apply filters:
|
|
||||||
// - managed storage
|
|
||||||
// - local storage
|
|
||||||
if (storagePool.isManaged() || storagePool.isLocal()) {
|
|
||||||
|
|
||||||
volumeLocators = getVolumesByHost(neighbor, storagePool);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// - zone wide storage for specific hypervisortypes
|
// - zone wide storage for specific hypervisortypes
|
||||||
if (ScopeType.ZONE.equals(storagePool.getScope()) && storagePool.getHypervisor() != neighbor.getHypervisorType()) {
|
if ((ScopeType.ZONE.equals(storagePool.getScope()) && storagePool.getHypervisor() != neighbor.getHypervisorType())) {
|
||||||
// skip this neighbour if their hypervisor type is not the same as that of the store
|
// skip this neighbour if their hypervisor type is not the same as that of the store
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<String> volumeLocators = getVolumesByHost(neighbor, storagePool);
|
||||||
|
if (!CollectionUtils.isEmpty(volumeLocators)) {
|
||||||
|
|
||||||
GetVolumeStatsCommand cmd = new GetVolumeStatsCommand(poolType, poolUuid, volumeLocators);
|
GetVolumeStatsCommand cmd = new GetVolumeStatsCommand(poolType, poolUuid, volumeLocators);
|
||||||
|
|
||||||
if (timeout > 0) {
|
if (timeout > 0) {
|
||||||
@ -1943,16 +1942,20 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||||||
|
|
||||||
if (answer instanceof GetVolumeStatsAnswer){
|
if (answer instanceof GetVolumeStatsAnswer){
|
||||||
GetVolumeStatsAnswer volstats = (GetVolumeStatsAnswer)answer;
|
GetVolumeStatsAnswer volstats = (GetVolumeStatsAnswer)answer;
|
||||||
return volstats.getVolumeStats();
|
if (volstats.getVolumeStats() != null) {
|
||||||
|
volumeStatsByUuid.putAll(volstats.getVolumeStats());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
}
|
||||||
|
}
|
||||||
|
return volumeStatsByUuid.size() > 0 ? volumeStatsByUuid : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getVolumesByHost(HostVO host, StoragePool pool){
|
private List<String> getVolumesByHost(HostVO host, StoragePool pool){
|
||||||
List<UserVmVO> vmsPerHost = _vmDao.listByHostId(host.getId());
|
List<VMInstanceVO> vmsPerHost = _vmInstanceDao.listByHostId(host.getId());
|
||||||
return vmsPerHost.stream()
|
return vmsPerHost.stream()
|
||||||
.flatMap(vm -> _volsDao.findByInstanceIdAndPoolId(vm.getId(),pool.getId()).stream().map(vol -> vol.getPath()))
|
.flatMap(vm -> _volsDao.findByInstanceIdAndPoolId(vm.getId(),pool.getId()).stream().map(vol ->
|
||||||
|
vol.getState() == Volume.State.Ready ? (vol.getFormat() == ImageFormat.OVA ? vol.getChainInfo() : vol.getPath()) : null).filter(Objects::nonNull))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user