From cb99af60bececc64eba8b3ed12621d0028010755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josejulio=20Mart=C3=ADnez=20Maga=C3=B1a?= Date: Mon, 26 Oct 2015 14:41:37 -0600 Subject: [PATCH] Bug 833547 - make agent shutdown timeout configurable Takes the configuration from AgentConfiguration. Created the defaults in AgentConfigurationConstants. The configuration is taken from the entry: "rhq.agent.agent-update.exit-timeout-msecs". --- .../org/rhq/enterprise/agent/AgentConfiguration.java | 9 +++++++-- .../agent/AgentConfigurationConstants.java | 12 +++++++++++- .../org/rhq/enterprise/agent/AgentUpdateThread.java | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentConfiguration.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentConfiguration.java index 0b6c6eae641..a6e1c1391dc 100644 --- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentConfiguration.java +++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentConfiguration.java @@ -27,8 +27,6 @@ import java.util.prefs.BackingStoreException; import java.util.prefs.Preferences; -import mazz.i18n.Logger; - import org.rhq.core.pc.PluginContainerConfiguration; import org.rhq.core.util.obfuscation.ObfuscatedPreferences; import org.rhq.enterprise.agent.i18n.AgentI18NFactory; @@ -38,6 +36,8 @@ import org.rhq.enterprise.communications.command.client.PersistentFifo; import org.rhq.enterprise.communications.util.SecurityUtil; +import mazz.i18n.Logger; + /** * Just provides some convienence methods to extract agent configuration properties. * @@ -374,6 +374,11 @@ public String getAgentUpdateVersionUrlIfDefined() { return str; } + public long getAgentUpdateExitTimeout() { + return m_preferences.getLong(AgentConfigurationConstants.AGENT_UPDATE_EXIT_TIMEOUT_MSECS, + AgentConfigurationConstants.DEFAULT_AGENT_UPDATE_EXIT_TIMEOUT_MSECS); + } + /** * This will return the URL that the agent should use when it needs to find out * the version information of the latest agent update binary. diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentConfigurationConstants.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentConfigurationConstants.java index 298f1a94fba..978fdb5f677 100644 --- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentConfigurationConstants.java +++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentConfigurationConstants.java @@ -161,6 +161,16 @@ public interface AgentConfigurationConstants { */ String AGENT_UPDATE_DOWNLOAD_URL = PROPERTY_NAME_PREFIX + "agent-update.download-url"; + /** + * The amount of milliseconds the agent will wait before force closing after an update. + */ + String AGENT_UPDATE_EXIT_TIMEOUT_MSECS = PROPERTY_NAME_PREFIX + "agent-update.exit-timeout-msecs"; + + /** + * If the update-exit timeout is not defined, this is the default. + */ + long DEFAULT_AGENT_UPDATE_EXIT_TIMEOUT_MSECS = 1000L * 60 * 1; + /** * The amount of milliseconds the agent will wait at startup for the server to be detected. */ @@ -818,4 +828,4 @@ public interface AgentConfigurationConstants { */ @Restricted String COMMUNICATIONS_CONNECTOR_SECURITY_TRUSTSTORE_PASSWORD = "rhq.communications.connector.security.truststore.password"; -} \ No newline at end of file +} diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentUpdateThread.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentUpdateThread.java index d4fc4c88cd5..900ef62334b 100644 --- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentUpdateThread.java +++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentUpdateThread.java @@ -216,7 +216,7 @@ public void run() { // We should only ever get here if everything was successful. // We now need to exit the thread; and if everything goes according to plan, the VM will now exit - shutdownHook.spawnKillThread(1000L * 60 * 1); // pull the pin - FIRE IN THE HOLE! + shutdownHook.spawnKillThread(this.agent.getConfiguration().getAgentUpdateExitTimeout()); // pull the pin - FIRE IN THE HOLE! return; }