Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.cloudstack.api.response.HostTagResponse;
import org.apache.cloudstack.framework.config.ConfigKey;
import org.apache.cloudstack.framework.config.Configurable;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
Expand All @@ -46,8 +45,10 @@ public class HostTagsDaoImpl extends GenericDaoBase<HostTagVO, Long> implements
private final SearchBuilder<HostTagVO> ImplicitTagsSearch;
private final GenericSearchBuilder<HostTagVO, String> tagSearch;

@Inject
private ConfigurationDao _configDao;
// Registered/owned by ManagementServer; declared here too so this lower-layer module can read it without depending on the server module.
private static final ConfigKey<Integer> DetailBatchQuerySize = new ConfigKey<>("Advanced", Integer.class, "detail.batch.query.size", "2000",
"Default entity detail batch query size for listing", true);

@Inject
private HostDao hostDao;

Expand Down Expand Up @@ -191,9 +192,7 @@ public HostTagResponse newHostTagResponse(HostTagVO tag) {

@Override
public List<HostTagVO> searchByIds(Long... tagIds) {
String batchCfg = _configDao.getValue("detail.batch.query.size");

final int detailsBatchSize = batchCfg != null ? Integer.parseInt(batchCfg) : 2000;
final int detailsBatchSize = DetailBatchQuerySize.value();

// query details by batches
List<HostTagVO> tagList = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
import java.util.List;
import java.util.stream.Collectors;

import javax.inject.Inject;

import org.apache.cloudstack.api.response.StorageTagResponse;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.framework.config.ConfigKey;

import com.cloud.storage.StoragePoolTagVO;
import com.cloud.utils.db.GenericDaoBase;
Expand All @@ -36,14 +34,13 @@

public class StoragePoolTagsDaoImpl extends GenericDaoBase<StoragePoolTagVO, Long> implements StoragePoolTagsDao {

@Inject
private ConfigurationDao _configDao;
// Registered/owned by ManagementServer; declared here too so this lower-layer module can read it without depending on the server module.
private static final ConfigKey<Integer> DetailBatchQuerySize = new ConfigKey<>("Advanced", Integer.class, "detail.batch.query.size", "2000",
"Default entity detail batch query size for listing", true);

protected final SearchBuilder<StoragePoolTagVO> StoragePoolSearch;
private final SearchBuilder<StoragePoolTagVO> StoragePoolIdsSearch;

private static final int DEFAULT_BATCH_QUERY_SIZE = 2000;

public StoragePoolTagsDaoImpl() {
StoragePoolSearch = createSearchBuilder();
StoragePoolSearch.and("poolId", StoragePoolSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
Expand Down Expand Up @@ -151,12 +148,11 @@ protected void searchForStoragePoolIdsInternal(int currIndex, int batchSize, Lon
}

/**
* Retrieve {@code detail.batch.query.size} configuration value. If not available, return default value {@link StoragePoolTagsDaoImpl#DEFAULT_BATCH_QUERY_SIZE}
* Retrieve {@code detail.batch.query.size} configuration value.
* @return detail.batch.query.size configuration value
*/
protected int getDetailsBatchSize() {
String batchCfg = _configDao.getValue("detail.batch.query.size");
return batchCfg != null ? Integer.parseInt(batchCfg) : DEFAULT_BATCH_QUERY_SIZE;
return DetailBatchQuerySize.value();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@
import com.cloud.utils.db.TransactionStatus;

import org.apache.cloudstack.api.response.ObjectStoreResponse;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.framework.config.ConfigKey;
import org.springframework.stereotype.Component;

import javax.inject.Inject;
import javax.naming.ConfigurationException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Component
public class ObjectStoreDaoImpl extends GenericDaoBase<ObjectStoreVO, Long> implements ObjectStoreDao {
// Registered/owned by ManagementServer; declared here too so this lower-layer module can read it without depending on the server module.
private static final ConfigKey<Integer> DetailBatchQuerySize = new ConfigKey<>("Advanced", Integer.class, "detail.batch.query.size", "2000",
"Default entity detail batch query size for listing", true);
private SearchBuilder<ObjectStoreVO> nameSearch;
private SearchBuilder<ObjectStoreVO> providerSearch;
@Inject
private ConfigurationDao _configDao;
private final SearchBuilder<ObjectStoreVO> osSearch;

private SearchBuilder<ObjectStoreVO> urlSearch;
Expand Down Expand Up @@ -100,11 +100,7 @@ public List<ObjectStoreVO> listObjectStores() {
@Override
public List<ObjectStoreVO> searchByIds(Long[] osIds) {
// set detail batch query size
int DETAILS_BATCH_SIZE = 2000;
String batchCfg = _configDao.getValue("detail.batch.query.size");
if (batchCfg != null) {
DETAILS_BATCH_SIZE = Integer.parseInt(batchCfg);
}
int DETAILS_BATCH_SIZE = DetailBatchQuerySize.value();
// query details by batches
List<ObjectStoreVO> osList = new ArrayList<>();
// query details by batches
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
// under the License.
package com.cloud.storage.dao;

import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.framework.config.ConfigKey;
import org.apache.cloudstack.framework.config.impl.ConfigDepotImpl;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -47,7 +49,7 @@
public class StoragePoolTagsDaoImplTest extends TestCase {

@Mock
ConfigurationDao _configDao;
ConfigDepotImpl configDepot;
@Mock
SearchBuilder<StoragePoolTagVO> StoragePoolIdsSearch;

Expand All @@ -70,19 +72,25 @@

@Before
public void setup() {
when(_configDao.getValue(batchSizeConfigurationKey)).thenReturn(batchSizeValue);
ConfigKey.init(configDepot);
when(configDepot.getConfigStringValue(batchSizeConfigurationKey, ConfigKey.Scope.Global, null)).thenReturn(batchSizeValue);
doReturn(storagePoolTagList).when(_storagePoolTagsDaoImpl).searchIncludingRemoved(
ArgumentMatchers.any(SearchCriteria.class), ArgumentMatchers.isNull(Filter.class), ArgumentMatchers.isNull(Boolean.class), ArgumentMatchers.eq(false));
}

@After
public void tearDown() {

Check warning on line 82 in engine/schema/src/test/java/com/cloud/storage/dao/StoragePoolTagsDaoImplTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add the "@Override" annotation above this method signature

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaFpJL4ADzH0MnfOd3lU&open=AaFpJL4ADzH0MnfOd3lU&pullRequest=14477
ConfigKey.init(null);
}

@Test
public void testGetDetailsBatchSizeNotNull() {
assertEquals(Integer.parseInt(batchSizeValue), _storagePoolTagsDaoImpl.getDetailsBatchSize());
}

@Test
public void testGetDetailsBatchSizeNull() {
when(_configDao.getValue(batchSizeConfigurationKey)).thenReturn(null);
when(configDepot.getConfigStringValue(batchSizeConfigurationKey, ConfigKey.Scope.Global, null)).thenReturn(null);
assertEquals(Integer.parseInt(batchSizeDefaultValue), _storagePoolTagsDaoImpl.getDetailsBatchSize());
}

Expand All @@ -108,7 +116,7 @@

@Test
public void testSearchByIdsStorageTagsIdsGreaterOrEqualThanBatchSize() {
when(_configDao.getValue(batchSizeConfigurationKey)).thenReturn(batchSizeLow);
when(configDepot.getConfigStringValue(batchSizeConfigurationKey, ConfigKey.Scope.Global, null)).thenReturn(batchSizeLow);
doNothing().when(_storagePoolTagsDaoImpl).searchForStoragePoolIdsInternal(ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt(), ArgumentMatchers.any(Long[].class), ArgumentMatchers.anyList());
_storagePoolTagsDaoImpl.searchByIds(storageTagsIds);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
import org.bouncycastle.util.io.pem.PemReader;

import com.cloud.certificate.dao.CrlDao;
import com.cloud.configuration.Config;
import com.cloud.server.ManagementServer;
import com.cloud.utils.component.AdapterBase;
import com.cloud.utils.db.GlobalLock;
import com.cloud.utils.exception.CloudRuntimeException;
Expand Down Expand Up @@ -439,7 +439,7 @@ private boolean loadManagementKeyStore() {
}

protected void addConfiguredManagementIp(List<String> ipList) {
String msNetworkCidr = configDao.getValue(Config.ManagementNetwork.key());
String msNetworkCidr = ManagementServer.ManagementNetwork.value();
try {
logger.debug(String.format("Trying to find management IP in CIDR range [%s].", msNetworkCidr));
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import com.cloud.agent.api.StartupCommand;
import com.cloud.agent.api.StartupRoutingCommand;
import com.cloud.baremetal.networkservice.BareMetalResourceBase;
import com.cloud.configuration.Config;
import com.cloud.dc.ClusterVO;
import com.cloud.dc.DataCenterVO;
import com.cloud.exception.DiscoveryException;
Expand All @@ -51,6 +50,7 @@
import com.cloud.resource.ResourceStateAdapter;
import com.cloud.resource.ServerResource;
import com.cloud.resource.UnableDeleteHostException;
import com.cloud.server.ManagementServer;
import com.cloud.utils.UuidUtils;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.script.Script;
Expand Down Expand Up @@ -160,12 +160,12 @@ public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long p
params.put("vmDao", _vmDao);
params.put("configDao", _configDao);

String resourceClassName = _configDao.getValue(Config.ExternalBaremetalResourceClassName.key());
String resourceClassName = BaremetalManager.ExternalBaremetalResourceClassName.value();
BareMetalResourceBase resource = null;
if (resourceClassName != null) {
Class<?> clazz = Class.forName(resourceClassName);
resource = (BareMetalResourceBase) clazz.newInstance();
String externalUrl = _configDao.getValue(Config.ExternalBaremetalSystemUrl.key());
String externalUrl = ManagementServer.ExternalBaremetalSystemUrl.value();
if (externalUrl == null) {
throw new IllegalArgumentException(String.format("You must specify ExternalBaremetalSystemUrl in global config page as ExternalBaremetalResourceClassName is not null"));
}
Expand Down Expand Up @@ -193,7 +193,7 @@ public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long p
if (vmIp != null) {
details.put(ApiConstants.IP_ADDRESS, vmIp);
}
String isEchoScAgent = _configDao.getValue(Config.EnableBaremetalSecurityGroupAgentEcho.key());
String isEchoScAgent = String.valueOf(BaremetalManager.EnableBaremetalSecurityGroupAgentEcho.value());
details.put(BaremetalManager.EchoSecurityGroupAgent, isEchoScAgent);

resources.put(resource, details);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@
import com.cloud.agent.api.baremetal.IpmiBootorResetCommand;
import com.cloud.agent.api.to.VirtualMachineTO;
import com.cloud.baremetal.manager.BaremetalManager;
import com.cloud.configuration.Config;
import com.cloud.host.Host.Type;
import com.cloud.hypervisor.Hypervisor;
import com.cloud.resource.ServerResource;
import com.cloud.server.ManagementServer;
import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.db.QueryBuilder;
import com.cloud.utils.db.SearchCriteria;
Expand Down Expand Up @@ -172,20 +172,20 @@ public boolean configure(String name, Map<String, Object> params) throws Configu

String ipmiIface = "default";
try {
ipmiIface = configDao.getValue(Config.BaremetalIpmiLanInterface.key());
ipmiIface = BaremetalManager.BaremetalIpmiLanInterface.value();
} catch (Exception e) {
logger.debug(e.getMessage(), e);
}

try {
ipmiRetryTimes = Integer.parseInt(configDao.getValue(Config.BaremetalIpmiRetryTimes.key()));
ipmiRetryTimes = BaremetalManager.BaremetalIpmiRetryTimes.value();
} catch (Exception e) {
logger.debug(e.getMessage(), e);
}

try {
provisionDoneNotificationOn = Boolean.valueOf(configDao.getValue(Config.BaremetalProvisionDoneNotificationEnabled.key()));
isProvisionDoneNotificationTimeout = Integer.parseInt(configDao.getValue(Config.BaremetalProvisionDoneNotificationTimeout.key()));
provisionDoneNotificationOn = ManagementServer.BaremetalProvisionDoneNotificationEnabled.value();
isProvisionDoneNotificationTimeout = BaremetalManager.BaremetalProvisionDoneNotificationTimeout.value();
} catch (Exception e) {
logger.debug(e.getMessage(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
import com.cloud.agent.api.baremetal.IpmISetBootDevCommand.BootDev;
import com.cloud.baremetal.database.BaremetalPxeDao;
import com.cloud.baremetal.database.BaremetalPxeVO;
import com.cloud.baremetal.manager.BaremetalManager;
import com.cloud.baremetal.networkservice.BaremetalPxeManager.BaremetalPxeType;
import com.cloud.configuration.Config;
import com.cloud.dc.DataCenter;
import com.cloud.deploy.DeployDestination;
import com.cloud.exception.AgentUnavailableException;
Expand Down Expand Up @@ -219,7 +219,7 @@ private boolean preparePxeInAdvancedZone(VirtualMachineProfile profile, NicProfi
throw new CloudRuntimeException(String.format("Cannot find Management NIC on virtual router[id:%s]", vr.getId()));
}

String internalServerIp = _configDao.getValue(Config.BaremetalInternalStorageServer.key());
String internalServerIp = BaremetalManager.BaremetalInternalStorageServer.value();
if (internalServerIp == null) {
throw new CloudRuntimeException(String.format("please specify 'baremetal.internal.storage.server.ip', which is the http server/nfs server storing kickstart files and ISO files, in global setting"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import javax.inject.Inject;
import javax.naming.ConfigurationException;


import com.cloud.agent.AgentManager;
import com.cloud.agent.Listener;
import com.cloud.agent.api.AgentControlAnswer;
Expand All @@ -41,7 +40,6 @@
import com.cloud.agent.api.StartupCommand;
import com.cloud.agent.api.StartupRoutingCommand;
import com.cloud.alert.AlertManager;
import com.cloud.configuration.Config;
import com.cloud.dc.ClusterVO;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
Expand All @@ -62,6 +60,7 @@
import com.cloud.resource.ResourceStateAdapter;
import com.cloud.resource.ServerResource;
import com.cloud.resource.UnableDeleteHostException;
import com.cloud.server.ManagementServer;
import com.cloud.storage.StorageLayer;
import com.cloud.utils.UuidUtils;

Expand Down Expand Up @@ -285,7 +284,7 @@ public final Map<? extends ServerResource, Map<String, String>> find(final long

params.putAll(details);

params.put("router.aggregation.command.each.timeout", _configDao.getValue(Config.RouterAggregationCommandEachTimeout.toString()));
params.put("router.aggregation.command.each.timeout", String.valueOf(ManagementServer.RouterAggregationCommandEachTimeout.value()));

HypervDirectConnectResource resource = new HypervDirectConnectResource();
resource.configure(agentIp, params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import com.cloud.agent.api.StartupCommand;
import com.cloud.agent.api.StartupRoutingCommand;
import com.cloud.alert.AlertManager;
import com.cloud.configuration.Config;
import com.cloud.dc.ClusterDetailsDao;
import com.cloud.dc.ClusterVO;
import com.cloud.dc.DataCenter.NetworkType;
Expand Down Expand Up @@ -66,6 +65,7 @@
import com.cloud.resource.ResourceStateAdapter;
import com.cloud.resource.ServerResource;
import com.cloud.resource.UnableDeleteHostException;
import com.cloud.server.ManagementServer;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.Storage.TemplateType;
import com.cloud.storage.VMTemplateVO;
Expand Down Expand Up @@ -381,7 +381,7 @@ public VmwareServerDiscoverer() {
params.put("guestTrafficInfo", guestTrafficLabelObj);
params.put("publicTrafficInfo", publicTrafficLabelObj);

params.put("router.aggregation.command.each.timeout", _configDao.getValue(Config.RouterAggregationCommandEachTimeout.toString()));
params.put("router.aggregation.command.each.timeout", String.valueOf(ManagementServer.RouterAggregationCommandEachTimeout.value()));

VmwareResource resource = new VmwareResource();
try {
Expand Down Expand Up @@ -692,12 +692,9 @@ private VmwareTrafficLabel getTrafficInfo(TrafficType trafficType, String zoneWi
}

private void _readGlobalConfigParameters() {
String value;
if (_configDao != null) {
value = _configDao.getValue(Config.VmwareUseDVSwitch.key());
useDVS = Boolean.parseBoolean(value);
value = _configDao.getValue(Config.VmwareUseNexusVSwitch.key());
nexusDVS = Boolean.parseBoolean(value);
useDVS = ManagementServer.VmwareUseDVSwitch.value();
nexusDVS = ManagementServer.VmwareUseNexusVSwitch.value();
}
}

Expand Down
Loading
Loading