ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [01/25] ambari git commit: AMBARI-21551 Restart due to Stale configurations leads to an internal system exception (dsen)
Date Mon, 31 Jul 2017 14:10:16 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-feature-AMBARI-21450 68cffbf39 -> 2f873b009


AMBARI-21551 Restart due to Stale configurations leads to an internal system exception (dsen)


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

Branch: refs/heads/branch-feature-AMBARI-21450
Commit: b38901bd9133c469a604fd8e6b8916e4b83d755a
Parents: cfedbdf
Author: Dmytro Sen <dsen@apache.org>
Authored: Tue Jul 25 18:28:28 2017 +0300
Committer: Dmytro Sen <dsen@apache.org>
Committed: Tue Jul 25 18:28:28 2017 +0300

----------------------------------------------------------------------
 .../controller/AmbariCustomCommandExecutionHelper.java      | 8 ++++++++
 .../server/controller/internal/RequestResourceProvider.java | 4 +++-
 .../controller/internal/RequestResourceProviderTest.java    | 9 ++++++---
 3 files changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b38901bd/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
index 9bd38fc..ee423e2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
@@ -43,6 +43,7 @@ import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.STACK_NAM
 import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.STACK_VERSION;
 import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.USER_GROUPS;
 import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.USER_LIST;
+import static org.apache.ambari.server.controller.internal.RequestResourceProvider.HAS_RESOURCE_FILTERS;
 
 import java.text.MessageFormat;
 import java.util.ArrayList;
@@ -1044,6 +1045,13 @@ public class AmbariCustomCommandExecutionHelper {
 
     List<RequestResourceFilter> resourceFilters = actionRequest.getResourceFilters();
 
+    if (resourceFilters != null && resourceFilters.isEmpty() &&
+            actionRequest.getParameters().containsKey(HAS_RESOURCE_FILTERS) &&
+            actionRequest.getParameters().get(HAS_RESOURCE_FILTERS).equalsIgnoreCase("true"))
{
+      LOG.warn("Couldn't find any resource that satisfies given resource filters");
+      return;
+    }
+
     if (resourceFilters == null || resourceFilters.isEmpty()) {
       throw new AmbariException("Command execution cannot proceed without a " +
         "resource filter.");

http://git-wip-us.apache.org/repos/asf/ambari/blob/b38901bd/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
index b4b26ce..5a0549d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
@@ -128,6 +128,7 @@ public class RequestResourceProvider extends AbstractControllerResourceProvider
   protected static final String ACTION_ID = "action";
   protected static final String INPUTS_ID = "parameters";
   protected static final String EXLUSIVE_ID = "exclusive";
+  public static final String HAS_RESOURCE_FILTERS = "HAS_RESOURCE_FILTERS";
   private static Set<String> pkPropertyIds =
       new HashSet<String>(Arrays.asList(new String[]{
         REQUEST_ID_PROPERTY_ID}));
@@ -442,12 +443,14 @@ public class RequestResourceProvider extends AbstractControllerResourceProvider
     List<RequestResourceFilter> resourceFilterList = null;
     Set<Map<String, Object>> resourceFilters;
 
+    Map<String, String> params = new HashMap<String, String>();
     Object resourceFilterObj = propertyMap.get(REQUEST_RESOURCE_FILTER_ID);
     if (resourceFilterObj != null && resourceFilterObj instanceof HashSet) {
       resourceFilters = (HashSet<Map<String, Object>>) resourceFilterObj;
       resourceFilterList = new ArrayList<RequestResourceFilter>();
 
       for (Map<String, Object> resourceMap : resourceFilters) {
+        params.put(HAS_RESOURCE_FILTERS, "true");
         resourceFilterList.addAll(parseRequestResourceFilter(resourceMap,
           (String) propertyMap.get(REQUEST_CLUSTER_NAME_PROPERTY_ID)));
       }
@@ -459,7 +462,6 @@ public class RequestResourceProvider extends AbstractControllerResourceProvider
       operationLevel = new RequestOperationLevel(requestInfoProperties);
     }
 
-    Map<String, String> params = new HashMap<String, String>();
     String keyPrefix = INPUTS_ID + "/";
     for (String key : requestInfoProperties.keySet()) {
       if (key.startsWith(keyPrefix)) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/b38901bd/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java
index 590df04a..c519323 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java
@@ -1032,7 +1032,7 @@ public class RequestResourceProviderTest {
     Assert.assertEquals(null, capturedResourceFilter.getComponentName());
     Assert.assertNotNull(capturedResourceFilter.getHostNames());
     Assert.assertEquals(0, capturedResourceFilter.getHostNames().size());
-    Assert.assertEquals(0, actionRequest.getValue().getParameters().size());
+    Assert.assertEquals(1, actionRequest.getValue().getParameters().size());
   }
 
   @Test
@@ -1152,7 +1152,7 @@ public class RequestResourceProviderTest {
     Assert.assertEquals(null, capturedResourceFilter.getComponentName());
     Assert.assertEquals(3, capturedResourceFilter.getHostNames().size());
     Assert.assertArrayEquals(expectedHosts, capturedResourceFilter.getHostNames().toArray());
-    Assert.assertEquals(2, capturedRequest.getParameters().size());
+    Assert.assertEquals(3, capturedRequest.getParameters().size());
     for(String key : expectedParams.keySet()) {
       Assert.assertEquals(expectedParams.get(key), capturedRequest.getParameters().get(key));
     }
@@ -1239,6 +1239,9 @@ public class RequestResourceProviderTest {
     }
     Assert.assertNotNull(propertyIdToAssert);
     Assert.assertEquals("true", propertyValueToAssert);
+    Assert.assertTrue(capturedRequest.getResourceFilters().isEmpty());
+    Assert.assertEquals(1, capturedRequest.getParameters().size());
+    Assert.assertEquals("true", capturedRequest.getParameters().get(RequestResourceProvider.HAS_RESOURCE_FILTERS));
   }
 
   @Test
@@ -1548,7 +1551,7 @@ public class RequestResourceProviderTest {
     Assert.assertEquals(null, capturedResourceFilter.getComponentName());
     Assert.assertNotNull(capturedResourceFilter.getHostNames());
     Assert.assertEquals(2, capturedResourceFilter.getHostNames().size());
-    Assert.assertEquals(0, actionRequest.getValue().getParameters().size());
+    Assert.assertEquals(1, actionRequest.getValue().getParameters().size());
   }
 
   @Test


Mime
View raw message