Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions tez-dag/src/main/java/org/apache/tez/dag/app/DAGAppMaster.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
import com.google.common.collect.Lists;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.hadoop.yarn.api.records.NodeId;
Expand Down Expand Up @@ -2400,11 +2401,14 @@ public static void main(String[] args) {
.getenv(ApplicationConstants.Environment.USER.name());

// Command line options
Options opts = new Options();
opts.addOption(TezConstants.TEZ_SESSION_MODE_CLI_OPTION,
false, "Run Tez Application Master in Session mode");

CommandLine cliParser = new GnuParser().parse(opts, args);
Option option = Option.builder()
.longOpt(TezConstants.TEZ_SESSION_MODE_CLI_OPTION)
.hasArg(false)
.desc("Run Tez Application Master in Session mode")
.build();
Options opts = new Options().addOption(option);

CommandLine cliParser = new DefaultParser().parse(opts, args);
boolean sessionModeCliOption = cliParser.hasOption(TezConstants.TEZ_SESSION_MODE_CLI_OPTION);

LOG.info("Creating DAGAppMaster for "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@
import com.sun.jersey.client.urlconnection.URLConnectionClientHandler;
import com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.io.IOUtils;
Expand Down Expand Up @@ -358,27 +357,27 @@ public int run(String[] args) throws Exception {
}

private static Options buildOptions() {
Option dagIdOption = OptionBuilder.withArgName(DAG_ID).withLongOpt(DAG_ID)
.withDescription("DagId that needs to be downloaded").hasArg().isRequired(true).create();
Option dagIdOption = Option.builder().argName(DAG_ID).longOpt(DAG_ID)
.desc("DagId that needs to be downloaded").hasArg().required(true).build();

Option downloadDirOption = OptionBuilder.withArgName(BASE_DOWNLOAD_DIR).withLongOpt
Option downloadDirOption = Option.builder().argName(BASE_DOWNLOAD_DIR).longOpt
(BASE_DOWNLOAD_DIR)
.withDescription("Download directory where data needs to be downloaded").hasArg()
.isRequired(true).create();
.desc("Download directory where data needs to be downloaded").hasArg()
.required(true).build();

Option atsAddressOption = OptionBuilder.withArgName(YARN_TIMELINE_SERVICE_ADDRESS).withLongOpt(
Option atsAddressOption = Option.builder().argName(YARN_TIMELINE_SERVICE_ADDRESS).longOpt(
YARN_TIMELINE_SERVICE_ADDRESS)
.withDescription("Optional. ATS address (e.g http://clusterATSNode:8188)").hasArg()
.isRequired(false)
.create();
.desc("Optional. ATS address (e.g http://clusterATSNode:8188)").hasArg()
.required(false)
.build();

Option batchSizeOption = OptionBuilder.withArgName(BATCH_SIZE).withLongOpt(BATCH_SIZE)
.withDescription("Optional. batch size for downloading data").hasArg()
.isRequired(false)
.create();
Option batchSizeOption = Option.builder().argName(BATCH_SIZE).longOpt(BATCH_SIZE)
.desc("Optional. batch size for downloading data").hasArg()
.required(false)
.build();

Option help = OptionBuilder.withArgName("help").withLongOpt("help")
.withDescription("print help").isRequired(false).create();
Option help = Option.builder().argName("help").longOpt("help")
.desc("print help").required(false).build();

Options opts = new Options();
opts.addOption(dagIdOption);
Expand Down Expand Up @@ -451,7 +450,7 @@ public static int process(String[] args) throws Exception {
Options options = buildOptions();
try {
Configuration conf = new Configuration();
CommandLine cmdLine = new GnuParser().parse(options, args);
CommandLine cmdLine = new DefaultParser().parse(options, args);
String dagId = cmdLine.getOptionValue(DAG_ID);

File downloadDir = new File(cmdLine.getOptionValue(BASE_DOWNLOAD_DIR));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;

Expand Down Expand Up @@ -50,15 +49,15 @@ public boolean parse(String[] args, boolean defaultVal) throws ParseException {
Preconditions.checkState(parsed == false,
"Create a new instance for different option sets");
parsed = true;
Options opts = new Options();
Option opt = OptionBuilder
.withArgName("splits_in_client")
Option opt = Option.builder()
.option("generateSplitsInClient")
.argName("splits_in_client")
.hasArg()
.withDescription(
.desc(
"specify whether splits should be generated in the client")
.create("generateSplitsInClient");
opts.addOption(opt);
CommandLineParser parser = new GnuParser();
.build();
Options opts = new Options().addOption(opt);
CommandLineParser parser = new DefaultParser();

cmdLine = parser.parse(opts, args, false);
if (cmdLine.hasOption("generateSplitsInClient")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@
import java.util.stream.Collectors;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.io.FileUtils;
Expand Down Expand Up @@ -75,35 +74,35 @@ public TezAnalyzerBase(Configuration config) {

@SuppressWarnings("static-access")
private static Options buildOptions() {
Option dagIdOption = OptionBuilder.withArgName(DAG_ID).withLongOpt(DAG_ID)
.withDescription("DagId that needs to be analyzed").hasArg().isRequired(true).create();
Option dagIdOption = Option.builder().argName(DAG_ID).longOpt(DAG_ID)
.desc("DagId that needs to be analyzed").hasArg().required(true).build();

Option outputDirOption = OptionBuilder.withArgName(OUTPUT_DIR).withLongOpt(OUTPUT_DIR)
.withDescription("Directory to write outputs to.").hasArg().isRequired(false).create();
Option outputDirOption = Option.builder().argName(OUTPUT_DIR).longOpt(OUTPUT_DIR)
.desc("Directory to write outputs to.").hasArg().required(false).build();

Option saveResults = OptionBuilder.withArgName(SAVE_RESULTS).withLongOpt(SAVE_RESULTS)
.withDescription("Saves results to output directory (optional)")
.hasArg(false).isRequired(false).create();
Option saveResults = Option.builder().argName(SAVE_RESULTS).longOpt(SAVE_RESULTS)
.desc("Saves results to output directory (optional)")
.hasArg(false).required(false).build();

Option eventFileNameOption = OptionBuilder.withArgName(EVENT_FILE_NAME).withLongOpt
Option eventFileNameOption = Option.builder().argName(EVENT_FILE_NAME).longOpt
(EVENT_FILE_NAME)
.withDescription("File with event data for the DAG").hasArg()
.isRequired(false).create();
.desc("File with event data for the DAG").hasArg()
.required(false).build();

Option fromSimpleHistoryOption = OptionBuilder.withArgName(FROM_SIMPLE_HISTORY).withLongOpt
Option fromSimpleHistoryOption = Option.builder().argName(FROM_SIMPLE_HISTORY).longOpt
(FROM_SIMPLE_HISTORY)
.withDescription("Event data from Simple History logging. Must also specify event file")
.isRequired(false).create();
.desc("Event data from Simple History logging. Must also specify event file")
.required(false).build();

Option fromProtoHistoryOption =
OptionBuilder.withArgName(FROM_PROTO_HISTORY).withLongOpt(FROM_PROTO_HISTORY)
.withDescription("Event data from Proto History logging. Must also specify event file")
.isRequired(false).create();
Option.builder().argName(FROM_PROTO_HISTORY).longOpt(FROM_PROTO_HISTORY)
.desc("Event data from Proto History logging. Must also specify event file")
.required(false).build();

Option help = OptionBuilder.withArgName(HELP).withLongOpt
Option help = Option.builder().argName(HELP).longOpt
(HELP)
.withDescription("print help")
.isRequired(false).create();
.desc("print help")
.required(false).build();

Options opts = new Options();
opts.addOption(dagIdOption);
Expand All @@ -123,8 +122,7 @@ protected String getOutputDir() {
private void printUsage() {
System.err.println("Analyzer base options are");
Options options = buildOptions();
for (Object obj : options.getOptions()) {
Option option = (Option) obj;
for (Option option : options.getOptions()) {
System.err.println(option.getArgName() + " : " + option.getDescription());
}
}
Expand All @@ -134,7 +132,7 @@ public int run(String[] args) throws Exception {
//Parse downloaded contents
CommandLine cmdLine = null;
try {
cmdLine = new GnuParser().parse(buildOptions(), args);
cmdLine = new DefaultParser().parse(buildOptions(), args);
} catch (ParseException e) {
System.err.println("Invalid options on command line");
printUsage();
Expand Down