hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From junping...@apache.org
Subject hadoop git commit: YARN-7076. yarn application -list -appTypes is not working. Contributed by Jian He.
Date Tue, 29 Aug 2017 01:27:54 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 e19f004f6 -> f252e1fe2


YARN-7076. yarn application -list -appTypes is not working. Contributed by Jian He.

(cherry picked from commit 312b1fd9da2781da97f8c76fe1262c4d99b9c37f)


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

Branch: refs/heads/branch-2
Commit: f252e1fe2887cc961cf3ad532bfa22d646775fbf
Parents: e19f004
Author: Junping Du <junping_du@apache.org>
Authored: Mon Aug 28 18:26:51 2017 -0700
Committer: Junping Du <junping_du@apache.org>
Committed: Mon Aug 28 18:27:38 2017 -0700

----------------------------------------------------------------------
 .../server/resourcemanager/ClientRMService.java | 30 +++++++++++---------
 .../resourcemanager/webapp/RMWebServices.java   |  2 +-
 .../resourcemanager/TestClientRMService.java    | 14 ++++++++-
 .../webapp/TestRMWebServices.java               |  5 ++--
 4 files changed, 33 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/f252e1fe/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java
index aeacd2e..59c5b95 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java
@@ -29,6 +29,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.EnumSet;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -748,21 +749,14 @@ public class ClientRMService extends AbstractService implements
     response.setClusterMetrics(ymetrics);
     return response;
   }
-  
-  @Override
-  public GetApplicationsResponse getApplications(
-      GetApplicationsRequest request) throws YarnException {
-    return getApplications(request, true);
-  }
 
   /**
    * Get applications matching the {@link GetApplicationsRequest}. If
    * caseSensitive is set to false, applicationTypes in
    * GetApplicationRequest are expected to be in all-lowercase
    */
-  @Private
-  public GetApplicationsResponse getApplications(
-      GetApplicationsRequest request, boolean caseSensitive)
+  @Override
+  public GetApplicationsResponse getApplications(GetApplicationsRequest request)
       throws YarnException {
     UserGroupInformation callerUGI;
     try {
@@ -772,7 +766,7 @@ public class ClientRMService extends AbstractService implements
       throw RPCUtil.getRemoteException(ie);
     }
 
-    Set<String> applicationTypes = request.getApplicationTypes();
+    Set<String> applicationTypes = getLowerCasedAppTypes(request);
     EnumSet<YarnApplicationState> applicationStates =
         request.getApplicationStates();
     Set<String> users = request.getUsers();
@@ -836,9 +830,8 @@ public class ClientRMService extends AbstractService implements
       }
 
       if (applicationTypes != null && !applicationTypes.isEmpty()) {
-        String appTypeToMatch = caseSensitive
-            ? application.getApplicationType()
-            : StringUtils.toLowerCase(application.getApplicationType());
+        String appTypeToMatch =
+            StringUtils.toLowerCase(application.getApplicationType());
         if (!applicationTypes.contains(appTypeToMatch)) {
           continue;
         }
@@ -898,6 +891,17 @@ public class ClientRMService extends AbstractService implements
     return response;
   }
 
+  private Set<String> getLowerCasedAppTypes(GetApplicationsRequest request) {
+    Set<String> applicationTypes = new HashSet<>();
+    if (request.getApplicationTypes() != null && !request.getApplicationTypes()
+        .isEmpty()) {
+      for (String type : request.getApplicationTypes()) {
+        applicationTypes.add(StringUtils.toLowerCase(type));
+      }
+    }
+    return applicationTypes;
+  }
+
   @Override
   public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request)
       throws YarnException {

http://git-wip-us.apache.org/repos/asf/hadoop/blob/f252e1fe/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebServices.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebServices.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebServices.java
index 11b8515..95a3ae7 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebServices.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebServices.java
@@ -559,7 +559,7 @@ public class RMWebServices extends WebServices implements RMWebServiceProtocol
{
 
     List<ApplicationReport> appReports = null;
     try {
-      appReports = rm.getClientRMService().getApplications(request, false)
+      appReports = rm.getClientRMService().getApplications(request)
           .getApplicationList();
     } catch (YarnException e) {
       LOG.error("Unable to retrieve apps from ClientRMService", e);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/f252e1fe/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java
index c2e7094..e7ecbd3 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java
@@ -733,6 +733,18 @@ public class TestClientRMService {
     Assert.assertEquals(appId2,
         getAllApplicationsResponse.getApplicationList()
             .get(0).getApplicationId());
+
+    // Test query with uppercase appType also works
+    appTypes = new HashSet<String>();
+    appTypes.add("MATCHTYPE");
+    getAllAppsRequest = GetApplicationsRequest.newInstance(appTypes);
+    getAllApplicationsResponse =
+        rmService.getApplications(getAllAppsRequest);
+    Assert.assertEquals(1,
+        getAllApplicationsResponse.getApplicationList().size());
+    Assert.assertEquals(appId2,
+        getAllApplicationsResponse.getApplicationList()
+            .get(0).getApplicationId());
   }
 
   @Test
@@ -822,7 +834,7 @@ public class TestClientRMService {
     assertEquals("Incorrect number of applications in queue", 2,
         rmService.getApplications(request).getApplicationList().size());
     assertEquals("Incorrect number of applications in queue", 2,
-        rmService.getApplications(request, false).getApplicationList().size());
+        rmService.getApplications(request).getApplicationList().size());
 
     queueSet.add(queues[1]);
     assertEquals("Incorrect number of applications in queue", 3,

http://git-wip-us.apache.org/repos/asf/hadoop/blob/f252e1fe/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java
index 7ec62a0..cc8fda6 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java
@@ -21,7 +21,6 @@ package org.apache.hadoop.yarn.server.resourcemanager.webapp;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import static org.mockito.Matchers.anyBoolean;
 import static org.mockito.Matchers.isA;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -634,8 +633,8 @@ public class TestRMWebServices extends JerseyTestBase {
     when(mockAppsResponse.getApplicationList())
       .thenReturn(Arrays.asList(new ApplicationReport[] { mockReport }));
     ClientRMService mockClientSvc = mock(ClientRMService.class);
-    when(mockClientSvc.getApplications(isA(GetApplicationsRequest.class),
-        anyBoolean())).thenReturn(mockAppsResponse);
+    when(mockClientSvc.getApplications(isA(GetApplicationsRequest.class)))
+        .thenReturn(mockAppsResponse);
     ResourceManager mockRM = mock(ResourceManager.class);
     RMContextImpl rmContext = new RMContextImpl(null, null, null, null, null,
         null, null, null, null, null);


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message