CLOUDSTACK-741 - Making storage disable thresholds 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/807ad0a3
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/807ad0a3
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/807ad0a3

Branch: refs/heads/internallb
Commit: 807ad0a39ab272a4af2de3156b0b367570acccea
Parents: e091f43
Author: Nitin Mehta <[email protected]>
Authored: Wed May 1 15:44:09 2013 +0530
Committer: Nitin Mehta <[email protected]>
Committed: Wed May 1 15:44:09 2013 +0530

----------------------------------------------------------------------
 server/src/com/cloud/configuration/Config.java     |    4 +-
 .../src/com/cloud/storage/StorageManagerImpl.java  |   44 +++-----------
 2 files changed, 12 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/807ad0a3/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 3f3c66c..1f0a1a9 100755
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -61,8 +61,8 @@ public enum Config {
        VlanCapacityThreshold("Alert", ManagementServer.class, Float.class, 
"zone.vlan.capacity.notificationthreshold", "0.75", "Percentage (as a value 
between 0 and 1) of Zone Vlan utilization above which alerts will be sent about 
low number of Zone Vlans.", null),
        DirectNetworkPublicIpCapacityThreshold("Alert", ManagementServer.class, 
Float.class, "zone.directnetwork.publicip.capacity.notificationthreshold", 
"0.75", "Percentage (as a value between 0 and 1) of Direct Network Public Ip 
Utilization above which alerts will be sent about low number of direct network 
public ips.", null),
        LocalStorageCapacityThreshold("Alert", ManagementServer.class, 
Float.class, "cluster.localStorage.capacity.notificationthreshold", "0.75", 
"Percentage (as a value between 0 and 1) of local storage utilization above 
which alerts will be sent about low local storage available.", null),
-       StorageAllocatedCapacityDisableThreshold("Alert", 
ManagementServer.class, Float.class, 
"pool.storage.allocated.capacity.disablethreshold", "0.85", "Percentage (as a 
value between 0 and 1) of allocated storage utilization above which allocators 
will disable using the pool for low allocated storage available.", null),
-       StorageCapacityDisableThreshold("Alert", ManagementServer.class, 
Float.class, "pool.storage.capacity.disablethreshold", "0.85", "Percentage (as 
a value between 0 and 1) of storage utilization above which allocators will 
disable using the pool for low storage available.", null),
+       StorageAllocatedCapacityDisableThreshold("Alert", 
ManagementServer.class, Float.class, 
"pool.storage.allocated.capacity.disablethreshold", "0.85", "Percentage (as a 
value between 0 and 1) of allocated storage utilization above which allocators 
will disable using the pool for low allocated storage available.", null, 
ConfigurationParameterScope.zone.toString()),
+       StorageCapacityDisableThreshold("Alert", ManagementServer.class, 
Float.class, "pool.storage.capacity.disablethreshold", "0.85", "Percentage (as 
a value between 0 and 1) of storage utilization above which allocators will 
disable using the pool for low storage available.", null, 
ConfigurationParameterScope.zone.toString()),
        CPUCapacityDisableThreshold("Alert", ManagementServer.class, 
Float.class, "cluster.cpu.allocated.capacity.disablethreshold", "0.85", 
"Percentage (as a value between 0 and 1) of cpu utilization above which 
allocators will disable using the cluster for low cpu available. Keep the 
corresponding notification threshold lower than this to be notified 
beforehand.", null, ConfigurationParameterScope.cluster.toString()),
        MemoryCapacityDisableThreshold("Alert", ManagementServer.class, 
Float.class, "cluster.memory.allocated.capacity.disablethreshold", "0.85", 
"Percentage (as a value between 0 and 1) of memory utilization above which 
allocators will disable using the cluster for low memory available. Keep the 
corresponding notification threshold lower than this to be notified 
beforehand.", null, ConfigurationParameterScope.cluster.toString()),
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/807ad0a3/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 30d2113..1d4dcef 100755
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -298,6 +298,8 @@ public class StorageManagerImpl extends ManagerBase 
implements StorageManager, C
 
     @Inject protected ResourceTagDao _resourceTagDao;
 
+
+
     protected List<StoragePoolAllocator> _storagePoolAllocators;
     public List<StoragePoolAllocator> getStoragePoolAllocators() {
                return _storagePoolAllocators;
@@ -336,9 +338,6 @@ public class StorageManagerImpl extends ManagerBase 
implements StorageManager, C
 
     private int _customDiskOfferingMinSize = 1;
     private int _customDiskOfferingMaxSize = 1024;
-    private double _storageUsedThreshold = 1.0d;
-    private double _storageAllocatedThreshold = 1.0d;
-    //protected BigDecimal _storageOverprovisioningFactor = new BigDecimal(1);
     private Map<String, HypervisorHostListener> hostListeners = new 
HashMap<String, HypervisorHostListener>();
 
     private boolean _recreateSystemVmEnabled;
@@ -538,12 +537,6 @@ public class StorageManagerImpl extends ManagerBase 
implements StorageManager, C
         Map<String, String> configs = _configDao.getConfiguration(
                 "management-server", params);
 
-        /*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);
         _hostRetry = NumbersUtil.parseInt(configs.get("host.retry"), 2);
@@ -579,25 +572,6 @@ public class StorageManagerImpl extends ManagerBase 
implements StorageManager, C
         String time = configs.get("storage.cleanup.interval");
         _storageCleanupInterval = NumbersUtil.parseInt(time, 86400);
 
-        String storageUsedThreshold = _configDao
-                .getValue(Config.StorageCapacityDisableThreshold.key());
-        if (storageUsedThreshold != null) {
-            _storageUsedThreshold = Double.parseDouble(storageUsedThreshold);
-        }
-
-        String storageAllocatedThreshold = _configDao
-                
.getValue(Config.StorageAllocatedCapacityDisableThreshold.key());
-        if (storageAllocatedThreshold != null) {
-            _storageAllocatedThreshold = Double
-                    .parseDouble(storageAllocatedThreshold);
-        }
-
-        /*String globalStorageOverprovisioningFactor = configs
-                .get("storage.overprovisioning.factor");
-        _storageOverprovisioningFactor = new BigDecimal(NumbersUtil.parseFloat(
-                globalStorageOverprovisioningFactor, 2.0f));
-        */
-
         s_logger.info("Storage cleanup enabled: " + _storageCleanupEnabled
                 + ", interval: " + _storageCleanupInterval
                 + ", template cleanup enabled: " + _templateCleanupEnabled);
@@ -1741,6 +1715,7 @@ public class StorageManagerImpl extends ManagerBase 
implements StorageManager, C
 
     private boolean checkUsagedSpace(StoragePool pool) {
         StatsCollector sc = StatsCollector.getInstance();
+        double storageUsedThreshold = 
Double.parseDouble(_configServer.getConfigValue(Config.StorageCapacityDisableThreshold.key(),
 Config.ConfigurationParameterScope.zone.toString(), pool.getDataCenterId()));
         if (sc != null) {
             long totalSize = pool.getCapacityBytes();
             StorageStats stats = sc.getStoragePoolStats(pool.getId());
@@ -1755,16 +1730,16 @@ public class StorageManagerImpl extends ManagerBase 
implements StorageManager, C
                             + pool.getCapacityBytes() + ", usedBytes: "
                             + stats.getByteUsed() + ", usedPct: "
                             + usedPercentage + ", disable threshold: "
-                            + _storageUsedThreshold);
+                            + storageUsedThreshold);
                 }
-                if (usedPercentage >= _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);
+                                + storageUsedThreshold);
                     }
                     return false;
                 }
