Search in sources :

Example 1 with StatsCollector

use of com.cloud.server.StatsCollector in project cloudstack by apache.

the class StorageManagerImpl method checkUsagedSpace.

private boolean checkUsagedSpace(StoragePool pool) {
    StatsCollector sc = StatsCollector.getInstance();
    double storageUsedThreshold = CapacityManager.StorageCapacityDisableThreshold.valueIn(pool.getDataCenterId());
    if (sc != null) {
        long totalSize = pool.getCapacityBytes();
        StorageStats stats = sc.getStoragePoolStats(pool.getId());
        if (stats == null) {
            stats = sc.getStorageStats(pool.getId());
        }
        if (stats != null) {
            double usedPercentage = ((double) stats.getByteUsed() / (double) totalSize);
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Checking pool " + pool.getId() + " for storage, totalSize: " + pool.getCapacityBytes() + ", usedBytes: " + stats.getByteUsed() + ", usedPct: " + usedPercentage + ", disable threshold: " + storageUsedThreshold);
            }
            if (usedPercentage >= storageUsedThreshold) {
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug("Insufficient space on pool: " + pool.getId() + " since its usage percentage: " + usedPercentage + " has crossed the pool.storage.capacity.disablethreshold: " + storageUsedThreshold);
                }
                return false;
            }
        }
        return true;
    }
    return false;
}
Also used : StatsCollector(com.cloud.server.StatsCollector)

Aggregations

StatsCollector (com.cloud.server.StatsCollector)1