CLOUDSTACK-2036 - Adding storage storage.overprovisioning.factor configurable at zone level.

This commit is contained in:
Nitin Mehta 2013-05-01 14:21:09 +05:30
parent 817c46db7c
commit b16ccc9fa6
5 changed files with 29 additions and 17 deletions

View File

@ -142,7 +142,7 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager,
_executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("HostCapacity-Checker"));
VirtualMachine.State.getStateMachine().registerListener(this);
_agentManager.registerForHostEvents(new StorageCapacityListener(_capacityDao, _storageOverProvisioningFactor), true, false, false);
_agentManager.registerForHostEvents(new StorageCapacityListener(_capacityDao, _storageMgr), true, false, false);
_agentManager.registerForHostEvents(new ComputeCapacityListener(_capacityDao, this), true, false, false);
return true;

View File

@ -16,8 +16,10 @@
// under the License.
package com.cloud.capacity;
import java.math.BigDecimal;
import java.util.List;
import com.cloud.storage.StorageManager;
import org.apache.log4j.Logger;
import com.cloud.agent.Listener;
@ -39,14 +41,11 @@ import com.cloud.utils.db.SearchCriteria;
public class StorageCapacityListener implements Listener {
CapacityDao _capacityDao;
float _overProvisioningFactor = 1.0f;
StorageManager _storageMgr;
public StorageCapacityListener(CapacityDao _capacityDao,
float _overProvisioningFactor) {
super();
this._capacityDao = _capacityDao;
this._overProvisioningFactor = _overProvisioningFactor;
public StorageCapacityListener(CapacityDao capacityDao, StorageManager storageMgr) {
this._capacityDao = capacityDao;
this._storageMgr = storageMgr;
}
@ -79,9 +78,10 @@ public class StorageCapacityListener implements Listener {
StartupStorageCommand ssCmd = (StartupStorageCommand) startup;
if (ssCmd.getResourceType() == Storage.StorageResourceType.STORAGE_HOST) {
BigDecimal overProvFactor = _storageMgr.getStorageOverProvisioningFactor(server.getDataCenterId());
CapacityVO capacity = new CapacityVO(server.getId(),
server.getDataCenterId(), server.getPodId(), server.getClusterId(), 0L,
(long) (server.getTotalSize() * _overProvisioningFactor),
(overProvFactor.multiply(new BigDecimal(server.getTotalSize()))).longValue(),
CapacityVO.CAPACITY_TYPE_STORAGE_ALLOCATED);
_capacityDao.persist(capacity);
}

View File

@ -69,7 +69,7 @@ public enum Config {
// Storage
StorageOverprovisioningFactor("Storage", StoragePoolAllocator.class, String.class, "storage.overprovisioning.factor", "2", "Used for storage overprovisioning calculation; available storage will be (actualStorageSize * storage.overprovisioning.factor)", null),
StorageOverprovisioningFactor("Storage", StoragePoolAllocator.class, String.class, "storage.overprovisioning.factor", "2", "Used for storage overprovisioning calculation; available storage will be (actualStorageSize * storage.overprovisioning.factor)", null, ConfigurationParameterScope.zone.toString()),
StorageStatsInterval("Storage", ManagementServer.class, String.class, "storage.stats.interval", "60000", "The interval (in milliseconds) when storage stats (per host) are retrieved from agents.", null),
MaxVolumeSize("Storage", ManagementServer.class, Integer.class, "storage.max.volume.size", "2000", "The maximum size for a volume (in GB).", null),
MaxUploadVolumeSize("Storage", ManagementServer.class, Integer.class, "storage.max.volume.upload.size", "500", "The maximum size for a uploaded volume(in GB).", null),

View File

@ -16,6 +16,7 @@
// under the License.
package com.cloud.storage;
import java.math.BigDecimal;
import java.util.List;
import java.util.Set;
@ -120,4 +121,5 @@ public interface StorageManager extends StorageService {
DataStore createLocalStorage(Host host, StoragePoolInfo poolInfo) throws ConnectionException;
BigDecimal getStorageOverProvisioningFactor(Long dcId);
}

View File

@ -40,6 +40,7 @@ import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import com.cloud.server.ConfigurationServer;
import org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaintenanceCmd;
import org.apache.cloudstack.api.command.admin.storage.CreateStoragePoolCmd;
import org.apache.cloudstack.api.command.admin.storage.DeletePoolCmd;
@ -292,6 +293,8 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
SnapshotDataFactory snapshotFactory;
@Inject
protected HypervisorCapabilitiesDao _hypervisorCapabilitiesDao;
@Inject
ConfigurationServer _configServer;
@Inject protected ResourceTagDao _resourceTagDao;
@ -327,7 +330,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
protected int _retry = 2;
protected int _pingInterval = 60; // seconds
protected int _hostRetry;
protected BigDecimal _overProvisioningFactor = new BigDecimal(1);
//protected BigDecimal _overProvisioningFactor = new BigDecimal(1);
private long _maxVolumeSizeInGb;
private long _serverId;
@ -335,7 +338,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
private int _customDiskOfferingMaxSize = 1024;
private double _storageUsedThreshold = 1.0d;
private double _storageAllocatedThreshold = 1.0d;
protected BigDecimal _storageOverprovisioningFactor = new BigDecimal(1);
//protected BigDecimal _storageOverprovisioningFactor = new BigDecimal(1);
private Map<String, HypervisorHostListener> hostListeners = new HashMap<String, HypervisorHostListener>();
private boolean _recreateSystemVmEnabled;
@ -535,11 +538,11 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
Map<String, String> configs = _configDao.getConfiguration(
"management-server", params);
String overProvisioningFactorStr = configs
/*String overProvisioningFactorStr = configs
.get("storage.overprovisioning.factor");
if (overProvisioningFactorStr != null) {
_overProvisioningFactor = new BigDecimal(overProvisioningFactorStr);
}
}*/
_retry = NumbersUtil.parseInt(configs.get(Config.StartRetry.key()), 10);
_pingInterval = NumbersUtil.parseInt(configs.get("ping.interval"), 60);
@ -589,10 +592,11 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
.parseDouble(storageAllocatedThreshold);
}
String globalStorageOverprovisioningFactor = configs
/*String globalStorageOverprovisioningFactor = configs
.get("storage.overprovisioning.factor");
_storageOverprovisioningFactor = new BigDecimal(NumbersUtil.parseFloat(
globalStorageOverprovisioningFactor, 2.0f));
*/
s_logger.info("Storage cleanup enabled: " + _storageCleanupEnabled
+ ", interval: " + _storageCleanupInterval
@ -979,6 +983,11 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
listener.hostConnect(hostId, pool.getId());
}
@Override
public BigDecimal getStorageOverProvisioningFactor(Long dcId){
return new BigDecimal(_configServer.getConfigValue(Config.StorageOverprovisioningFactor.key(), Config.ConfigurationParameterScope.zone.toString(), dcId));
}
@Override
public void createCapacityEntry(StoragePoolVO storagePool, short capacityType, long allocated) {
SearchCriteria<CapacityVO> capacitySC = _capacityDao.createSearchCriteria();
@ -990,7 +999,8 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
long totalOverProvCapacity;
if (storagePool.getPoolType() == StoragePoolType.NetworkFilesystem) {
totalOverProvCapacity = _overProvisioningFactor.multiply(new BigDecimal(storagePool.getCapacityBytes())).longValue();// All this for the inaccuracy of floats for big number multiplication.
BigDecimal overProvFactor = getStorageOverProvisioningFactor(storagePool.getDataCenterId());
totalOverProvCapacity = overProvFactor.multiply(new BigDecimal(storagePool.getCapacityBytes())).longValue();// All this for the inaccuracy of floats for big number multiplication.
} else {
totalOverProvCapacity = storagePool.getCapacityBytes();
}
@ -1793,7 +1803,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
long totalOverProvCapacity;
if (pool.getPoolType() == StoragePoolType.NetworkFilesystem) {
totalOverProvCapacity = _storageOverprovisioningFactor.multiply(
totalOverProvCapacity = getStorageOverProvisioningFactor(pool.getDataCenterId()).multiply(
new BigDecimal(pool.getCapacityBytes())).longValue();
} else {
totalOverProvCapacity = pool.getCapacityBytes();