use of org.apache.flink.client.cli.RunOptions in project flink by apache.
the class CliFrontendYarnAddressConfigurationTest method testInvalidYarnPropertiesFile.
@Test(expected = IllegalConfigurationException.class)
public void testInvalidYarnPropertiesFile() throws Exception {
File directoryPath = writeYarnPropertiesFile(invalidPropertiesFile);
TestCLI frontend = new CustomYarnTestCLI(directoryPath.getAbsolutePath());
RunOptions options = CliFrontendParser.parseRunCommand(new String[] {});
frontend.retrieveClient(options);
Configuration config = frontend.getConfiguration();
checkJobManagerAddress(config, TEST_JOB_MANAGER_ADDRESS, TEST_JOB_MANAGER_PORT);
}
use of org.apache.flink.client.cli.RunOptions in project flink by apache.
the class FlinkYarnSessionCliTest method testCorrectSettingOfMaxSlots.
@Test
public void testCorrectSettingOfMaxSlots() throws Exception {
File confFile = tmp.newFile("flink-conf.yaml");
File jarFile = tmp.newFile("test.jar");
new CliFrontend(tmp.getRoot().getAbsolutePath());
String[] params = new String[] { "-yn", "2", "-ys", "3", jarFile.getAbsolutePath() };
RunOptions runOptions = CliFrontendParser.parseRunCommand(params);
FlinkYarnSessionCli yarnCLI = new TestCLI("y", "yarn");
AbstractYarnClusterDescriptor descriptor = yarnCLI.createDescriptor("", runOptions.getCommandLine());
// each task manager has 3 slots but the parallelism is 7. Thus the slots should be increased.
Assert.assertEquals(3, descriptor.getTaskManagerSlots());
Assert.assertEquals(2, descriptor.getTaskManagerCount());
Configuration config = new Configuration();
CliFrontend.setJobManagerAddressInConfig(config, new InetSocketAddress("test", 9000));
ClusterClient client = new TestingYarnClusterClient(descriptor, config);
Assert.assertEquals(6, client.getMaxSlots());
}
use of org.apache.flink.client.cli.RunOptions in project flink by apache.
the class CliFrontend method run.
// --------------------------------------------------------------------------------------------
// Execute Actions
// --------------------------------------------------------------------------------------------
/**
* Executions the run action.
*
* @param args Command line arguments for the run action.
*/
protected int run(String[] args) {
LOG.info("Running 'run' command.");
RunOptions options;
try {
options = CliFrontendParser.parseRunCommand(args);
} catch (CliArgsException e) {
return handleArgException(e);
} catch (Throwable t) {
return handleError(t);
}
// evaluate help flag
if (options.isPrintHelp()) {
CliFrontendParser.printHelpForRun();
return 0;
}
if (options.getJarFilePath() == null) {
return handleArgException(new CliArgsException("The program JAR file was not specified."));
}
PackagedProgram program;
try {
LOG.info("Building program from JAR file");
program = buildProgram(options);
} catch (FileNotFoundException e) {
return handleArgException(e);
} catch (Throwable t) {
return handleError(t);
}
ClusterClient client = null;
try {
client = createClient(options, program);
client.setPrintStatusDuringExecution(options.getStdoutLogging());
client.setDetached(options.getDetachedMode());
LOG.debug("Client slots is set to {}", client.getMaxSlots());
LOG.debug(options.getSavepointRestoreSettings().toString());
int userParallelism = options.getParallelism();
LOG.debug("User parallelism is set to {}", userParallelism);
if (client.getMaxSlots() != -1 && userParallelism == -1) {
logAndSysout("Using the parallelism provided by the remote cluster (" + client.getMaxSlots() + "). " + "To use another parallelism, set it at the ./bin/flink client.");
userParallelism = client.getMaxSlots();
}
return executeProgram(program, client, userParallelism);
} catch (Throwable t) {
return handleError(t);
} finally {
if (client != null) {
client.shutdown();
}
if (program != null) {
program.deleteExtractedLibraries();
}
}
}
use of org.apache.flink.client.cli.RunOptions in project flink by apache.
the class CliFrontendAddressConfigurationTest method testValidConfig.
@Test
public void testValidConfig() {
try {
CliFrontend frontend = new CliFrontend(CliFrontendTestUtils.getConfigDir());
RunOptions options = CliFrontendParser.parseRunCommand(new String[] {});
ClusterClient clusterClient = frontend.retrieveClient(options);
checkJobManagerAddress(clusterClient.getFlinkConfiguration(), CliFrontendTestUtils.TEST_JOB_MANAGER_ADDRESS, CliFrontendTestUtils.TEST_JOB_MANAGER_PORT);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.client.cli.RunOptions in project flink by apache.
the class CliFrontendPackageProgramTest method testValidVariantWithNoJarAndNoArgumentsOption.
@Test
public void testValidVariantWithNoJarAndNoArgumentsOption() {
try {
String[] arguments = { "--classpath", "file:///tmp/foo", "--classpath", "file:///tmp/bar", getTestJarPath(), "--debug", "true", "arg1", "arg2" };
URL[] classpath = new URL[] { new URL("file:///tmp/foo"), new URL("file:///tmp/bar") };
String[] reducedArguments = { "--debug", "true", "arg1", "arg2" };
RunOptions options = CliFrontendParser.parseRunCommand(arguments);
assertEquals(getTestJarPath(), options.getJarFilePath());
assertArrayEquals(classpath, options.getClasspaths().toArray());
assertArrayEquals(reducedArguments, options.getProgramArgs());
CliFrontend frontend = new CliFrontend(CliFrontendTestUtils.getConfigDir());
PackagedProgram prog = frontend.buildProgram(options);
Assert.assertArrayEquals(reducedArguments, prog.getArguments());
Assert.assertEquals(TEST_JAR_MAIN_CLASS, prog.getMainClassName());
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
Aggregations