Removed the configuration parameters from Config.java
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5161ded6 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5161ded6 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5161ded6 Branch: refs/heads/master Commit: 5161ded69c5eb092eacd6180db0b86e77566d1eb Parents: 49cd4fa Author: Alex Huang <alex.hu...@citrix.com> Authored: Wed Aug 7 10:52:06 2013 -0700 Committer: Alex Huang <alex.hu...@citrix.com> Committed: Wed Aug 7 16:41:05 2013 -0700 ---------------------------------------------------------------------- .../apache/cloudstack/config/Configuration.java | 2 +- client/tomcatconf/componentContext.xml.in | 2 +- client/tomcatconf/nonossComponentContext.xml.in | 2 +- .../framework/config/ConfigDepotImpl.java | 17 +++++++++-------- .../framework/config/ConfigurationVO.java | 6 +++++- .../com/cloud/agent/manager/AgentManagerImpl.java | 4 ++-- .../agent/manager/ClusteredAgentManagerImpl.java | 14 ++++++++++++++ server/src/com/cloud/configuration/Config.java | 9 --------- .../com/cloud/vm/VirtualMachineManagerImpl.java | 10 +--------- setup/db/db/schema-420to430.sql | 7 +++++++ 10 files changed, 41 insertions(+), 32 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5161ded6/api/src/org/apache/cloudstack/config/Configuration.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/config/Configuration.java b/api/src/org/apache/cloudstack/config/Configuration.java index 97cc8c4..a8031a5 100644 --- a/api/src/org/apache/cloudstack/config/Configuration.java +++ b/api/src/org/apache/cloudstack/config/Configuration.java @@ -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(); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5161ded6/client/tomcatconf/componentContext.xml.in ---------------------------------------------------------------------- diff --git a/client/tomcatconf/componentContext.xml.in b/client/tomcatconf/componentContext.xml.in index 5ca0750..e0552aa 100644 --- a/client/tomcatconf/componentContext.xml.in +++ b/client/tomcatconf/componentContext.xml.in @@ -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" /> <!-- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5161ded6/client/tomcatconf/nonossComponentContext.xml.in ---------------------------------------------------------------------- diff --git a/client/tomcatconf/nonossComponentContext.xml.in b/client/tomcatconf/nonossComponentContext.xml.in index e9290db..2be071e 100644 --- a/client/tomcatconf/nonossComponentContext.xml.in +++ b/client/tomcatconf/nonossComponentContext.xml.in @@ -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" /> http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5161ded6/framework/config/src/org/apache/cloudstack/framework/config/ConfigDepotImpl.java ---------------------------------------------------------------------- diff --git a/framework/config/src/org/apache/cloudstack/framework/config/ConfigDepotImpl.java b/framework/config/src/org/apache/cloudstack/framework/config/ConfigDepotImpl.java index df79d9d..b2be0f2 100644 --- a/framework/config/src/org/apache/cloudstack/framework/config/ConfigDepotImpl.java +++ b/framework/config/src/org/apache/cloudstack/framework/config/ConfigDepotImpl.java @@ -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()); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5161ded6/framework/config/src/org/apache/cloudstack/framework/config/ConfigurationVO.java ---------------------------------------------------------------------- diff --git a/framework/config/src/org/apache/cloudstack/framework/config/ConfigurationVO.java b/framework/config/src/org/apache/cloudstack/framework/config/ConfigurationVO.java index ad2b582..0cc1019 100644 --- a/framework/config/src/org/apache/cloudstack/framework/config/ConfigurationVO.java +++ b/framework/config/src/org/apache/cloudstack/framework/config/ConfigurationVO.java @@ -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; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5161ded6/server/src/com/cloud/agent/manager/AgentManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/agent/manager/AgentManagerImpl.java b/server/src/com/cloud/agent/manager/AgentManagerImpl.java index 01c2137..f78cff4 100755 --- a/server/src/com/cloud/agent/manager/AgentManagerImpl.java +++ b/server/src/com/cloud/agent/manager/AgentManagerImpl.java @@ -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; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5161ded6/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java b/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java index 742d798..5cbed3f 100755 --- a/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java +++ b/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java @@ -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()]); + } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5161ded6/server/src/com/cloud/configuration/Config.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index 006c7d7..0329ffd 100755 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -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), http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5161ded6/server/src/com/cloud/vm/VirtualMachineManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java index d67d3e2..b1388a0 100755 --- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -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); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5161ded6/setup/db/db/schema-420to430.sql ---------------------------------------------------------------------- diff --git a/setup/db/db/schema-420to430.sql b/setup/db/db/schema-420to430.sql index 52b8391..dc52665 100644 --- a/setup/db/db/schema-420to430.sql +++ b/setup/db/db/schema-420to430.sql @@ -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`;