@@ -1809,6 +1784,7 @@ public class StorageManagerImpl extends ManagerBase 
implements StorageManager, C
             totalOverProvCapacity = pool.getCapacityBytes();
         }
 
+        double storageAllocatedThreshold = 
Double.parseDouble(_configServer.getConfigValue(Config.StorageAllocatedCapacityDisableThreshold.key(),
 Config.ConfigurationParameterScope.zone.toString(), pool.getDataCenterId()));
         if (s_logger.isDebugEnabled()) {
             s_logger.debug("Checking pool: " + pool.getId()
                     + " for volume allocation " + volumes.toString()
@@ -1816,12 +1792,12 @@ public class StorageManagerImpl extends ManagerBase 
implements StorageManager, C
                     + ", totalAllocatedSize : " + allocatedSizeWithtemplate
                     + ", askingSize : " + totalAskingSize
                     + ", allocated disable threshold: "
-                    + _storageAllocatedThreshold);
+                    + storageAllocatedThreshold);
         }
 
         double usedPercentage = (allocatedSizeWithtemplate + totalAskingSize)
                 / (double) (totalOverProvCapacity);
-        if (usedPercentage > _storageAllocatedThreshold) {
+        if (usedPercentage > storageAllocatedThreshold) {
             if (s_logger.isDebugEnabled()) {
                 s_logger.debug("Insufficient un-allocated capacity on: "
                         + pool.getId()
@@ -1830,7 +1806,7 @@ public class StorageManagerImpl extends ManagerBase 
implements StorageManager, C
                         + " since its allocated percentage: "
                         + usedPercentage
                         + " has crossed the allocated 
pool.storage.allocated.capacity.disablethreshold: "
-                        + _storageAllocatedThreshold + ", skipping this pool");
+                        + storageAllocatedThreshold + ", skipping this pool");
             }
             return false;
         }

Reply via email to