YARN-5870. Expose getApplications API in YarnClient with GetApplicationsRequest parameter. Contributed by Jian He.

This commit is contained in:
Rohith Sharma K S 2016-11-17 08:48:35 +05:30
parent 04a024b683
commit ce2847e794
2 changed files with 33 additions and 0 deletions

View File

@ -32,6 +32,8 @@ import org.apache.hadoop.classification.InterfaceStability.Unstable;
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 class YarnClient extends AbstractService {
EnumSet<YarnApplicationState> applicationStates) throws YarnException,
IOException;
/**
* <p>
* Get a list of ApplicationReports that match the given
* {@link GetApplicationsRequest}.
*</p>
*
* <p>
* If the user does not have <code>VIEW_APP</code> access for an application
* then the corresponding report will be filtered as described in
* {@link #getApplicationReport(ApplicationId)}.
* </p>
*
* @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<ApplicationReport> getApplications(GetApplicationsRequest request)
throws YarnException, IOException {
throw new UnsupportedOperationException(
"The sub-class extending " + YarnClient.class.getName()
+ " is expected to implement this !");
}
/**
* <p>
* Get metrics ({@link YarnClusterMetrics}) about the cluster.

View File

@ -543,6 +543,13 @@ public class YarnClientImpl extends YarnClient {
return response.getApplicationList();
}
@Override
public List<ApplicationReport> getApplications(
GetApplicationsRequest request) throws YarnException, IOException {
GetApplicationsResponse response = rmClient.getApplications(request);
return response.getApplicationList();
}
@Override
public YarnClusterMetrics getYarnClusterMetrics() throws YarnException,
IOException {