Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8919C18AC5 for ; Mon, 1 Feb 2016 22:55:43 +0000 (UTC) Received: (qmail 48473 invoked by uid 500); 1 Feb 2016 22:55:43 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 48449 invoked by uid 500); 1 Feb 2016 22:55:43 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 48440 invoked by uid 99); 1 Feb 2016 22:55:43 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Feb 2016 22:55:43 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3488EDFD7D; Mon, 1 Feb 2016 22:55:43 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rlevas@apache.org To: commits@ambari.apache.org Message-Id: <32512ba8589d4be28d9a7f5195059859@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: ambari git commit: AMBARI-14866. Increase timeout for server-side tasks (rlevas) Date: Mon, 1 Feb 2016 22:55:43 +0000 (UTC) Repository: ambari Updated Branches: refs/heads/branch-2.2 40395be10 -> 54d4287b8 AMBARI-14866. Increase timeout for server-side tasks (rlevas) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/54d4287b Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/54d4287b Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/54d4287b Branch: refs/heads/branch-2.2 Commit: 54d4287b82ee5671105d6daadecf638459b60da8 Parents: 40395be Author: Robert Levas Authored: Mon Feb 1 17:55:32 2016 -0500 Committer: Robert Levas Committed: Mon Feb 1 17:55:37 2016 -0500 ---------------------------------------------------------------------- ambari-server/conf/unix/ambari.properties | 3 +++ ambari-server/conf/windows/ambari.properties | 3 +++ .../server/configuration/Configuration.java | 20 ++++++++++++++++ .../server/controller/KerberosHelperImpl.java | 16 ++++++------- .../internal/UpgradeResourceProvider.java | 2 +- .../serveraction/ServerActionExecutor.java | 25 +++++++++++++++++--- .../server/configuration/ConfigurationTest.java | 15 ++++++++++++ 7 files changed, 72 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/54d4287b/ambari-server/conf/unix/ambari.properties ---------------------------------------------------------------------- diff --git a/ambari-server/conf/unix/ambari.properties b/ambari-server/conf/unix/ambari.properties index 3290c5a..5022712 100644 --- a/ambari-server/conf/unix/ambari.properties +++ b/ambari-server/conf/unix/ambari.properties @@ -77,6 +77,9 @@ agent.task.timeout=900 # Default timeout in seconds before package installation task is killed agent.package.install.task.timeout=1800 +# Default timeout in seconds before a server-side task is killed +server.task.timeout=1200 + # thread pool maximums client.threadpool.size.max=25 agent.threadpool.size.max=25 http://git-wip-us.apache.org/repos/asf/ambari/blob/54d4287b/ambari-server/conf/windows/ambari.properties ---------------------------------------------------------------------- diff --git a/ambari-server/conf/windows/ambari.properties b/ambari-server/conf/windows/ambari.properties index 570e904..7a50690 100644 --- a/ambari-server/conf/windows/ambari.properties +++ b/ambari-server/conf/windows/ambari.properties @@ -66,6 +66,9 @@ agent.task.timeout=600 # Default timeout in seconds before package installation task is killed agent.package.install.task.timeout=1800 +# Default timeout in seconds before a server-side task is killed +server.task.timeout=1200 + # thread pool maximums client.threadpool.size.max=25 agent.threadpool.size.max=25 http://git-wip-us.apache.org/repos/asf/ambari/blob/54d4287b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java index 32e2ea9..f74073f 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java @@ -346,6 +346,12 @@ public class Configuration { public static final String AGENT_TASK_TIMEOUT_DEFAULT = "900"; public static final String AGENT_PACKAGE_INSTALL_TASK_TIMEOUT_DEFAULT = "1800"; + /** + * Server side task (default) timeout value + */ + public static final String SERVER_TASK_TIMEOUT_KEY = "server.task.timeout"; + public static final String SERVER_TASK_TIMEOUT_DEFAULT = "1200"; + public static final String CUSTOM_ACTION_DEFINITION_KEY = "custom.action.definitions"; public static final String SHARED_RESOURCES_DIR_KEY = "shared.resources.dir"; private static final String CUSTOM_ACTION_DEFINITION_DEF_VALUE = "/var/lib/ambari-server/resources/custom_action_definitions"; @@ -1858,6 +1864,20 @@ public class Configuration { } } + /** + * @return default server-side task timeout in seconds. + */ + public Integer getDefaultServerTaskTimeout() { + String value = properties.getProperty(SERVER_TASK_TIMEOUT_KEY, SERVER_TASK_TIMEOUT_DEFAULT); + if (StringUtils.isNumeric(value)) { + return Integer.parseInt(value); + } else { + LOG.warn("Value of {} ({}) should be a number, falling back to default value ({})", + SERVER_TASK_TIMEOUT_KEY, value, SERVER_TASK_TIMEOUT_DEFAULT); + return Integer.parseInt(SERVER_TASK_TIMEOUT_DEFAULT); + } + } + public String getResourceDirPath() { return properties.getProperty(RESOURCES_DIR_KEY, RESOURCES_DIR_DEFAULT); } http://git-wip-us.apache.org/repos/asf/ambari/blob/54d4287b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java index 852bc59..6ebe568 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java @@ -2413,7 +2413,7 @@ public class KerberosHelperImpl implements KerberosHelper { event, commandParameters, "Preparing Operations", - 1200); + configuration.getDefaultServerTaskTimeout()); RoleGraph roleGraph = roleGraphFactory.createNew(roleCommandOrder); roleGraph.build(stage); @@ -2436,7 +2436,7 @@ public class KerberosHelperImpl implements KerberosHelper { event, commandParameters, "Preparing Operations", - 1200); + configuration.getDefaultServerTaskTimeout()); RoleGraph roleGraph = roleGraphFactory.createNew(roleCommandOrder); roleGraph.build(stage); @@ -2459,7 +2459,7 @@ public class KerberosHelperImpl implements KerberosHelper { event, commandParameters, "Preparing Operations", - 1200); + configuration.getDefaultServerTaskTimeout()); RoleGraph roleGraph = roleGraphFactory.createNew(roleCommandOrder); roleGraph.build(stage); @@ -2482,7 +2482,7 @@ public class KerberosHelperImpl implements KerberosHelper { event, commandParameters, "Create Principals", - 1200); + configuration.getDefaultServerTaskTimeout()); RoleGraph roleGraph = roleGraphFactory.createNew(roleCommandOrder); roleGraph.build(stage); @@ -2505,7 +2505,7 @@ public class KerberosHelperImpl implements KerberosHelper { event, commandParameters, "Destroy Principals", - 1200); + configuration.getDefaultServerTaskTimeout()); RoleGraph roleGraph = roleGraphFactory.createNew(roleCommandOrder); roleGraph.build(stage); @@ -2528,7 +2528,7 @@ public class KerberosHelperImpl implements KerberosHelper { event, commandParameters, "Create Keytabs", - 1200); + configuration.getDefaultServerTaskTimeout()); RoleGraph roleGraph = roleGraphFactory.createNew(roleCommandOrder); roleGraph.build(stage); @@ -2660,7 +2660,7 @@ public class KerberosHelperImpl implements KerberosHelper { event, commandParameters, "Update Service Configurations", - 1200); + configuration.getDefaultServerTaskTimeout()); RoleGraph roleGraph = roleGraphFactory.createNew(roleCommandOrder); roleGraph.build(stage); @@ -2713,7 +2713,7 @@ public class KerberosHelperImpl implements KerberosHelper { event, commandParameters, "Kerberization Clean Up", - 1200); + configuration.getDefaultServerTaskTimeout()); RoleGraph roleGraph = roleGraphFactory.createNew(roleCommandOrder); roleGraph.build(stage); http://git-wip-us.apache.org/repos/asf/ambari/blob/54d4287b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java index f728562..371c611 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java @@ -1500,7 +1500,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider getManagementController().getAuthName(), Role.AMBARI_SERVER_ACTION, RoleCommand.EXECUTE, cluster.getClusterName(), new ServiceComponentHostServerActionEvent(null, System.currentTimeMillis()), commandParams, - itemDetail, null, Integer.valueOf(1200), allowRetry, + itemDetail, null, s_configuration.getDefaultServerTaskTimeout(), allowRetry, context.isComponentFailureAutoSkipped()); request.addStages(Collections.singletonList(stage)); http://git-wip-us.apache.org/repos/asf/ambari/blob/54d4287b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/ServerActionExecutor.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/ServerActionExecutor.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/ServerActionExecutor.java index 00b8a74..20cf5bb 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/ServerActionExecutor.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/ServerActionExecutor.java @@ -35,6 +35,7 @@ import org.apache.ambari.server.actionmanager.HostRoleStatus; import org.apache.ambari.server.actionmanager.Request; import org.apache.ambari.server.agent.CommandReport; import org.apache.ambari.server.agent.ExecutionCommand; +import org.apache.ambari.server.configuration.Configuration; import org.apache.ambari.server.controller.internal.CalculatedStatus; import org.apache.ambari.server.security.authorization.internal.InternalAuthenticationToken; import org.apache.ambari.server.utils.StageUtils; @@ -57,7 +58,7 @@ import org.springframework.security.core.context.SecurityContextHolder; public class ServerActionExecutor { private final static Logger LOG = LoggerFactory.getLogger(ServerActionExecutor.class); - private final static Long EXECUTION_TIMEOUT_MS = 1000L * 60 * 5; + private final static Long DEFAULT_EXECUTION_TIMEOUT_MS = 1000L * 60 * 5; private final static Long POLLING_TIMEOUT_MS = 1000L * 5; /** @@ -67,6 +68,13 @@ public class ServerActionExecutor { private static Injector injector; /** + * The Ambari configuration used to obtain configured details such as the default server-side action + * timeout. + */ + @Inject + private static Configuration configuration; + + /** * Maps request IDs to "blackboards" of shared data. *

