use of org.apache.flink.runtime.jobmaster.JobResult in project flink by apache.
the class JobResultDeserializerTest method testDeserialization.
@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));
}
use of org.apache.flink.runtime.jobmaster.JobResult in project flink by apache.
the class BlobsCleanupITCase method testBlobServerCleanup.
private void testBlobServerCleanup(final TestCase testCase) throws Exception {
final MiniCluster miniCluster = miniClusterResource.getMiniCluster();
final int numTasks = 2;
final Deadline timeout = Deadline.fromNow(Duration.ofSeconds(30L));
final JobGraph jobGraph = createJobGraph(testCase, numTasks);
final JobID jid = jobGraph.getJobID();
// upload a blob
final File tempBlob = File.createTempFile("Required", ".jar");
final int blobPort = miniCluster.getClusterInformation().getBlobServerPort();
List<PermanentBlobKey> keys = BlobClient.uploadFiles(new InetSocketAddress("localhost", blobPort), configuration, jid, Collections.singletonList(new Path(tempBlob.getAbsolutePath())));
assertThat(keys, hasSize(1));
jobGraph.addUserJarBlobKey(keys.get(0));
if (testCase == TestCase.JOB_SUBMISSION_FAILS) {
// add an invalid key so that the submission fails
jobGraph.addUserJarBlobKey(new PermanentBlobKey());
}
final CompletableFuture<JobSubmissionResult> submissionFuture = miniCluster.submitJob(jobGraph);
if (testCase == TestCase.JOB_SUBMISSION_FAILS) {
try {
submissionFuture.get();
fail("Expected job submission failure.");
} catch (ExecutionException e) {
assertThat(ExceptionUtils.findThrowable(e, JobSubmissionException.class).isPresent(), is(true));
}
} else {
final JobSubmissionResult jobSubmissionResult = submissionFuture.get();
assertThat(jobSubmissionResult.getJobID(), is(jid));
final CompletableFuture<JobResult> resultFuture = miniCluster.requestJobResult(jid);
if (testCase == TestCase.JOB_FAILS) {
// fail a task so that the job is going to be recovered (we actually do not
// need the blocking part of the invokable and can start throwing right away)
FailingBlockingInvokable.unblock();
// job will get restarted, BlobCache may re-download the BLOB if already deleted
// then the tasks will fail again and the restart strategy will finalise the job
final JobResult jobResult = resultFuture.get();
assertThat(jobResult.isSuccess(), is(false));
assertThat(jobResult.getApplicationStatus(), is(ApplicationStatus.FAILED));
} else if (testCase == TestCase.JOB_IS_CANCELLED) {
miniCluster.cancelJob(jid);
final JobResult jobResult = resultFuture.get();
assertThat(jobResult.isSuccess(), is(false));
assertThat(jobResult.getApplicationStatus(), is(ApplicationStatus.CANCELED));
} else {
final JobResult jobResult = resultFuture.get();
Throwable cause = jobResult.getSerializedThrowable().map(throwable -> throwable.deserializeError(getClass().getClassLoader())).orElse(null);
assertThat(ExceptionUtils.stringifyException(cause), jobResult.isSuccess(), is(true));
}
}
// both BlobServer and BlobCache should eventually delete all files
File[] blobDirs = blobBaseDir.listFiles((dir, name) -> name.startsWith("blobStore-"));
assertNotNull(blobDirs);
for (File blobDir : blobDirs) {
waitForEmptyBlobDir(blobDir, timeout.timeLeft());
}
}
use of org.apache.flink.runtime.jobmaster.JobResult in project flink by apache.
the class AdaptiveSchedulerClusterITCase method testAutomaticScaleDownInCaseOfLostSlots.
@Test
public void testAutomaticScaleDownInCaseOfLostSlots() throws Exception {
final MiniCluster miniCluster = miniClusterResource.getMiniCluster();
final JobGraph jobGraph = createBlockingJobGraph(PARALLELISM);
miniCluster.submitJob(jobGraph).join();
final CompletableFuture<JobResult> resultFuture = miniCluster.requestJobResult(jobGraph.getJobID());
waitUntilParallelismForVertexReached(jobGraph.getJobID(), JOB_VERTEX_ID, NUMBER_SLOTS_PER_TASK_MANAGER * NUMBER_TASK_MANAGERS);
miniCluster.terminateTaskManager(0);
waitUntilParallelismForVertexReached(jobGraph.getJobID(), JOB_VERTEX_ID, NUMBER_SLOTS_PER_TASK_MANAGER * (NUMBER_TASK_MANAGERS - 1));
OnceBlockingNoOpInvokable.unblock();
final JobResult jobResult = resultFuture.join();
assertTrue(jobResult.isSuccess());
}
use of org.apache.flink.runtime.jobmaster.JobResult in project flink by apache.
the class AdaptiveSchedulerSimpleITCase method testGlobalFailoverIfTaskFails.
@Test
public void testGlobalFailoverIfTaskFails() throws Throwable {
final MiniCluster miniCluster = MINI_CLUSTER_RESOURCE.getMiniCluster();
final JobGraph jobGraph = createOnceFailingJobGraph();
miniCluster.submitJob(jobGraph).join();
final JobResult jobResult = miniCluster.requestJobResult(jobGraph.getJobID()).join();
if (!jobResult.isSuccess()) {
throw jobResult.getSerializedThrowable().get().deserializeError(ClassLoader.getSystemClassLoader());
}
}
use of org.apache.flink.runtime.jobmaster.JobResult in project flink by apache.
the class AdaptiveSchedulerSimpleITCase method testSchedulingOfSimpleJob.
@Test
public void testSchedulingOfSimpleJob() throws Exception {
final MiniCluster miniCluster = MINI_CLUSTER_RESOURCE.getMiniCluster();
final JobGraph jobGraph = createJobGraph();
miniCluster.submitJob(jobGraph).join();
final JobResult jobResult = miniCluster.requestJobResult(jobGraph.getJobID()).join();
final JobExecutionResult jobExecutionResult = jobResult.toJobExecutionResult(getClass().getClassLoader());
assertTrue(jobResult.isSuccess());
}
Aggregations