/** * Submits the job based on the arguments. */ public static void main(final String[] args) { EnvironmentInformation.logEnvironmentInfo(LOG, "Command Line Client", args); // 1. find the configuration directory final String configurationDirectory = getConfigurationDirectoryFromEnv(); // 2. load the global configuration final Configuration configuration = GlobalConfiguration.loadConfiguration(configurationDirectory); // 3. load the custom command lines final List<CustomCommandLine<?>> customCommandLines = loadCustomCommandLines( configuration, configurationDirectory); try { final CliFrontend cli = new CliFrontend( configuration, customCommandLines); SecurityUtils.install(new SecurityConfiguration(cli.configuration)); int retCode = SecurityUtils.getInstalledContext() .runSecured(() -> cli.parseParameters(args)); System.exit(retCode); } catch (Throwable t) { final Throwable strippedThrowable = ExceptionUtils.stripException(t, UndeclaredThrowableException.class); LOG.error("Fatal error while running command line interface.", strippedThrowable); strippedThrowable.printStackTrace(); System.exit(31); } }
@Before public void setup() throws Exception { final Configuration configuration = new Configuration(); frontend = new CliFrontend( configuration, Collections.singletonList(new DefaultCLI(configuration))); }
@Test(expected = CliArgsException.class) public void testCancelWithSavepointWithoutJobId() throws Exception { // Cancel with savepoint (with target directory), but no job ID String[] parameters = { "-s", "targetDirectory" }; Configuration configuration = getConfiguration(); CliFrontend testFrontend = new CliFrontend( configuration, Collections.singletonList(getCli(configuration))); testFrontend.cancel(parameters); }
@Test(expected = CliArgsException.class) public void testMissingJobId() throws Exception { // test missing job id String[] parameters = {}; Configuration configuration = getConfiguration(); CliFrontend testFrontend = new CliFrontend( configuration, Collections.singletonList(getCli(configuration))); testFrontend.stop(parameters); }
@Test(expected = CliArgsException.class) public void testUnrecognizedOption() throws Exception { // test unrecognized option String[] parameters = {"-v", "-l", "-a", "some", "program", "arguments"}; Configuration configuration = getConfiguration(); CliFrontend testFrontend = new CliFrontend( configuration, Collections.singletonList(getCli(configuration))); testFrontend.run(parameters); }
@Test(expected = CliArgsException.class) public void testUnrecognizedOption() throws Exception { String[] parameters = {"-v", "-l"}; Configuration configuration = getConfiguration(); CliFrontend testFrontend = new CliFrontend( configuration, Collections.singletonList(getCli(configuration))); testFrontend.cancel(parameters); }
@Test(expected = CliArgsException.class) public void testUnrecognizedOption() throws Exception { String[] parameters = {"-v", "-l"}; Configuration configuration = getConfiguration(); CliFrontend testFrontend = new CliFrontend( configuration, Collections.singletonList(getCli(configuration))); testFrontend.cancel(parameters); }
@Test(expected = CliArgsException.class) public void testMissingJobId() throws Exception { String[] parameters = {}; Configuration configuration = getConfiguration(); CliFrontend testFrontend = new CliFrontend( configuration, Collections.singletonList(getCli(configuration))); testFrontend.cancel(parameters); }
@Test(expected = CliArgsException.class) public void testUnrecognizedOption() throws Exception { // test unrecognized option String[] parameters = { "-v", "-l" }; Configuration configuration = getConfiguration(); CliFrontend testFrontend = new CliFrontend( configuration, Collections.singletonList(getCli(configuration))); testFrontend.stop(parameters); }
@Test(expected = CliArgsException.class) public void testMissingOption() throws Exception { String[] parameters = {}; Configuration configuration = getConfiguration(); CliFrontend testFrontend = new CliFrontend( configuration, Collections.singletonList(getCli(configuration))); testFrontend.cancel(parameters); }
@Test(expected = CliArgsException.class) public void testUnrecognizedOption() throws Exception { String[] parameters = {"-v", "-k"}; Configuration configuration = getConfiguration(); CliFrontend testFrontend = new CliFrontend( configuration, Collections.singletonList(getCli(configuration))); testFrontend.list(parameters); }
@Test(expected = CliArgsException.class) public void testCancelWithSavepointWithoutParameters() throws Exception { // Cancel with savepoint (no target directory) and no job ID String[] parameters = { "-s" }; Configuration configuration = getConfiguration(); CliFrontend testFrontend = new CliFrontend( configuration, Collections.singletonList(getCli(configuration))); testFrontend.cancel(parameters); }
@Test(expected = CliArgsException.class) public void testParallelismWithOverflow() throws Exception { // test configure parallelism with overflow integer value String[] parameters = {"-v", "-p", "475871387138", getTestJarPath()}; Configuration configuration = new Configuration(); CliFrontend testFrontend = new CliFrontend( configuration, Collections.singletonList(getCli(configuration))); testFrontend.run(parameters); }
@Test(expected = CliArgsException.class) public void testInvalidParallelismOption() throws Exception { // test configure parallelism with non integer value String[] parameters = {"-v", "-p", "text", getTestJarPath()}; Configuration configuration = getConfiguration(); CliFrontend testFrontend = new CliFrontend( configuration, Collections.singletonList(getCli(configuration))); testFrontend.run(parameters); }
case CLI_FRONTEND: try { CliFrontend cli = new CliFrontend( configuration, CliFrontend.loadCustomCommandLines(configuration, configurationDirectory));
@Test public void testShowExecutionPlan() throws Exception { replaceStdOut(); try { String[] parameters = new String[]{CliFrontendTestUtils.getTestJarPath(), "-f", "true"}; Configuration configuration = getConfiguration(); CliFrontend testFrontend = new CliFrontend( configuration, Collections.singletonList(getCli(configuration))); testFrontend.info(parameters); assertTrue(buffer.toString().contains("\"parallelism\": \"1\"")); } finally { restoreStdOut(); } }
@Test public void testShowExecutionPlanWithParallelism() { replaceStdOut(); try { String[] parameters = {"-p", "17", CliFrontendTestUtils.getTestJarPath()}; Configuration configuration = getConfiguration(); CliFrontend testFrontend = new CliFrontend( configuration, Collections.singletonList(getCli(configuration))); testFrontend.info(parameters); assertTrue(buffer.toString().contains("\"parallelism\": \"17\"")); } catch (Exception e) { e.printStackTrace(); fail("Program caused an exception: " + e.getMessage()); } finally { restoreStdOut(); } }
/** * Submits the job based on the arguments. */ public static void main(final String[] args) { EnvironmentInformation.logEnvironmentInfo(LOG, "Command Line Client", args); // 1. find the configuration directory final String configurationDirectory = getConfigurationDirectoryFromEnv(); // 2. load the global configuration final Configuration configuration = GlobalConfiguration.loadConfiguration(configurationDirectory); // 3. load the custom command lines final List<CustomCommandLine<?>> customCommandLines = loadCustomCommandLines( configuration, configurationDirectory); try { final CliFrontend cli = new CliFrontend( configuration, customCommandLines); SecurityUtils.install(new SecurityConfiguration(cli.configuration)); int retCode = SecurityUtils.getInstalledContext() .runSecured(() -> cli.parseParameters(args)); System.exit(retCode); } catch (Throwable t) { LOG.error("Fatal error while running command line interface.", t); t.printStackTrace(); System.exit(31); } }
/** * Submits the job based on the arguments. */ public static void main(final String[] args) { EnvironmentInformation.logEnvironmentInfo(LOG, "Command Line Client", args); // 1. find the configuration directory final String configurationDirectory = getConfigurationDirectoryFromEnv(); // 2. load the global configuration final Configuration configuration = GlobalConfiguration.loadConfiguration(configurationDirectory); // 3. load the custom command lines final List<CustomCommandLine<?>> customCommandLines = loadCustomCommandLines( configuration, configurationDirectory); try { final CliFrontend cli = new CliFrontend( configuration, customCommandLines); SecurityUtils.install(new SecurityConfiguration(cli.configuration)); int retCode = SecurityUtils.getInstalledContext() .runSecured(() -> cli.parseParameters(args)); System.exit(retCode); } catch (Throwable t) { final Throwable strippedThrowable = ExceptionUtils.stripException(t, UndeclaredThrowableException.class); LOG.error("Fatal error while running command line interface.", strippedThrowable); strippedThrowable.printStackTrace(); System.exit(31); } }
List<CustomCommandLine<?>> customCommandLines = CliFrontend.loadCustomCommandLines(configuration, flinkConfig.getConfigDir()); CliFrontend flinkCli = new CliFrontend(configuration, customCommandLines); FlinkRestApi flinkRestApi = new FlinkRestApi(new RestTemplate(), flinkConfig.getMasterUrl());