* This map is not synchronized, so any access to it should synchronize on @@ -354,13 +362,24 @@ public class ServerActionExecutor { try { timeout = (paramsTimeout == null) ? null - : (Long.parseLong(paramsTimeout) * 1000); // Convert seconds to milliseconds + : (Long.parseLong(paramsTimeout) * 1000L); // Convert seconds to milliseconds } catch (NumberFormatException e) { timeout = null; } + // If a configured timeout value is not set for the command, attempt to get the configured + // default + if (timeout == null) { + Integer defaultTimeoutSeconds = configuration.getDefaultServerTaskTimeout(); + if (defaultTimeoutSeconds != null) { + timeout = defaultTimeoutSeconds * 1000L; // convert seconds to milliseconds + } + } + + // If a timeout value was not determined, return the hard-coded timeout value, else return the + // determined timeout value. return (timeout == null) - ? EXECUTION_TIMEOUT_MS + ? DEFAULT_EXECUTION_TIMEOUT_MS : ((timeout < 0) ? 0 : timeout); } http://git-wip-us.apache.org/repos/asf/ambari/blob/54d4287b/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java b/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java index 7af0167..1f90813 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java @@ -319,6 +319,21 @@ public class ConfigurationTest { @Test + public void testGetDefaultServerTaskTimeout() { + Properties ambariProperties = new Properties(); + Configuration conf = new Configuration(ambariProperties); + + Assert.assertEquals(Integer.valueOf(1200), conf.getDefaultServerTaskTimeout()); + + ambariProperties = new Properties(); + ambariProperties.setProperty(Configuration.SERVER_TASK_TIMEOUT_KEY, "3600"); + + conf = new Configuration(ambariProperties); + + Assert.assertEquals(Integer.valueOf(3600), conf.getDefaultServerTaskTimeout()); + } + + @Test public void testGetLdapServerProperties_WrongManagerPassword() throws Exception { final Properties ambariProperties = new Properties(); ambariProperties.setProperty(Configuration.LDAP_MANAGER_PASSWORD_KEY, "somePassword");