Repository: flink Updated Branches: refs/heads/master 40eef52e9 -> d73cb7369
[FLINK-2459] [cli] Cli API and doc fixes. 1. Remove CliFrontendLoggingTest. Test directly that the logging flag is interpreted correctly. 2. Doc fix for cli api 3. Info command shouldn't print logging option for help. This closes #971 Project: http://git-wip-us.apache.org/repos/asf/flink/repo Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/81f9b214 Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/81f9b214 Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/81f9b214 Branch: refs/heads/master Commit: 81f9b214a37aa81017eface6ba43f24f845a4ec8 Parents: 40eef52 Author: Sachin Goel <[email protected]> Authored: Sat Aug 1 21:04:39 2015 +0530 Committer: Stephan Ewen <[email protected]> Committed: Sun Aug 2 17:38:13 2015 +0200 ---------------------------------------------------------------------- docs/apis/cli.md | 5 + .../flink/client/cli/CliFrontendParser.java | 3 +- .../org/apache/flink/client/program/Client.java | 7 ++ .../flink/client/CliFrontendLoggingTest.java | 113 ------------------- .../apache/flink/client/CliFrontendRunTest.java | 18 ++- 5 files changed, 28 insertions(+), 118 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flink/blob/81f9b214/docs/apis/cli.md ---------------------------------------------------------------------- diff --git a/docs/apis/cli.md b/docs/apis/cli.md index c0ae9b1..5117bbb 100644 --- a/docs/apis/cli.md +++ b/docs/apis/cli.md @@ -128,6 +128,11 @@ Action "run" compiles and runs a program. program. Optional flag to override the default value specified in the configuration. + -q --sysoutLogging Specfying this flag will disable log messages + being reported on the console. All messages + however will still be logged by SLF4J loggers, + regardless of this setting. + Additional arguments if -m yarn-cluster is set: -yD <arg> Dynamic properties -yd,--yarndetached Start detached http://git-wip-us.apache.org/repos/asf/flink/blob/81f9b214/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontendParser.java ---------------------------------------------------------------------- diff --git a/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontendParser.java b/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontendParser.java index ae8499b..0a9af8d 100644 --- a/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontendParser.java +++ b/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontendParser.java @@ -149,7 +149,8 @@ public class CliFrontendParser { } private static Options getInfoOptionsWithoutDeprecatedOptions(Options options) { - options = getProgramSpecificOptionsWithoutDeprecatedOptions(options); + options.addOption(CLASS_OPTION); + options.addOption(PARALLELISM_OPTION); options = getJobManagerAddressOption(options); return options; } http://git-wip-us.apache.org/repos/asf/flink/blob/81f9b214/flink-clients/src/main/java/org/apache/flink/client/program/Client.java ---------------------------------------------------------------------- diff --git a/flink-clients/src/main/java/org/apache/flink/client/program/Client.java b/flink-clients/src/main/java/org/apache/flink/client/program/Client.java index 1de0703..d2022bb 100644 --- a/flink-clients/src/main/java/org/apache/flink/client/program/Client.java +++ b/flink-clients/src/main/java/org/apache/flink/client/program/Client.java @@ -192,6 +192,13 @@ public class Client { } /** + * @return whether the client will print progress updates during the execution to {@code System.out} + */ + public boolean getPrintStatusDuringExecution() { + return this.printStatusDuringExecution; + } + + /** * @return -1 if unknown. The maximum number of available processing slots at the Flink cluster * connected to this client. */ http://git-wip-us.apache.org/repos/asf/flink/blob/81f9b214/flink-clients/src/test/java/org/apache/flink/client/CliFrontendLoggingTest.java ---------------------------------------------------------------------- diff --git a/flink-clients/src/test/java/org/apache/flink/client/CliFrontendLoggingTest.java b/flink-clients/src/test/java/org/apache/flink/client/CliFrontendLoggingTest.java deleted file mode 100644 index 157e070..0000000 --- a/flink-clients/src/test/java/org/apache/flink/client/CliFrontendLoggingTest.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.flink.client; - -import org.apache.flink.configuration.ConfigConstants; -import org.apache.flink.configuration.Configuration; -import org.apache.flink.runtime.StreamingMode; -import org.apache.flink.runtime.minicluster.LocalFlinkMiniCluster; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; - -import static org.apache.flink.client.CliFrontendTestUtils.getTestJarPath; -import static org.apache.flink.client.CliFrontendTestUtils.getConfigDir; -import static org.junit.Assert.fail; - -public class CliFrontendLoggingTest { - - private static LocalFlinkMiniCluster cluster; - private static Configuration config; - private static String hostPort; - private ByteArrayOutputStream stream = new ByteArrayOutputStream(); - private CliFrontend cli; - private PrintStream output; - - @Before - public void setUp() throws Exception { - stream.reset(); - output = System.out; - System.setOut(new PrintStream(stream)); - - config = new Configuration(); - config.setString(ConfigConstants.JOB_MANAGER_IPC_ADDRESS_KEY, "localhost"); - config.setInteger(ConfigConstants.TASK_MANAGER_NUM_TASK_SLOTS, 2); - config.setInteger(ConfigConstants.LOCAL_INSTANCE_MANAGER_NUMBER_TASK_MANAGER, 1); - config.setBoolean(ConfigConstants.LOCAL_INSTANCE_MANAGER_START_WEBSERVER, false); - hostPort = config.getString(ConfigConstants.JOB_MANAGER_IPC_ADDRESS_KEY, null) + ":" + - config.getInteger(ConfigConstants.JOB_MANAGER_IPC_PORT_KEY, ConfigConstants.DEFAULT_JOB_MANAGER_IPC_PORT); - - try { - cluster = new LocalFlinkMiniCluster(config, false, StreamingMode.BATCH_ONLY); - } - catch (Exception e) { - e.printStackTrace(); - fail("Setup of test actor system failed."); - } - - cli = new CliFrontend(getConfigDir()); - } - - @After - public void shutDownActorSystem() { - System.setOut(output); - if(cluster != null){ - cluster.shutdown(); - } - } - - @Test - public void verifyLogging(){ - try { - int ret = cli.run(new String[]{"-m", hostPort, getTestJarPath()}); - System.out.flush(); - assert(ret == 0 && checkForLogs(stream.toString())); - } catch(Exception e){ - e.printStackTrace(); - fail(e.getMessage()); - } finally { - if(cluster != null){ - cluster.shutdown(); - } - } - } - - @Test - public void verifyNoLogging(){ - try { - int ret = cli.run(new String[]{"-q", "-m", hostPort, getTestJarPath()}); - System.out.flush(); - assert(ret == 0 && !checkForLogs(stream.toString())); - } catch(Exception e){ - e.printStackTrace(); - fail(e.getMessage()); - } finally { - if(cluster != null){ - cluster.shutdown(); - } - } - } - - private boolean checkForLogs(String output){ - return output.indexOf("RUNNING") >= 0; - } -} http://git-wip-us.apache.org/repos/asf/flink/blob/81f9b214/flink-clients/src/test/java/org/apache/flink/client/CliFrontendRunTest.java ---------------------------------------------------------------------- diff --git a/flink-clients/src/test/java/org/apache/flink/client/CliFrontendRunTest.java b/flink-clients/src/test/java/org/apache/flink/client/CliFrontendRunTest.java index 034ee4e..6798806 100644 --- a/flink-clients/src/test/java/org/apache/flink/client/CliFrontendRunTest.java +++ b/flink-clients/src/test/java/org/apache/flink/client/CliFrontendRunTest.java @@ -50,17 +50,24 @@ public class CliFrontendRunTest { // test without parallelism { String[] parameters = {"-v", getTestJarPath()}; - RunTestingCliFrontend testFrontend = new RunTestingCliFrontend(-1); + RunTestingCliFrontend testFrontend = new RunTestingCliFrontend(-1, true); assertEquals(0, testFrontend.run(parameters)); } // test configure parallelism { String[] parameters = {"-v", "-p", "42", getTestJarPath()}; - RunTestingCliFrontend testFrontend = new RunTestingCliFrontend(42); + RunTestingCliFrontend testFrontend = new RunTestingCliFrontend(42, true); assertEquals(0, testFrontend.run(parameters)); } - + + // test configure sysout logging + { + String[] parameters = {"-p", "2", "-q", getTestJarPath()}; + RunTestingCliFrontend testFrontend = new RunTestingCliFrontend(2, false); + assertEquals(0, testFrontend.run(parameters)); + } + // test configure parallelism with non integer value { String[] parameters = {"-v", "-p", "text", getTestJarPath()}; @@ -86,15 +93,18 @@ public class CliFrontendRunTest { public static final class RunTestingCliFrontend extends CliFrontend { private final int expectedParallelim; + private final boolean sysoutLogging; - public RunTestingCliFrontend(int expectedParallelim) throws Exception { + public RunTestingCliFrontend(int expectedParallelim, boolean logging) throws Exception { super(CliFrontendTestUtils.getConfigDir()); this.expectedParallelim = expectedParallelim; + this.sysoutLogging = logging; } @Override protected int executeProgram(PackagedProgram program, Client client, int parallelism, boolean wait) { assertEquals(this.expectedParallelim, parallelism); + assertEquals(client.getPrintStatusDuringExecution(), sysoutLogging); return 0; } }
