Class ApiServiceClient

java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.service.CompositeService
org.apache.hadoop.yarn.client.api.AppAdminClient
org.apache.hadoop.yarn.service.client.ApiServiceClient
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.hadoop.service.Service

public class ApiServiceClient extends org.apache.hadoop.yarn.client.api.AppAdminClient
The rest API client for users to manage services on YARN.
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.apache.hadoop.service.CompositeService

    org.apache.hadoop.service.CompositeService.CompositeServiceShutdownHook

    Nested classes/interfaces inherited from interface org.apache.hadoop.service.Service

    org.apache.hadoop.service.Service.STATE
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.apache.hadoop.yarn.client.api.YarnClient
     

    Fields inherited from class org.apache.hadoop.yarn.client.api.AppAdminClient

    DEFAULT_CLASS_NAME, DEFAULT_TYPE, UNIT_TEST_CLASS_NAME, UNIT_TEST_TYPE, YARN_APP_ADMIN_CLIENT_PREFIX

    Fields inherited from class org.apache.hadoop.service.CompositeService

    STOP_ONLY_STARTED_SERVICES
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    ApiServiceClient(org.apache.hadoop.conf.Configuration c)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    int
    actionCleanUp(String appName, String userName)
     
    int
    actionDecommissionInstances(String appName, List<String> componentInstances)
     
    int
    Decommission a YARN service.
    int
    actionFlex(String appName, Map<String,String> componentCounts)
    Change number of containers associated with a service.
    int
    actionLaunch(String fileName, String appName, Long lifetime, String queue)
    Launch YARN service application.
    int
    actionSave(String fileName, String appName, Long lifetime, String queue)
    Save Service configuration.
    int
    Start YARN service application.
    int
    actionStop(String appName)
    Stop YARN service application.
    int
    actionUpgradeComponents(String appName, List<String> components)
     
    int
     
    int
    actionUpgradeInstances(String appName, List<String> compInstances)
     
    int
    enableFastLaunch(String destinationFolder)
     
    javax.ws.rs.client.Invocation.Builder
     
    javax.ws.rs.client.Invocation.Builder
    getApiClient(String requestPath)
    Setup API service web request.
    getInstances(String appName, List<String> components, String version, List<String> containerStates)
     
    Compute active resource manager API service location.
    getStatusString(String appIdOrName)
    Retrieve Service Status through REST API.
    int
    initiateUpgrade(String appName, String fileName, boolean autoFinalize)
     
    org.apache.hadoop.yarn.service.api.records.Service
    loadAppJsonFromLocalFS(String fileName, String serviceName, Long lifetime, String queue)
    Utility method to load Service json from disk or from YARN examples.
    protected void
    serviceInit(org.apache.hadoop.conf.Configuration configuration)
     

    Methods inherited from class org.apache.hadoop.yarn.client.api.AppAdminClient

    createAppAdminClient

    Methods inherited from class org.apache.hadoop.service.CompositeService

    addIfService, addService, getServices, removeService, serviceStart, serviceStop

    Methods inherited from class org.apache.hadoop.service.AbstractService

    close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStop

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • yarnClient

      protected org.apache.hadoop.yarn.client.api.YarnClient yarnClient
  • Constructor Details

    • ApiServiceClient

      public ApiServiceClient()
    • ApiServiceClient

      public ApiServiceClient(org.apache.hadoop.conf.Configuration c) throws Exception
      Throws:
      Exception
  • Method Details

    • serviceInit

      protected void serviceInit(org.apache.hadoop.conf.Configuration configuration) throws Exception
      Overrides:
      serviceInit in class org.apache.hadoop.service.CompositeService
      Throws:
      Exception
    • getServicePath

      public String getServicePath(String appName) throws IOException
      Compute active resource manager API service location.
      Parameters:
      appName - - YARN service name
      Returns:
      URI to API Service
      Throws:
      IOException
    • getApiClient

      public javax.ws.rs.client.Invocation.Builder getApiClient() throws IOException
      Throws:
      IOException
    • getApiClient

      public javax.ws.rs.client.Invocation.Builder getApiClient(String requestPath) throws IOException
      Setup API service web request.
      Parameters:
      requestPath -
      Returns:
      Throws:
      IOException
    • loadAppJsonFromLocalFS

      public org.apache.hadoop.yarn.service.api.records.Service loadAppJsonFromLocalFS(String fileName, String serviceName, Long lifetime, String queue) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException
      Utility method to load Service json from disk or from YARN examples.
      Parameters:
      fileName - - path to yarnfile
      serviceName - - YARN Service Name
      lifetime - - application lifetime
      queue - - Queue to submit application
      Returns:
      Throws:
      IOException
      org.apache.hadoop.yarn.exceptions.YarnException
    • actionLaunch

      public int actionLaunch(String fileName, String appName, Long lifetime, String queue) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException
      Launch YARN service application.
      Specified by:
      actionLaunch in class org.apache.hadoop.yarn.client.api.AppAdminClient
      Parameters:
      fileName - - path to yarnfile
      appName - - YARN Service Name
      lifetime - - application lifetime
      queue - - Queue to submit application
      Throws:
      IOException
      org.apache.hadoop.yarn.exceptions.YarnException
    • actionStop

      public int actionStop(String appName) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException
      Stop YARN service application.
      Specified by:
      actionStop in class org.apache.hadoop.yarn.client.api.AppAdminClient
      Parameters:
      appName - - YARN Service Name
      Throws:
      IOException
      org.apache.hadoop.yarn.exceptions.YarnException
    • actionStart

      public int actionStart(String appName) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException
      Start YARN service application.
      Specified by:
      actionStart in class org.apache.hadoop.yarn.client.api.AppAdminClient
      Parameters:
      appName - - YARN Service Name
      Throws:
      IOException
      org.apache.hadoop.yarn.exceptions.YarnException
    • actionSave

      public int actionSave(String fileName, String appName, Long lifetime, String queue) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException
      Save Service configuration.
      Specified by:
      actionSave in class org.apache.hadoop.yarn.client.api.AppAdminClient
      Parameters:
      fileName - - path to Yarnfile
      appName - - YARN Service Name
      lifetime - - container life time
      queue - - Queue to submit the application
      Throws:
      IOException
      org.apache.hadoop.yarn.exceptions.YarnException
    • actionDestroy

      public int actionDestroy(String appName) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException
      Decommission a YARN service.
      Specified by:
      actionDestroy in class org.apache.hadoop.yarn.client.api.AppAdminClient
      Parameters:
      appName - - YARN Service Name
      Throws:
      IOException
      org.apache.hadoop.yarn.exceptions.YarnException
    • actionFlex

      public int actionFlex(String appName, Map<String,String> componentCounts) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException
      Change number of containers associated with a service.
      Specified by:
      actionFlex in class org.apache.hadoop.yarn.client.api.AppAdminClient
      Parameters:
      appName - - YARN Service Name
      componentCounts - - list of components and desired container count
      Throws:
      IOException
      org.apache.hadoop.yarn.exceptions.YarnException
    • enableFastLaunch

      public int enableFastLaunch(String destinationFolder) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException
      Specified by:
      enableFastLaunch in class org.apache.hadoop.yarn.client.api.AppAdminClient
      Throws:
      IOException
      org.apache.hadoop.yarn.exceptions.YarnException
    • getStatusString

      public String getStatusString(String appIdOrName) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException
      Retrieve Service Status through REST API.
      Specified by:
      getStatusString in class org.apache.hadoop.yarn.client.api.AppAdminClient
      Parameters:
      appIdOrName - - YARN application ID or application name
      Returns:
      Status output
      Throws:
      IOException
      org.apache.hadoop.yarn.exceptions.YarnException
    • actionUpgradeExpress

      public int actionUpgradeExpress(String appName, File path) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException
      Specified by:
      actionUpgradeExpress in class org.apache.hadoop.yarn.client.api.AppAdminClient
      Throws:
      IOException
      org.apache.hadoop.yarn.exceptions.YarnException
    • initiateUpgrade

      public int initiateUpgrade(String appName, String fileName, boolean autoFinalize) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException
      Specified by:
      initiateUpgrade in class org.apache.hadoop.yarn.client.api.AppAdminClient
      Throws:
      IOException
      org.apache.hadoop.yarn.exceptions.YarnException
    • actionUpgradeInstances

      public int actionUpgradeInstances(String appName, List<String> compInstances) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException
      Specified by:
      actionUpgradeInstances in class org.apache.hadoop.yarn.client.api.AppAdminClient
      Throws:
      IOException
      org.apache.hadoop.yarn.exceptions.YarnException
    • actionUpgradeComponents

      public int actionUpgradeComponents(String appName, List<String> components) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException
      Specified by:
      actionUpgradeComponents in class org.apache.hadoop.yarn.client.api.AppAdminClient
      Throws:
      IOException
      org.apache.hadoop.yarn.exceptions.YarnException
    • actionCleanUp

      public int actionCleanUp(String appName, String userName) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException, InterruptedException
      Specified by:
      actionCleanUp in class org.apache.hadoop.yarn.client.api.AppAdminClient
      Throws:
      IOException
      org.apache.hadoop.yarn.exceptions.YarnException
      InterruptedException
    • getInstances

      public String getInstances(String appName, List<String> components, String version, List<String> containerStates) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException
      Specified by:
      getInstances in class org.apache.hadoop.yarn.client.api.AppAdminClient
      Throws:
      IOException
      org.apache.hadoop.yarn.exceptions.YarnException
    • actionCancelUpgrade

      public int actionCancelUpgrade(String appName) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException
      Specified by:
      actionCancelUpgrade in class org.apache.hadoop.yarn.client.api.AppAdminClient
      Throws:
      IOException
      org.apache.hadoop.yarn.exceptions.YarnException
    • actionDecommissionInstances

      public int actionDecommissionInstances(String appName, List<String> componentInstances) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException
      Specified by:
      actionDecommissionInstances in class org.apache.hadoop.yarn.client.api.AppAdminClient
      Throws:
      IOException
      org.apache.hadoop.yarn.exceptions.YarnException