Removed the configuration parameters from Config.java

This commit is contained in:
Alex Huang 2013-08-07 10:52:06 -07:00
parent 49cd4fa380
commit 5161ded69c
10 changed files with 41 additions and 32 deletions

View File

@ -57,7 +57,7 @@ public interface Configuration {
String getDescription();
/**
* @return Default value for this parameter. Cannot be null.
* @return Default value for this parameter. Null indicates this parameter is optional.
*/
String getDefaultValue();

View File

@ -46,7 +46,7 @@
-->
<bean id="databaseUpgradeChecker" class="com.cloud.upgrade.DatabaseUpgradeChecker" />
<bean id="configurationDaoImpl" class="com.cloud.configuration.dao.ConfigurationDaoImpl" />
<bean id="configurationDaoImpl" class="org.apache.cloudstack.framework.config.dao.ConfigurationDaoImpl" />
<bean id="GlobalLoadBalancingRulesServiceImpl" class ="org.apache.cloudstack.region.gslb.GlobalLoadBalancingRulesServiceImpl" />
<!--

View File

@ -52,7 +52,7 @@
<!--
DAO with customized configuration under non-OSS deployment
-->
<bean id="configurationDaoImpl" class="com.cloud.configuration.dao.ConfigurationDaoImpl">
<bean id="configurationDaoImpl" class="org.apache.cloudstack.framework.config.dao.ConfigurationDaoImpl">
<property name="configParams">
<map>
<entry key="premium" value="true" />

View File

@ -50,11 +50,11 @@ import com.cloud.utils.db.EntityManager;
*/
class ConfigDepotImpl implements ConfigDepot, ConfigDepotAdmin {
@Inject
EntityManager _entityMgr;
EntityManager _entityMgr;
@Inject
ConfigurationDao _configDao;
ConfigurationDao _configDao;
@Inject
List<Configurable> _configurables;
@ -65,14 +65,13 @@ class ConfigDepotImpl implements ConfigDepot, ConfigDepotAdmin {
public <T> ConfigValue<T> get(ConfigKey<T> config) {
return new ConfigValue<T>(_entityMgr, config);
}
@Override
public <T> ScopedConfigValue<T> getScopedValue(ConfigKey<T> config) {
assert (config.scope() != null) : "Did you notice the configuration you're trying to retrieve is not scoped?";
return new ScopedConfigValue<T>(_entityMgr, config);
}
@Override
public void populateConfigurations() {
Date date = new Date();
@ -85,8 +84,10 @@ class ConfigDepotImpl implements ConfigDepot, ConfigDepotAdmin {
_configDao.persist(vo);
} else {
if (vo.isDynamic() != key.isDynamic() ||
!vo.getDescription().equals(key.description()) ||
!vo.getDefaultValue().equals(key.defaultValue())) {
!vo.getDescription().equals(key.description()) ||
((vo.getDefaultValue() != null && key.defaultValue() == null) ||
(vo.getDefaultValue() == null && key.defaultValue() != null) ||
!vo.getDefaultValue().equals(key.defaultValue()))) {
vo.setDynamic(key.isDynamic());
vo.setDescription(key.description());
vo.setDefaultValue(key.defaultValue());

View File

@ -80,7 +80,7 @@ public class ConfigurationVO implements Configuration {
this(key.category(), "DEFAULT", component, key.key(), key.defaultValue(), key.description());
defaultValue = key.defaultValue();
dynamic = key.isDynamic();
scope = key.scope().getName();
scope = key.scope() != null ? key.scope().getName() : null;
}
@Override
@ -137,10 +137,12 @@ public class ConfigurationVO implements Configuration {
this.description = description;
}
@Override
public String getScope() {
return scope;
}
@Override
public boolean isDynamic() {
return dynamic;
}
@ -149,6 +151,7 @@ public class ConfigurationVO implements Configuration {
this.dynamic = dynamic;
}
@Override
public String getDefaultValue() {
return defaultValue;
}
@ -161,6 +164,7 @@ public class ConfigurationVO implements Configuration {
this.scope = scope;
}
@Override
public Date getUpdated() {
return updated;
}

View File

@ -190,9 +190,9 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
protected final ConfigKey<Integer> AlertWait = new ConfigKey<Integer>(Integer.class, "alert.wait", "Advance", "1800",
"Seconds to wait before alerting on a disconnected agent", true);
protected final ConfigKey<Integer> DirectAgentLoadSize = new ConfigKey<Integer>(Integer.class, "direct.agent.load.size", "Advance", "16",
"The number of direct agents to load each time", false, null);
"The number of direct agents to load each time", false);
protected final ConfigKey<Integer> DirectAgentPoolSize = new ConfigKey<Integer>(Integer.class, "direct.agent.pool.size", "Advance", "500",
"Default size for DirectAgentPool", false, null);
"Default size for DirectAgentPool", false);
protected ConfigValue<Integer> _port;

View File

@ -45,6 +45,8 @@ import javax.net.ssl.SSLEngine;
import org.apache.log4j.Logger;
import edu.emory.mathcs.backport.java.util.Arrays;
import com.google.gson.Gson;
import org.apache.cloudstack.framework.config.ConfigDepot;
@ -1404,4 +1406,16 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
}
profilerAgentLB.stop();
}
@Override
public ConfigKey<?>[] getConfigKeys() {
ConfigKey<?>[] keys = super.getConfigKeys();
@SuppressWarnings("unchecked")
List<ConfigKey<?>> keysLst = Arrays.asList(keys);
keysLst.add(EnableLB);
keysLst.add(ConnectedAgentThreshold);
keysLst.add(LoadSize);
keysLst.add(ScanInterval);
return keysLst.toArray(new ConfigKey<?>[keysLst.size()]);
}
}

View File

@ -49,7 +49,6 @@ public enum Config {
AlertSMTPPort("Alert", ManagementServer.class, Integer.class, "alert.smtp.port", "465", "Port the SMTP server is listening on.", null),
AlertSMTPUseAuth("Alert", ManagementServer.class, String.class, "alert.smtp.useAuth", null, "If true, use SMTP authentication when sending emails.", null),
AlertSMTPUsername("Alert", ManagementServer.class, String.class, "alert.smtp.username", null, "Username for SMTP authentication (applies only if alert.smtp.useAuth is true).", null),
AlertWait("Alert", AgentManager.class, Integer.class, "alert.wait", null, "Seconds to wait before alerting on a disconnected agent", null),
CapacityCheckPeriod("Alert", ManagementServer.class, Integer.class, "capacity.check.period", "300000", "The interval in milliseconds between capacity checks", null),
StorageAllocatedCapacityThreshold("Alert", ManagementServer.class, Float.class, "cluster.storage.allocated.capacity.notificationthreshold", "0.75", "Percentage (as a value between 0 and 1) of allocated storage utilization above which alerts will be sent about low storage available.", null, ConfigurationParameterScope.cluster.toString()),
StorageCapacityThreshold("Alert", ManagementServer.class, Float.class, "cluster.storage.capacity.notificationthreshold", "0.75", "Percentage (as a value between 0 and 1) of storage utilization above which alerts will be sent about low storage available.", null, ConfigurationParameterScope.cluster.toString()),
@ -165,10 +164,7 @@ public enum Config {
IntegrationAPIPort("Advanced", ManagementServer.class, Integer.class, "integration.api.port", null, "Defaul API port", null),
InvestigateRetryInterval("Advanced", HighAvailabilityManager.class, Integer.class, "investigate.retry.interval", "60", "Time (in seconds) between VM pings when agent is disconnected", null),
MigrateRetryInterval("Advanced", HighAvailabilityManager.class, Integer.class, "migrate.retry.interval", "120", "Time (in seconds) between migration retries", null),
PingInterval("Advanced", AgentManager.class, Integer.class, "ping.interval", "60", "Ping interval in seconds", null),
PingTimeout("Advanced", AgentManager.class, Float.class, "ping.timeout", "2.5", "Multiplier to ping.interval before announcing an agent has timed out", null),
ClusterDeltaSyncInterval("Advanced", AgentManager.class, Integer.class, "sync.interval", "60", "Cluster Delta sync interval in seconds", null),
Port("Advanced", AgentManager.class, Integer.class, "port", "8250", "Port to listen on for agent connection.", null),
RouterCpuMHz("Advanced", NetworkManager.class, Integer.class, "router.cpu.mhz", String.valueOf(VpcVirtualNetworkApplianceManager.DEFAULT_ROUTER_CPU_MHZ), "Default CPU speed (MHz) for router VM.", null),
RestartRetryInterval("Advanced", HighAvailabilityManager.class, Integer.class, "restart.retry.interval", "600", "Time (in seconds) between retries to restart a vm", null),
RouterStatsInterval("Advanced", NetworkManager.class, Integer.class, "router.stats.interval", "300", "Interval (in seconds) to report router statistics.", null),
@ -191,7 +187,6 @@ public enum Config {
Wait("Advanced", AgentManager.class, Integer.class, "wait", "1800", "Time in seconds to wait for control commands to return", null),
XapiWait("Advanced", AgentManager.class, Integer.class, "xapiwait", "600", "Time (in seconds) to wait for XAPI to return", null),
MigrateWait("Advanced", AgentManager.class, Integer.class, "migratewait", "3600", "Time (in seconds) to wait for VM migrate finish", null),
Workers("Advanced", AgentManager.class, Integer.class, "workers", "5", "Number of worker threads.", null),
HAWorkers("Advanced", AgentManager.class, Integer.class, "ha.workers", "5", "Number of ha worker threads.", null),
MountParent("Advanced", ManagementServer.class, String.class, "mount.parent", "/var/cloudstack/mnt", "The mount point on the Management Server for Secondary Storage.", null),
// UpgradeURL("Advanced", ManagementServer.class, String.class, "upgrade.url", "http://example.com:8080/client/agent/update.zip", "The upgrade URL is the URL of the management server that agents will connect to in order to automatically upgrade.", null),
@ -339,7 +334,6 @@ public enum Config {
VmOpCancelInterval("Advanced", ManagementServer.class, Long.class, "vm.op.cancel.interval", "3600", "Time (in seconds) to wait before cancelling a operation", "Seconds"),
DefaultPageSize("Advanced", ManagementServer.class, Long.class, "default.page.size", "500", "Default page size for API list* commands", null),
DirectAgentPoolSize("Advanced", ManagementServer.class, Integer.class, "direct.agent.pool.size", "500", "Default size for DirectAgentPool", null),
TaskCleanupRetryInterval("Advanced", ManagementServer.class, Integer.class, "task.cleanup.retry.interval", "600", "Time (in seconds) to wait before retrying cleanup of tasks if the cleanup failed previously. 0 means to never retry.", "Seconds"),
@ -357,11 +351,8 @@ public enum Config {
DefaultMaxAccountSecondaryStorage("Account Defaults", ManagementServer.class, Long.class, "max.account.secondary.storage", "400", "The default maximum secondary storage space (in GiB) that can be used for an account", null),
ResourceCountCheckInterval("Advanced", ManagementServer.class, Long.class, "resourcecount.check.interval", "0", "Time (in seconds) to wait before retrying resource count check task. Default is 0 which is to never run the task", "Seconds"),
DirectAgentLoadSize("Advanced", ManagementServer.class, Integer.class, "direct.agent.load.size", "16", "The number of direct agents to load each time", null),
DirectAgentScanInterval("Advanced", ManagementServer.class, Integer.class, "direct.agent.scan.interval", "90", "Time interval (in seconds) to run the direct agent scan task", null),
//disabling lb as cluster sync does not work with distributed cluster
AgentLbEnable("Advanced", ManagementServer.class, Boolean.class, "agent.lb.enabled", "false", "If agent load balancing enabled in cluster setup", null),
SubDomainNetworkAccess("Advanced", NetworkManager.class, Boolean.class, "allow.subdomain.network.access", "true", "Allow subdomains to use networks dedicated to their parent domain(s)", null),
UseExternalDnsServers("Advanced", NetworkManager.class, Boolean.class, "use.external.dns", "false", "Bypass internal dns, use external dns1 and dns2", null, ConfigurationParameterScope.zone.toString()),
EncodeApiResponse("Advanced", ManagementServer.class, Boolean.class, "encode.api.response", "false", "Do URL encoding for the api response, false by default", null),

View File

@ -41,6 +41,7 @@ import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.cloudstack.utils.identity.ManagementServerNode;
@ -184,15 +185,6 @@ import com.cloud.vm.snapshot.VMSnapshotManager;
import com.cloud.vm.snapshot.VMSnapshotVO;
import com.cloud.vm.snapshot.dao.VMSnapshotDao;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.log4j.Logger;
@Local(value = VirtualMachineManager.class)
public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMachineManager, Listener {
private static final Logger s_logger = Logger.getLogger(VirtualMachineManagerImpl.class);

View File

@ -87,3 +87,10 @@ CREATE TABLE `cloud`.`async_job_join_map` (
INDEX `i_async_job_join_map__next_wakeup`(`next_wakeup`),
INDEX `i_async_job_join_map__expiration`(`expiration`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `cloud`.`configuration` ADD COLUMN `default_value` VARCHAR(4095) COMMENT 'Default value for a configuration parameter';
ALTER TABLE `cloud`.`configuration` ADD COLUMN `updated` datetime COMMENT 'Time this was updated by the server. null means this row is obsolete.';
ALTER TABLE `cloud`.`configuration` ADD COLUMN `scope` VARCHAR(255) DEFAULT NULL COMMENT 'Can this parameter be scoped';
ALTER TABLE `cloud`.`configuration` ADD COLUMN `is_dynamic` TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'Can the parameter be change dynamically without restarting the server';
UPDATE `cloud`.`configuration` SET `default_value` = `value`;