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 @@ -47,7 +47,6 @@
import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
import org.apache.cloudstack.engine.subsystem.api.storage.StorageCacheManager;
import org.apache.cloudstack.framework.async.AsyncCallFuture;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.framework.config.ConfigKey;
import org.apache.cloudstack.framework.config.Configurable;
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
Expand All @@ -56,9 +55,8 @@
import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;

import com.cloud.agent.api.to.DataObjectType;
import com.cloud.configuration.Config;
import com.cloud.storage.DataStoreRole;
import com.cloud.utils.NumbersUtil;
import com.cloud.storage.StorageManager;
import com.cloud.utils.component.Manager;
import com.cloud.utils.concurrency.NamedThreadFactory;
import com.cloud.utils.db.GlobalLock;
Expand All @@ -68,6 +66,7 @@

public class StorageCacheManagerImpl implements StorageCacheManager, Manager, Configurable {
protected Logger logger = LogManager.getLogger(getClass());

@Inject
List<StorageCacheAllocator> storageCacheAllocator;
@Inject
Expand All @@ -78,8 +77,6 @@ public class StorageCacheManagerImpl implements StorageCacheManager, Manager, Co
DataStoreManager dataStoreManager;
@Inject
StorageCacheReplacementAlgorithm cacheReplacementAlgorithm;
@Inject
ConfigurationDao configDao;
Boolean cacheReplacementEnabled = Boolean.TRUE;
int workers;
ScheduledExecutorService executors;
Expand Down Expand Up @@ -161,9 +158,9 @@ public void setRunLevel(int level) {

@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
cacheReplacementEnabled = Boolean.parseBoolean(configDao.getValue(Config.StorageCacheReplacementEnabled.key()));
cacheReplaceMentInterval = NumbersUtil.parseInt(configDao.getValue(Config.StorageCacheReplacementInterval.key()), 86400);
workers = NumbersUtil.parseInt(configDao.getValue(Config.ExpungeWorkers.key()), 10);
cacheReplacementEnabled = StorageCacheReplacementEnabled.value();
cacheReplaceMentInterval = StorageCacheReplacementInterval.value();
workers = StorageManager.ExpungeWorkers.value();
executors = Executors.newScheduledThreadPool(workers, new NamedThreadFactory("StorageCacheManager-cache-replacement"));
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,19 @@
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
import org.apache.cloudstack.engine.subsystem.api.storage.StorageCacheManager;
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;

import com.cloud.configuration.Config;
import com.cloud.utils.DateUtil;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.db.QueryBuilder;
import com.cloud.utils.db.SearchCriteria;

public class StorageCacheReplacementAlgorithmLRU implements StorageCacheReplacementAlgorithm {
@Inject
ConfigurationDao configDao;

@Inject
TemplateDataFactory templateFactory;
@Inject
Expand All @@ -59,7 +56,7 @@ public StorageCacheReplacementAlgorithmLRU() {

@PostConstruct
public void initialize() {
/* Avoid using configDao at this time, we can't be sure that the database is already upgraded
/* Avoid resolving the config value at this time, we can't be sure that the database is already upgraded
* and there might be fatal errors when using a dao.
*/
}
Expand All @@ -71,7 +68,7 @@ public void setUnusedTimeInterval(Integer interval) {
@Override
public DataObject chooseOneToBeReplaced(DataStore store) {
if (unusedTimeInterval == null) {
unusedTimeInterval = NumbersUtil.parseInt(configDao.getValue(Config.StorageCacheReplacementLRUTimeInterval.key()), 30);
unusedTimeInterval = StorageCacheManager.StorageCacheReplacementLRUTimeInterval.value();
}
Calendar cal = Calendar.getInstance();
cal.setTime(DateUtil.now());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.StoragePool;
import com.cloud.storage.VolumeApiService;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.SnapshotDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.storage.snapshot.SnapshotManager;
import com.cloud.template.TemplateManager;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.db.DB;
import com.cloud.utils.exception.CloudRuntimeException;
Expand Down Expand Up @@ -340,8 +343,7 @@ protected Answer copyVolumeFromSnapshot(DataObject snapObj, DataObject volObj) {
srcData = cacheSnapshotChain(snapshot, new ZoneScope(pool.getDataCenterId()));
}

String value = configDao.getValue(Config.CreateVolumeFromSnapshotWait.toString());
int _createVolumeFromSnapshotWait = NumbersUtil.parseInt(value, Integer.parseInt(Config.CreateVolumeFromSnapshotWait.getDefaultValue()));
int _createVolumeFromSnapshotWait = VolumeApiService.CreateVolumeFromSnapshotWait.value();

EndPoint ep = null;
if (srcData.getDataStore().getRole() == DataStoreRole.Primary) {
Expand Down Expand Up @@ -425,8 +427,7 @@ private void deleteVolumeOnSecondaryStore(DataObject objectInStore) {
}

protected Answer copyVolumeBetweenPools(DataObject srcData, DataObject destData) {
String value = configDao.getValue(Config.CopyVolumeWait.key());
int _copyvolumewait = NumbersUtil.parseInt(value, Integer.parseInt(Config.CopyVolumeWait.getDefaultValue()));
int _copyvolumewait = VolumeApiService.CopyVolumeWait.value();

Scope destScope = getZoneScope(destData.getDataStore().getScope());
DataStore cacheStore = cacheMgr.getCacheStorage(destScope);
Expand Down Expand Up @@ -741,8 +742,7 @@ public void copyAsync(DataObject srcData, DataObject destData, Host destHost, As
@DB
protected Answer createTemplateFromSnapshot(DataObject srcData, DataObject destData) {

String value = configDao.getValue(Config.CreatePrivateTemplateFromSnapshotWait.toString());
int _createprivatetemplatefromsnapshotwait = NumbersUtil.parseInt(value, Integer.parseInt(Config.CreatePrivateTemplateFromSnapshotWait.getDefaultValue()));
int _createprivatetemplatefromsnapshotwait = TemplateManager.CreatePrivateTemplateFromSnapshotWait.value();

boolean needCache = false;
if (needCacheStorage(srcData, destData)) {
Expand Down Expand Up @@ -775,8 +775,7 @@ protected Answer createTemplateFromSnapshot(DataObject srcData, DataObject destD
}

protected Answer copySnapshot(DataObject srcData, DataObject destData) {
String value = configDao.getValue(Config.BackupSnapshotWait.toString());
int _backupsnapshotwait = NumbersUtil.parseInt(value, Integer.parseInt(Config.BackupSnapshotWait.getDefaultValue()));
int _backupsnapshotwait = SnapshotManager.BackupSnapshotWait.value();

DataObject cacheData = null;
SnapshotInfo snapshotInfo = (SnapshotInfo)srcData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@ else if (volumeInfo.getFormat() == ImageFormat.OVA) {

AsyncCallFuture<VolumeApiResult> future = _volumeService.createVolumeAsync(volumeInfo, volumeInfo.getDataStore());

int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(_configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600);
int storagePoolMaxWaitSeconds = VolumeApiService.StoragePoolMaxWaitSeconds.value();

VolumeApiResult result = future.get(storagePoolMaxWaitSeconds, TimeUnit.SECONDS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
import com.cloud.agent.api.to.StorageFilerTO;
import com.cloud.agent.api.to.VirtualMachineTO;
import com.cloud.alert.AlertManager;
import com.cloud.configuration.Config;
import com.cloud.configuration.Resource.ResourceType;
import com.cloud.dc.dao.ClusterDao;
import com.cloud.event.EventTypes;
Expand Down Expand Up @@ -138,6 +137,7 @@
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.Volume;
import com.cloud.storage.VolumeApiService;
import com.cloud.storage.VolumeApiServiceImpl;
import com.cloud.storage.Volume.State;
import com.cloud.storage.VolumeDetailVO;
Expand All @@ -155,7 +155,6 @@
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
import com.cloud.user.ResourceLimitService;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.Pair;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.GlobalLock;
Expand Down Expand Up @@ -669,7 +668,7 @@ public long getTemplatePoolId() {
}

private TemplateInfo waitForTemplateDownloaded(PrimaryDataStore store, TemplateInfo template) {
int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600);
int storagePoolMaxWaitSeconds = VolumeApiService.StoragePoolMaxWaitSeconds.value();
int sleepTime = 120;
int tries = storagePoolMaxWaitSeconds / sleepTime;
while (tries > 0) {
Expand Down Expand Up @@ -705,7 +704,7 @@ protected void createBaseImageAsync(VolumeInfo volume, PrimaryDataStore dataStor
AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
caller.setCallback(caller.getTarget().copyBaseImageCallback(null, null)).setContext(context);

int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600);
int storagePoolMaxWaitSeconds = VolumeApiService.StoragePoolMaxWaitSeconds.value();
if (logger.isDebugEnabled()) {
logger.debug("Acquire lock on VMTemplateStoragePool " + templatePoolRefId + " with timeout " + storagePoolMaxWaitSeconds + " seconds");
}
Expand Down Expand Up @@ -980,7 +979,7 @@ private TemplateInfo createManagedTemplateVolume(TemplateInfo srcTemplateInfo, P
// At this point, we have an entry in the DB that points to our cached template.
// We need to lock it as there may be other VMs that may get started using the same template.
// We want to avoid having to create multiple cache copies of the same template.
int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600);
int storagePoolMaxWaitSeconds = VolumeApiService.StoragePoolMaxWaitSeconds.value();
long templatePoolRefId = templatePoolRef.getId();

templatePoolRef = _tmpltPoolDao.acquireInLockTable(templatePoolRefId, storagePoolMaxWaitSeconds);
Expand Down Expand Up @@ -1045,7 +1044,7 @@ public void complete(CreateCmdResult result) {
private void copyTemplateToManagedTemplateVolume(TemplateInfo srcTemplateInfo, TemplateInfo templateOnPrimary, VMTemplateStoragePoolVO templatePoolRef, PrimaryDataStore destPrimaryDataStore,
Host destHost) throws StorageAccessException {
AsyncCallFuture<VolumeApiResult> copyTemplateFuture = new AsyncCallFuture<>();
int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600);
int storagePoolMaxWaitSeconds = VolumeApiService.StoragePoolMaxWaitSeconds.value();
long templatePoolRefId = templatePoolRef.getId();

try {
Expand Down Expand Up @@ -1432,7 +1431,7 @@ public TemplateInfo createManagedStorageTemplate(long srcTemplateId, long destDa
throw new CloudRuntimeException("Unable to create managed storage template, couldn't get global lock on " + templateIdManagedPoolIdLockString);
}

int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600);
int storagePoolMaxWaitSeconds = VolumeApiService.StoragePoolMaxWaitSeconds.value();
if (!lock.lock(storagePoolMaxWaitSeconds)) {
logger.debug("Unable to create managed storage template, couldn't lock on " + templateIdManagedPoolIdLockString);
throw new CloudRuntimeException("Unable to create managed storage template, couldn't lock on " + templateIdManagedPoolIdLockString);
Expand Down Expand Up @@ -1539,7 +1538,7 @@ public AsyncCallFuture<VolumeApiResult> createManagedStorageVolumeFromTemplateAs
throw new CloudRuntimeException("Unable to create managed storage template/volume, couldn't get global lock on " + tmplIdManagedPoolIdLockString);
}

int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600);
int storagePoolMaxWaitSeconds = VolumeApiService.StoragePoolMaxWaitSeconds.value();
if (!lock.lock(storagePoolMaxWaitSeconds)) {
logger.debug("Unable to create managed storage template/volume, couldn't lock on " + tmplIdManagedPoolIdLockString);
throw new CloudRuntimeException("Unable to create managed storage template/volume, couldn't lock on " + tmplIdManagedPoolIdLockString);
Expand Down Expand Up @@ -1611,7 +1610,7 @@ private void createManagedVolumeCopyManagedTemplateAsyncWithLock(VolumeInfo volu
throw new CloudRuntimeException("Unable to create volume from template, couldn't get global lock on " + tmplIdManagedPoolIdDestinationHostLockString);
}

int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600);
int storagePoolMaxWaitSeconds = VolumeApiService.StoragePoolMaxWaitSeconds.value();
if (!lock.lock(storagePoolMaxWaitSeconds)) {
logger.debug("Unable to create volume from template, couldn't lock on " + tmplIdManagedPoolIdDestinationHostLockString);
throw new CloudRuntimeException("Unable to create volume from template, couldn't lock on " + tmplIdManagedPoolIdDestinationHostLockString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public boolean addUserData(NicProfile nic, VirtualMachineProfile profile) {
cmd.addVmData("metadata", "instance-id", String.valueOf(vm.getUuid()));
cmd.addVmData("metadata", "vm-id", String.valueOf(vm.getInstanceName()));
cmd.addVmData("metadata", "public-keys", null);
String cloudIdentifier = _configDao.getValue("cloud.identifier");
String cloudIdentifier = NetworkModel.CloudIdentifier.value();
if (cloudIdentifier == null) {
cloudIdentifier = "";
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,10 @@ private void createApplyLoadBalancingRulesCommands(List<LoadBalancingRule> rules
cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, elbVm.getInstanceName());
//FIXME: why are we setting attributes directly? Ick!! There should be accessors and
//the constructor should set defaults.
cmd.lbStatsVisibility = _configDao.getValue(Config.NetworkLBHaproxyStatsVisbility.key());
cmd.lbStatsUri = _configDao.getValue(Config.NetworkLBHaproxyStatsUri.key());
cmd.lbStatsAuth = _configDao.getValue(Config.NetworkLBHaproxyStatsAuth.key());
cmd.lbStatsPort = _configDao.getValue(Config.NetworkLBHaproxyStatsPort.key());
cmd.lbStatsVisibility = NetworkOrchestrationService.NetworkLBHaproxyStatsVisbility.value();
cmd.lbStatsUri = NetworkOrchestrationService.NetworkLBHaproxyStatsUri.value();
cmd.lbStatsAuth = NetworkOrchestrationService.NetworkLBHaproxyStatsAuth.value();
cmd.lbStatsPort = NetworkOrchestrationService.NetworkLBHaproxyStatsPort.value();

cmds.addCommand(cmd);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,10 @@ private void createApplyLoadBalancingRulesCommands(final List<LoadBalancingRule>
internalLbVm.getHypervisorType()), internalLbVm.getVpcId(), maxconn, offering.isKeepAliveEnabled(),
NetworkOrchestrationService.NETWORK_LB_HAPROXY_IDLE_TIMEOUT.value());

cmd.lbStatsVisibility = _configDao.getValue(Config.NetworkLBHaproxyStatsVisbility.key());
cmd.lbStatsUri = _configDao.getValue(Config.NetworkLBHaproxyStatsUri.key());
cmd.lbStatsAuth = _configDao.getValue(Config.NetworkLBHaproxyStatsAuth.key());
cmd.lbStatsPort = _configDao.getValue(Config.NetworkLBHaproxyStatsPort.key());
cmd.lbStatsVisibility = NetworkOrchestrationService.NetworkLBHaproxyStatsVisbility.value();
cmd.lbStatsUri = NetworkOrchestrationService.NetworkLBHaproxyStatsUri.value();
cmd.lbStatsAuth = NetworkOrchestrationService.NetworkLBHaproxyStatsAuth.value();
cmd.lbStatsPort = NetworkOrchestrationService.NetworkLBHaproxyStatsPort.value();

cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, getInternalLbControlIp(internalLbVm.getId()));
cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, guestNic.getIPv4Address());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.cloud.agent.api.StartupCommand;
import com.cloud.agent.api.to.LoadBalancerTO;
import com.cloud.api.ApiDBUtils;
import com.cloud.configuration.Config;
import com.cloud.dc.DataCenter;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
Expand Down Expand Up @@ -105,7 +104,7 @@
import com.cloud.vm.dao.NicDao;
import com.cloud.vm.dao.VMInstanceDao;
import com.google.gson.Gson;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
import org.apache.cloudstack.framework.messagebus.MessageBus;
import org.apache.cloudstack.framework.messagebus.PublishScope;
import org.apache.cloudstack.network.tungsten.agent.api.ApplyTungstenNetworkPolicyCommand;
Expand Down Expand Up @@ -180,8 +179,6 @@ public class TungstenElement extends AdapterBase
@Inject
AgentManager agentMgr;
@Inject
ConfigurationDao configDao;
@Inject
VlanDao vlanDao;
@Inject
HostDao hostDao;
Expand Down Expand Up @@ -436,11 +433,11 @@ private void updateLBPool(Network network, LoadBalancingRule loadBalancingRule,

// update haproxy
TungstenCommand updateTungstenLoadBalancerPoolCommand;
String lbStatsVisibility = configDao.getValue(Config.NetworkLBHaproxyStatsVisbility.key());
String lbStatsVisibility = NetworkOrchestrationService.NetworkLBHaproxyStatsVisbility.value();
if (!lbStatsVisibility.equals("disabled")) {
String lbStatsUri = configDao.getValue(Config.NetworkLBHaproxyStatsUri.key());
String lbStatsAuth = configDao.getValue(Config.NetworkLBHaproxyStatsAuth.key());
String lbStatsPort = configDao.getValue(Config.NetworkLBHaproxyStatsPort.key());
String lbStatsUri = NetworkOrchestrationService.NetworkLBHaproxyStatsUri.value();
String lbStatsAuth = NetworkOrchestrationService.NetworkLBHaproxyStatsAuth.value();
String lbStatsPort = NetworkOrchestrationService.NetworkLBHaproxyStatsPort.value();
updateTungstenLoadBalancerPoolCommand = new UpdateTungstenLoadBalancerPoolCommand(
tungstenProjectFqn, TungstenUtils.getLoadBalancerPoolName(loadBalancingRule.getId()),
TungstenUtils.getLoadBalancerAlgorithm(loadBalancingRule.getAlgorithm()),
Expand Down
Loading
Loading