Search in sources :

Example 1 with VolumeStatistics

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;
}
Also used : Volume(org.apache.cloudstack.storage.datastore.api.Volume) VolumeStatistics(org.apache.cloudstack.storage.datastore.api.VolumeStatistics)

Example 2 with VolumeStatistics

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;
}
Also used : CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ScaleIOGatewayClient(org.apache.cloudstack.storage.datastore.client.ScaleIOGatewayClient) VolumeStatistics(org.apache.cloudstack.storage.datastore.api.VolumeStatistics) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) Pair(com.cloud.utils.Pair)

Aggregations

VolumeStatistics (org.apache.cloudstack.storage.datastore.api.VolumeStatistics)2 Pair (com.cloud.utils.Pair)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 Volume (org.apache.cloudstack.storage.datastore.api.Volume)1 ScaleIOGatewayClient (org.apache.cloudstack.storage.datastore.client.ScaleIOGatewayClient)1