Class ServiceClient
- All Implemented Interfaces:
Closeable,AutoCloseable,Service,org.apache.hadoop.yarn.service.conf.SliderExitCodes,org.apache.hadoop.yarn.service.conf.YarnServiceConstants,org.apache.hadoop.yarn.service.exceptions.LauncherExitCodes
-
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
Service.STATE -
Field Summary
FieldsFields 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_SERVICESFields inherited from interface org.apache.hadoop.yarn.service.exceptions.LauncherExitCodes
EXIT_CLIENT_INITIATED_SHUTDOWN, EXIT_COMMAND_ARGUMENT_ERROR, EXIT_CONFLICT, EXIT_CONNECTIVITY_PROBLEM, EXIT_EXCEPTION_THROWN, EXIT_FALSE, EXIT_FORBIDDEN, EXIT_FOUND, EXIT_INTERNAL_ERROR, EXIT_INTERRUPTED, EXIT_MOVED, EXIT_NOT_ACCEPTABLE, EXIT_NOT_FOUND, EXIT_NOT_MODIFIED, EXIT_OPERATION_NOT_ALLOWED, EXIT_OTHER_FAILURE, EXIT_SERVICE_UNAVAILABLE, EXIT_SUCCESS, EXIT_TASK_LAUNCH_FAILURE, EXIT_UNAUTHORIZED, EXIT_UNIMPLEMENTED, EXIT_UNSUPPORTED_VERSION, EXIT_USAGEFields inherited from interface org.apache.hadoop.yarn.service.conf.SliderExitCodes
_EXIT_CODE_BASE, EXIT_APPLICATION_IN_USE, EXIT_BAD_CONFIGURATION, EXIT_BAD_STATE, EXIT_DEPLOYMENT_FAILED, EXIT_INSTANCE_EXISTS, EXIT_PROCESS_FAILED, EXIT_TIMED_OUT, EXIT_UNKNOWN_INSTANCE, EXIT_YARN_SERVICE_FAILED, EXIT_YARN_SERVICE_FINISHED_WITH_ERROR, EXIT_YARN_SERVICE_KILLEDFields inherited from interface org.apache.hadoop.yarn.service.conf.YarnServiceConstants
APP_CONF_DIR, APP_LIB_DIR, APP_RESOURCES_DIR, APP_TYPE, CONTAINER_STATE_REPORT_AS_SERVICE_STATE, CONTENT, DEPENDENCY_DIR, DEPENDENCY_DIR_PERMISSIONS, DEPENDENCY_LOCALIZED_DIR_LINK, DEPENDENCY_TAR_GZ_FILE_EXT, DEPENDENCY_TAR_GZ_FILE_NAME, ERR_FILE, HADOOP_USER_NAME, KEYTAB_DIR, KEYTAB_LOCATION, OUT_FILE, PRINCIPAL, PROPERTY_LIB_DIR, RESOURCE_DIR, SERVICE_BASE_DIRECTORY, SERVICE_CORE_JAR, SERVICES_DIRECTORY, SERVICES_PUBLIC_DIRECTORY, STDERR_AM, STDOUT_AM, SUBMITTED_CONF_DIR, SYSPROP_LOG_DIR, SYSPROP_LOG4J_CONFIGURATION, TMP_DIR_PREFIX, UPGRADE_DIR, YARN_SERVICE_LOG4J_FILENAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintactionBuild(Service service) intactionCancelUpgrade(String appName) Cancels the upgrade of the service.intactionCleanUp(String appName, String userName) Operation to be performed by the RM after an application has completed.actionCreate(Service service) intactionDecommissionInstances(String appName, List<String> componentInstances) Decommission component instances of a long running service.intactionDependency(String destinationFolder, boolean overwrite) intactionDestroy(String serviceName) Remove the specification and all application data for a YARN application.intactionFlex(String serviceName, Map<String, String> componentCountStrings) Change the number of running containers for a component of a YARN application / long-running service.intactionLaunch(String fileName, String serviceName, Long lifetime, String queue) Launch a new YARN application.intactionSave(String fileName, String serviceName, Long lifetime, String queue) Save the specification for a YARN application / long-running service.intactionStart(String serviceName) Start a YARN application from a previously saved specification.actionStartAndGetId(String serviceName) intactionStop(String serviceName) Stop a YARN application (attempt to stop gracefully before killing the application).intactionStop(String serviceName, boolean waitForAppStopped) intactionUpgrade(Service service, List<Container> compInstances) intactionUpgradeComponents(String appName, List<String> components) Upgrade components of a long running service.intactionUpgradeExpress(String appName, File path) Express upgrade a long running service.intactionUpgradeExpress(Service service) intactionUpgradeInstances(String appName, List<String> componentInstances) Upgrade component instances of a long running service.addAMEnv()protected PathaddJarResource(String serviceName, Map<String, LocalResource> localResources) static FilecompressFiles(Collection<File> files, File output, String bundleRoot) Compress (tar) the input files to the output file.convertState(YarnApplicationState state) protected org.apache.hadoop.yarn.service.ClientAMProtocolcreateAMProxy(String serviceName, ApplicationReport appReport) intenableFastLaunch(String destinationFolder) Upload AM dependencies to HDFS.flexByRestService(String serviceName, Map<String, Long> componentCounts) getContainers(String appName, List<String> components, String version, List<ContainerState> containerStates) getStatusString(String appIdOrName) Get detailed app specific status string for a YARN application.intinitiateUpgrade(String appName, String fileName, boolean autoFinalize) Initiate upgrade of a long running service.intinitiateUpgrade(Service service) loadAppJsonFromLocalFS(String fileName, String serviceName, Long lifetime, String queue) protected voidserviceInit(Configuration configuration) All initialization code needed by a service.protected voidActions called during the transition to the STOPPED state.updateLifetime(String serviceName, long lifetime) Methods inherited from class org.apache.hadoop.yarn.client.api.AppAdminClient
createAppAdminClientMethods inherited from class org.apache.hadoop.service.CompositeService
addIfService, addService, getServices, removeService, serviceStartMethods 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
-
-
Constructor Details
-
ServiceClient
public ServiceClient()
-
-
Method Details
-
serviceInit
Description copied from class:AbstractServiceAll initialization code needed by a service. This method will only ever be called once during the lifecycle of a specific service instance. Implementations do not need to be synchronized as the logic inAbstractService.init(Configuration)prevents re-entrancy. The base implementation checks to see if the subclass has created a new configuration instance, and if so, updates the base class value- Overrides:
serviceInitin classCompositeService- Parameters:
configuration- configuration- Throws:
Exception- on a failure -these will be caught, possibly wrapped, and will trigger a service stop
-
serviceStop
Description copied from class:AbstractServiceActions called during the transition to the STOPPED state. This method will only ever be called once during the lifecycle of a specific service instance. Implementations do not need to be synchronized as the logic inAbstractService.stop()prevents re-entrancy. Implementations MUST write this to be robust against failures, including checks for null references -and for the first failure to not stop other attempts to shut down parts of the service.- Overrides:
serviceStopin classCompositeService- Throws:
Exception- if needed -these will be caught and logged.
-
loadAppJsonFromLocalFS
public Service loadAppJsonFromLocalFS(String fileName, String serviceName, Long lifetime, String queue) throws IOException, YarnException - Throws:
IOExceptionYarnException
-
actionSave
public int actionSave(String fileName, String serviceName, Long lifetime, String queue) throws IOException, YarnException Description copied from class:AppAdminClientSave the specification for a YARN application / long-running service. The application may be started later.
- Specified by:
actionSavein classAppAdminClient- Parameters:
fileName- specification of application to saveserviceName- name of the applicationlifetime- lifetime of the applicationqueue- queue of the application- Returns:
- exit code
- Throws:
IOException- IOExceptionYarnException- exception in client or server
-
actionBuild
- Throws:
YarnExceptionIOException
-
actionUpgradeExpress
Description copied from class:AppAdminClientExpress upgrade a long running service.- Specified by:
actionUpgradeExpressin classAppAdminClient- Parameters:
appName- the name of the applicationpath- specification of application upgrade to save.- Returns:
- exit code
- Throws:
IOException- io error occur.YarnException- exceptions from yarn servers.
-
actionUpgradeExpress
- Throws:
YarnExceptionIOException
-
initiateUpgrade
public int initiateUpgrade(String appName, String fileName, boolean autoFinalize) throws IOException, YarnException Description copied from class:AppAdminClientInitiate upgrade of a long running service.- Specified by:
initiateUpgradein classAppAdminClient- Parameters:
appName- the name of the application.fileName- specification of application upgrade to save.autoFinalize- when true, finalization of upgrade will be done automatically.- Returns:
- exit code
- Throws:
IOException- IOExceptionYarnException- exception in client or server
-
initiateUpgrade
- Throws:
YarnExceptionIOException
-
actionUpgradeInstances
public int actionUpgradeInstances(String appName, List<String> componentInstances) throws IOException, YarnException Description copied from class:AppAdminClientUpgrade component instances of a long running service.- Specified by:
actionUpgradeInstancesin classAppAdminClient- Parameters:
appName- the name of the application.componentInstances- the name of the component instances.- Returns:
- exit code.
- Throws:
IOException- io error occur.YarnException- exceptions from yarn servers.
-
actionUpgradeComponents
public int actionUpgradeComponents(String appName, List<String> components) throws IOException, YarnException Description copied from class:AppAdminClientUpgrade components of a long running service.- Specified by:
actionUpgradeComponentsin classAppAdminClient- Parameters:
appName- the name of the application.components- the name of the components.- Returns:
- exit code.
- Throws:
IOException- io error occur.YarnException- exceptions from yarn servers.
-
actionCancelUpgrade
Description copied from class:AppAdminClientCancels the upgrade of the service.- Specified by:
actionCancelUpgradein classAppAdminClient- Parameters:
appName- the name of the application- Returns:
- exit code
- Throws:
IOException- io error occur.YarnException- exceptions from yarn servers.
-
actionDecommissionInstances
public int actionDecommissionInstances(String appName, List<String> componentInstances) throws IOException, YarnException Description copied from class:AppAdminClientDecommission component instances of a long running service.- Specified by:
actionDecommissionInstancesin classAppAdminClient- Parameters:
appName- the name of the application.componentInstances- the name of the component instances.- Returns:
- exit code.
- Throws:
IOException- io error occur.YarnException- exceptions from yarn servers.
-
actionCleanUp
Description copied from class:AppAdminClientOperation to be performed by the RM after an application has completed.- Specified by:
actionCleanUpin classAppAdminClient- Parameters:
appName- the name of the application.userName- the name of the user.- Returns:
- exit code
- Throws:
IOException- io error occur.YarnException- exceptions from yarn servers.
-
getInstances
public String getInstances(String appName, List<String> components, String version, List<String> containerStates) throws IOException, YarnException - Specified by:
getInstancesin classAppAdminClient- Throws:
IOExceptionYarnException
-
getContainers
public ComponentContainers[] getContainers(String appName, List<String> components, String version, List<ContainerState> containerStates) throws IOException, YarnException - Throws:
IOExceptionYarnException
-
actionUpgrade
public int actionUpgrade(Service service, List<Container> compInstances) throws IOException, YarnException - Throws:
IOExceptionYarnException
-
actionLaunch
public int actionLaunch(String fileName, String serviceName, Long lifetime, String queue) throws IOException, YarnException Description copied from class:AppAdminClientLaunch a new YARN application.
- Specified by:
actionLaunchin classAppAdminClient- Parameters:
fileName- specification of applicationserviceName- name of the applicationlifetime- lifetime of the applicationqueue- queue of the application- Returns:
- exit code
- Throws:
IOException- IOExceptionYarnException- exception in client or server
-
actionCreate
- Throws:
IOExceptionYarnException
-
actionFlex
public int actionFlex(String serviceName, Map<String, String> componentCountStrings) throws YarnException, IOExceptionDescription copied from class:AppAdminClientChange the number of running containers for a component of a YARN application / long-running service.
- Specified by:
actionFlexin classAppAdminClient- Parameters:
serviceName- the name of the applicationcomponentCountStrings- map of component name to new component count or amount to change existing component count (e.g. 5, +5, -5)- Returns:
- exit code
- Throws:
YarnException- exception in client or serverIOException- IOException
-
flexByRestService
public Map<String,Long> flexByRestService(String serviceName, Map<String, Long> componentCounts) throws YarnException, IOException- Throws:
YarnExceptionIOException
-
actionStop
Description copied from class:AppAdminClientStop a YARN application (attempt to stop gracefully before killing the application). In the case of a long-running service, the service may be restarted later.
- Specified by:
actionStopin classAppAdminClient- Parameters:
serviceName- the name of the application- Returns:
- exit code
- Throws:
YarnException- exception in client or serverIOException- IOException
-
actionStop
public int actionStop(String serviceName, boolean waitForAppStopped) throws YarnException, IOException - Throws:
YarnExceptionIOException
-
actionDestroy
Description copied from class:AppAdminClientRemove the specification and all application data for a YARN application. The application cannot be running.
- Specified by:
actionDestroyin classAppAdminClient- Parameters:
serviceName- the name of the application- Returns:
- exit code
- Throws:
YarnException- exception in client or serverIOException- IOException
-
compressFiles
public static File compressFiles(Collection<File> files, File output, String bundleRoot) throws IOException Compress (tar) the input files to the output file.- Parameters:
files- The files to compressoutput- The resulting output file (should end in .tar.gz)bundleRoot-- Throws:
IOException
-
addAMEnv
- Throws:
IOException
-
addJarResource
protected Path addJarResource(String serviceName, Map<String, LocalResource> localResources) throws IOException, YarnException- Throws:
IOExceptionYarnException
-
actionStart
Description copied from class:AppAdminClientStart a YARN application from a previously saved specification. In the case of a long-running service, the service must have been previously launched/started and then stopped, or previously saved but not started.
- Specified by:
actionStartin classAppAdminClient- Parameters:
serviceName- the name of the application- Returns:
- exit code
- Throws:
YarnException- exception in client or serverIOException- IOException
-
actionStartAndGetId
- Throws:
YarnExceptionIOException
-
updateLifetime
- Throws:
YarnExceptionIOException
-
convertState
-
getStatusString
Description copied from class:AppAdminClientGet detailed app specific status string for a YARN application.
- Specified by:
getStatusStringin classAppAdminClient- Parameters:
appIdOrName- appId or appName- Returns:
- status string
- Throws:
IOException- IOExceptionYarnException- exception in client or server
-
getStatus
- Throws:
IOExceptionYarnException
-
getYarnClient
-
enableFastLaunch
Description copied from class:AppAdminClientUpload AM dependencies to HDFS. This makes future application launches faster since the dependencies do not have to be uploaded on each launch.
- Specified by:
enableFastLaunchin classAppAdminClient- Parameters:
destinationFolder- an optional HDFS folder where dependency tarball will be uploaded- Returns:
- exit code
- Throws:
IOException- IOExceptionYarnException- exception in client or server
-
actionDependency
-
createAMProxy
protected org.apache.hadoop.yarn.service.ClientAMProtocol createAMProxy(String serviceName, ApplicationReport appReport) throws IOException, YarnException - Throws:
IOExceptionYarnException
-
getAppId
- Throws:
IOExceptionYarnException
-