From 5161ded69c5eb092eacd6180db0b86e77566d1eb Mon Sep 17 00:00:00 2001 From: Alex Huang Date: Wed, 7 Aug 2013 10:52:06 -0700 Subject: [PATCH] Removed the configuration parameters from Config.java --- .../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 +++++- .../cloud/agent/manager/AgentManagerImpl.java | 4 ++-- .../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(-) diff --git a/api/src/org/apache/cloudstack/config/Configuration.java b/api/src/org/apache/cloudstack/config/Configuration.java index 97cc8c4e52d..a8031a5b5c9 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(); diff --git a/client/tomcatconf/componentContext.xml.in b/client/tomcatconf/componentContext.xml.in index 5ca07502a22..e0552aa01bc 100644 --- a/client/tomcatconf/componentContext.xml.in +++ b/client/tomcatconf/componentContext.xml.in @@ -46,7 +46,7 @@ --> - + - + 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 df79d9d9c2a..b2be0f2f298 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 _configurables; @@ -65,14 +65,13 @@ class ConfigDepotImpl implements ConfigDepot, ConfigDepotAdmin { public ConfigValue get(ConfigKey config) { return new ConfigValue(_entityMgr, config); } - + @Override public ScopedConfigValue getScopedValue(ConfigKey config) { assert (config.scope() != null) : "Did you notice the configuration you're trying to retrieve is not scoped?"; return new ScopedConfigValue(_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()); 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 ad2b5828f41..0cc10190efd 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; } diff --git a/server/src/com/cloud/agent/manager/AgentManagerImpl.java b/server/src/com/cloud/agent/manager/AgentManagerImpl.java index 01c21376089..f78cff4bd7e 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 AlertWait = new ConfigKey(Integer.class, "alert.wait", "Advance", "1800", "Seconds to wait before alerting on a disconnected agent", true); protected final ConfigKey DirectAgentLoadSize = new ConfigKey(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 DirectAgentPoolSize = new ConfigKey(Integer.class, "direct.agent.pool.size", "Advance", "500", - "Default size for DirectAgentPool", false, null); + "Default size for DirectAgentPool", false); protected ConfigValue _port; diff --git a/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java b/server/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java index 742d798dfe6..5cbed3f6977 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> keysLst = Arrays.asList(keys); + keysLst.add(EnableLB); + keysLst.add(ConnectedAgentThreshold); + keysLst.add(LoadSize); + keysLst.add(ScanInterval); + return keysLst.toArray(new ConfigKey[keysLst.size()]); + } } diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index 006c7d79da5..0329ffd337e 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), diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java index d67d3e27daf..b1388a06431 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); diff --git a/setup/db/db/schema-420to430.sql b/setup/db/db/schema-420to430.sql index 52b8391f7e5..dc526659ba5 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`;