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:43:25 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 4dadeb9fe -> 464773614


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/46477361
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/46477361
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/46477361

Branch: refs/heads/branch-2.1
Commit: 46477361446ce9f716f8fd3b22ff084a8afc6697
Parents: 4dadeb9
Author: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Authored: Fri Oct 9 12:43:07 2015 +0300
Committer: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Committed: Fri Oct 9 12:43:07 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/46477361/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/46477361/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 fa485e3..79f4b9f 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