mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
server: Update use_bytes of storage pools (#4360)
Update the used_bytes for all default primary storage pools Also get used_bytes of storage pool from database instead of memory
This commit is contained in:
parent
a5d4bd5f5a
commit
71c5dbcf49
@ -195,6 +195,10 @@ public class StoragePoolVO implements StoragePool {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDataCenterId() {
|
||||
return dataCenterId;
|
||||
|
||||
@ -36,6 +36,7 @@ import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
@ -1027,8 +1028,13 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
|
||||
storagePoolStats.put(pool.getId(), (StorageStats)answer);
|
||||
|
||||
// Seems like we have dynamically updated the pool size since the prev. size and the current do not match
|
||||
if (_storagePoolStats.get(poolId) != null && _storagePoolStats.get(poolId).getCapacityBytes() != ((StorageStats)answer).getCapacityBytes()) {
|
||||
if (pool.getCapacityBytes() != ((StorageStats)answer).getCapacityBytes() ||
|
||||
pool.getUsedBytes() != ((StorageStats)answer).getByteUsed()) {
|
||||
pool.setCapacityBytes(((StorageStats)answer).getCapacityBytes());
|
||||
if (pool.getStorageProviderName().equalsIgnoreCase(DataStoreProvider.DEFAULT_PRIMARY)) {
|
||||
pool.setUsedBytes(((StorageStats) answer).getByteUsed());
|
||||
pool.setUpdateTime(new Date());
|
||||
}
|
||||
_storagePoolDao.update(pool.getId(), pool);
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,7 +151,6 @@ import com.cloud.org.Grouping.AllocationState;
|
||||
import com.cloud.resource.ResourceState;
|
||||
import com.cloud.server.ConfigurationServer;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.server.StatsCollector;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.storage.Volume.Type;
|
||||
@ -1730,32 +1729,22 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
||||
return true;
|
||||
}
|
||||
|
||||
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);
|
||||
double usedPercentage = ((double)pool.getUsedBytes() / (double)totalSize);
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Checking pool " + pool.getId() + " for storage, totalSize: " + toHumanReadableSize(pool.getCapacityBytes()) + ", usedBytes: " + toHumanReadableSize(stats.getByteUsed()) + ", usedPct: " + usedPercentage
|
||||
+ ", disable threshold: " + storageUsedThreshold);
|
||||
s_logger.debug("Checking pool " + pool.getId() + " for storage, totalSize: " + pool.getCapacityBytes() + ", usedBytes: " + pool.getUsedBytes() +
|
||||
", 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);
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean storagePoolHasEnoughIops(List<Volume> requestedVolumes, StoragePool pool) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user