use of org.apache.cloudstack.storage.datastore.api.VolumeStatistics in project cloudstack by apache.
the class ScaleIOGatewayClientImpl method getVolumeStatistics.
@Override
public VolumeStatistics getVolumeStatistics(String volumeId) {
Preconditions.checkArgument(StringUtils.isNotEmpty(volumeId), "Volume id cannot be null");
Volume volume = getVolume(volumeId);
if (volume != null) {
String volumeTreeId = volume.getVtreeId();
if (StringUtils.isNotEmpty(volumeTreeId)) {
VolumeStatistics volumeStatistics = get("/instances/VTree::" + volumeTreeId + "/relationships/Statistics", VolumeStatistics.class);
if (volumeStatistics != null) {
volumeStatistics.setAllocatedSizeInKb(volume.getSizeInKb());
return volumeStatistics;
}
}
}
return null;
}
use of org.apache.cloudstack.storage.datastore.api.VolumeStatistics in project cloudstack by apache.
the class ScaleIOPrimaryDataStoreDriver method getVolumeStats.
@Override
public Pair<Long, Long> getVolumeStats(StoragePool storagePool, String volumePath) {
Preconditions.checkArgument(storagePool != null, "storagePool cannot be null");
Preconditions.checkArgument(StringUtils.isNotEmpty(volumePath), "volumePath cannot be null");
try {
final ScaleIOGatewayClient client = getScaleIOClient(storagePool.getId());
VolumeStatistics volumeStatistics = client.getVolumeStatistics(ScaleIOUtil.getVolumePath(volumePath));
if (volumeStatistics != null) {
Long provisionedSizeInBytes = volumeStatistics.getNetProvisionedAddressesInBytes();
Long allocatedSizeInBytes = volumeStatistics.getAllocatedSizeInBytes();
return new Pair<Long, Long>(provisionedSizeInBytes, allocatedSizeInBytes);
}
} catch (Exception e) {
String errMsg = "Unable to get stats for the volume: " + volumePath + " in the pool: " + storagePool.getId() + " due to " + e.getMessage();
LOGGER.warn(errMsg);
throw new CloudRuntimeException(errMsg, e);
}
return null;
}
Aggregations