You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ni...@apache.org on 2013/05/01 10:51:25 UTC
git commit: updated refs/heads/master to b16ccc9
Updated Branches:
refs/heads/master 817c46db7 -> b16ccc9fa
CLOUDSTACK-2036 - Adding storage storage.overprovisioning.factor configurable at zone level.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b16ccc9f
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b16ccc9f
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b16ccc9f
Branch: refs/heads/master
Commit: b16ccc9fa6c5dd05a3016e3b2e22ecdc3f06b1ef
Parents: 817c46d
Author: Nitin Mehta <ni...@citrix.com>
Authored: Wed May 1 14:21:09 2013 +0530
Committer: Nitin Mehta <ni...@citrix.com>
Committed: Wed May 1 14:21:09 2013 +0530
----------------------------------------------------------------------
.../com/cloud/capacity/CapacityManagerImpl.java | 2 +-
.../cloud/capacity/StorageCapacityListener.java | 16 +++++-----
server/src/com/cloud/configuration/Config.java | 2 +-
server/src/com/cloud/storage/StorageManager.java | 2 +
.../src/com/cloud/storage/StorageManagerImpl.java | 24 ++++++++++----
5 files changed, 29 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b16ccc9f/server/src/com/cloud/capacity/CapacityManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/capacity/CapacityManagerImpl.java b/server/src/com/cloud/capacity/CapacityManagerImpl.java
index 292ef0a..089307f 100755
--- a/server/src/com/cloud/capacity/CapacityManagerImpl.java
+++ b/server/src/com/cloud/capacity/CapacityManagerImpl.java
@@ -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;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b16ccc9f/server/src/com/cloud/capacity/StorageCapacityListener.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/capacity/StorageCapacityListener.java b/server/src/com/cloud/capacity/StorageCapacityListener.java
index d5751a3..bc03f72 100755
--- a/server/src/com/cloud/capacity/StorageCapacityListener.java
+++ b/server/src/com/cloud/capacity/StorageCapacityListener.java
@@ -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);
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b16ccc9f/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java
index 9fbb692..3f3c66c 100755
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -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),
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b16ccc9f/server/src/com/cloud/storage/StorageManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManager.java b/server/src/com/cloud/storage/StorageManager.java
index 6026cd9..d49a7f8 100755
--- a/server/src/com/cloud/storage/StorageManager.java
+++ b/server/src/com/cloud/storage/StorageManager.java
@@ -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);
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b16ccc9f/server/src/com/cloud/storage/StorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java
index a182e39..30d2113 100755
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -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
@@ -980,6 +984,11 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
}
@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();
capacitySC.addAnd("hostOrPoolId", SearchCriteria.Op.EQ, storagePool.getId());
@@ -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();