ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smoha...@apache.org
Subject ambari git commit: AMBARI-12233. Custom actions do not allow max time out higher than 10 minutes (smohanty)
Date Wed, 01 Jul 2015 20:03:49 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 1148d12da -> bc848ae1f


AMBARI-12233. Custom actions do not allow max time out higher than 10 minutes (smohanty)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/bc848ae1
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/bc848ae1
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/bc848ae1

Branch: refs/heads/trunk
Commit: bc848ae1f5835b184e3751d5a7d0bac6a2a40378
Parents: 1148d12
Author: Sumit Mohanty <smohanty@hortonworks.com>
Authored: Wed Jul 1 12:36:35 2015 -0700
Committer: Sumit Mohanty <smohanty@hortonworks.com>
Committed: Wed Jul 1 12:36:35 2015 -0700

----------------------------------------------------------------------
 .../server/controller/AmbariActionExecutionHelper.java    | 10 +++++++++-
 .../server/customactions/ActionDefinitionManager.java     |  2 +-
 .../server/controller/AmbariManagementControllerTest.java |  6 ++++--
 3 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/bc848ae1/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
index 1e1001c..ee8fd32 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
@@ -38,6 +38,7 @@ import org.apache.ambari.server.actionmanager.Stage;
 import org.apache.ambari.server.actionmanager.TargetHostType;
 import org.apache.ambari.server.agent.ExecutionCommand;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
+import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.internal.RequestResourceFilter;
 import org.apache.ambari.server.customactions.ActionDefinition;
 import org.apache.ambari.server.state.Cluster;
@@ -75,6 +76,8 @@ public class AmbariActionExecutionHelper {
   private MaintenanceStateHelper maintenanceStateHelper;
   @Inject
   private ConfigHelper configHelper;
+  @Inject
+  private Configuration configs;
 
   /**
    * Validates the request to execute an action.
@@ -349,7 +352,12 @@ public class AmbariActionExecutionHelper {
       }
 
       Map<String, String> commandParams = new TreeMap<String, String>();
-      commandParams.put(COMMAND_TIMEOUT, actionContext.getTimeout().toString());
+      int maxTaskTimeout = Integer.parseInt(configs.getDefaultAgentTaskTimeout(false));
+      if(maxTaskTimeout < actionContext.getTimeout()) {
+        commandParams.put(COMMAND_TIMEOUT, Integer.toString(maxTaskTimeout));
+      } else {
+        commandParams.put(COMMAND_TIMEOUT, actionContext.getTimeout().toString());
+      }
       commandParams.put(SCRIPT, actionName + ".py");
       commandParams.put(SCRIPT_TYPE, TYPE_PYTHON);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/bc848ae1/ambari-server/src/main/java/org/apache/ambari/server/customactions/ActionDefinitionManager.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/customactions/ActionDefinitionManager.java
b/ambari-server/src/main/java/org/apache/ambari/server/customactions/ActionDefinitionManager.java
index e058ce7..97aa8a0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/customactions/ActionDefinitionManager.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/customactions/ActionDefinitionManager.java
@@ -43,7 +43,7 @@ public class ActionDefinitionManager {
       .getLogger(ActionDefinitionManager.class);
   private static final Map<Class<?>, JAXBContext> _jaxbContexts =
       new HashMap<Class<?>, JAXBContext>();
-  private static final Short MAX_TIMEOUT = 600;
+  private static final Short MAX_TIMEOUT = Short.MAX_VALUE-1;
 
   static {
     try {

http://git-wip-us.apache.org/repos/asf/ambari/blob/bc848ae1/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index 5ee2016..46dbb8e 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -4161,7 +4161,7 @@ public class AmbariManagementControllerTest {
 
     controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
         "a2", ActionType.SYSTEM, "", "HDFS", "DATANODE", "Does file exist",
-        TargetHostType.ALL, Short.valueOf("100")));
+        TargetHostType.ALL, Short.valueOf("1000")));
 
     Map<String, String> params = new HashMap<String, String>() {{
       put("test", "test");
@@ -4200,6 +4200,7 @@ public class AmbariManagementControllerTest {
     Assert.assertEquals("HDFS", cmd.getServiceName());
     Assert.assertEquals("DATANODE", cmd.getComponentName());
     Assert.assertNotNull(hostParametersStage.get("jdk_location"));
+    Assert.assertEquals("100", cmd.getCommandParams().get("command_timeout"));
     Assert.assertEquals(requestProperties.get(REQUEST_CONTEXT_PROPERTY), response.getRequestContext());
 
     resourceFilters.clear();
@@ -6388,7 +6389,7 @@ public class AmbariManagementControllerTest {
 
     controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
       "a1", ActionType.SYSTEM, "", "HDFS", "", "Some custom action.",
-      TargetHostType.ALL, Short.valueOf("100")));
+      TargetHostType.ALL, Short.valueOf("10010")));
 
     Map<String, String> params = new HashMap<String, String>() {{
       put("test", "test");
@@ -6432,6 +6433,7 @@ public class AmbariManagementControllerTest {
     Assert.assertNotNull(nnCommand);
     ExecutionCommand cmd = nnCommand.getExecutionCommandWrapper().getExecutionCommand();
     Assert.assertEquals("a1", cmd.getRole());
+    Assert.assertEquals("900", cmd.getCommandParams().get("command_timeout"));
     Type type = new TypeToken<Map<String, String>>(){}.getType();
     for (Stage stage : actionDB.getAllStages(response.getRequestId())){
       Map<String, String> commandParamsStage = StageUtils.getGson().fromJson(stage.getCommandParamsStage(),
type);


Mime
View raw message