Skip to content

Commit 6e7fe6e

Browse files
committed
Minor service layer changes
1 parent c5da8fa commit 6e7fe6e

File tree

8 files changed

+16
-29
lines changed

8 files changed

+16
-29
lines changed

engine/components-api/src/main/java/com/cloud/capacity/CapacityManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public interface CapacityManager {
7171
"0.85",
7272
"Percentage (as a value between 0 and 1) of storage utilization above which allocators will disable using the pool for low storage available.",
7373
true,
74-
List.of(ConfigKey.Scope.Zone, ConfigKey.Scope.StoragePool));
74+
List.of(ConfigKey.Scope.StoragePool, ConfigKey.Scope.Zone));
7575
static final ConfigKey<Double> StorageOverprovisioningFactor =
7676
new ConfigKey<>(
7777
"Storage",
@@ -89,7 +89,7 @@ public interface CapacityManager {
8989
"0.85",
9090
"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.",
9191
true,
92-
List.of(ConfigKey.Scope.Zone, ConfigKey.Scope.StoragePool));
92+
List.of(ConfigKey.Scope.StoragePool, ConfigKey.Scope.Zone));
9393
static final ConfigKey<Boolean> StorageOperationsExcludeCluster =
9494
new ConfigKey<>(
9595
Boolean.class,
@@ -129,7 +129,7 @@ public interface CapacityManager {
129129
"Percentage (as a value between 0 and 1) of allocated storage utilization above which allocators will disable using the pool for volume resize. " +
130130
"This is applicable only when volume.resize.allowed.beyond.allocation is set to true.",
131131
true,
132-
List.of(ConfigKey.Scope.Zone, ConfigKey.Scope.StoragePool));
132+
List.of(ConfigKey.Scope.StoragePool, ConfigKey.Scope.Zone));
133133

134134
public boolean releaseVmCapacity(VirtualMachine vm, boolean moveFromReserved, boolean moveToReservered, Long hostId);
135135

framework/config/src/main/java/org/apache/cloudstack/framework/config/ConfigKey.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ public int getBitValue() {
7070
}
7171

