private MiniClusterClient createMiniClusterClient() { return new MiniClusterClient(getClientConfiguration(), getMiniCluster()); } }
@Override public JobSubmissionResult submitJob(JobGraph jobGraph, ClassLoader classLoader) throws ProgramInvocationException { final CompletableFuture<JobSubmissionResult> jobSubmissionResultFuture = submitJob(jobGraph); if (isDetached()) { try { return jobSubmissionResultFuture.get(); } catch (InterruptedException | ExecutionException e) { ExceptionUtils.checkInterrupted(e); throw new ProgramInvocationException("Could not run job in detached mode.", jobGraph.getJobID(), e); } } else { final CompletableFuture<JobResult> jobResultFuture = jobSubmissionResultFuture.thenCompose( (JobSubmissionResult ignored) -> requestJobResult(jobGraph.getJobID())); final JobResult jobResult; try { jobResult = jobResultFuture.get(); } catch (InterruptedException | ExecutionException e) { ExceptionUtils.checkInterrupted(e); throw new ProgramInvocationException("Could not run job", jobGraph.getJobID(), e); } try { return jobResult.toJobExecutionResult(classLoader); } catch (JobExecutionException e) { throw new ProgramInvocationException("Job failed", jobGraph.getJobID(), e); } catch (IOException | ClassNotFoundException e) { throw new ProgramInvocationException("Job failed", jobGraph.getJobID(), e); } } }
@Override public Map<String, OptionalFailure<Object>> getAccumulators(JobID jobID) throws Exception { return getAccumulators(jobID, ClassLoader.getSystemClassLoader()); }
private void executeSchedulingTest(Configuration configuration) throws Exception { configuration.setInteger(RestOptions.PORT, 0); final long slotIdleTimeout = 50L; configuration.setLong(JobManagerOptions.SLOT_IDLE_TIMEOUT, slotIdleTimeout); 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); CompletableFuture<JobSubmissionResult> submissionFuture = miniClusterClient.submitJob(jobGraph); // wait for the submission to succeed JobSubmissionResult jobSubmissionResult = submissionFuture.get(); CompletableFuture<JobResult> resultFuture = miniClusterClient.requestJobResult(jobSubmissionResult.getJobID()); JobResult jobResult = resultFuture.get(); assertThat(jobResult.getSerializedThrowable().isPresent(), is(false)); } }
private void waitForJob() throws Exception { for (int i = 0; i < 60; i++) { try { final JobStatus jobStatus = clusterClient.getJobStatus(jobGraph.getJobID()).get(60, TimeUnit.SECONDS); assertThat(jobStatus.isGloballyTerminalState(), equalTo(false)); if (jobStatus == JobStatus.RUNNING) { return; } } catch (ExecutionException ignored) { // JobManagerRunner is not yet registered in Dispatcher } Thread.sleep(1000); } throw new AssertionError("Job did not become running within timeout."); }
private String cancelWithSavepoint() throws Exception { return clusterClient.cancelWithSavepoint( jobGraph.getJobID(), savepointDirectory.toAbsolutePath().toString()); }
@Test public void testStopJobAfterSavepoint() throws Exception { setUpWithCheckpointInterval(10L); final String savepointLocation = cancelWithSavepoint(); final JobStatus jobStatus = clusterClient.getJobStatus(jobGraph.getJobID()).get(); assertThat(jobStatus, isOneOf(JobStatus.CANCELED, JobStatus.CANCELLING)); final List<Path> savepoints; try (Stream<Path> savepointFiles = Files.list(savepointDirectory)) { savepoints = savepointFiles.map(Path::getFileName).collect(Collectors.toList()); } assertThat(savepoints, hasItem(Paths.get(savepointLocation).getFileName())); }
/** * Tests that cancel with savepoint without a properly configured savepoint * directory, will fail with a meaningful exception message. */ @Test public void testCancelWithSavepointWithoutConfiguredSavepointDirectory() throws Exception { setUpWithCheckpointInterval(10L); try { clusterClient.cancelWithSavepoint(jobGraph.getJobID(), null); } catch (Exception e) { if (!ExceptionUtils.findThrowableWithMessage(e, "savepoint directory").isPresent()) { throw e; } } }
@Override public JobSubmissionResult submitJob(JobGraph jobGraph, ClassLoader classLoader, boolean detached) throws ProgramInvocationException { final CompletableFuture<JobSubmissionResult> jobSubmissionResultFuture = submitJob(jobGraph); if (isDetached() || detached) { try { return jobSubmissionResultFuture.get(); (JobSubmissionResult ignored) -> requestJobResult(jobGraph.getJobID()));
ClusterClient<?> clusterClient = new MiniClusterClient(new Configuration(), miniClusterResource.getMiniCluster());
@Test public void testStopJobAfterSavepointWithDeactivatedPeriodicCheckpointing() throws Exception { // set checkpointInterval to Long.MAX_VALUE, which means deactivated checkpointing setUpWithCheckpointInterval(Long.MAX_VALUE); final String savepointLocation = cancelWithSavepoint(); final JobStatus jobStatus = clusterClient.getJobStatus(jobGraph.getJobID()).get(60, TimeUnit.SECONDS); assertThat(jobStatus, isOneOf(JobStatus.CANCELED, JobStatus.CANCELLING)); final List<Path> savepoints; try (Stream<Path> savepointFiles = Files.list(savepointDirectory)) { savepoints = savepointFiles.map(Path::getFileName).collect(Collectors.toList()); } assertThat(savepoints, hasItem(Paths.get(savepointLocation).getFileName())); }
@Override public Map<String, OptionalFailure<Object>> getAccumulators(JobID jobID) throws Exception { return getAccumulators(jobID, ClassLoader.getSystemClassLoader()); }
@Override public JobSubmissionResult submitJob(JobGraph jobGraph, ClassLoader classLoader) throws ProgramInvocationException { final CompletableFuture<JobSubmissionResult> jobSubmissionResultFuture = submitJob(jobGraph); if (isDetached()) { try { return jobSubmissionResultFuture.get(); } catch (InterruptedException | ExecutionException e) { ExceptionUtils.checkInterrupted(e); throw new ProgramInvocationException("Could not run job in detached mode.", jobGraph.getJobID(), e); } } else { final CompletableFuture<JobResult> jobResultFuture = jobSubmissionResultFuture.thenCompose( (JobSubmissionResult ignored) -> requestJobResult(jobGraph.getJobID())); final JobResult jobResult; try { jobResult = jobResultFuture.get(); } catch (InterruptedException | ExecutionException e) { ExceptionUtils.checkInterrupted(e); throw new ProgramInvocationException("Could not run job", jobGraph.getJobID(), e); } try { return jobResult.toJobExecutionResult(classLoader); } catch (JobExecutionException e) { throw new ProgramInvocationException("Job failed", jobGraph.getJobID(), e); } catch (IOException | ClassNotFoundException e) { throw new ProgramInvocationException("Job failed", jobGraph.getJobID(), e); } } }
private MiniClusterClient createMiniClusterClient() { return new MiniClusterClient(getClientConfiguration(), getMiniCluster()); } }
@Test public void testDoNotCancelJobIfSavepointFails() throws Exception { setUpWithCheckpointInterval(10L); try { Files.setPosixFilePermissions(savepointDirectory, Collections.emptySet()); } catch (IOException e) { Assume.assumeNoException(e); } try { cancelWithSavepoint(); } catch (Exception e) { assertThat(ExceptionUtils.findThrowable(e, CheckpointTriggerException.class).isPresent(), equalTo(true)); } final JobStatus jobStatus = clusterClient.getJobStatus(jobGraph.getJobID()).get(60, TimeUnit.SECONDS); assertThat(jobStatus, equalTo(JobStatus.RUNNING)); // assert that checkpoints are continued to be triggered triggerCheckpointLatch = new CountDownLatch(1); assertThat(triggerCheckpointLatch.await(60L, TimeUnit.SECONDS), equalTo(true)); }
@Override public Map<String, OptionalFailure<Object>> getAccumulators(JobID jobID) throws Exception { return getAccumulators(jobID, ClassLoader.getSystemClassLoader()); }
private MiniClusterClient createMiniClusterClient() { return new MiniClusterClient(getClientConfiguration(), getMiniCluster()); } }
clusterClient = new MiniClusterClient(configuration, miniCluster);