Class RouterWebServiceUtil

java.lang.Object
org.apache.hadoop.yarn.server.router.webapp.RouterWebServiceUtil

public final class RouterWebServiceUtil extends Object
The Router webservice util class.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected static javax.ws.rs.client.Client
    createJerseyClient(org.apache.hadoop.conf.Configuration conf)
    Create a Jersey client instance.
    static void
    createKerberosUserGroupInformation(javax.servlet.http.HttpServletRequest hsr)
     
    static org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodesInfo
    deleteDuplicateNodesInfo(ArrayList<org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeInfo> nodes)
    Deletes all the duplicate NodeInfo by discarding the old instances.
    static org.apache.hadoop.security.token.Token<org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier>
    extractToken(String encodedToken)
    Parse Token data.
    static org.apache.hadoop.security.token.Token<org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier>
    extractToken(javax.servlet.http.HttpServletRequest request)
     
    static String
     
    protected static <T> T
    genericForward(String webApp, javax.servlet.http.HttpServletRequest hsr, Class<T> returnType, HTTPMethods method, String targetPath, Object formParam, Map<String,String[]> additionalParam, org.apache.hadoop.conf.Configuration conf, javax.ws.rs.client.Client client)
    Creates and performs a REST call to a specific WebService.
    static org.apache.hadoop.security.UserGroupInformation
    getKerberosUserGroupInformation(org.apache.hadoop.conf.Configuration conf, javax.servlet.http.HttpServletRequest request)
    Get Kerberos UserGroupInformation.
    protected static <T> String
    getMediaTypeFromHttpServletRequest(javax.servlet.http.HttpServletRequest request, Class<T> returnType)
    Extract from HttpServletRequest the MediaType in output.
    static void
    initForWritableEndpoints(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.security.UserGroupInformation callerUGI)
    initForWritableEndpoints does the init and acls verification for all writable REST end points.
    static org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationStatisticsInfo
    mergeApplicationStatisticsInfo(Collection<org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationStatisticsInfo> appStatistics)
     
    static org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppsInfo
    mergeAppsInfo(ArrayList<org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppInfo> appsInfo, boolean returnPartialResult)
    Merges a list of AppInfo grouping by ApplicationId.
    static void
    mergeMetrics(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ClusterMetricsInfo metrics, org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ClusterMetricsInfo metricsResponse)
    Adds all the values from the second ClusterMetricsInfo to the first one.
    static org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeLabelsInfo
    mergeNodeLabelsInfo(Map<org.apache.hadoop.yarn.server.federation.store.records.SubClusterInfo,org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeLabelsInfo> paramMap)
     
    static org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeToLabelsInfo
    mergeNodeToLabels(Map<org.apache.hadoop.yarn.server.federation.store.records.SubClusterInfo,org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeToLabelsInfo> nodeToLabelsInfoMap)
     
    static void
    retrieveException(javax.ws.rs.core.Response response)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • genericForward

      protected static <T> T genericForward(String webApp, javax.servlet.http.HttpServletRequest hsr, Class<T> returnType, HTTPMethods method, String targetPath, Object formParam, Map<String,String[]> additionalParam, org.apache.hadoop.conf.Configuration conf, javax.ws.rs.client.Client client)
      Creates and performs a REST call to a specific WebService.
      Type Parameters:
      T - Type of return object.
      Parameters:
      webApp - the address of the remote webapp
      hsr - the servlet request
      returnType - the return type of the REST call
      method - the HTTP method of the REST call
      targetPath - additional path to add to the webapp address
      formParam - the form parameters as input for a specific REST call
      additionalParam - the query parameters as input for a specific REST call in case the call has no servlet request
      conf - configuration.
      client - same client used to reduce number of clients created
      Returns:
      the retrieved entity from the REST call
    • retrieveException

      public static void retrieveException(javax.ws.rs.core.Response response)
    • mergeAppsInfo

      public static org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppsInfo mergeAppsInfo(ArrayList<org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppInfo> appsInfo, boolean returnPartialResult)
      Merges a list of AppInfo grouping by ApplicationId. Our current policy is to merge the application reports from the reachable SubClusters. Via configuration parameter, we decide whether to return applications for which the primary AM is missing or to omit them.
      Parameters:
      appsInfo - a list of AppInfo to merge
      returnPartialResult - if the merge AppsInfo should contain partial result or not
      Returns:
      the merged AppsInfo
    • createJerseyClient

      protected static javax.ws.rs.client.Client createJerseyClient(org.apache.hadoop.conf.Configuration conf)
      Create a Jersey client instance.
      Parameters:
      conf - Configuration
      Returns:
      a jersey client
    • deleteDuplicateNodesInfo

      public static org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodesInfo deleteDuplicateNodesInfo(ArrayList<org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeInfo> nodes)
      Deletes all the duplicate NodeInfo by discarding the old instances.
      Parameters:
      nodes - a list of NodeInfo to check for duplicates
      Returns:
      a NodesInfo that contains a list of NodeInfos without duplicates
    • mergeMetrics

      public static void mergeMetrics(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ClusterMetricsInfo metrics, org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ClusterMetricsInfo metricsResponse)
      Adds all the values from the second ClusterMetricsInfo to the first one.
      Parameters:
      metrics - the ClusterMetricsInfo we want to update
      metricsResponse - the ClusterMetricsInfo we want to add to the first param
    • getMediaTypeFromHttpServletRequest

      protected static <T> String getMediaTypeFromHttpServletRequest(javax.servlet.http.HttpServletRequest request, Class<T> returnType)
      Extract from HttpServletRequest the MediaType in output.
      Type Parameters:
      T - Generic Type T.
      Parameters:
      request - the servlet request.
      returnType - the return type of the REST call.
      Returns:
      MediaType.
    • mergeNodeToLabels

      public static org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeToLabelsInfo mergeNodeToLabels(Map<org.apache.hadoop.yarn.server.federation.store.records.SubClusterInfo,org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeToLabelsInfo> nodeToLabelsInfoMap)
    • mergeApplicationStatisticsInfo

      public static org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationStatisticsInfo mergeApplicationStatisticsInfo(Collection<org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationStatisticsInfo> appStatistics)
    • mergeNodeLabelsInfo

      public static org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeLabelsInfo mergeNodeLabelsInfo(Map<org.apache.hadoop.yarn.server.federation.store.records.SubClusterInfo,org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeLabelsInfo> paramMap)
    • initForWritableEndpoints

      public static void initForWritableEndpoints(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.security.UserGroupInformation callerUGI) throws org.apache.hadoop.security.authorize.AuthorizationException
      initForWritableEndpoints does the init and acls verification for all writable REST end points.
      Parameters:
      conf - Configuration.
      callerUGI - remote caller who initiated the request.
      Throws:
      org.apache.hadoop.security.authorize.AuthorizationException - in case of no access to perfom this op.
    • createKerberosUserGroupInformation

      public static void createKerberosUserGroupInformation(javax.servlet.http.HttpServletRequest hsr) throws org.apache.hadoop.yarn.exceptions.YarnException
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException
    • extractToken

      public static org.apache.hadoop.security.token.Token<org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier> extractToken(String encodedToken)
      Parse Token data.
      Parameters:
      encodedToken - tokenData
      Returns:
      RMDelegationTokenIdentifier.
    • extractToken

      public static org.apache.hadoop.security.token.Token<org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier> extractToken(javax.servlet.http.HttpServletRequest request)
    • getKerberosUserGroupInformation

      public static org.apache.hadoop.security.UserGroupInformation getKerberosUserGroupInformation(org.apache.hadoop.conf.Configuration conf, javax.servlet.http.HttpServletRequest request) throws org.apache.hadoop.security.authorize.AuthorizationException, org.apache.hadoop.yarn.exceptions.YarnException
      Get Kerberos UserGroupInformation. Parse ugi from hsr and set kerberos authentication attributes.
      Parameters:
      conf - Configuration.
      request - the servlet request.
      Returns:
      UserGroupInformation.
      Throws:
      org.apache.hadoop.security.authorize.AuthorizationException - if Kerberos auth failed.
      org.apache.hadoop.yarn.exceptions.YarnException - If Authentication Type verification fails.
    • generateWebTitle

      public static String generateWebTitle(String title, String msg)