From ce2847e79441881eeca888b581c7be2cc3ac74f4 Mon Sep 17 00:00:00 2001 From: Rohith Sharma K S Date: Thu, 17 Nov 2016 08:48:35 +0530 Subject: [PATCH] YARN-5870. Expose getApplications API in YarnClient with GetApplicationsRequest parameter. Contributed by Jian He. --- .../hadoop/yarn/client/api/YarnClient.java | 26 +++++++++++++++++++ .../yarn/client/api/impl/YarnClientImpl.java | 7 +++++ 2 files changed, 33 insertions(+) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/YarnClient.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/YarnClient.java index 4cac2c24da..4e0ba2c792 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/YarnClient.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/YarnClient.java @@ -32,6 +32,8 @@ import org.apache.hadoop.io.Text; import org.apache.hadoop.service.AbstractService; import org.apache.hadoop.yarn.api.ApplicationClientProtocol; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest; +import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationRequest; import org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationResponse; import org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteRequest; import org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteResponse; @@ -377,6 +379,30 @@ public abstract List getApplications(Set queues, EnumSet applicationStates) throws YarnException, IOException; + /** + *

+ * Get a list of ApplicationReports that match the given + * {@link GetApplicationsRequest}. + *

+ * + *

+ * If the user does not have VIEW_APP access for an application + * then the corresponding report will be filtered as described in + * {@link #getApplicationReport(ApplicationId)}. + *

+ * + * @param request the request object to get the list of applications. + * @return The list of ApplicationReports that match the request + * @throws YarnException Exception specific to YARN. + * @throws IOException Exception mostly related to connection errors. + */ + public List getApplications(GetApplicationsRequest request) + throws YarnException, IOException { + throw new UnsupportedOperationException( + "The sub-class extending " + YarnClient.class.getName() + + " is expected to implement this !"); + } + /** *

* Get metrics ({@link YarnClusterMetrics}) about the cluster. diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/YarnClientImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/YarnClientImpl.java index 80e453fccf..57f50c4677 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/YarnClientImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/YarnClientImpl.java @@ -543,6 +543,13 @@ public List getApplications(Set queues, return response.getApplicationList(); } + @Override + public List getApplications( + GetApplicationsRequest request) throws YarnException, IOException { + GetApplicationsResponse response = rmClient.getApplications(request); + return response.getApplicationList(); + } + @Override public YarnClusterMetrics getYarnClusterMetrics() throws YarnException, IOException {