|
146 | 146 |
|
147 | 147 | import static com.cloud.utils.NumbersUtil.toHumanReadableSize; |
148 | 148 | import org.apache.commons.io.FileUtils; |
| 149 | +import org.apache.commons.lang3.math.NumberUtils; |
149 | 150 |
|
150 | 151 | /** |
151 | 152 | * Provides real time stats for various agent resources up to x seconds |
@@ -1625,16 +1626,27 @@ public ConfigKey<?>[] getConfigKeys() { |
1625 | 1626 | } |
1626 | 1627 |
|
1627 | 1628 | public double getImageStoreCapacityThreshold() { |
1628 | | - double thresholdConfig = secondaryStorageCapacityThreshold.value(); |
| 1629 | + double thresholdConfigValue = secondaryStorageCapacityThreshold.value(); |
| 1630 | + double thresholdConfigDefaultValue = NumberUtils.toDouble(secondaryStorageCapacityThreshold.defaultValue()); |
| 1631 | + String thresholdConfigKey = secondaryStorageCapacityThreshold.key(); |
1629 | 1632 |
|
1630 | | - if (thresholdConfig >= MIN_STORAGE_SECONDARY_CAPACITY_THRESHOLD && thresholdConfig <= MAX_STORAGE_SECONDARY_CAPACITY_THRESHOLD) { |
1631 | | - return thresholdConfig; |
| 1633 | + if (thresholdConfigValue >= MIN_STORAGE_SECONDARY_CAPACITY_THRESHOLD && thresholdConfigValue <= MAX_STORAGE_SECONDARY_CAPACITY_THRESHOLD) { |
| 1634 | + return thresholdConfigValue; |
1632 | 1635 | } |
1633 | 1636 |
|
1634 | | - s_logger.warn(String.format("Invalid [%s] configuration: value set [%s] is [%s]. Assuming %s as secondary storage capacity threshold.", |
1635 | | - secondaryStorageCapacityThreshold.key(), |
1636 | | - thresholdConfig, |
1637 | | - thresholdConfig < MIN_STORAGE_SECONDARY_CAPACITY_THRESHOLD ? String.format("lower than '%s'", MIN_STORAGE_SECONDARY_CAPACITY_THRESHOLD) : String.format("bigger than '%s'", MAX_STORAGE_SECONDARY_CAPACITY_THRESHOLD), |
| 1637 | + if (thresholdConfigValue < MIN_STORAGE_SECONDARY_CAPACITY_THRESHOLD) { |
| 1638 | + s_logger.warn(String.format("Invalid [%s] configuration: value set [%s] is lower than '%s'. Assuming '%s', default value, as secondary storage capacity threshold.", |
| 1639 | + thresholdConfigKey, |
| 1640 | + thresholdConfigValue, |
| 1641 | + MIN_STORAGE_SECONDARY_CAPACITY_THRESHOLD, |
| 1642 | + thresholdConfigDefaultValue)); |
| 1643 | + return thresholdConfigDefaultValue; |
| 1644 | + } |
| 1645 | + |
| 1646 | + s_logger.warn(String.format("Invalid [%s] configuration: value set [%s] is bigger than '%s'. Assuming '%s', top limit, as secondary storage capacity threshold.", |
| 1647 | + thresholdConfigKey, |
| 1648 | + thresholdConfigValue, |
| 1649 | + MAX_STORAGE_SECONDARY_CAPACITY_THRESHOLD, |
1638 | 1650 | MAX_STORAGE_SECONDARY_CAPACITY_THRESHOLD)); |
1639 | 1651 | return MAX_STORAGE_SECONDARY_CAPACITY_THRESHOLD; |
1640 | 1652 | } |
|
0 commit comments