[ https://issues.apache.org/jira/browse/FLINK-2021?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15132358#comment-15132358 ]
ASF GitHub Bot commented on FLINK-2021: --------------------------------------- Github user stefanobaghino commented on a diff in the pull request: https://github.com/apache/flink/pull/1581#discussion_r51875652 --- Diff: flink-examples/flink-examples-batch/src/main/java/org/apache/flink/examples/java/distcp/DistCp.java --- @@ -62,18 +63,32 @@ public static final String FILES_COPIED_CNT_NAME = "FILES_COPIED"; public static void main(String[] args) throws Exception { - if (args.length != 3) { - printHelp(); + + // set up the execution environment + final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); + + ParameterTool params = ParameterTool.fromArgs(args); + if (!params.has("input") || !params.has("output")) { + System.err.println("Usage: --input <path> --output <path> [--parallelism <n>]"); return; } - final Path sourcePath = new Path(args[0]); - final Path targetPath = new Path(args[1]); - int parallelism = Integer.valueOf(args[2], 10); + final Path sourcePath = new Path(params.get("input")); + final Path targetPath = new Path(params.get("output")); + if (!isLocal(env) && !(isOnDistributedFS(sourcePath) && isOnDistributedFS(targetPath))) { + System.out.println("In a distributed mode only HDFS input/output paths are supported"); + return; + } + + final int parallelism = Integer.valueOf(params.getInt("parallelism", 10)); --- End diff -- Right, fixing it right away, thanks! > Rework examples to use ParameterTool > ------------------------------------ > > Key: FLINK-2021 > URL: https://issues.apache.org/jira/browse/FLINK-2021 > Project: Flink > Issue Type: Improvement > Components: Examples > Affects Versions: 0.9 > Reporter: Robert Metzger > Priority: Minor > Labels: starter > > In FLINK-1525, we introduced the {{ParameterTool}}. > We should port the examples to use the tool. > The examples could look like this (we should maybe discuss it first on the > mailing lists): > {code} > public static void main(String[] args) throws Exception { > ParameterTool pt = ParameterTool.fromArgs(args); > boolean fileOutput = pt.getNumberOfParameters() == 2; > String textPath = null; > String outputPath = null; > if(fileOutput) { > textPath = pt.getRequired("input"); > outputPath = pt.getRequired("output"); > } > // set up the execution environment > final ExecutionEnvironment env = > ExecutionEnvironment.getExecutionEnvironment(); > env.getConfig().setUserConfig(pt); > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)