7272
public boolean isDescendantOf(Scope other) {
73-
Scope current = this;
74-
while (current != null) {
75-
if (current == other) {
73+
Scope parent = this.getParent();
74+
while (parent != null) {
75+
if (parent == other) {
7676
return true;
7777
}
78-
current = current.getParent();
78+
parent = parent.getParent();
7979
}
8080
return false;
8181
}
@@ -365,10 +365,6 @@ public T valueIn(Long id) {
365365
return valueInScope(getPrimaryScope(), id);
366366
}
367367

368-
public T valueInDomain(Long domainId) {
369-
return valueInScope(Scope.Domain, domainId);
370-
}
371-
372368
@SuppressWarnings("unchecked")
373369
protected T valueOf(String value) {
374370
if (value == null) {

framework/config/src/main/java/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.util.Map;
2323

2424
import javax.annotation.PostConstruct;
25-
import javax.inject.Inject;
2625
import javax.naming.ConfigurationException;
2726

2827
import org.apache.cloudstack.framework.config.impl.ConfigurationVO;
@@ -31,7 +30,6 @@
3130
import com.cloud.utils.component.ComponentLifecycle;
3231
import com.cloud.utils.crypt.DBEncryptionUtil;
3332
import com.cloud.utils.db.DB;
34-
import com.cloud.utils.db.EntityManager;
3533
import com.cloud.utils.db.GenericDaoBase;
3634
import com.cloud.utils.db.SearchBuilder;
3735
import com.cloud.utils.db.SearchCriteria;
@@ -40,9 +38,6 @@
4038

4139
@Component
4240
public class ConfigurationDaoImpl extends GenericDaoBase<ConfigurationVO, String> implements ConfigurationDao {
43-
@Inject
44-
EntityManager entityManager;
45-
4641
private Map<String, String> _configs = null;
4742
private boolean _premium;
4843

@@ -211,4 +206,5 @@ public ConfigurationVO findByName(String name) {
211206
sc.setParameters("name", name);
212207
return findOneIncludingRemovedBy(sc);
213208
}
209+
214210
}

plugins/metrics/src/main/java/org/apache/cloudstack/metrics/MetricsServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ public List<StoragePoolMetricsResponse> listStoragePoolMetrics(List<StoragePoolR
649649
Long poolClusterId = clusterUuidToIdMap.get(poolResponse.getClusterId());
650650
Long poolId = poolUuidToIdMap.get(poolResponse.getId());
651651
final Double storageThreshold = AlertManager.StorageCapacityThreshold.valueIn(poolClusterId);
652-
final Double storageDisableThreshold = CapacityManager.StorageCapacityDisableThreshold.valueInScope(ConfigKey.Scope.StoragePool, poolId);
652+
final Double storageDisableThreshold = CapacityManager.StorageCapacityDisableThreshold.valueIn(poolId);
653653

654654
metricsResponse.setHasAnnotation(poolResponse.hasAnnotation());
655655
metricsResponse.setDiskSizeUsedGB(poolResponse.getDiskSizeUsed());

server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ protected String validateConfigurationValue(String name, String value, String sc
12291229
if (scope != null) {
12301230
ConfigKey.Scope scopeVal = ConfigKey.Scope.valueOf(scope);
12311231
if (!configScope.contains(scopeVal) &&
1232-
!(ENABLE_ACCOUNT_SETTINGS_FOR_DOMAIN.value() && configScope.contains(ConfigKey.Scope.Account.toString()) &&
1232+
!(ENABLE_ACCOUNT_SETTINGS_FOR_DOMAIN.value() && configScope.contains(ConfigKey.Scope.Account) &&
12331233
scope.equals(ConfigKey.Scope.Domain.toString()))) {
12341234
logger.error("Invalid scope id provided for the parameter " + name);
12351235
return "Invalid scope id provided for the parameter " + name;

server/src/main/java/com/cloud/network/IpAddressManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2476,7 +2476,7 @@ public boolean isPublicIpAddressStillInQuarantine(PublicIpQuarantineVO publicIpQ
24762476

24772477
@Override
24782478
public PublicIpQuarantine addPublicIpAddressToQuarantine(IpAddress publicIpAddress, Long domainId) {
2479-
Integer quarantineDuration = PUBLIC_IP_ADDRESS_QUARANTINE_DURATION.valueInDomain(domainId);
2479+
Integer quarantineDuration = PUBLIC_IP_ADDRESS_QUARANTINE_DURATION.valueIn(domainId);
24802480
if (quarantineDuration <= 0) {
24812481
logger.debug(String.format("Not adding IP [%s] to quarantine because configuration [%s] has value equal or less to 0.", publicIpAddress.getAddress(),
24822482
PUBLIC_IP_ADDRESS_QUARANTINE_DURATION.key()));

server/src/main/java/com/cloud/server/ManagementServerImpl.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,13 +2311,8 @@ public Pair<List<? extends Configuration>, Integer> searchForConfigurations(fina
23112311
if (configVo != null) {
23122312
final ConfigKey<?> key = _configDepot.get(param.getName());
23132313
if (key != null) {
2314-
if (scope.equals(ConfigKey.Scope.Domain)) {
2315-
Object value = key.valueInDomain(id);
2316-
configVo.setValue(value == null ? null : value.toString());
2317-
} else {
2318-
Object value = key.valueInScope(scope, id);
2319-
configVo.setValue(value == null ? null : value.toString());
2320-
}
2314+
Object value = key.valueInScope(scope, id);
2315+
configVo.setValue(value == null ? null : value.toString());
23212316
configVOList.add(configVo);
23222317
} else {
23232318
logger.warn("ConfigDepot could not find parameter " + param.getName() + " for scope " + scope);

server/src/main/java/com/cloud/storage/StorageManagerImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2921,7 +2921,7 @@ private boolean checkUsagedSpace(StoragePool pool) {
29212921
long totalSize = pool.getCapacityBytes();
29222922
long usedSize = getUsedSize(pool);
29232923
double usedPercentage = ((double)usedSize / (double)totalSize);
2924-
double storageUsedThreshold = CapacityManager.StorageCapacityDisableThreshold.valueInScope(ConfigKey.Scope.StoragePool, pool.getId());
2924+
double storageUsedThreshold = CapacityManager.StorageCapacityDisableThreshold.valueIn(pool.getDataCenterId());
29252925
if (logger.isDebugEnabled()) {
29262926
logger.debug("Checking pool {} for storage, totalSize: {}, usedBytes: {}, usedPct: {}, disable threshold: {}", pool, pool.getCapacityBytes(), pool.getUsedBytes(), usedPercentage, storageUsedThreshold);
29272927
}
@@ -3193,7 +3193,7 @@ protected boolean checkPoolforSpace(StoragePool pool, long allocatedSizeWithTemp
31933193

31943194
logger.debug("Total capacity of the pool {} is {}", poolVO, toHumanReadableSize(totalOverProvCapacity));
31953195

3196-
double storageAllocatedThreshold = CapacityManager.StorageAllocatedCapacityDisableThreshold.valueInScope(ConfigKey.Scope.StoragePool, pool.getId());
3196+
double storageAllocatedThreshold = CapacityManager.StorageAllocatedCapacityDisableThreshold.valueIn(pool.getDataCenterId());
31973197

31983198
if (logger.isDebugEnabled()) {
31993199
logger.debug("Checking pool: {} for storage allocation , maxSize : {}, " +
@@ -3218,7 +3218,7 @@ protected boolean checkPoolforSpace(StoragePool pool, long allocatedSizeWithTemp
32183218
return false;
32193219
}
32203220

3221-
double storageAllocatedThresholdForResize = CapacityManager.StorageAllocatedCapacityDisableThresholdForVolumeSize.valueInScope(ConfigKey.Scope.StoragePool, pool.getId());
3221+
double storageAllocatedThresholdForResize = CapacityManager.StorageAllocatedCapacityDisableThresholdForVolumeSize.valueIn(pool.getDataCenterId());
32223222
if (usedPercentage > storageAllocatedThresholdForResize) {
32233223
logger.debug(String.format("Skipping the pool %s since its allocated percentage: %s has crossed the allocated %s: %s",
32243224
pool, usedPercentage, CapacityManager.StorageAllocatedCapacityDisableThresholdForVolumeSize.key(), storageAllocatedThresholdForResize));

0 commit comments

Comments
 (0)