You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by sv...@apache.org on 2019/12/18 13:45:09 UTC

[cloudstack] branch revert-3737-fix_ha_config_keys created (now 1476545)

This is an automated email from the ASF dual-hosted git repository.

svogel pushed a change to branch revert-3737-fix_ha_config_keys
in repository https://gitbox.apache.org/repos/asf/cloudstack.git.


      at 1476545  Revert "Add missing HA config keys (#3737)"

This branch includes the following new commits:

     new 1476545  Revert "Add missing HA config keys (#3737)"

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[cloudstack] 01/01: Revert "Add missing HA config keys (#3737)"

Posted by sv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

svogel pushed a commit to branch revert-3737-fix_ha_config_keys
in repository https://gitbox.apache.org/repos/asf/cloudstack.git

commit 1476545bc6e0dacb4882fc5783c1b10c691d50b8
Author: Sven Vogel <sv...@qform.de>
AuthorDate: Wed Dec 18 14:44:56 2019 +0100

    Revert "Add missing HA config keys (#3737)"
    
    This reverts commit 16527f1eb070a796732e99cf8fe466b61cf972c3.
---
 .../java/com/cloud/ha/HighAvailabilityManager.java | 20 +----
 .../com/cloud/ha/HighAvailabilityManagerImpl.java  | 87 ++++++++--------------
 2 files changed, 35 insertions(+), 72 deletions(-)

diff --git a/engine/components-api/src/main/java/com/cloud/ha/HighAvailabilityManager.java b/engine/components-api/src/main/java/com/cloud/ha/HighAvailabilityManager.java
index d6907ac..ecfb6f6 100644
--- a/engine/components-api/src/main/java/com/cloud/ha/HighAvailabilityManager.java
+++ b/engine/components-api/src/main/java/com/cloud/ha/HighAvailabilityManager.java
@@ -16,34 +16,18 @@
 // under the License.
 package com.cloud.ha;
 
+import java.util.List;
+
 import com.cloud.deploy.DeploymentPlanner;
 import com.cloud.host.HostVO;
 import com.cloud.host.Status;
 import com.cloud.utils.component.Manager;
 import com.cloud.vm.VMInstanceVO;
