YARN-7384. Remove apiserver cmd and merge service cmd into application cmd. Contributed by Billie Rinaldi
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/ba7ed7b6 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/ba7ed7b6 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/ba7ed7b6 Branch: refs/heads/trunk Commit: ba7ed7b66a48c61086ea837f39ff0f22ffe31eca Parents: 8ec9e72 Author: Jian He <jia...@apache.org> Authored: Sat Oct 28 23:04:19 2017 -0700 Committer: Jian He <jia...@apache.org> Committed: Mon Nov 6 13:30:19 2017 -0800 ---------------------------------------------------------------------- NOTICE.txt | 4 - hadoop-project/pom.xml | 6 - hadoop-yarn-project/hadoop-yarn/bin/yarn | 27 +- .../hadoop-yarn/conf/yarn-env.sh | 18 +- .../hadoop-yarn-services-core/pom.xml | 5 - .../hadoop/yarn/service/ServiceMaster.java | 21 +- .../hadoop/yarn/service/client/ServiceCLI.java | 113 ------- .../yarn/service/client/ServiceClient.java | 187 +++++------ .../client/params/AbstractActionArgs.java | 139 -------- .../client/params/AbstractArgsDelegate.java | 28 -- .../AbstractClusterBuildingActionArgs.java | 46 --- .../service/client/params/ActionBuildArgs.java | 39 --- .../service/client/params/ActionClientArgs.java | 71 ----- .../service/client/params/ActionCreateArgs.java | 46 --- .../client/params/ActionDependencyArgs.java | 65 ---- .../client/params/ActionDestroyArgs.java | 37 --- .../service/client/params/ActionExistsArgs.java | 49 --- .../service/client/params/ActionFlexArgs.java | 50 --- .../service/client/params/ActionFreezeArgs.java | 56 ---- .../service/client/params/ActionHelpArgs.java | 44 --- .../service/client/params/ActionKeytabArgs.java | 76 ----- .../service/client/params/ActionListArgs.java | 76 ----- .../client/params/ActionRegistryArgs.java | 218 ------------- .../client/params/ActionResolveArgs.java | 153 --------- .../client/params/ActionResourceArgs.java | 70 ---- .../service/client/params/ActionStatusArgs.java | 51 --- .../service/client/params/ActionThawArgs.java | 67 ---- .../service/client/params/ActionTokensArgs.java | 78 ----- .../service/client/params/ActionUpdateArgs.java | 37 --- .../yarn/service/client/params/ArgOps.java | 156 --------- .../yarn/service/client/params/Arguments.java | 103 ------ .../yarn/service/client/params/ClientArgs.java | 193 ----------- .../yarn/service/client/params/CommonArgs.java | 245 -------------- .../client/params/ComponentArgsDelegate.java | 52 --- .../client/params/DontSplitArguments.java | 34 -- .../client/params/LaunchArgsAccessor.java | 30 -- .../client/params/LaunchArgsDelegate.java | 51 --- .../client/params/OptionArgsDelegate.java | 66 ---- .../client/params/PathArgumentConverter.java | 34 -- .../service/client/params/ServiceAMArgs.java | 50 --- .../client/params/ServiceAMCreateAction.java | 37 --- .../service/client/params/SliderActions.java | 79 ----- .../service/client/params/WaitArgsDelegate.java | 42 --- .../service/client/params/WaitTimeAccessor.java | 24 -- .../hadoop/yarn/service/utils/SliderUtils.java | 6 +- .../client/TestBuildExternalComponents.java | 19 +- .../yarn/service/client/TestServiceCLI.java | 125 +++----- .../hadoop/yarn/client/api/AppAdminClient.java | 222 +++++++++++++ .../hadoop/yarn/client/cli/ApplicationCLI.java | 318 ++++++++++++++++--- .../hadoop/yarn/client/cli/TestYarnCLI.java | 158 ++++++--- .../src/site/markdown/YarnCommands.md | 86 ++--- .../src/site/markdown/yarn-service/Examples.md | 12 +- .../site/markdown/yarn-service/QuickStart.md | 46 ++- .../markdown/yarn-service/YarnServiceAPI.md | 20 +- 54 files changed, 840 insertions(+), 3245 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba7ed7b6/NOTICE.txt ---------------------------------------------------------------------- diff --git a/NOTICE.txt b/NOTICE.txt index f3af2f7..bc7a26f 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -582,10 +582,6 @@ Ehcache 3.3.1, which has the following notices: * Ehcache V3 Copyright 2014-2016 Terracotta, Inc. -JCommander (https://github.com/cbeust/jcommander), -which has the following notices: - * Copyright 2010 Cedric Beust ced...@beust.com - The binary distribution of this product bundles binaries of snakeyaml (https://bitbucket.org/asomov/snakeyaml), which has the following notices: http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba7ed7b6/hadoop-project/pom.xml ---------------------------------------------------------------------- diff --git a/hadoop-project/pom.xml b/hadoop-project/pom.xml index d18c9a8..f99e413 100644 --- a/hadoop-project/pom.xml +++ b/hadoop-project/pom.xml @@ -146,7 +146,6 @@ <swagger-annotations-version>1.5.4</swagger-annotations-version> <snakeyaml.version>1.16</snakeyaml.version> - <jcommander.version>1.48</jcommander.version> </properties> <dependencyManagement> @@ -1353,11 +1352,6 @@ <artifactId>snakeyaml</artifactId> <version>${snakeyaml.version}</version> </dependency> - <dependency> - <groupId>com.beust</groupId> - <artifactId>jcommander</artifactId> - <version>${jcommander.version}</version> - </dependency> </dependencies> </dependencyManagement> http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba7ed7b6/hadoop-yarn-project/hadoop-yarn/bin/yarn ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/bin/yarn b/hadoop-yarn-project/hadoop-yarn/bin/yarn index cc269d8..00596c2 100755 --- a/hadoop-yarn-project/hadoop-yarn/bin/yarn +++ b/hadoop-yarn-project/hadoop-yarn/bin/yarn @@ -31,8 +31,7 @@ function hadoop_usage hadoop_add_option "--hosts filename" "list of hosts to use in worker mode" hadoop_add_option "--workers" "turn on worker mode" - hadoop_add_subcommand "apiserver" daemon "run the api-server for deploying/managing services on YARN" - hadoop_add_subcommand "application" client "prints application(s) report/kill application" + hadoop_add_subcommand "app|application" client "prints application(s) report/kill application/manage long running application" hadoop_add_subcommand "applicationattempt" client "prints applicationattempt(s) report" hadoop_add_subcommand "classpath" client "prints the class path needed to get the hadoop jar and the required libraries" hadoop_add_subcommand "cluster" client "prints cluster information" @@ -51,7 +50,6 @@ function hadoop_usage hadoop_add_subcommand "router" daemon "run the Router daemon" hadoop_add_subcommand "schedulerconf" client "Updates scheduler configuration" hadoop_add_subcommand "scmadmin" admin "SharedCacheManager admin tools" - hadoop_add_subcommand "service" client "deploy/manage a service on YARN" hadoop_add_subcommand "sharedcachemanager" daemon "run the SharedCacheManager daemon" hadoop_add_subcommand "timelinereader" client "run the timeline reader server" hadoop_add_subcommand "timelineserver" daemon "run the timeline server" @@ -71,9 +69,10 @@ function yarncmd_case shift case ${subcmd} in - apiserver) - HADOOP_SUBCMD_SUPPORTDAEMONIZATION="true" - HADOOP_CLASSNAME='org.apache.hadoop.yarn.service.webapp.ApiServerWebApp' + app|application|applicationattempt|container) + HADOOP_CLASSNAME=org.apache.hadoop.yarn.client.cli.ApplicationCLI + set -- "${subcmd}" "$@" + HADOOP_SUBCMD_ARGS=("$@") local sld="${HADOOP_YARN_HOME}/${YARN_DIR},\ ${HADOOP_YARN_HOME}/${YARN_LIB_JARS_DIR},\ ${HADOOP_HDFS_HOME}/${HDFS_DIR},\ @@ -83,11 +82,6 @@ ${HADOOP_COMMON_HOME}/${HADOOP_COMMON_LIB_JARS_DIR}" hadoop_translate_cygwin_path sld hadoop_add_param HADOOP_OPTS service.libdir "-Dservice.libdir=${sld}" ;; - application|applicationattempt|container) - HADOOP_CLASSNAME=org.apache.hadoop.yarn.client.cli.ApplicationCLI - set -- "${subcmd}" "$@" - HADOOP_SUBCMD_ARGS=("$@") - ;; classpath) hadoop_do_classpath_subcommand HADOOP_CLASSNAME "$@" ;; @@ -169,17 +163,6 @@ ${HADOOP_COMMON_HOME}/${HADOOP_COMMON_LIB_JARS_DIR}" scmadmin) HADOOP_CLASSNAME='org.apache.hadoop.yarn.client.SCMAdmin' ;; - service) - HADOOP_CLASSNAME='org.apache.hadoop.yarn.service.client.ServiceCLI' - local sld="${HADOOP_YARN_HOME}/${YARN_DIR},\ -${HADOOP_YARN_HOME}/${YARN_LIB_JARS_DIR},\ -${HADOOP_HDFS_HOME}/${HDFS_DIR},\ -${HADOOP_HDFS_HOME}/${HDFS_LIB_JARS_DIR},\ -${HADOOP_COMMON_HOME}/${HADOOP_COMMON_DIR},\ -${HADOOP_COMMON_HOME}/${HADOOP_COMMON_LIB_JARS_DIR}" - hadoop_translate_cygwin_path sld - hadoop_add_param HADOOP_OPTS service.libdir "-Dservice.libdir=${sld}" - ;; sharedcachemanager) HADOOP_SUBCMD_SUPPORTDAEMONIZATION="true" HADOOP_CLASSNAME='org.apache.hadoop.yarn.server.sharedcachemanager.SharedCacheManager' http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba7ed7b6/hadoop-yarn-project/hadoop-yarn/conf/yarn-env.sh ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/conf/yarn-env.sh b/hadoop-yarn-project/hadoop-yarn/conf/yarn-env.sh index 4bd1d3e..d865023 100644 --- a/hadoop-yarn-project/hadoop-yarn/conf/yarn-env.sh +++ b/hadoop-yarn-project/hadoop-yarn/conf/yarn-env.sh @@ -150,18 +150,6 @@ #export YARN_ROUTER_OPTS= ### -# Services API specific parameters -### -# Specify the JVM options to be used when starting the services API. -# -# These options will be appended to the options specified as HADOOP_OPTS -# and therefore may override any similar flags set in HADOOP_OPTS -# -# See ResourceManager for some examples -# -#export YARN_APISERVER_OPTS="-verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -Xloggc:${HADOOP_LOG_DIR}/gc-apiserver.log-$(date +'%Y%m%d%H%M')" - -### # Registry DNS specific parameters ### # For privileged registry DNS, user to run as after dropping privileges @@ -172,3 +160,9 @@ # By default, Hadoop uses jsvc which needs to know to launch a # server jvm. # export YARN_REGISTRYDNS_SECURE_EXTRA_OPTS="-jvm server" + +### +# YARN Services parameters +### +# Directory containing service examples +# export YARN_SERVICE_EXAMPLES_DIR = $HADOOP_YARN_HOME/share/hadoop/yarn/yarn-service-examples http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba7ed7b6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/pom.xml ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/pom.xml index 851f73b..6c9a875 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/pom.xml +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/pom.xml @@ -102,11 +102,6 @@ </build> <dependencies> <dependency> - <groupId>com.beust</groupId> - <artifactId>jcommander</artifactId> - </dependency> - - <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </dependency> http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba7ed7b6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/ServiceMaster.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/ServiceMaster.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/ServiceMaster.java index 2abdae1..d58e32b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/ServiceMaster.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/ServiceMaster.java @@ -18,6 +18,8 @@ package org.apache.hadoop.yarn.service; +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.Options; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem; @@ -34,7 +36,6 @@ import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.security.client.ClientToAMTokenSecretManager; -import org.apache.hadoop.yarn.service.client.params.ServiceAMArgs; import org.apache.hadoop.yarn.service.monitor.ServiceMonitor; import org.apache.hadoop.yarn.service.utils.ServiceApiUtil; import org.apache.hadoop.yarn.service.utils.SliderFileSystem; @@ -51,7 +52,9 @@ public class ServiceMaster extends CompositeService { private static final Logger LOG = LoggerFactory.getLogger(ServiceMaster.class); - private static ServiceAMArgs amArgs; + public static final String YARNFILE_OPTION = "yarnfile"; + + private static String serviceDefPath; protected ServiceContext context; public ServiceMaster(String name) { @@ -108,7 +111,7 @@ public class ServiceMaster extends CompositeService { } protected Path getAppDir() { - return new Path(amArgs.getServiceDefPath()).getParent(); + return new Path(serviceDefPath).getParent(); } protected ServiceScheduler createServiceScheduler(ServiceContext context) @@ -119,7 +122,7 @@ public class ServiceMaster extends CompositeService { protected void loadApplicationJson(ServiceContext context, SliderFileSystem fs) throws IOException { context.service = ServiceApiUtil - .loadServiceFrom(fs, new Path(amArgs.getServiceDefPath())); + .loadServiceFrom(fs, new Path(serviceDefPath)); LOG.info(context.service.toString()); } @@ -138,14 +141,18 @@ public class ServiceMaster extends CompositeService { public static void main(String[] args) throws Exception { Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler()); StringUtils.startupShutdownMessage(ServiceMaster.class, args, LOG); - amArgs = new ServiceAMArgs(args); - amArgs.parse(); try { ServiceMaster serviceMaster = new ServiceMaster("Service Master"); ShutdownHookManager.get() .addShutdownHook(new CompositeServiceShutdownHook(serviceMaster), 30); YarnConfiguration conf = new YarnConfiguration(); - new GenericOptionsParser(conf, args); + Options opts = new Options(); + opts.addOption(YARNFILE_OPTION, true, "HDFS path to JSON service " + + "specification"); + opts.getOption(YARNFILE_OPTION).setRequired(true); + GenericOptionsParser parser = new GenericOptionsParser(conf, opts, args); + CommandLine cmdLine = parser.getCommandLine(); + serviceMaster.serviceDefPath = cmdLine.getOptionValue(YARNFILE_OPTION); serviceMaster.init(conf); serviceMaster.start(); } catch (Throwable t) { http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba7ed7b6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/ServiceCLI.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/ServiceCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/ServiceCLI.java deleted file mode 100644 index 928c06f..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/ServiceCLI.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.service.client; - -import com.beust.jcommander.ParameterException; -import org.apache.commons.lang.StringUtils; -import org.apache.hadoop.yarn.conf.YarnConfiguration; -import org.apache.hadoop.yarn.service.api.records.Service; -import org.apache.hadoop.yarn.service.client.params.ClientArgs; -import org.apache.hadoop.yarn.service.exceptions.SliderException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.FileNotFoundException; - -import static org.apache.hadoop.yarn.service.client.params.SliderActions.*; - -public class ServiceCLI { - private static final Logger LOG = - LoggerFactory.getLogger(ServiceClient.class); - protected ServiceClient client; - - int exec(ClientArgs args) throws Throwable { - if (StringUtils.isEmpty(args.getAction())) { - System.out.println(args.usage()); - return -1; - } - switch (args.getAction()) { - case ACTION_BUILD: // Upload app json onto hdfs - client.actionBuild(args.getActionBuildArgs()); - break; - case ACTION_START: // start the app with the pre-uploaded app json on hdfs - client.actionStart(args.getClusterName()); - break; - case ACTION_CREATE: // create == build + start - client.actionCreate(args.getActionCreateArgs()); - break; - case ACTION_STATUS: - Service app = client.getStatus(args.getClusterName()); - System.out.println(app); - break; - case ACTION_FLEX: - try { - client.actionFlexByCLI(args); - } catch (FileNotFoundException e) { - System.err.println( - args.getClusterName() + " doesn't exist: " + e.getMessage()); - return -1; - } - break; - case ACTION_STOP: - client.actionStop(args.getClusterName(), false); - break; - case ACTION_DESTROY: // Destroy can happen only if app is already stopped - client.actionDestroy(args.getClusterName()); - break; - case ACTION_DEPENDENCY: // upload dependency jars - client.actionDependency(args.getActionDependencyArgs()); - break; - case ACTION_UPDATE: - client.updateLifetime(args.getClusterName(), - args.getActionUpdateArgs().lifetime); - break; - case ACTION_HELP: - LOG.info(args.usage()); - break; - default: - LOG.info("NOT IMPLEMENTED: " + args.getAction()); - LOG.info(args.usage()); - return -1; - } - return 0; - } - - public ServiceCLI() { - createServiceClient(); - } - - protected void createServiceClient() { - client = new ServiceClient(); - client.init(new YarnConfiguration()); - client.start(); - } - - public static void main(String[] args) throws Throwable { - ClientArgs clientArgs = new ClientArgs(args); - try { - clientArgs.parse(); - } catch (ParameterException | SliderException e) { - System.err.println(e.getMessage()); - System.exit(-1); - } - ServiceCLI cli = new ServiceCLI(); - int res = cli.exec(clientArgs); - System.exit(res); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba7ed7b6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/ServiceClient.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/ServiceClient.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/ServiceClient.java index f6d35e4..636b127 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/ServiceClient.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/ServiceClient.java @@ -34,7 +34,6 @@ import org.apache.hadoop.registry.client.api.RegistryOperations; import org.apache.hadoop.registry.client.api.RegistryOperationsFactory; import org.apache.hadoop.registry.client.binding.RegistryUtils; import org.apache.hadoop.security.UserGroupInformation; -import org.apache.hadoop.service.CompositeService; import org.apache.hadoop.util.VersionInfo; import org.apache.hadoop.yarn.api.ApplicationConstants; import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest; @@ -50,6 +49,7 @@ import org.apache.hadoop.yarn.api.records.LocalResource; import org.apache.hadoop.yarn.api.records.LocalResourceType; import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.api.records.YarnApplicationState; +import org.apache.hadoop.yarn.client.api.AppAdminClient; import org.apache.hadoop.yarn.client.api.YarnClient; import org.apache.hadoop.yarn.client.api.YarnClientApplication; import org.apache.hadoop.yarn.conf.YarnConfiguration; @@ -65,13 +65,6 @@ import org.apache.hadoop.yarn.service.ServiceMaster; import org.apache.hadoop.yarn.service.api.records.Component; import org.apache.hadoop.yarn.service.api.records.Service; import org.apache.hadoop.yarn.service.api.records.ServiceState; -import org.apache.hadoop.yarn.service.client.params.AbstractClusterBuildingActionArgs; -import org.apache.hadoop.yarn.service.client.params.ActionCreateArgs; -import org.apache.hadoop.yarn.service.client.params.ActionDependencyArgs; -import org.apache.hadoop.yarn.service.client.params.ActionFlexArgs; -import org.apache.hadoop.yarn.service.client.params.Arguments; -import org.apache.hadoop.yarn.service.client.params.ClientArgs; -import org.apache.hadoop.yarn.service.client.params.CommonArgs; import org.apache.hadoop.yarn.service.conf.SliderExitCodes; import org.apache.hadoop.yarn.service.conf.YarnServiceConf; import org.apache.hadoop.yarn.service.conf.YarnServiceConstants; @@ -80,7 +73,6 @@ import org.apache.hadoop.yarn.service.containerlaunch.JavaCommandLineBuilder; import org.apache.hadoop.yarn.service.exceptions.BadClusterStateException; import org.apache.hadoop.yarn.service.exceptions.BadConfigException; import org.apache.hadoop.yarn.service.exceptions.SliderException; -import org.apache.hadoop.yarn.service.exceptions.UsageException; import org.apache.hadoop.yarn.service.provider.AbstractClientProvider; import org.apache.hadoop.yarn.service.provider.ProviderUtils; import org.apache.hadoop.yarn.service.utils.ServiceApiUtil; @@ -107,16 +99,14 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import static org.apache.hadoop.yarn.api.records.YarnApplicationState.*; -import static org.apache.hadoop.yarn.service.client.params.SliderActions.ACTION_CREATE; -import static org.apache.hadoop.yarn.service.client.params.SliderActions.ACTION_FLEX; import static org.apache.hadoop.yarn.service.conf.YarnServiceConf.YARN_QUEUE; import static org.apache.hadoop.yarn.service.utils.ServiceApiUtil.jsonSerDeser; import static org.apache.hadoop.yarn.service.utils.SliderUtils.*; @InterfaceAudience.Public @InterfaceStability.Unstable -public class ServiceClient extends CompositeService - implements SliderExitCodes, YarnServiceConstants { +public class ServiceClient extends AppAdminClient implements SliderExitCodes, + YarnServiceConstants { private static final Logger LOG = LoggerFactory.getLogger(ServiceClient.class); private SliderFileSystem fs; @@ -136,10 +126,6 @@ public class ServiceClient extends CompositeService private static EnumSet<YarnApplicationState> preRunningStates = EnumSet.of(NEW, NEW_SAVING, SUBMITTED, ACCEPTED); - public ServiceClient() { - super(ServiceClient.class.getName()); - } - @Override protected void serviceInit(Configuration configuration) throws Exception { fs = new SliderFileSystem(configuration); @@ -157,28 +143,60 @@ public class ServiceClient extends CompositeService super.serviceStop(); } - private Service loadAppJsonFromLocalFS( - AbstractClusterBuildingActionArgs args) throws IOException { - File file = args.getFile(); + public Service loadAppJsonFromLocalFS(String fileName, String serviceName, + Long lifetime, String queue) throws IOException, YarnException { + File file = new File(fileName); + if (!file.exists() && fileName.equals(file.getName())) { + String examplesDirStr = System.getenv("YARN_SERVICE_EXAMPLES_DIR"); + String[] examplesDirs; + if (examplesDirStr == null) { + String yarnHome = System + .getenv(ApplicationConstants.Environment.HADOOP_YARN_HOME.key()); + examplesDirs = new String[]{ + yarnHome + "/share/hadoop/yarn/yarn-service-examples", + yarnHome + "/yarn-service-examples" + }; + } else { + examplesDirs = StringUtils.split(examplesDirStr, ":"); + } + for (String dir : examplesDirs) { + file = new File(MessageFormat.format("{0}/{1}/{2}.json", + dir, fileName, fileName)); + if (file.exists()) { + break; + } + // Then look for secondary location. + file = new File(MessageFormat.format("{0}/{1}.json", + dir, fileName)); + if (file.exists()) { + break; + } + } + } + if (!file.exists()) { + throw new YarnException("File or example could not be found: " + + fileName); + } Path filePath = new Path(file.getAbsolutePath()); LOG.info("Loading service definition from: " + filePath); Service service = jsonSerDeser .load(FileSystem.getLocal(getConfig()), filePath); - if (args.lifetime > 0) { - service.setLifetime(args.lifetime); + if (!StringUtils.isEmpty(serviceName)) { + service.setName(serviceName); } - if (!StringUtils.isEmpty(args.getServiceName())) { - service.setName(args.getServiceName()); + if (lifetime != null && lifetime > 0) { + service.setLifetime(lifetime); } - if (!StringUtils.isEmpty(args.queue)) { - service.setQueue(args.queue); + if (!StringUtils.isEmpty(queue)) { + service.setQueue(queue); } return service; } - public int actionBuild(AbstractClusterBuildingActionArgs args) - throws IOException, YarnException { - return actionBuild(loadAppJsonFromLocalFS(args)); + public int actionSave(String fileName, String serviceName, Long lifetime, + String queue) throws IOException, YarnException { + return actionBuild(loadAppJsonFromLocalFS(fileName, serviceName, + lifetime, queue)); } public int actionBuild(Service service) @@ -189,43 +207,13 @@ public class ServiceClient extends CompositeService return EXIT_SUCCESS; } - public int actionCreate(ActionCreateArgs args) - throws IOException, YarnException { - Service serviceDef; - if (args.file != null) { - serviceDef = loadAppJsonFromLocalFS(args); - } else if (!StringUtils.isEmpty(args.example)) { - // create an example service - args.file = findExampleService(args); - serviceDef = loadAppJsonFromLocalFS(args); - } else { - throw new YarnException("No service definition provided!"); - } - actionCreate(serviceDef); + public int actionLaunch(String fileName, String serviceName, Long lifetime, + String queue) throws IOException, YarnException { + actionCreate(loadAppJsonFromLocalFS(fileName, serviceName, lifetime, + queue)); return EXIT_SUCCESS; } - private File findExampleService(ActionCreateArgs args) throws YarnException { - String yarnHome = System - .getenv(ApplicationConstants.Environment.HADOOP_YARN_HOME.key()); - // First look for the standard location. - File file = new File(MessageFormat - .format("{0}/share/hadoop/yarn/yarn-service-examples/{1}/{2}.json", - yarnHome, args.example, args.example)); - if (file.exists()) { - return file; - } - // Then look for secondary location. - file = new File(MessageFormat - .format("{0}/yarn-service-examples/{1}/{2}.json", yarnHome, - args.example, args.example)); - if (file.exists()) { - return file; - } - throw new YarnException( - "Example service " + args.example + " does not exist!"); - } - public ApplicationId actionCreate(Service service) throws IOException, YarnException { String serviceName = service.getName(); @@ -244,14 +232,12 @@ public class ServiceClient extends CompositeService return appId; } - // Called by ServiceCLI - protected int actionFlexByCLI(ClientArgs args) - throws YarnException, IOException { - ActionFlexArgs flexArgs = args.getActionFlexArgs(); + public int actionFlex(String serviceName, Map<String, String> + componentCountStrings) throws YarnException, IOException { Map<String, Long> componentCounts = - new HashMap<>(flexArgs.getComponentMap().size()); + new HashMap<>(componentCountStrings.size()); Service persistedService = - ServiceApiUtil.loadService(fs, flexArgs.getServiceName()); + ServiceApiUtil.loadService(fs, serviceName); if (!StringUtils.isEmpty(persistedService.getId())) { cachedAppIds.put(persistedService.getName(), ApplicationId.fromString(persistedService.getId())); @@ -260,8 +246,7 @@ public class ServiceClient extends CompositeService + " appId is null, may be not submitted to YARN yet"); } - for (Map.Entry<String, String> entry : flexArgs.getComponentMap() - .entrySet()) { + for (Map.Entry<String, String> entry : componentCountStrings.entrySet()) { String compName = entry.getKey(); ServiceApiUtil.validateNameFormat(compName, getConfig()); Component component = persistedService.getComponent(compName); @@ -272,11 +257,7 @@ public class ServiceClient extends CompositeService parseNumberOfContainers(component, entry.getValue()); componentCounts.put(compName, numberOfContainers); } - // throw usage exception if no changes proposed - if (componentCounts.size() == 0) { - actionHelp(ACTION_FLEX, args); - } - flexComponents(args.getClusterName(), componentCounts, persistedService); + flexComponents(serviceName, componentCounts, persistedService); return EXIT_SUCCESS; } @@ -372,6 +353,11 @@ public class ServiceClient extends CompositeService return original; } + public int actionStop(String serviceName) + throws YarnException, IOException { + return actionStop(serviceName, true); + } + public int actionStop(String serviceName, boolean waitForAppStopped) throws YarnException, IOException { ServiceApiUtil.validateNameFormat(serviceName, getConfig()); @@ -442,7 +428,8 @@ public class ServiceClient extends CompositeService return EXIT_SUCCESS; } - public int actionDestroy(String serviceName) throws Exception { + public int actionDestroy(String serviceName) throws YarnException, + IOException { ServiceApiUtil.validateNameFormat(serviceName, getConfig()); verifyNoLiveAppInRM(serviceName, "destroy"); @@ -461,7 +448,11 @@ public class ServiceClient extends CompositeService throw new YarnException(message); } } - deleteZKNode(serviceName); + try { + deleteZKNode(serviceName); + } catch (Exception e) { + throw new IOException("Could not delete zk node for " + serviceName, e); + } String registryPath = ServiceRegistryUtils.registryPathForInstance(serviceName); try { getRegistryClient().delete(registryPath, true); @@ -517,11 +508,6 @@ public class ServiceClient extends CompositeService return curatorClient; } - private int actionHelp(String actionName, CommonArgs args) - throws YarnException, IOException { - throw new UsageException(CommonArgs.usage(args, actionName)); - } - private void verifyNoLiveAppInRM(String serviceName, String action) throws IOException, YarnException { Set<String> types = new HashSet<>(1); @@ -634,9 +620,9 @@ public class ServiceClient extends CompositeService CLI.sysprop(SYSPROP_LOG_DIR, ApplicationConstants.LOG_DIR_EXPANSION_VAR); } CLI.add(ServiceMaster.class.getCanonicalName()); - CLI.add(ACTION_CREATE, serviceName); //TODO debugAM CLI.add(Arguments.ARG_DEBUG) - CLI.add(Arguments.ARG_SERVICE_DEF_PATH, new Path(appRootDir, serviceName + ".json")); + CLI.add("-" + ServiceMaster.YARNFILE_OPTION, new Path(appRootDir, + serviceName + ".json")); // pass the registry binding CLI.addConfOptionToCLI(conf, RegistryConstants.KEY_REGISTRY_ZK_ROOT, RegistryConstants.DEFAULT_ZK_REGISTRY_ROOT); @@ -841,6 +827,24 @@ public class ServiceClient extends CompositeService return ServiceState.ACCEPTED; } + public String getStatusString(String appId) + throws IOException, YarnException { + ApplicationReport appReport = + yarnClient.getApplicationReport(ApplicationId.fromString(appId)); + + if (appReport.getYarnApplicationState() != RUNNING) { + return ""; + } + if (StringUtils.isEmpty(appReport.getHost())) { + return ""; + } + ClientAMProtocol amProxy = + createAMProxy(appReport.getHost(), appReport.getRpcPort()); + GetStatusResponseProto response = + amProxy.getStatus(GetStatusRequestProto.newBuilder().build()); + return response.getStatus(); + } + public Service getStatus(String serviceName) throws IOException, YarnException { ServiceApiUtil.validateNameFormat(serviceName, getConfig()); @@ -877,7 +881,11 @@ public class ServiceClient extends CompositeService return this.yarnClient; } - public int actionDependency(ActionDependencyArgs args) + public int enableFastLaunch() throws IOException, YarnException { + return actionDependency(true); + } + + public int actionDependency(boolean overwrite) throws IOException, YarnException { String currentUser = RegistryUtils.currentUser(); LOG.info("Running command as user {}", currentUser); @@ -886,11 +894,10 @@ public class ServiceClient extends CompositeService // Check if dependency has already been uploaded, in which case log // appropriately and exit success (unless overwrite has been requested) - if (fs.isFile(dependencyLibTarGzip) && !args.overwrite) { + if (fs.isFile(dependencyLibTarGzip) && !overwrite) { System.out.println(String.format( - "Dependency libs are already uploaded to %s. Use %s " - + "if you want to re-upload", dependencyLibTarGzip.toUri(), - Arguments.ARG_OVERWRITE)); + "Dependency libs are already uploaded to %s.", dependencyLibTarGzip + .toUri())); return EXIT_SUCCESS; } http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba7ed7b6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/AbstractActionArgs.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/AbstractActionArgs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/AbstractActionArgs.java deleted file mode 100644 index 9b7e2a4..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/AbstractActionArgs.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.service.client.params; - -import com.beust.jcommander.Parameter; -import org.apache.hadoop.fs.Path; -import org.apache.hadoop.yarn.service.exceptions.BadCommandArgumentsException; -import org.apache.hadoop.yarn.service.exceptions.ErrorStrings; -import org.apache.hadoop.yarn.service.exceptions.UsageException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.List; - -/** - * Base args for all actions - */ -public abstract class AbstractActionArgs extends ArgOps implements Arguments { - protected static final Logger log = - LoggerFactory.getLogger(AbstractActionArgs.class); - - - protected AbstractActionArgs() { - } - - /** - * This is the default parameter - */ - @Parameter - public List<String> parameters = new ArrayList<>(); - - /** - * get the name: relies on arg 1 being the cluster name in all operations - * @return the name argument, null if there is none - */ - public String getServiceName() { - return (parameters.isEmpty()) ? null : parameters.get(0); - } - - /** - -D name=value - - Define an configuration option which overrides any options in - the configuration XML files of the image or in the image configuration - directory. The values will be persisted. - Configuration options are only passed to the cluster when creating or reconfiguring a cluster. - - */ - - @Parameter(names = ARG_DEFINE, arity = 1, description = "Definitions", hidden = true) - public List<String> definitions = new ArrayList<>(); - - /** - * System properties - */ - @Parameter(names = {ARG_SYSPROP}, arity = 1, - description = "system properties in the form name value" + - " These are set after the JVM is started.", - hidden = true) - public List<String> sysprops = new ArrayList<>(0); - - - @Parameter(names = ARG_DEBUG, description = "Debug mode", hidden = true) - public boolean debug = false; - - /** - * Get the min #of params expected - * @return the min number of params in the {@link #parameters} field - */ - public int getMinParams() { - return 1; - } - - /** - * Get the name of the action - * @return the action name - */ - public abstract String getActionName() ; - - /** - * Get the max #of params expected - * @return the number of params in the {@link #parameters} field; - */ - public int getMaxParams() { - return getMinParams(); - } - - public void validate() throws BadCommandArgumentsException, UsageException { - - int minArgs = getMinParams(); - int actionArgSize = parameters.size(); - if (minArgs > actionArgSize) { - throw new BadCommandArgumentsException( - ErrorStrings.ERROR_NOT_ENOUGH_ARGUMENTS + getActionName() + - ", Expected minimum " + minArgs + " but got " + actionArgSize); - } - int maxArgs = getMaxParams(); - if (maxArgs == -1) { - maxArgs = minArgs; - } - if (actionArgSize > maxArgs) { - String message = String.format("%s for action %s: limit is %d but saw %d: ", - ErrorStrings.ERROR_TOO_MANY_ARGUMENTS, - getActionName(), maxArgs, - actionArgSize); - - log.error(message); - int index = 1; - StringBuilder buf = new StringBuilder(message); - for (String actionArg : parameters) { - log.error("[{}] \"{}\"", index++, actionArg); - buf.append(" \"").append(actionArg).append("\" "); - } - throw new BadCommandArgumentsException(buf.toString()); - } - } - - @Override - public String toString() { - return super.toString() + ": " + getActionName(); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba7ed7b6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/AbstractArgsDelegate.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/AbstractArgsDelegate.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/AbstractArgsDelegate.java deleted file mode 100644 index 457e357..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/AbstractArgsDelegate.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.service.client.params; - -import org.apache.hadoop.yarn.service.client.params.ArgOps; -import org.apache.hadoop.yarn.service.client.params.Arguments; - -/** - * Base class for all the delegates - */ -public class AbstractArgsDelegate extends ArgOps implements Arguments { -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba7ed7b6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/AbstractClusterBuildingActionArgs.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/AbstractClusterBuildingActionArgs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/AbstractClusterBuildingActionArgs.java deleted file mode 100644 index 4ecbe9c..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/AbstractClusterBuildingActionArgs.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.service.client.params; - -import com.beust.jcommander.Parameter; - -import java.io.File; - -/** - * Abstract Action to build things; shares args across build and - * list - */ -public abstract class AbstractClusterBuildingActionArgs - extends AbstractActionArgs { - @Parameter(names = { ARG_FILE, ARG_FILE_SHORT }, - description = "The path to the service definition file in JSON format.") - public File file; - - public File getFile() { - return file; - } - - @Parameter(names = { - ARG_QUEUE, ARG_SHORT_QUEUE}, description = "Queue to submit the service") - public String queue; - - @Parameter(names = { - ARG_LIFETIME }, description = "Lifetime of the service from the time of request") - public long lifetime; -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba7ed7b6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionBuildArgs.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionBuildArgs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionBuildArgs.java deleted file mode 100644 index 0228125..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionBuildArgs.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.yarn.service.client.params; - -import com.beust.jcommander.Parameters; -import org.apache.hadoop.yarn.service.exceptions.BadCommandArgumentsException; - -@Parameters(commandNames = { SliderActions.ACTION_BUILD}, - commandDescription = SliderActions.DESCRIBE_ACTION_BUILD) - -public class ActionBuildArgs extends AbstractClusterBuildingActionArgs { - - @Override - public String getActionName() { - return SliderActions.ACTION_BUILD; - } - - @Override - public void validate() throws BadCommandArgumentsException { - if (file == null) { - throw new BadCommandArgumentsException("No service definition provided."); - } - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba7ed7b6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionClientArgs.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionClientArgs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionClientArgs.java deleted file mode 100644 index c43d61a..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionClientArgs.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.service.client.params; - -import com.beust.jcommander.Parameter; -import com.beust.jcommander.Parameters; -import org.apache.hadoop.yarn.service.client.params.AbstractActionArgs; -import org.apache.hadoop.yarn.service.client.params.SliderActions; - -import java.io.File; - -@Parameters(commandNames = { SliderActions.ACTION_CLIENT}, - commandDescription = SliderActions.DESCRIBE_ACTION_CLIENT) - -public class ActionClientArgs extends AbstractActionArgs { - - @Override - public String getActionName() { - return SliderActions.ACTION_CLIENT; - } - - @Parameter(names = {ARG_INSTALL}, - description = "Install client") - public boolean install; - - @Parameter(names = {ARG_NAME}, - description = "The name of the service") - public String name; - - @Parameter(names = {ARG_PACKAGE}, - description = "Path to app package") - public String packageURI; - - @Parameter(names = {ARG_DEST}, - description = "The location where to install the client") - public File installLocation; - - @Parameter(names = {ARG_CONFIG}, - description = "Client configuration") - public File clientConfig; - - /** - * Get the min #of params expected - * - * @return the min number of params in the {@link #parameters} field - */ - public int getMinParams() { - return 0; - } - - @Override - public int getMaxParams() { - return 1; - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba7ed7b6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionCreateArgs.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionCreateArgs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionCreateArgs.java deleted file mode 100644 index 039f528..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionCreateArgs.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.service.client.params; - -import com.beust.jcommander.Parameter; -import com.beust.jcommander.Parameters; -import org.apache.hadoop.yarn.service.exceptions.BadCommandArgumentsException; - -@Parameters(commandNames = { SliderActions.ACTION_CREATE}, - commandDescription = SliderActions.DESCRIBE_ACTION_CREATE) - -public class ActionCreateArgs extends AbstractClusterBuildingActionArgs { - - @Parameter(names = { ARG_EXAMPLE, ARG_EXAMPLE_SHORT }, - description = "The name of the example service such as sleeper") - public String example; - - @Override - public String getActionName() { - return SliderActions.ACTION_CREATE; - } - - @Override - public void validate() throws BadCommandArgumentsException { - if (file == null && example == null) { - throw new BadCommandArgumentsException("No service definition provided."); - } - } -} - http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba7ed7b6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionDependencyArgs.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionDependencyArgs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionDependencyArgs.java deleted file mode 100644 index 699e6ab..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionDependencyArgs.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.yarn.service.client.params; - -import org.apache.hadoop.yarn.service.exceptions.BadCommandArgumentsException; -import org.apache.hadoop.yarn.service.exceptions.UsageException; - -import com.beust.jcommander.Parameter; -import com.beust.jcommander.Parameters; - -@Parameters(commandNames = { SliderActions.ACTION_DEPENDENCY }, - commandDescription = SliderActions.DESCRIBE_ACTION_DEPENDENCY) -public class ActionDependencyArgs extends AbstractActionArgs { - - @Override - public String getActionName() { - return SliderActions.ACTION_DEPENDENCY; - } - - @Parameter(names = { ARG_UPLOAD }, required = true, - description = "Upload AM libraries to HDFS for this client version") - public boolean upload; - - @Parameter(names = { ARG_OVERWRITE }, - description = "Overwrite current uploaded dependency libs") - public boolean overwrite = false; - - /** - * Get the min #of params expected - * - * @return the min number of params in the {@link #parameters} field - */ - public int getMinParams() { - return 0; - } - - @Override - public int getMaxParams() { - return 1; - } - - @Override - public void validate() throws BadCommandArgumentsException, UsageException { - super.validate(); - - if (!upload) { - throw new UsageException("Option " + ARG_UPLOAD + " is mandatory"); - } - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba7ed7b6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionDestroyArgs.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionDestroyArgs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionDestroyArgs.java deleted file mode 100644 index 8c41c04..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionDestroyArgs.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.service.client.params; - -import com.beust.jcommander.Parameter; -import com.beust.jcommander.Parameters; - -@Parameters(commandNames = { SliderActions.ACTION_DESTROY}, - commandDescription = SliderActions.DESCRIBE_ACTION_DESTROY) - -public class ActionDestroyArgs extends AbstractActionArgs { - - @Override - public String getActionName() { - return SliderActions.ACTION_DESTROY; - } - - @Parameter(names = {ARG_FORCE}, - description = "force the operation") - public boolean force; -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba7ed7b6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionExistsArgs.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionExistsArgs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionExistsArgs.java deleted file mode 100644 index 088ad47..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionExistsArgs.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.service.client.params; - -import com.beust.jcommander.Parameter; -import com.beust.jcommander.Parameters; -import org.apache.hadoop.yarn.service.client.params.AbstractActionArgs; -import org.apache.hadoop.yarn.service.client.params.SliderActions; - -import java.io.File; - -@Parameters(commandNames = { SliderActions.ACTION_EXISTS}, - commandDescription = SliderActions.DESCRIBE_ACTION_EXISTS) - -public class ActionExistsArgs extends AbstractActionArgs { - - @Override - public String getActionName() { - return SliderActions.ACTION_EXISTS; - } - - @Parameter(names = {ARG_LIVE}, - description = "verify that the service is running") - public boolean live; - - @Parameter(names = {ARG_STATE}, - description = "verify that the service is in the specific YARN state") - public String state = ""; - - @Parameter(names = {ARG_OUTPUT, ARG_OUTPUT_SHORT}, - description = "output file for any service report") - public File out; -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba7ed7b6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionFlexArgs.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionFlexArgs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionFlexArgs.java deleted file mode 100644 index b7acf58..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionFlexArgs.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.service.client.params; - -import com.beust.jcommander.Parameters; -import com.beust.jcommander.ParametersDelegate; -import org.apache.hadoop.yarn.service.exceptions.BadCommandArgumentsException; - -import java.util.List; -import java.util.Map; - -@Parameters(commandNames = { SliderActions.ACTION_FLEX}, - commandDescription = SliderActions.DESCRIBE_ACTION_FLEX) - -public class ActionFlexArgs extends AbstractActionArgs { - - @Override - public String getActionName() { - return SliderActions.ACTION_FLEX; - } - - @ParametersDelegate - public ComponentArgsDelegate componentDelegate = new ComponentArgsDelegate(); - - /** - * Get the component mapping (may be empty, but never null) - * @return mapping - * @throws BadCommandArgumentsException parse problem - */ - public Map<String, String> getComponentMap() throws - BadCommandArgumentsException { - return componentDelegate.getComponentMap(); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba7ed7b6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionFreezeArgs.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionFreezeArgs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionFreezeArgs.java deleted file mode 100644 index aecf0eb..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionFreezeArgs.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.service.client.params; - -import com.beust.jcommander.Parameter; -import com.beust.jcommander.Parameters; -import com.beust.jcommander.ParametersDelegate; - -@Parameters(commandNames = { SliderActions.ACTION_STOP }, - commandDescription = SliderActions.DESCRIBE_ACTION_FREEZE) - -public class ActionFreezeArgs extends AbstractActionArgs implements - WaitTimeAccessor { - @Override - public String getActionName() { - return SliderActions.ACTION_STOP; - } - - public static final String FREEZE_COMMAND_ISSUED = "stop command issued"; - @ParametersDelegate - public WaitArgsDelegate waitDelegate = new WaitArgsDelegate(); - - @Override - public int getWaittime() { - return waitDelegate.getWaittime(); - } - - @Override - public void setWaittime(int waittime) { - waitDelegate.setWaittime(waittime); - } - - @Parameter(names={ARG_MESSAGE}, - description = "reason for the operation") - public String message = FREEZE_COMMAND_ISSUED; - - @Parameter(names = {ARG_FORCE}, - description = "force the operation") - public boolean force; -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba7ed7b6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionHelpArgs.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionHelpArgs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionHelpArgs.java deleted file mode 100644 index 51aa88a..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionHelpArgs.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.service.client.params; - -import com.beust.jcommander.Parameters; -import org.apache.hadoop.yarn.service.client.params.AbstractActionArgs; -import org.apache.hadoop.yarn.service.client.params.SliderActions; - -/** - * The Help command - */ -@Parameters(commandNames = { SliderActions.ACTION_HELP}, - commandDescription = SliderActions.DESCRIBE_ACTION_HELP) -public class ActionHelpArgs extends AbstractActionArgs { - @Override - public String getActionName() { - return SliderActions.ACTION_HELP; - } - - /** - * Get the min #of params expected - * @return the min number of params in the {@link #parameters} field - */ - @Override - public int getMinParams() { - return 0; - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba7ed7b6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionKeytabArgs.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionKeytabArgs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionKeytabArgs.java deleted file mode 100644 index 7e51457..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionKeytabArgs.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.service.client.params; - -import com.beust.jcommander.Parameter; -import com.beust.jcommander.Parameters; -import org.apache.hadoop.yarn.service.client.params.AbstractActionArgs; -import org.apache.hadoop.yarn.service.client.params.SliderActions; - -@Parameters(commandNames = { SliderActions.ACTION_KEYTAB}, - commandDescription = SliderActions.DESCRIBE_ACTION_KEYTAB) - -public class ActionKeytabArgs extends AbstractActionArgs { - - public ActionKeytabArgs() { - super(); - } - - @Override - public String getActionName() { - return SliderActions.ACTION_INSTALL_KEYTAB; - } - - @Parameter(names = {ARG_KEYTABINSTALL}, - description = "Install the keytab") - public boolean install; - - @Parameter(names = {ARG_KEYTABDELETE}, - description = "Delete the keytab") - public boolean delete; - - @Parameter(names = {ARG_KEYTABLIST}, - description = "List of installed keytabs") - public boolean list; - - @Parameter(names = {ARG_KEYTAB}, - description = "Path or name of the keytab") - public String keytab; - - @Parameter(names = {ARG_FOLDER}, - description = "The name of the folder in which to store the keytab") - public String folder; - - @Parameter(names = {ARG_OVERWRITE}, description = "Overwrite existing keytab") - public boolean overwrite = false; - - /** - * Get the min #of params expected - * @return the min number of params in the {@link #parameters} field - */ - public int getMinParams() { - return 0; - } - - @Override - public int getMaxParams() { - return 3; - } - -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba7ed7b6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionListArgs.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionListArgs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionListArgs.java deleted file mode 100644 index c05e602..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionListArgs.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.service.client.params; - -import java.util.HashSet; -import java.util.Set; - -import com.beust.jcommander.Parameter; -import com.beust.jcommander.Parameters; -import org.apache.hadoop.yarn.service.client.params.AbstractActionArgs; -import org.apache.hadoop.yarn.service.client.params.SliderActions; - -@Parameters(commandNames = { SliderActions.ACTION_LIST}, - commandDescription = SliderActions.DESCRIBE_ACTION_LIST) - -public class ActionListArgs extends AbstractActionArgs { - @Override - public String getActionName() { - return SliderActions.ACTION_LIST; - } - - @Parameter(names = {ARG_LIVE}, - description = "List only live service instances") - public boolean live; - - @Parameter(names = {ARG_STATE}, - description = "list only applications in the specific YARN state") - public String state = ""; - - @Parameter(names = {ARG_VERBOSE}, - description = "print out information in details") - public boolean verbose = false; - - @Parameter(names = {ARG_CONTAINERS}, - description = "List containers of a service instance") - public boolean containers; - - @Parameter(names = {ARG_VERSION}, - description = "Filter containers by app version (used with " + - ARG_CONTAINERS + ")") - public String version; - - @Parameter(names = {ARG_COMPONENTS}, variableArity = true, - description = "Filter containers by component names (used with " + - ARG_CONTAINERS + ")") - public Set<String> components = new HashSet<>(0); - - /** - * Get the min #of params expected - * @return the min number of params in the {@link #parameters} field - */ - public int getMinParams() { - return 0; - } - - @Override - public int getMaxParams() { - return 1; - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba7ed7b6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionRegistryArgs.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionRegistryArgs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionRegistryArgs.java deleted file mode 100644 index 3e53418..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/params/ActionRegistryArgs.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.service.client.params; - -import com.beust.jcommander.Parameter; -import com.beust.jcommander.Parameters; -import org.apache.hadoop.yarn.service.conf.YarnServiceConstants; -import org.apache.hadoop.yarn.service.exceptions.BadCommandArgumentsException; -import org.apache.hadoop.yarn.service.exceptions.UsageException; -import org.apache.hadoop.yarn.service.api.records.ConfigFormat; - -import static org.apache.hadoop.yarn.service.client.params.SliderActions.ACTION_REGISTRY; -import static org.apache.hadoop.yarn.service.client.params.SliderActions.DESCRIBE_ACTION_REGISTRY; -import java.io.File; - -/** - * Registry actions - * - * --instance {app name}, if a / is in it, refers underneath? - * --dest {destfile} - * --list : list instances of slider service - * --listfiles - */ -@Parameters(commandNames = {ACTION_REGISTRY}, - commandDescription = DESCRIBE_ACTION_REGISTRY) - -public class ActionRegistryArgs extends AbstractActionArgs { - - public static final String USAGE = - "Usage: " + SliderActions.ACTION_REGISTRY - + " (" - + Arguments.ARG_LIST + "|" - + Arguments.ARG_LISTCONF + "|" - + Arguments.ARG_LISTEXP + "|" - + Arguments.ARG_LISTFILES + "|" - + Arguments.ARG_GETCONF + "|" - + Arguments.ARG_GETEXP + "> " - + Arguments.ARG_NAME + " <name> " - + " )" - + "[" + Arguments.ARG_VERBOSE + "] " - + "[" + Arguments.ARG_USER + "] " - + "[" + Arguments.ARG_OUTPUT + " <filename> ] " - + "[" + Arguments.ARG_SERVICETYPE + " <servicetype> ] " - + "[" + Arguments.ARG_FORMAT + " <xml|json|properties>] " - + System.getProperty("line.separator") - + "Arguments.ARG_GETEXP only supports " + Arguments.ARG_FORMAT + " json" - ; - public ActionRegistryArgs() { - } - - public ActionRegistryArgs(String name) { - this.name = name; - } - - @Override - public String getActionName() { - return ACTION_REGISTRY; - } - - /** - * Get the min #of params expected - * @return the min number of params in the {@link #parameters} field - */ - @Override - public int getMinParams() { - return 0; - } - - @Parameter(names = {ARG_LIST}, - description = "list services") - public boolean list; - - @Parameter(names = {ARG_LISTCONF}, - description = "list configurations") - public boolean listConf; - - @Parameter(names = {ARG_GETCONF}, - description = "get configuration") - public String getConf; - - @Parameter(names = {ARG_LISTEXP}, - description = "list exports") - public boolean listExports; - - @Parameter(names = {ARG_GETEXP}, - description = "get export") - public String getExport; - - @Parameter(names = {ARG_LISTFILES}, - description = "list files") - public String listFiles; - - @Parameter(names = {ARG_GETFILES}, - description = "get files") - public String getFiles; - - //--format - @Parameter(names = ARG_FORMAT, - description = "Format for a response: <xml|json|properties>") - public String format = ConfigFormat.XML.toString() ; - - @Parameter(names = {ARG_OUTPUT, ARG_OUTPUT_SHORT, ARG_DEST}, - description = "Output destination") - public File out; - - @Parameter(names = {ARG_NAME}, - description = "name of an instance") - public String name; - - @Parameter(names = {ARG_SERVICETYPE}, - description = "optional service type") - public String serviceType = YarnServiceConstants.APP_TYPE; - - @Parameter(names = {ARG_VERBOSE}, - description = "verbose output") - public boolean verbose; - - @Parameter(names = {ARG_INTERNAL}, - description = "fetch internal registry entries") - public boolean internal; - - @Parameter(names = {ARG_USER}, - description = "the name of the user whose service is being resolved") - public String user; - - /** - * validate health of all the different operations - * @throws BadCommandArgumentsException - */ - @Override - public void validate() throws BadCommandArgumentsException, UsageException { - super.validate(); - - //verify that at most one of the operations is set - int gets = s(getConf) + s(getFiles) + s(getExport); - int lists = s(list) + s(listConf) + s(listFiles) + s(listExports); - int set = lists + gets; - if (set > 1) { - throw new UsageException(USAGE); - } - - if (out != null && ( set == 0)) { - throw new UsageException("output path" - + " is only supported on 'get' operations: "); - } - if (!list && !is(name)) { - throw new UsageException("Argument " + ARG_NAME - +" missing: "); - - } - } - - private int s(String arg) { - return is(arg) ? 1 : 0; - } - - private boolean is(String arg) { - return arg != null; - } - - private int s(boolean arg) { - return arg ? 1 : 0; - } - - private String ifdef(String arg, boolean val) { - return val ? (arg + " "): ""; - } - - private String ifdef(String arg, String val) { - if (is(val)) { - return arg + " " + val + " "; - } else { - return ""; - } - } - - @Override - public String toString() { - final StringBuilder sb = - new StringBuilder(ACTION_REGISTRY); - sb.append(' '); - sb.append(ifdef(ARG_LIST, list)); - sb.append(ifdef(ARG_LISTCONF, listConf)); - sb.append(ifdef(ARG_LISTFILES, listFiles)); - sb.append(ifdef(ARG_GETCONF, getConf)); - sb.append(ifdef(ARG_GETFILES, getFiles)); - - sb.append(ifdef(ARG_NAME, name)); - sb.append(ifdef(ARG_SERVICETYPE, serviceType)); - - - sb.append(ifdef(ARG_VERBOSE, verbose)); - sb.append(ifdef(ARG_INTERNAL, internal)); - - if (out != null) { - sb.append(ifdef(ARG_OUTPUT, out.toString())); - } - sb.append(ifdef(ARG_FORMAT, format)); - - return sb.toString(); - } -} --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org