ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vbrodets...@apache.org
Subject ambari git commit: AMBARI-13274. Define a new API to refresh HDP.repo files using the provided repo baseurl. Fix hosts check.(vbrodetskyi)
Date Fri, 09 Oct 2015 09:45:40 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 6eb636211 -> 946404922


AMBARI-13274. Define a new API to refresh HDP.repo files using the provided repo baseurl.
Fix hosts check.(vbrodetskyi)


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

Branch: refs/heads/trunk
Commit: 9464049229afc83fe33dc39eeb75980b56d71f89
Parents: 6eb6362
Author: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Authored: Fri Oct 9 12:44:38 2015 +0300
Committer: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Committed: Fri Oct 9 12:44:38 2015 +0300

----------------------------------------------------------------------
 .../controller/AmbariActionExecutionHelper.java | 22 +++++++++++++-------
 .../AmbariManagementControllerTest.java         |  6 +++---
 2 files changed, 17 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/94640492/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 a379a75..0f76808 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
@@ -202,14 +202,20 @@ public class AmbariActionExecutionHelper {
       }
     }
 
-    // decided to hide this part of code, to have ability, by default execute custom action
on all hosts(according to targetType in definition)
-    //if (TargetHostType.SPECIFIC.equals(actionDef.getTargetType())
-    //  || (targetService.isEmpty() && targetComponent.isEmpty())) {
-    //  if (resourceFilter == null || resourceFilter.getHostNames().size() == 0) {
-    //    throw new AmbariException("Action " + actionRequest.getActionName() + " requires
explicit target host(s)" +
-    //      " that is not provided.");
-    //  }
-    //}
+    TargetHostType targetHostType = actionDef.getTargetType();
+
+    if (TargetHostType.SPECIFIC.equals(actionDef.getTargetType())
+      || (targetService.isEmpty() && targetComponent.isEmpty())) {
+      if ((resourceFilter == null || resourceFilter.getHostNames().size() == 0) &&
!isTargetHostTypeAllowsEmptyHosts(targetHostType)) {
+        throw new AmbariException("Action " + actionRequest.getActionName() + " requires
explicit target host(s)" +
+          " that is not provided.");
+      }
+    }
+  }
+
+  private boolean isTargetHostTypeAllowsEmptyHosts(TargetHostType targetHostType) {
+    return targetHostType.equals(TargetHostType.ALL) || targetHostType.equals(TargetHostType.ANY)
+            || targetHostType.equals(TargetHostType.MAJORITY);
   }
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/94640492/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 0a86fe3..824a9d1 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
@@ -4531,9 +4531,9 @@ public class AmbariManagementControllerTest {
         "Action a1 requires input 'dirName' that is not provided");
 
     params.put("dirName", "dirName");
-    //actionRequest = new ExecuteActionRequest("c1", null, "a1", null, null, params, false);
-    //expectActionCreationErrorWithMessage(actionRequest, requestProperties,
-    //    "Action a1 requires explicit target host(s)");
+    actionRequest = new ExecuteActionRequest("c1", null, "a1", null, null, params, false);
+    expectActionCreationErrorWithMessage(actionRequest, requestProperties,
+        "Action a1 requires explicit target host(s)");
 
     resourceFilters.clear();
     resourceFilter = new RequestResourceFilter("HIVE", null, null);


Mime
View raw message