-import org.apache.cloudstack.framework.config.ConfigKey;
-
-import java.util.List;
 
 /**
  * HighAvailabilityManager checks to make sure the VMs are running fine.
  */
 public interface HighAvailabilityManager extends Manager {
-
-    ConfigKey<Long> TimeBetweenCleanup = new ConfigKey<>("Advanced", Long.class,
-        "time.between.cleanup", "86400", "Time in seconds to wait before the cleanup thread runs.",
-        false, null);
-
-    ConfigKey<Integer> MaxRetries = new ConfigKey<>("Advanced", Integer.class, "max.retries",
-        "5", "Number of times to retry start.", false, null);
-
-    ConfigKey<Long> TimeToSleep = new ConfigKey<>("Advanced", Long.class, "time.to.sleep",
-        "60", "Time in seconds to sleep if no work items are found.", false, null);
-
-    ConfigKey<Long> TimeBetweenFailures = new ConfigKey<>("Advanced", Long.class,
-        "time.between.failures", "3600", "Time in seconds before try to cleanup all the VMs"
-        + " which are registered for the HA event that were successful and are now ready to be purged.", false, null);
-
     public enum WorkType {
         Migration,  // Migrating VMs off of a host.
         Stop,       // Stops a VM for storage pool migration purposes.  This should be obsolete now.
diff --git a/server/src/main/java/com/cloud/ha/HighAvailabilityManagerImpl.java b/server/src/main/java/com/cloud/ha/HighAvailabilityManagerImpl.java
index 4a7a179..49211f5 100644
--- a/server/src/main/java/com/cloud/ha/HighAvailabilityManagerImpl.java
+++ b/server/src/main/java/com/cloud/ha/HighAvailabilityManagerImpl.java
@@ -16,9 +16,29 @@
 // under the License.
 package com.cloud.ha;
 
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.NDC;
+import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
+import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.apache.cloudstack.managed.context.ManagedContext;
+import org.apache.cloudstack.managed.context.ManagedContextRunnable;
+
 import com.cloud.agent.AgentManager;
 import com.cloud.alert.AlertManager;
 import com.cloud.cluster.ClusterManagerListener;
+import org.apache.cloudstack.management.ManagementServerHost;
 import com.cloud.configuration.Config;
 import com.cloud.dc.ClusterDetailsDao;
 import com.cloud.dc.DataCenterVO;
@@ -58,27 +78,6 @@ import com.cloud.vm.VirtualMachine.State;
 import com.cloud.vm.VirtualMachineManager;
 import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.vm.dao.VMInstanceDao;
-import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
-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.cloudstack.managed.context.ManagedContext;
-import org.apache.cloudstack.managed.context.ManagedContextRunnable;
-import org.apache.cloudstack.management.ManagementServerHost;
-import org.apache.log4j.Logger;
-import org.apache.log4j.NDC;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-import javax.inject.Inject;
-import javax.naming.ConfigurationException;
 
 /**
  * HighAvailabilityManagerImpl coordinates the HA process. VMs are registered with the HA Manager for HA. The request is stored
@@ -102,13 +101,7 @@ import javax.naming.ConfigurationException;
  *         ha.retry.wait | time to wait before retrying the work item | seconds | 120 || || stop.retry.wait | time to wait
  *         before retrying the stop | seconds | 120 || * }
  **/
-public class HighAvailabilityManagerImpl extends ManagerBase implements Configurable, HighAvailabilityManager, ClusterManagerListener {
-
-    private static final int SECONDS_TO_MILLISECONDS_FACTOR = 1000;
-    private static final int STOP_RETRY_INTERVAL_SECONDS = 600;
-    private static final int RESTART_RETRY_INTERVAL_SECONDS = 600;
-    private static final int INVESTIGATE_RETRY_INTERVAL_SECONDS = 60;
-    private static final int MIGRATE_RETRY_INTERVAL_SECONDS = 120;
+public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvailabilityManager, ClusterManagerListener {
 
     protected static final Logger s_logger = Logger.getLogger(HighAvailabilityManagerImpl.class);
     WorkerThread[] _workers;
@@ -851,25 +844,29 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements Configur
         value = params.get("force.ha");
         _forceHA = Boolean.parseBoolean(value);
 
-        _timeToSleep = TimeToSleep.value() * SECONDS_TO_MILLISECONDS_FACTOR;
+        value = params.get("time.to.sleep");
+        _timeToSleep = (long)NumbersUtil.parseInt(value, 60) * 1000;
 
-        _maxRetries = MaxRetries.value();
+        value = params.get("max.retries");
+        _maxRetries = NumbersUtil.parseInt(value, 5);
 
-        _timeBetweenFailures = TimeBetweenFailures.value() * SECONDS_TO_MILLISECONDS_FACTOR;
+        value = params.get("time.between.failures");
+        _timeBetweenFailures = NumbersUtil.parseLong(value, 3600) * 1000;
 
-        _timeBetweenCleanups = TimeBetweenCleanup.value();
+        value = params.get("time.between.cleanup");
+        _timeBetweenCleanups = NumbersUtil.parseLong(value, 3600 * 24);
 
         value = params.get("stop.retry.interval");
-        _stopRetryInterval = NumbersUtil.parseInt(value, STOP_RETRY_INTERVAL_SECONDS);
+        _stopRetryInterval = NumbersUtil.parseInt(value, 10 * 60);
 
         value = params.get("restart.retry.interval");
-        _restartRetryInterval = NumbersUtil.parseInt(value, RESTART_RETRY_INTERVAL_SECONDS);
+        _restartRetryInterval = NumbersUtil.parseInt(value, 10 * 60);
 
         value = params.get("investigate.retry.interval");
-        _investigateRetryInterval = NumbersUtil.parseInt(value, INVESTIGATE_RETRY_INTERVAL_SECONDS);
+        _investigateRetryInterval = NumbersUtil.parseInt(value, 1 * 60);
 
         value = params.get("migrate.retry.interval");
-        _migrateRetryInterval = NumbersUtil.parseInt(value, MIGRATE_RETRY_INTERVAL_SECONDS);
+        _migrateRetryInterval = NumbersUtil.parseInt(value, 2 * 60);
 
         _instance = params.get("instance");
         if (_instance == null) {
@@ -1007,22 +1004,4 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements Configur
         List<HaWorkVO> haWorks = _haDao.listPendingHaWorkForVm(vmId);
         return haWorks.size() > 0;
     }
-
-    /**
-     * @return The name of the component that provided this configuration
-     * variable.  This value is saved in the database so someone can easily
-     * identify who provides this variable.
-     **/
-    @Override
-    public String getConfigComponentName() {
-        return HighAvailabilityManager.class.getSimpleName();
-    }
-
-    /**
-     * @return The list of config keys provided by this configuable.
-     */
-    @Override
-    public ConfigKey<?>[] getConfigKeys() {
-        return new ConfigKey[] {TimeBetweenCleanup, MaxRetries, TimeToSleep, TimeBetweenFailures};
-    }
 }