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.CompositeServiceShutdownHookNested classes/interfaces inherited from interface org.apache.hadoop.service.Service
org.apache.hadoop.service.Service.STATE -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.apache.hadoop.yarn.client.api.YarnClientFields 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_PREFIXFields inherited from class org.apache.hadoop.service.CompositeService
STOP_ONLY_STARTED_SERVICES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintactionCancelUpgrade(String appName) intactionCleanUp(String appName, String userName) intactionDecommissionInstances(String appName, List<String> componentInstances) intactionDestroy(String appName) Decommission a YARN service.intactionFlex(String appName, Map<String, String> componentCounts) Change number of containers associated with a service.intactionLaunch(String fileName, String appName, Long lifetime, String queue) Launch YARN service application.intactionSave(String fileName, String appName, Long lifetime, String queue) Save Service configuration.intactionStart(String appName) Start YARN service application.intactionStop(String appName) Stop YARN service application.intactionUpgradeComponents(String appName, List<String> components) intactionUpgradeExpress(String appName, File path) intactionUpgradeInstances(String appName, List<String> compInstances) intenableFastLaunch(String destinationFolder) javax.ws.rs.client.Invocation.Builderjavax.ws.rs.client.Invocation.BuildergetApiClient(String requestPath) Setup API service web request.getServicePath(String appName) Compute active resource manager API service location.getStatusString(String appIdOrName) Retrieve Service Status through REST API.intinitiateUpgrade(String appName, String fileName, boolean autoFinalize) org.apache.hadoop.yarn.service.api.records.ServiceloadAppJsonFromLocalFS(String fileName, String serviceName, Long lifetime, String queue) Utility method to load Service json from disk or from YARN examples.protected voidserviceInit(org.apache.hadoop.conf.Configuration configuration) Methods inherited from class org.apache.hadoop.yarn.client.api.AppAdminClient
createAppAdminClientMethods inherited from class org.apache.hadoop.service.CompositeService
addIfService, addService, getServices, removeService, serviceStart, serviceStopMethods 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
-
Field Details
-
yarnClient
protected org.apache.hadoop.yarn.client.api.YarnClient yarnClient
-
-
Constructor Details
-
ApiServiceClient
public ApiServiceClient() -
ApiServiceClient
- Throws:
Exception
-
-
Method Details
-
serviceInit
- Overrides:
serviceInitin classorg.apache.hadoop.service.CompositeService- Throws:
Exception
-
getServicePath
Compute active resource manager API service location.- Parameters:
appName- - YARN service name- Returns:
- URI to API Service
- Throws:
IOException
-
getApiClient
- Throws:
IOException
-
getApiClient
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 yarnfileserviceName- - YARN Service Namelifetime- - application lifetimequeue- - Queue to submit application- Returns:
- Throws:
IOExceptionorg.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:
actionLaunchin classorg.apache.hadoop.yarn.client.api.AppAdminClient- Parameters:
fileName- - path to yarnfileappName- - YARN Service Namelifetime- - application lifetimequeue- - Queue to submit application- Throws:
IOExceptionorg.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:
actionStopin classorg.apache.hadoop.yarn.client.api.AppAdminClient- Parameters:
appName- - YARN Service Name- Throws:
IOExceptionorg.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:
actionStartin classorg.apache.hadoop.yarn.client.api.AppAdminClient- Parameters:
appName- - YARN Service Name- Throws:
IOExceptionorg.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:
actionSavein classorg.apache.hadoop.yarn.client.api.AppAdminClient- Parameters:
fileName- - path to YarnfileappName- - YARN Service Namelifetime- - container life timequeue- - Queue to submit the application- Throws:
IOExceptionorg.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:
actionDestroyin classorg.apache.hadoop.yarn.client.api.AppAdminClient- Parameters:
appName- - YARN Service Name- Throws:
IOExceptionorg.apache.hadoop.yarn.exceptions.YarnException
-
actionFlex
public int actionFlex(String appName, Map<String, String> componentCounts) throws IOException, org.apache.hadoop.yarn.exceptions.YarnExceptionChange number of containers associated with a service.- Specified by:
actionFlexin classorg.apache.hadoop.yarn.client.api.AppAdminClient- Parameters:
appName- - YARN Service NamecomponentCounts- - list of components and desired container count- Throws:
IOExceptionorg.apache.hadoop.yarn.exceptions.YarnException
-
enableFastLaunch
public int enableFastLaunch(String destinationFolder) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException - Specified by:
enableFastLaunchin classorg.apache.hadoop.yarn.client.api.AppAdminClient- Throws:
IOExceptionorg.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:
getStatusStringin classorg.apache.hadoop.yarn.client.api.AppAdminClient- Parameters:
appIdOrName- - YARN application ID or application name- Returns:
- Status output
- Throws:
IOExceptionorg.apache.hadoop.yarn.exceptions.YarnException
-
actionUpgradeExpress
public int actionUpgradeExpress(String appName, File path) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException - Specified by:
actionUpgradeExpressin classorg.apache.hadoop.yarn.client.api.AppAdminClient- Throws:
IOExceptionorg.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:
initiateUpgradein classorg.apache.hadoop.yarn.client.api.AppAdminClient- Throws:
IOExceptionorg.apache.hadoop.yarn.exceptions.YarnException
-
actionUpgradeInstances
public int actionUpgradeInstances(String appName, List<String> compInstances) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException - Specified by:
actionUpgradeInstancesin classorg.apache.hadoop.yarn.client.api.AppAdminClient- Throws:
IOExceptionorg.apache.hadoop.yarn.exceptions.YarnException
-
actionUpgradeComponents
public int actionUpgradeComponents(String appName, List<String> components) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException - Specified by:
actionUpgradeComponentsin classorg.apache.hadoop.yarn.client.api.AppAdminClient- Throws:
IOExceptionorg.apache.hadoop.yarn.exceptions.YarnException
-
actionCleanUp
public int actionCleanUp(String appName, String userName) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException, InterruptedException - Specified by:
actionCleanUpin classorg.apache.hadoop.yarn.client.api.AppAdminClient- Throws:
IOExceptionorg.apache.hadoop.yarn.exceptions.YarnExceptionInterruptedException
-
getInstances
public String getInstances(String appName, List<String> components, String version, List<String> containerStates) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException - Specified by:
getInstancesin classorg.apache.hadoop.yarn.client.api.AppAdminClient- Throws:
IOExceptionorg.apache.hadoop.yarn.exceptions.YarnException
-
actionCancelUpgrade
public int actionCancelUpgrade(String appName) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException - Specified by:
actionCancelUpgradein classorg.apache.hadoop.yarn.client.api.AppAdminClient- Throws:
IOExceptionorg.apache.hadoop.yarn.exceptions.YarnException
-
actionDecommissionInstances
public int actionDecommissionInstances(String appName, List<String> componentInstances) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException - Specified by:
actionDecommissionInstancesin classorg.apache.hadoop.yarn.client.api.AppAdminClient- Throws:
IOExceptionorg.apache.hadoop.yarn.exceptions.YarnException
-