org.apache.flink.runtime.jobmaster.JobResult Java Examples
The following examples show how to use
org.apache.flink.runtime.jobmaster.JobResult.
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: MiniDispatcher.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<JobResult> requestJobResult(JobID jobId, Time timeout) { final CompletableFuture<JobResult> jobResultFuture = super.requestJobResult(jobId, timeout); if (executionMode == ClusterEntrypoint.ExecutionMode.NORMAL) { // terminate the MiniDispatcher once we served the first JobResult successfully jobResultFuture.thenAccept((JobResult result) -> { ApplicationStatus status = result.getSerializedThrowable().isPresent() ? ApplicationStatus.FAILED : ApplicationStatus.SUCCEEDED; jobTerminationFuture.complete(status); }); } return jobResultFuture; }
Example #2
Source File: Dispatcher.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<JobResult> requestJobResult(JobID jobId, Time timeout) { final CompletableFuture<JobManagerRunner> jobManagerRunnerFuture = jobManagerRunnerFutures.get(jobId); if (jobManagerRunnerFuture == null) { final ArchivedExecutionGraph archivedExecutionGraph = archivedExecutionGraphStore.get(jobId); if (archivedExecutionGraph == null) { return FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId)); } else { return CompletableFuture.completedFuture(JobResult.createFrom(archivedExecutionGraph)); } } else { return jobManagerRunnerFuture.thenCompose(JobManagerRunner::getResultFuture).thenApply(JobResult::createFrom); } }
Example #3
Source File: DispatcherTest.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that a submitted job is suspended if the Dispatcher loses leadership. */ @Test public void testJobSuspensionWhenDispatcherLosesLeadership() throws Exception { dispatcher = createAndStartDispatcher(heartbeatServices, haServices, new ExpectedJobIdJobManagerRunnerFactory(TEST_JOB_ID, createdJobManagerRunnerLatch)); dispatcherLeaderElectionService.isLeader(UUID.randomUUID()).get(); DispatcherGateway dispatcherGateway = dispatcher.getSelfGateway(DispatcherGateway.class); dispatcherGateway.submitJob(jobGraph, TIMEOUT).get(); final CompletableFuture<JobResult> jobResultFuture = dispatcherGateway.requestJobResult(jobGraph.getJobID(), TIMEOUT); assertThat(jobResultFuture.isDone(), is(false)); dispatcherLeaderElectionService.notLeader(); try { jobResultFuture.get(); fail("Expected the job result to throw an exception."); } catch (ExecutionException ee) { assertThat(ExceptionUtils.findThrowable(ee, JobNotFinishedException.class).isPresent(), is(true)); } }
Example #4
Source File: ShuffleCompressionITCase.java From flink with Apache License 2.0 | 6 votes |
private void executeTest(JobGraph jobGraph) throws Exception { Configuration configuration = new Configuration(); configuration.set(TaskManagerOptions.TOTAL_FLINK_MEMORY, MemorySize.parse("1g")); configuration.setBoolean(NettyShuffleEnvironmentOptions.BLOCKING_SHUFFLE_COMPRESSION_ENABLED, true); final MiniClusterConfiguration miniClusterConfiguration = new MiniClusterConfiguration.Builder() .setConfiguration(configuration) .setNumTaskManagers(NUM_TASKMANAGERS) .setNumSlotsPerTaskManager(NUM_SLOTS) .build(); try (MiniCluster miniCluster = new MiniCluster(miniClusterConfiguration)) { miniCluster.start(); MiniClusterClient miniClusterClient = new MiniClusterClient(configuration, miniCluster); // wait for the submission to succeed JobID jobID = miniClusterClient.submitJob(jobGraph).get(); CompletableFuture<JobResult> resultFuture = miniClusterClient.requestJobResult(jobID); assertFalse(resultFuture.get().getSerializedThrowable().isPresent()); } }
Example #5
Source File: Dispatcher.java From flink with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<JobResult> requestJobResult(JobID jobId, Time timeout) { final CompletableFuture<JobManagerRunner> jobManagerRunnerFuture = jobManagerRunnerFutures.get(jobId); if (jobManagerRunnerFuture == null) { final ArchivedExecutionGraph archivedExecutionGraph = archivedExecutionGraphStore.get(jobId); if (archivedExecutionGraph == null) { return FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId)); } else { return CompletableFuture.completedFuture(JobResult.createFrom(archivedExecutionGraph)); } } else { return jobManagerRunnerFuture.thenCompose(JobManagerRunner::getResultFuture).thenApply(JobResult::createFrom); } }
Example #6
Source File: JobStatusPollingUtilsTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testHappyPath() throws ExecutionException, InterruptedException { final int maxAttemptCounter = 1; final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); try { final ScheduledExecutor scheduledExecutor = new ScheduledExecutorServiceAdapter(executor); final CallCountingJobStatusSupplier jobStatusSupplier = new CallCountingJobStatusSupplier(maxAttemptCounter); final CompletableFuture<JobResult> result = JobStatusPollingUtils.pollJobResultAsync( jobStatusSupplier, () -> CompletableFuture.completedFuture(createSuccessfulJobResult(new JobID(0, 0))), scheduledExecutor, 10 ); result.join(); assertThat(jobStatusSupplier.getAttemptCounter(), is(equalTo(maxAttemptCounter))); assertTrue(result.isDone() && result.get().isSuccess()); } finally { ExecutorUtils.gracefulShutdown(5, TimeUnit.SECONDS, executor); } }
Example #7
Source File: DistributedCacheDfsTest.java From flink with Apache License 2.0 | 6 votes |
/** * All the Flink Standalone, Yarn, Mesos, Kubernetes sessions are using {@link RestClusterClient#submitJob(JobGraph)} * to submit a job to an existing session. This test will cover this cases. */ @Test(timeout = 30000) public void testSubmittingJobViaRestClusterClient() throws Exception { RestClusterClient<String> restClusterClient = new RestClusterClient<>( MINI_CLUSTER_RESOURCE.getClientConfiguration(), "testSubmittingJobViaRestClusterClient"); final JobGraph jobGraph = createJobWithRegisteredCachedFiles() .getStreamGraph() .getJobGraph(); final JobResult jobResult = restClusterClient .submitJob(jobGraph) .thenCompose(restClusterClient::requestJobResult) .get(); final String messageInCaseOfFailure = jobResult.getSerializedThrowable().isPresent() ? jobResult.getSerializedThrowable().get().getFullStringifiedStackTrace() : "Job failed."; assertTrue(messageInCaseOfFailure, jobResult.isSuccess()); }
Example #8
Source File: JobExecutionResultResponseBodyTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Parameterized.Parameters public static Collection<Object[]> data() throws IOException { return Arrays.asList(new Object[][] { {JobExecutionResultResponseBody.created(new JobResult.Builder() .jobId(TEST_JOB_ID) .applicationStatus(ApplicationStatus.SUCCEEDED) .netRuntime(TEST_NET_RUNTIME) .accumulatorResults(TEST_ACCUMULATORS) .serializedThrowable(new SerializedThrowable(new RuntimeException("expected"))) .build())}, {JobExecutionResultResponseBody.created(new JobResult.Builder() .jobId(TEST_JOB_ID) .applicationStatus(ApplicationStatus.FAILED) .netRuntime(TEST_NET_RUNTIME) .accumulatorResults(TEST_ACCUMULATORS) .build())}, {JobExecutionResultResponseBody.inProgress()} }); }
Example #9
Source File: MiniDispatcher.java From flink with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<JobResult> requestJobResult(JobID jobId, Time timeout) { final CompletableFuture<JobResult> jobResultFuture = super.requestJobResult(jobId, timeout); if (executionMode == ClusterEntrypoint.ExecutionMode.NORMAL) { // terminate the MiniDispatcher once we served the first JobResult successfully jobResultFuture.thenAccept((JobResult result) -> { ApplicationStatus status = result.getSerializedThrowable().isPresent() ? ApplicationStatus.FAILED : ApplicationStatus.SUCCEEDED; jobTerminationFuture.complete(status); }); } return jobResultFuture; }
Example #10
Source File: JobExecutionResultResponseBodyTest.java From flink with Apache License 2.0 | 6 votes |
@Parameterized.Parameters public static Collection<Object[]> data() throws IOException { return Arrays.asList(new Object[][] { {JobExecutionResultResponseBody.created(new JobResult.Builder() .jobId(TEST_JOB_ID) .applicationStatus(ApplicationStatus.SUCCEEDED) .netRuntime(TEST_NET_RUNTIME) .accumulatorResults(TEST_ACCUMULATORS) .serializedThrowable(new SerializedThrowable(new RuntimeException("expected"))) .build())}, {JobExecutionResultResponseBody.created(new JobResult.Builder() .jobId(TEST_JOB_ID) .applicationStatus(ApplicationStatus.FAILED) .netRuntime(TEST_NET_RUNTIME) .accumulatorResults(TEST_ACCUMULATORS) .build())}, {JobExecutionResultResponseBody.inProgress()} }); }
Example #11
Source File: Dispatcher.java From flink with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<JobResult> requestJobResult(JobID jobId, Time timeout) { final CompletableFuture<JobManagerRunner> jobManagerRunnerFuture = jobManagerRunnerFutures.get(jobId); if (jobManagerRunnerFuture == null) { final ArchivedExecutionGraph archivedExecutionGraph = archivedExecutionGraphStore.get(jobId); if (archivedExecutionGraph == null) { return FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId)); } else { return CompletableFuture.completedFuture(JobResult.createFrom(archivedExecutionGraph)); } } else { return jobManagerRunnerFuture.thenCompose(JobManagerRunner::getResultFuture).thenApply(JobResult::createFrom); } }
Example #12
Source File: JobExecutionResultResponseBodyTest.java From flink with Apache License 2.0 | 6 votes |
@Parameterized.Parameters public static Collection<Object[]> data() throws IOException { return Arrays.asList(new Object[][] { {JobExecutionResultResponseBody.created(new JobResult.Builder() .jobId(TEST_JOB_ID) .applicationStatus(ApplicationStatus.SUCCEEDED) .netRuntime(TEST_NET_RUNTIME) .accumulatorResults(TEST_ACCUMULATORS) .serializedThrowable(new SerializedThrowable(new RuntimeException("expected"))) .build())}, {JobExecutionResultResponseBody.created(new JobResult.Builder() .jobId(TEST_JOB_ID) .applicationStatus(ApplicationStatus.FAILED) .netRuntime(TEST_NET_RUNTIME) .accumulatorResults(TEST_ACCUMULATORS) .build())}, {JobExecutionResultResponseBody.inProgress()} }); }
Example #13
Source File: SchedulingITCase.java From flink with Apache License 2.0 | 5 votes |
private void executeSchedulingTest(Configuration configuration) throws Exception { configuration.setString(RestOptions.BIND_PORT, "0"); final long slotIdleTimeout = 50L; configuration.setLong(JobManagerOptions.SLOT_IDLE_TIMEOUT, slotIdleTimeout); configuration.set(TaskManagerOptions.TOTAL_FLINK_MEMORY, MemorySize.parse("1g")); final int parallelism = 4; final MiniClusterConfiguration miniClusterConfiguration = new MiniClusterConfiguration.Builder() .setConfiguration(configuration) .setNumTaskManagers(parallelism) .setNumSlotsPerTaskManager(1) .build(); try (MiniCluster miniCluster = new MiniCluster(miniClusterConfiguration)) { miniCluster.start(); MiniClusterClient miniClusterClient = new MiniClusterClient(configuration, miniCluster); JobGraph jobGraph = createJobGraph(slotIdleTimeout << 1, parallelism); // wait for the submission to succeed JobID jobID = miniClusterClient.submitJob(jobGraph).get(); CompletableFuture<JobResult> resultFuture = miniClusterClient.requestJobResult(jobID); JobResult jobResult = resultFuture.get(); assertThat(jobResult.getSerializedThrowable().isPresent(), is(false)); } }
Example #14
Source File: RemoteStreamEnvironmentTest.java From flink with Apache License 2.0 | 5 votes |
@Override public CompletableFuture<JobResult> requestJobResult(@Nonnull JobID jobId) { assertThat(jobId, is(this.jobId)); JobResult jobResult = new Builder() .jobId(this.jobId) .netRuntime(0) .applicationStatus(ApplicationStatus.SUCCEEDED) .build(); return CompletableFuture.completedFuture(jobResult); }
Example #15
Source File: ApplicationDispatcherBootstrapTest.java From flink with Apache License 2.0 | 5 votes |
private static JobResult createCancelledJobResult(final JobID jobId) { return new JobResult.Builder() .jobId(jobId) .netRuntime(2L) .serializedThrowable( new SerializedThrowable( new JobCancellationException(jobId, "Hello", null))) .applicationStatus(ApplicationStatus.CANCELED) .build(); }
Example #16
Source File: RestClusterClientTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testJobSubmitCancel() throws Exception { TestJobSubmitHandler submitHandler = new TestJobSubmitHandler(); TestJobCancellationHandler terminationHandler = new TestJobCancellationHandler(); TestJobExecutionResultHandler testJobExecutionResultHandler = new TestJobExecutionResultHandler( JobExecutionResultResponseBody.created(new JobResult.Builder() .applicationStatus(ApplicationStatus.SUCCEEDED) .jobId(jobId) .netRuntime(Long.MAX_VALUE) .build())); try (TestRestServerEndpoint restServerEndpoint = createRestServerEndpoint( submitHandler, terminationHandler, testJobExecutionResultHandler)) { RestClusterClient<?> restClusterClient = createRestClusterClient(restServerEndpoint.getServerAddress().getPort()); try { Assert.assertFalse(submitHandler.jobSubmitted); restClusterClient.submitJob(jobGraph, ClassLoader.getSystemClassLoader()); Assert.assertTrue(submitHandler.jobSubmitted); Assert.assertFalse(terminationHandler.jobCanceled); restClusterClient.cancel(jobId); Assert.assertTrue(terminationHandler.jobCanceled); } finally { restClusterClient.shutdown(); } } }
Example #17
Source File: RestClusterClient.java From flink with Apache License 2.0 | 5 votes |
/** * Requests the {@link JobResult} for the given {@link JobID}. The method retries multiple * times to poll the {@link JobResult} before giving up. * * @param jobId specifying the job for which to retrieve the {@link JobResult} * @return Future which is completed with the {@link JobResult} once the job has completed or * with a failure if the {@link JobResult} could not be retrieved. */ @Override public CompletableFuture<JobResult> requestJobResult(@Nonnull JobID jobId) { return pollResourceAsync( () -> { final JobMessageParameters messageParameters = new JobMessageParameters(); messageParameters.jobPathParameter.resolve(jobId); return sendRequest( JobExecutionResultHeaders.getInstance(), messageParameters); }); }
Example #18
Source File: TaskExecutorITCase.java From flink with Apache License 2.0 | 5 votes |
private CompletableFuture<JobResult> submitJobAndWaitUntilRunning(JobGraph jobGraph) throws Exception { miniCluster.submitJob(jobGraph).get(); final CompletableFuture<JobResult> jobResultFuture = miniCluster.requestJobResult(jobGraph.getJobID()); assertThat(jobResultFuture.isDone(), is(false)); CommonTestUtils.waitUntilCondition( jobIsRunning(() -> miniCluster.getExecutionGraph(jobGraph.getJobID())), Deadline.fromNow(TESTING_TIMEOUT), 50L); return jobResultFuture; }
Example #19
Source File: TestingRestfulGateway.java From flink with Apache License 2.0 | 5 votes |
public TestingRestfulGateway( String address, String hostname, Function<JobID, CompletableFuture<Acknowledge>> cancelJobFunction, Function<JobID, CompletableFuture<ArchivedExecutionGraph>> requestJobFunction, Function<JobID, CompletableFuture<JobResult>> requestJobResultFunction, Function<JobID, CompletableFuture<JobStatus>> requestJobStatusFunction, Supplier<CompletableFuture<MultipleJobsDetails>> requestMultipleJobDetailsSupplier, Supplier<CompletableFuture<ClusterOverview>> requestClusterOverviewSupplier, Supplier<CompletableFuture<Collection<String>>> requestMetricQueryServiceAddressesSupplier, Supplier<CompletableFuture<Collection<Tuple2<ResourceID, String>>>> requestTaskManagerMetricQueryServiceAddressesSupplier, BiFunction<JobID, JobVertexID, CompletableFuture<OperatorBackPressureStatsResponse>> requestOperatorBackPressureStatsFunction, BiFunction<JobID, String, CompletableFuture<String>> triggerSavepointFunction, BiFunction<JobID, String, CompletableFuture<String>> stopWithSavepointFunction) { this.address = address; this.hostname = hostname; this.cancelJobFunction = cancelJobFunction; this.requestJobFunction = requestJobFunction; this.requestJobResultFunction = requestJobResultFunction; this.requestJobStatusFunction = requestJobStatusFunction; this.requestMultipleJobDetailsSupplier = requestMultipleJobDetailsSupplier; this.requestClusterOverviewSupplier = requestClusterOverviewSupplier; this.requestMetricQueryServiceAddressesSupplier = requestMetricQueryServiceAddressesSupplier; this.requestTaskManagerMetricQueryServiceAddressesSupplier = requestTaskManagerMetricQueryServiceAddressesSupplier; this.requestOperatorBackPressureStatsFunction = requestOperatorBackPressureStatsFunction; this.triggerSavepointFunction = triggerSavepointFunction; this.stopWithSavepointFunction = stopWithSavepointFunction; }
Example #20
Source File: TestingDispatcherGateway.java From flink with Apache License 2.0 | 5 votes |
public TestingDispatcherGateway( String address, String hostname, Function<JobID, CompletableFuture<Acknowledge>> cancelJobFunction, Function<JobID, CompletableFuture<ArchivedExecutionGraph>> requestJobFunction, Function<JobID, CompletableFuture<JobResult>> requestJobResultFunction, Function<JobID, CompletableFuture<JobStatus>> requestJobStatusFunction, Supplier<CompletableFuture<MultipleJobsDetails>> requestMultipleJobDetailsSupplier, Supplier<CompletableFuture<ClusterOverview>> requestClusterOverviewSupplier, Supplier<CompletableFuture<Collection<String>>> requestMetricQueryServiceAddressesSupplier, Supplier<CompletableFuture<Collection<Tuple2<ResourceID, String>>>> requestTaskManagerMetricQueryServiceGatewaysSupplier, BiFunction<JobID, JobVertexID, CompletableFuture<OperatorBackPressureStatsResponse>> requestOperatorBackPressureStatsFunction, BiFunction<JobID, String, CompletableFuture<String>> triggerSavepointFunction, BiFunction<JobID, String, CompletableFuture<String>> stopWithSavepointFunction, Function<JobGraph, CompletableFuture<Acknowledge>> submitFunction, Supplier<CompletableFuture<Collection<JobID>>> listFunction, int blobServerPort, DispatcherId fencingToken, Function<JobID, CompletableFuture<ArchivedExecutionGraph>> requestArchivedJobFunction) { super( address, hostname, cancelJobFunction, requestJobFunction, requestJobResultFunction, requestJobStatusFunction, requestMultipleJobDetailsSupplier, requestClusterOverviewSupplier, requestMetricQueryServiceAddressesSupplier, requestTaskManagerMetricQueryServiceGatewaysSupplier, requestOperatorBackPressureStatsFunction, triggerSavepointFunction, stopWithSavepointFunction); this.submitFunction = submitFunction; this.listFunction = listFunction; this.blobServerPort = blobServerPort; this.fencingToken = fencingToken; this.requestArchivedJobFunction = requestArchivedJobFunction; }
Example #21
Source File: MiniClusterITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testCallFinalizeOnMasterBeforeJobCompletes() throws Exception { final int parallelism = 11; final MiniClusterConfiguration cfg = new MiniClusterConfiguration.Builder() .setNumTaskManagers(1) .setNumSlotsPerTaskManager(parallelism) .setConfiguration(getDefaultConfiguration()) .build(); try (final MiniCluster miniCluster = new MiniCluster(cfg)) { miniCluster.start(); final JobVertex source = new JobVertex("Source"); source.setInvokableClass(WaitingNoOpInvokable.class); source.setParallelism(parallelism); final WaitOnFinalizeJobVertex sink = new WaitOnFinalizeJobVertex("Sink", 20L); sink.setInvokableClass(NoOpInvokable.class); sink.setParallelism(parallelism); sink.connectNewDataSetAsInput(source, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED); final JobGraph jobGraph = new JobGraph("SubtaskInFinalStateRaceCondition", source, sink); final CompletableFuture<JobSubmissionResult> submissionFuture = miniCluster.submitJob(jobGraph); final CompletableFuture<JobResult> jobResultFuture = submissionFuture.thenCompose( (JobSubmissionResult ignored) -> miniCluster.requestJobResult(jobGraph.getJobID())); jobResultFuture.get().toJobExecutionResult(getClass().getClassLoader()); assertTrue(sink.finalizedOnMaster.get()); } }
Example #22
Source File: FileBufferReaderITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testSequentialReading() throws Exception { // setup final Configuration configuration = new Configuration(); configuration.setString(RestOptions.BIND_PORT, "0"); configuration.setString(NettyShuffleEnvironmentOptions.NETWORK_BLOCKING_SHUFFLE_TYPE, "file"); configuration.set(TaskManagerOptions.TOTAL_FLINK_MEMORY, MemorySize.parse("1g")); final MiniClusterConfiguration miniClusterConfiguration = new MiniClusterConfiguration.Builder() .setConfiguration(configuration) .setNumTaskManagers(parallelism) .setNumSlotsPerTaskManager(1) .build(); try (final MiniCluster miniCluster = new MiniCluster(miniClusterConfiguration)) { miniCluster.start(); final MiniClusterClient client = new MiniClusterClient(configuration, miniCluster); final JobGraph jobGraph = createJobGraph(); // wait for the submission to succeed final JobID jobID = client.submitJob(jobGraph).get(); final CompletableFuture<JobResult> resultFuture = client.requestJobResult(jobID); final JobResult jobResult = resultFuture.get(); assertThat(jobResult.getSerializedThrowable().isPresent(), is(false)); } }
Example #23
Source File: JobExecutionResultHandlerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testCompletedResult() throws Exception { final JobStatus jobStatus = JobStatus.FINISHED; final ArchivedExecutionGraph executionGraph = new ArchivedExecutionGraphBuilder() .setJobID(TEST_JOB_ID) .setState(jobStatus) .build(); final TestingRestfulGateway testingRestfulGateway = TestingRestfulGateway.newBuilder() .setRequestJobStatusFunction( jobId -> { assertThat(jobId, equalTo(TEST_JOB_ID)); return CompletableFuture.completedFuture(jobStatus); }) .setRequestJobResultFunction( jobId -> { assertThat(jobId, equalTo(TEST_JOB_ID)); return CompletableFuture.completedFuture(JobResult.createFrom(executionGraph)); } ) .build(); final JobExecutionResultResponseBody responseBody = jobExecutionResultHandler.handleRequest( testRequest, testingRestfulGateway).get(); assertThat( responseBody.getStatus().getId(), equalTo(QueueStatus.Id.COMPLETED)); assertThat(responseBody.getJobExecutionResult(), not(nullValue())); }
Example #24
Source File: JobExecutionResultResponseBodyTest.java From flink with Apache License 2.0 | 5 votes |
@Override protected void assertOriginalEqualsToUnmarshalled( final JobExecutionResultResponseBody expected, final JobExecutionResultResponseBody actual) { assertThat(actual.getStatus(), equalTo(actual.getStatus())); final JobResult expectedJobExecutionResult = expected.getJobExecutionResult(); final JobResult actualJobExecutionResult = actual.getJobExecutionResult(); if (expectedJobExecutionResult != null) { assertNotNull(actualJobExecutionResult); assertThat(actualJobExecutionResult.getJobId(), equalTo(expectedJobExecutionResult.getJobId())); assertThat(actualJobExecutionResult.getApplicationStatus(), equalTo(expectedJobExecutionResult.getApplicationStatus())); assertThat(actualJobExecutionResult.getNetRuntime(), equalTo(expectedJobExecutionResult.getNetRuntime())); assertThat(actualJobExecutionResult.getAccumulatorResults(), equalTo(expectedJobExecutionResult.getAccumulatorResults())); final Optional<SerializedThrowable> expectedFailureCauseOptional = expectedJobExecutionResult.getSerializedThrowable(); expectedFailureCauseOptional.ifPresent(expectedFailureCause -> { final SerializedThrowable actualFailureCause = actualJobExecutionResult.getSerializedThrowable() .orElseThrow(() -> new AssertionError("actualFailureCause is not available")); assertThat(actualFailureCause.getFullStringifiedStackTrace(), equalTo(expectedFailureCause.getFullStringifiedStackTrace())); assertThat(actualFailureCause.getOriginalErrorClassName(), equalTo(expectedFailureCause.getOriginalErrorClassName())); assertArrayEquals(expectedFailureCause.getSerializedException(), actualFailureCause.getSerializedException()); }); if (expectedJobExecutionResult.getAccumulatorResults() != null) { assertNotNull(actualJobExecutionResult.getAccumulatorResults()); assertArrayEquals( actualJobExecutionResult.getAccumulatorResults().get(TEST_ACCUMULATOR_NAME).getByteArray(), expectedJobExecutionResult.getAccumulatorResults().get(TEST_ACCUMULATOR_NAME).getByteArray()); } } }
Example #25
Source File: RestClusterClient.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Requests the {@link JobResult} for the given {@link JobID}. The method retries multiple * times to poll the {@link JobResult} before giving up. * * @param jobId specifying the job for which to retrieve the {@link JobResult} * @return Future which is completed with the {@link JobResult} once the job has completed or * with a failure if the {@link JobResult} could not be retrieved. */ @Override public CompletableFuture<JobResult> requestJobResult(@Nonnull JobID jobId) { return pollResourceAsync( () -> { final JobMessageParameters messageParameters = new JobMessageParameters(); messageParameters.jobPathParameter.resolve(jobId); return sendRequest( JobExecutionResultHeaders.getInstance(), messageParameters); }); }
Example #26
Source File: FileBufferReaderITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testSequentialReading() throws Exception { // setup final Configuration configuration = new Configuration(); configuration.setString(RestOptions.BIND_PORT, "0"); configuration.setString(NettyShuffleEnvironmentOptions.NETWORK_BOUNDED_BLOCKING_SUBPARTITION_TYPE, "file"); final MiniClusterConfiguration miniClusterConfiguration = new MiniClusterConfiguration.Builder() .setConfiguration(configuration) .setNumTaskManagers(parallelism) .setNumSlotsPerTaskManager(1) .build(); try (final MiniCluster miniCluster = new MiniCluster(miniClusterConfiguration)) { miniCluster.start(); final MiniClusterClient client = new MiniClusterClient(configuration, miniCluster); final JobGraph jobGraph = createJobGraph(); final CompletableFuture<JobSubmissionResult> submitFuture = client.submitJob(jobGraph); // wait for the submission to succeed final JobSubmissionResult result = submitFuture.get(); final CompletableFuture<JobResult> resultFuture = client.requestJobResult(result.getJobID()); final JobResult jobResult = resultFuture.get(); assertThat(jobResult.getSerializedThrowable().isPresent(), is(false)); } }
Example #27
Source File: YARNHighAvailabilityITCase.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private void waitForJobTermination( final RestClusterClient<ApplicationId> restClusterClient, final JobID jobId) throws Exception { stopJobSignal.signal(); final CompletableFuture<JobResult> jobResult = restClusterClient.requestJobResult(jobId); jobResult.get(TIMEOUT.toMillis(), TimeUnit.MILLISECONDS); }
Example #28
Source File: RestClusterClientTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testJobSubmitCancelStop() throws Exception { TestJobSubmitHandler submitHandler = new TestJobSubmitHandler(); TestJobTerminationHandler terminationHandler = new TestJobTerminationHandler(); TestJobExecutionResultHandler testJobExecutionResultHandler = new TestJobExecutionResultHandler( JobExecutionResultResponseBody.created(new JobResult.Builder() .applicationStatus(ApplicationStatus.SUCCEEDED) .jobId(jobId) .netRuntime(Long.MAX_VALUE) .build())); try (TestRestServerEndpoint restServerEndpoint = createRestServerEndpoint( submitHandler, terminationHandler, testJobExecutionResultHandler)) { RestClusterClient<?> restClusterClient = createRestClusterClient(restServerEndpoint.getServerAddress().getPort()); try { Assert.assertFalse(submitHandler.jobSubmitted); restClusterClient.submitJob(jobGraph, ClassLoader.getSystemClassLoader()); Assert.assertTrue(submitHandler.jobSubmitted); Assert.assertFalse(terminationHandler.jobCanceled); restClusterClient.cancel(jobId); Assert.assertTrue(terminationHandler.jobCanceled); Assert.assertFalse(terminationHandler.jobStopped); restClusterClient.stop(jobId); Assert.assertTrue(terminationHandler.jobStopped); } finally { restClusterClient.shutdown(); } } }
Example #29
Source File: JobResultDeserializerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testDeserialization() throws Exception { final JobResult jobResult = objectMapper.readValue("{\n" + "\t\"id\": \"1bb5e8c7df49938733b7c6a73678de6a\",\n" + "\t\"accumulator-results\": {},\n" + "\t\"net-runtime\": 0,\n" + "\t\"unknownfield\": \"foobar\"\n" + "}", JobResult.class); assertThat(jobResult.getJobId(), equalTo(JobID.fromHexString("1bb5e8c7df49938733b7c6a73678de6a"))); assertThat(jobResult.getNetRuntime(), equalTo(0L)); assertThat(jobResult.getAccumulatorResults().size(), equalTo(0)); assertThat(jobResult.getSerializedThrowable().isPresent(), equalTo(false)); }
Example #30
Source File: MiniDispatcherTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that the {@link MiniDispatcher} only terminates in {@link ClusterEntrypoint.ExecutionMode#NORMAL} * after it has served the {@link org.apache.flink.runtime.jobmaster.JobResult} once. */ @Test public void testJobResultRetrieval() throws Exception { final MiniDispatcher miniDispatcher = createMiniDispatcher(ClusterEntrypoint.ExecutionMode.NORMAL); miniDispatcher.start(); try { // wait until we have submitted the job final TestingJobManagerRunner testingJobManagerRunner = testingJobManagerRunnerFactory.takeCreatedJobManagerRunner(); testingJobManagerRunner.completeResultFuture(archivedExecutionGraph); assertFalse(miniDispatcher.getTerminationFuture().isDone()); final DispatcherGateway dispatcherGateway = miniDispatcher.getSelfGateway(DispatcherGateway.class); final CompletableFuture<JobResult> jobResultFuture = dispatcherGateway.requestJobResult(jobGraph.getJobID(), timeout); final JobResult jobResult = jobResultFuture.get(); assertThat(jobResult.getJobId(), is(jobGraph.getJobID())); } finally { RpcUtils.terminateRpcEndpoint(miniDispatcher, timeout); } }