org.apache.flink.client.program.PackagedProgram Java Examples
The following examples show how to use
org.apache.flink.client.program.PackagedProgram.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AvroExternalJarProgramITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testExternalProgram() throws Exception { String jarFile = JAR_FILE; try { JobWithJars.checkJarFile(new File(jarFile).getAbsoluteFile().toURI().toURL()); } catch (IOException e) { jarFile = "target/".concat(jarFile); } TestEnvironment.setAsContext( MINI_CLUSTER, PARALLELISM, Collections.singleton(new Path(jarFile)), Collections.emptyList()); String testData = getClass().getResource(TEST_DATA_FILE).toString(); PackagedProgram program = new PackagedProgram(new File(jarFile), new String[]{testData}); program.invokeInteractiveModeForExecution(); }
Example #2
Source File: ClassLoaderITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testCheckpointingCustomKvStateJobWithCustomClassLoader() throws IOException, ProgramInvocationException { File checkpointDir = FOLDER.newFolder(); File outputDir = FOLDER.newFolder(); final PackagedProgram program = PackagedProgram.newBuilder() .setJarFile(new File(CHECKPOINTING_CUSTOM_KV_STATE_JAR_PATH)) .setArguments(new String[] { checkpointDir.toURI().toString(), outputDir.toURI().toString()}) .build(); TestStreamEnvironment.setAsContext( miniClusterResource.getMiniCluster(), parallelism, Collections.singleton(new Path(CHECKPOINTING_CUSTOM_KV_STATE_JAR_PATH)), Collections.emptyList()); try { program.invokeInteractiveModeForExecution(); fail("exception should happen"); } catch (ProgramInvocationException e) { assertTrue(ExceptionUtils.findThrowable(e, SuccessException.class).isPresent()); } }
Example #3
Source File: JarHandlerUtils.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
public JobGraph toJobGraph(Configuration configuration) { if (!Files.exists(jarFile)) { throw new CompletionException(new RestHandlerException( String.format("Jar file %s does not exist", jarFile), HttpResponseStatus.BAD_REQUEST)); } try { final PackagedProgram packagedProgram = new PackagedProgram( jarFile.toFile(), entryClass, programArgs.toArray(new String[0])); return PackagedProgramUtils.createJobGraph(packagedProgram, configuration, parallelism, jobId); } catch (final ProgramInvocationException e) { throw new CompletionException(e); } }
Example #4
Source File: ClassLoaderITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testKMeansJobWithCustomClassLoader() throws ProgramInvocationException { PackagedProgram kMeansProg = PackagedProgram.newBuilder() .setJarFile(new File(KMEANS_JAR_PATH)) .setArguments(new String[] { KMeansData.DATAPOINTS, KMeansData.INITIAL_CENTERS, "25"}) .build(); TestEnvironment.setAsContext( miniClusterResource.getMiniCluster(), parallelism, Collections.singleton(new Path(KMEANS_JAR_PATH)), Collections.emptyList()); kMeansProg.invokeInteractiveModeForExecution(); }
Example #5
Source File: CliFrontend.java From flink with Apache License 2.0 | 6 votes |
/** * Creates a Packaged program from the given command line options. * * @return A PackagedProgram (upon success) */ PackagedProgram buildProgram(final ProgramOptions runOptions) throws FileNotFoundException, ProgramInvocationException, CliArgsException { runOptions.validate(); String[] programArgs = runOptions.getProgramArgs(); String jarFilePath = runOptions.getJarFilePath(); List<URL> classpaths = runOptions.getClasspaths(); // Get assembler class String entryPointClass = runOptions.getEntryPointClassName(); File jarFile = jarFilePath != null ? getJarFile(jarFilePath) : null; return PackagedProgram.newBuilder() .setJarFile(jarFile) .setUserClassPaths(classpaths) .setEntryPointClassName(entryPointClass) .setConfiguration(configuration) .setSavepointRestoreSettings(runOptions.getSavepointRestoreSettings()) .setArguments(programArgs) .build(); }
Example #6
Source File: PreviewPlanDumpTest.java From flink with Apache License 2.0 | 6 votes |
private static void verifyPlanDump(Class<?> entrypoint, String... args) throws Exception { final PackagedProgram program = PackagedProgram .newBuilder() .setEntryPointClassName(entrypoint.getName()) .setArguments(args) .build(); final Pipeline pipeline = PackagedProgramUtils.getPipelineFromProgram(program, new Configuration(), 1, true); assertTrue(pipeline instanceof Plan); final Plan plan = (Plan) pipeline; final List<DataSinkNode> sinks = Optimizer.createPreOptimizedPlan(plan); final PlanJSONDumpGenerator dumper = new PlanJSONDumpGenerator(); final String json = dumper.getPactPlanAsJSON(sinks); try (JsonParser parser = new JsonFactory().createParser(json)) { while (parser.nextToken() != null) { } } }
Example #7
Source File: ClassLoaderITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testCheckpointingCustomKvStateJobWithCustomClassLoader() throws IOException, ProgramInvocationException { File checkpointDir = FOLDER.newFolder(); File outputDir = FOLDER.newFolder(); final PackagedProgram program = new PackagedProgram( new File(CHECKPOINTING_CUSTOM_KV_STATE_JAR_PATH), new String[] { checkpointDir.toURI().toString(), outputDir.toURI().toString() }); TestStreamEnvironment.setAsContext( miniClusterResource.getMiniCluster(), parallelism, Collections.singleton(new Path(CHECKPOINTING_CUSTOM_KV_STATE_JAR_PATH)), Collections.<URL>emptyList()); expectedException.expectCause( Matchers.<Throwable>hasProperty("cause", isA(SuccessException.class))); program.invokeInteractiveModeForExecution(); }
Example #8
Source File: ClassLoaderITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testKMeansJobWithCustomClassLoader() throws IOException, ProgramInvocationException { PackagedProgram kMeansProg = new PackagedProgram( new File(KMEANS_JAR_PATH), new String[] { KMeansData.DATAPOINTS, KMeansData.INITIAL_CENTERS, "25" }); TestEnvironment.setAsContext( miniClusterResource.getMiniCluster(), parallelism, Collections.singleton(new Path(KMEANS_JAR_PATH)), Collections.<URL>emptyList()); kMeansProg.invokeInteractiveModeForExecution(); }
Example #9
Source File: JarHandlerUtils.java From flink with Apache License 2.0 | 6 votes |
public PackagedProgram toPackagedProgram(Configuration configuration) { checkNotNull(configuration); if (!Files.exists(jarFile)) { throw new CompletionException(new RestHandlerException( String.format("Jar file %s does not exist", jarFile), HttpResponseStatus.BAD_REQUEST)); } try { return PackagedProgram.newBuilder() .setJarFile(jarFile.toFile()) .setEntryPointClassName(entryClass) .setConfiguration(configuration) .setArguments(programArgs.toArray(new String[0])) .build(); } catch (final ProgramInvocationException e) { throw new CompletionException(e); } }
Example #10
Source File: JarRunHandler.java From flink with Apache License 2.0 | 6 votes |
@Override protected CompletableFuture<JarRunResponseBody> handleRequest( @Nonnull final HandlerRequest<JarRunRequestBody, JarRunMessageParameters> request, @Nonnull final DispatcherGateway gateway) throws RestHandlerException { final Configuration effectiveConfiguration = new Configuration(configuration); effectiveConfiguration.set(DeploymentOptions.ATTACHED, false); effectiveConfiguration.set(DeploymentOptions.TARGET, EmbeddedExecutor.NAME); final JarHandlerContext context = JarHandlerContext.fromRequest(request, jarDir, log); context.applyToConfiguration(effectiveConfiguration); SavepointRestoreSettings.toConfiguration(getSavepointRestoreSettings(request), effectiveConfiguration); final PackagedProgram program = context.toPackagedProgram(effectiveConfiguration); return CompletableFuture .supplyAsync(() -> applicationRunner.run(gateway, program, effectiveConfiguration), executor) .thenApply(jobIds -> { if (jobIds.isEmpty()) { throw new CompletionException(new ProgramInvocationException("No jobs submitted.")); } return new JarRunResponseBody(jobIds.get(0)); }); }
Example #11
Source File: AvroExternalJarProgramITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testExternalProgram() throws Exception { String jarFile = JAR_FILE; try { JobWithJars.checkJarFile(new File(jarFile).getAbsoluteFile().toURI().toURL()); } catch (IOException e) { jarFile = "target/".concat(jarFile); } TestEnvironment.setAsContext( MINI_CLUSTER, PARALLELISM, Collections.singleton(new Path(jarFile)), Collections.emptyList()); String testData = getClass().getResource(TEST_DATA_FILE).toString(); PackagedProgram program = new PackagedProgram(new File(jarFile), new String[]{testData}); program.invokeInteractiveModeForExecution(); }
Example #12
Source File: CliFrontendPackageProgramTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testValidVariantWithNoJarAndNoArgumentsOption() throws Exception { 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"}; CommandLine commandLine = CliFrontendParser.parse(CliFrontendParser.RUN_OPTIONS, arguments, true); ProgramOptions programOptions = ProgramOptions.create(commandLine); assertEquals(getTestJarPath(), programOptions.getJarFilePath()); assertArrayEquals(classpath, programOptions.getClasspaths().toArray()); assertArrayEquals(reducedArguments, programOptions.getProgramArgs()); PackagedProgram prog = frontend.buildProgram(programOptions); Assert.assertArrayEquals(reducedArguments, prog.getArguments()); Assert.assertEquals(TEST_JAR_MAIN_CLASS, prog.getMainClassName()); }
Example #13
Source File: ClassPathPackagedProgramRetriever.java From flink with Apache License 2.0 | 6 votes |
@Override public PackagedProgram getPackagedProgram() throws FlinkException { try { if (jarFile != null) { return PackagedProgram.newBuilder() .setUserClassPaths(new ArrayList<>(userClassPaths)) .setArguments(programArguments) .setJarFile(jarFile) .setEntryPointClassName(jobClassName) .build(); } final String entryClass = getJobClassNameOrScanClassPath(); return PackagedProgram.newBuilder() .setUserClassPaths(new ArrayList<>(userClassPaths)) .setEntryPointClassName(entryClass) .setArguments(programArguments) .build(); } catch (ProgramInvocationException e) { throw new FlinkException("Could not load the provided entrypoint class.", e); } }
Example #14
Source File: CliFrontendPackageProgramTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testVariantWithExplicitJarAndNoArgumentsOption() throws Exception { String[] arguments = { "--classpath", "file:///tmp/foo", "--classpath", "file:///tmp/bar", "-j", getTestJarPath(), "--debug", "true", "arg1", "arg2" }; URL[] classpath = new URL[] { new URL("file:///tmp/foo"), new URL("file:///tmp/bar") }; String[] reducedArguments = new String[] {"--debug", "true", "arg1", "arg2"}; RunOptions options = CliFrontendParser.parseRunCommand(arguments); assertEquals(getTestJarPath(), options.getJarFilePath()); assertArrayEquals(classpath, options.getClasspaths().toArray()); assertArrayEquals(reducedArguments, options.getProgramArgs()); PackagedProgram prog = frontend.buildProgram(options); Assert.assertArrayEquals(reducedArguments, prog.getArguments()); Assert.assertEquals(TEST_JAR_MAIN_CLASS, prog.getMainClassName()); }
Example #15
Source File: CliFrontendPackageProgramTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testValidVariantWithNoJarAndNoArgumentsOption() throws Exception { 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()); PackagedProgram prog = frontend.buildProgram(options); Assert.assertArrayEquals(reducedArguments, prog.getArguments()); Assert.assertEquals(TEST_JAR_MAIN_CLASS, prog.getMainClassName()); }
Example #16
Source File: CliFrontendPackageProgramTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testVariantWithExplicitJarAndArgumentsOption() throws Exception { String[] arguments = { "--classpath", "file:///tmp/foo", "--classpath", "file:///tmp/bar", "-j", getTestJarPath(), "-a", "--debug", "true", "arg1", "arg2" }; URL[] classpath = new URL[] { new URL("file:///tmp/foo"), new URL("file:///tmp/bar") }; String[] reducedArguments = new String[] {"--debug", "true", "arg1", "arg2"}; RunOptions options = CliFrontendParser.parseRunCommand(arguments); assertEquals(getTestJarPath(), options.getJarFilePath()); assertArrayEquals(classpath, options.getClasspaths().toArray()); assertArrayEquals(reducedArguments, options.getProgramArgs()); PackagedProgram prog = frontend.buildProgram(options); Assert.assertArrayEquals(reducedArguments, prog.getArguments()); Assert.assertEquals(TEST_JAR_MAIN_CLASS, prog.getMainClassName()); }
Example #17
Source File: AvroExternalJarProgramITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testExternalProgram() throws Exception { String jarFile = JAR_FILE; try { JarUtils.checkJarFile(new File(jarFile).getAbsoluteFile().toURI().toURL()); } catch (IOException e) { jarFile = "target/".concat(jarFile); } TestEnvironment.setAsContext( MINI_CLUSTER, PARALLELISM, Collections.singleton(new Path(jarFile)), Collections.emptyList()); String testData = getClass().getResource(TEST_DATA_FILE).toString(); PackagedProgram program = PackagedProgram.newBuilder() .setJarFile(new File(jarFile)) .setArguments(new String[]{testData}) .build(); program.invokeInteractiveModeForExecution(); }
Example #18
Source File: FlinkRunnerTest.java From beam with Apache License 2.0 | 6 votes |
@Test public void testEnsureStdoutStdErrIsRestored() throws Exception { PackagedProgram packagedProgram = PackagedProgram.newBuilder().setEntryPointClassName(getClass().getName()).build(); // constructor changed between Flink 1.10.0 and 1.10.1 and will again change in 1.11 OptimizerPlanEnvironment env = new OptimizerPlanEnvironment(new Configuration()); try { // Flink will throw an error because no job graph will be generated by the main method env.getPipeline(packagedProgram, false); Assert.fail("This should have failed to create the Flink Plan."); } catch (ProgramInvocationException e) { // Test that Flink wasn't able to intercept the stdout/stderr and we printed to the regular // output instead MatcherAssert.assertThat( e.getMessage(), allOf( StringContains.containsString("System.out: (none)"), StringContains.containsString("System.err: (none)"))); } }
Example #19
Source File: FlinkRunnerTest.java From beam with Apache License 2.0 | 6 votes |
@Test public void testEnsureStdoutStdErrIsRestored() throws Exception { PackagedProgram packagedProgram = new PackagedProgram(getClass()); OptimizerPlanEnvironment env = new OptimizerPlanEnvironment(new Optimizer(new Configuration())); try { // Flink will throw an error because no job graph will be generated by the main method env.getOptimizedPlan(packagedProgram); Assert.fail("This should have failed to create the Flink Plan."); } catch (ProgramInvocationException e) { // Test that Flink wasn't able to intercept the stdout/stderr and we printed to the regular // output instead MatcherAssert.assertThat( e.getMessage(), allOf( StringContains.containsString("System.out: (none)"), StringContains.containsString("System.err: (none)"))); } }
Example #20
Source File: StatefulFunctionsJobGraphRetriever.java From flink-statefun with Apache License 2.0 | 6 votes |
private PackagedProgram createPackagedProgram() { File mainJar = new File(Constants.FLINK_JOB_JAR_PATH); if (!mainJar.exists()) { throw new IllegalStateException("Unable to locate the launcher jar"); } try { return PackagedProgram.newBuilder() .setJarFile(mainJar) .setUserClassPaths(obtainModuleAdditionalClassPath()) .setEntryPointClassName(StatefulFunctionsJob.class.getName()) .setArguments(programArguments) .build(); } catch (ProgramInvocationException e) { throw new RuntimeException("Unable to construct a packaged program", e); } }
Example #21
Source File: StatefulFunctionsJobGraphRetriever.java From flink-statefun with Apache License 2.0 | 6 votes |
@Override public JobGraph retrieveJobGraph(Configuration configuration) throws FlinkException { final PackagedProgram packagedProgram = createPackagedProgram(); int resolvedParallelism = resolveParallelism(parallelism, configuration); LOG.info( "Creating JobGraph for job {}, with parallelism {} and savepoint restore settings {}.", jobId, resolvedParallelism, savepointRestoreSettings); try { final JobGraph jobGraph = PackagedProgramUtils.createJobGraph( packagedProgram, configuration, resolvedParallelism, jobId, false); jobGraph.setSavepointRestoreSettings(savepointRestoreSettings); return jobGraph; } catch (Exception e) { throw new FlinkException("Could not create the JobGraph from the provided user code jar.", e); } }
Example #22
Source File: ClassLoaderITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testKMeansJobWithCustomClassLoader() throws IOException, ProgramInvocationException { PackagedProgram kMeansProg = new PackagedProgram( new File(KMEANS_JAR_PATH), new String[] { KMeansData.DATAPOINTS, KMeansData.INITIAL_CENTERS, "25" }); TestEnvironment.setAsContext( miniClusterResource.getMiniCluster(), parallelism, Collections.singleton(new Path(KMEANS_JAR_PATH)), Collections.<URL>emptyList()); kMeansProg.invokeInteractiveModeForExecution(); }
Example #23
Source File: StatefulFunctionsJobGraphRetriever.java From stateful-functions with Apache License 2.0 | 6 votes |
private PackagedProgram createPackagedProgram() { File mainJar = new File(Constants.FLINK_JOB_JAR_PATH); if (!mainJar.exists()) { throw new IllegalStateException("Unable to locate the launcher jar"); } try { return PackagedProgram.newBuilder() .setJarFile(mainJar) .setUserClassPaths(obtainModuleAdditionalClassPath()) .setEntryPointClassName(StatefulFunctionsJob.class.getName()) .setArguments(programArguments) .build(); } catch (ProgramInvocationException e) { throw new RuntimeException("Unable to construct a packaged program", e); } }
Example #24
Source File: ClassLoaderITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testCheckpointingCustomKvStateJobWithCustomClassLoader() throws IOException, ProgramInvocationException { File checkpointDir = FOLDER.newFolder(); File outputDir = FOLDER.newFolder(); final PackagedProgram program = new PackagedProgram( new File(CHECKPOINTING_CUSTOM_KV_STATE_JAR_PATH), new String[] { checkpointDir.toURI().toString(), outputDir.toURI().toString() }); TestStreamEnvironment.setAsContext( miniClusterResource.getMiniCluster(), parallelism, Collections.singleton(new Path(CHECKPOINTING_CUSTOM_KV_STATE_JAR_PATH)), Collections.<URL>emptyList()); expectedException.expectCause( Matchers.<Throwable>hasProperty("cause", isA(SuccessException.class))); program.invokeInteractiveModeForExecution(); }
Example #25
Source File: StatefulFunctionsJobGraphRetriever.java From stateful-functions with Apache License 2.0 | 6 votes |
@Override public JobGraph retrieveJobGraph(Configuration configuration) throws FlinkException { final PackagedProgram packagedProgram = createPackagedProgram(); final int defaultParallelism = configuration.getInteger(CoreOptions.DEFAULT_PARALLELISM); try { final JobGraph jobGraph = PackagedProgramUtils.createJobGraph( packagedProgram, configuration, defaultParallelism, jobId, false); jobGraph.setSavepointRestoreSettings(savepointRestoreSettings); return jobGraph; } catch (Exception e) { throw new FlinkException("Could not create the JobGraph from the provided user code jar.", e); } }
Example #26
Source File: CliFrontendPackageProgramTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testValidVariantWithNoJarAndNoArgumentsOption() throws Exception { 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()); PackagedProgram prog = frontend.buildProgram(options); Assert.assertArrayEquals(reducedArguments, prog.getArguments()); Assert.assertEquals(TEST_JAR_MAIN_CLASS, prog.getMainClassName()); }
Example #27
Source File: CliFrontendPackageProgramTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testVariantWithExplicitJarAndNoArgumentsOption() throws Exception { String[] arguments = { "--classpath", "file:///tmp/foo", "--classpath", "file:///tmp/bar", "-j", getTestJarPath(), "--debug", "true", "arg1", "arg2" }; URL[] classpath = new URL[] { new URL("file:///tmp/foo"), new URL("file:///tmp/bar") }; String[] reducedArguments = new String[] {"--debug", "true", "arg1", "arg2"}; RunOptions options = CliFrontendParser.parseRunCommand(arguments); assertEquals(getTestJarPath(), options.getJarFilePath()); assertArrayEquals(classpath, options.getClasspaths().toArray()); assertArrayEquals(reducedArguments, options.getProgramArgs()); PackagedProgram prog = frontend.buildProgram(options); Assert.assertArrayEquals(reducedArguments, prog.getArguments()); Assert.assertEquals(TEST_JAR_MAIN_CLASS, prog.getMainClassName()); }
Example #28
Source File: CliFrontendPackageProgramTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testVariantWithExplicitJarAndArgumentsOption() throws Exception { String[] arguments = { "--classpath", "file:///tmp/foo", "--classpath", "file:///tmp/bar", "-j", getTestJarPath(), "-a", "--debug", "true", "arg1", "arg2" }; URL[] classpath = new URL[] { new URL("file:///tmp/foo"), new URL("file:///tmp/bar") }; String[] reducedArguments = new String[] {"--debug", "true", "arg1", "arg2"}; RunOptions options = CliFrontendParser.parseRunCommand(arguments); assertEquals(getTestJarPath(), options.getJarFilePath()); assertArrayEquals(classpath, options.getClasspaths().toArray()); assertArrayEquals(reducedArguments, options.getProgramArgs()); PackagedProgram prog = frontend.buildProgram(options); Assert.assertArrayEquals(reducedArguments, prog.getArguments()); Assert.assertEquals(TEST_JAR_MAIN_CLASS, prog.getMainClassName()); }
Example #29
Source File: CliFrontend.java From flink with Apache License 2.0 | 6 votes |
protected void executeProgram(PackagedProgram program, ClusterClient<?> client, int parallelism) throws ProgramMissingJobException, ProgramInvocationException { logAndSysout("Starting execution of program"); final JobSubmissionResult result = client.run(program, parallelism); if (null == result) { throw new ProgramMissingJobException("No JobSubmissionResult returned, please make sure you called " + "ExecutionEnvironment.execute()"); } if (result.isJobExecutionResult()) { logAndSysout("Program execution finished"); JobExecutionResult execResult = result.getJobExecutionResult(); System.out.println("Job with JobID " + execResult.getJobID() + " has finished."); System.out.println("Job Runtime: " + execResult.getNetRuntime() + " ms"); Map<String, Object> accumulatorsResult = execResult.getAllAccumulatorResults(); if (accumulatorsResult.size() > 0) { System.out.println("Accumulator Results: "); System.out.println(AccumulatorHelper.getResultsFormatted(accumulatorsResult)); } } else { logAndSysout("Job has been submitted with JobID " + result.getJobID()); } }
Example #30
Source File: CliFrontendPackageProgramTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testVariantWithExplicitJarAndNoArgumentsOption() throws Exception { String[] arguments = { "--classpath", "file:///tmp/foo", "--classpath", "file:///tmp/bar", "-j", getTestJarPath(), "--debug", "true", "arg1", "arg2" }; URL[] classpath = new URL[] { new URL("file:///tmp/foo"), new URL("file:///tmp/bar") }; String[] reducedArguments = new String[] {"--debug", "true", "arg1", "arg2"}; CommandLine commandLine = CliFrontendParser.parse(CliFrontendParser.RUN_OPTIONS, arguments, true); ProgramOptions programOptions = ProgramOptions.create(commandLine); assertEquals(getTestJarPath(), programOptions.getJarFilePath()); assertArrayEquals(classpath, programOptions.getClasspaths().toArray()); assertArrayEquals(reducedArguments, programOptions.getProgramArgs()); PackagedProgram prog = frontend.buildProgram(programOptions); Assert.assertArrayEquals(reducedArguments, prog.getArguments()); Assert.assertEquals(TEST_JAR_MAIN_CLASS, prog.getMainClassName()); }