org.apache.flink.runtime.rest.messages.job.JobSubmitRequestBody Java Examples
The following examples show how to use
org.apache.flink.runtime.rest.messages.job.JobSubmitRequestBody.
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: JobSubmitHandlerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testSuccessfulJobSubmission() throws Exception { final Path jobGraphFile = TEMPORARY_FOLDER.newFile().toPath(); try (ObjectOutputStream objectOut = new ObjectOutputStream(Files.newOutputStream(jobGraphFile))) { objectOut.writeObject(new JobGraph("testjob")); } TestingDispatcherGateway.Builder builder = new TestingDispatcherGateway.Builder(); builder .setBlobServerPort(blobServer.getPort()) .setSubmitFunction(jobGraph -> CompletableFuture.completedFuture(Acknowledge.get())) .setHostname("localhost"); DispatcherGateway mockGateway = builder.build(); JobSubmitHandler handler = new JobSubmitHandler( () -> CompletableFuture.completedFuture(mockGateway), RpcUtils.INF_TIMEOUT, Collections.emptyMap(), TestingUtils.defaultExecutor(), configuration); JobSubmitRequestBody request = new JobSubmitRequestBody(jobGraphFile.getFileName().toString(), Collections.emptyList(), Collections.emptyList()); handler.handleRequest(new HandlerRequest<>(request, EmptyMessageParameters.getInstance(), Collections.emptyMap(), Collections.emptyMap(), Collections.singleton(jobGraphFile.toFile())), mockGateway) .get(); }
Example #2
Source File: JobSubmitHandlerTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testSerializationFailureHandling() throws Exception { final Path jobGraphFile = TEMPORARY_FOLDER.newFile().toPath(); DispatcherGateway mockGateway = new TestingDispatcherGateway.Builder() .setSubmitFunction(jobGraph -> CompletableFuture.completedFuture(Acknowledge.get())) .build(); JobSubmitHandler handler = new JobSubmitHandler( () -> CompletableFuture.completedFuture(mockGateway), RpcUtils.INF_TIMEOUT, Collections.emptyMap(), TestingUtils.defaultExecutor(), configuration); JobSubmitRequestBody request = new JobSubmitRequestBody(jobGraphFile.toString(), Collections.emptyList(), Collections.emptyList()); try { handler.handleRequest(new HandlerRequest<>(request, EmptyMessageParameters.getInstance()), mockGateway); Assert.fail(); } catch (RestHandlerException rhe) { Assert.assertEquals(HttpResponseStatus.BAD_REQUEST, rhe.getHttpResponseStatus()); } }
Example #3
Source File: JobSubmitHandlerTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testSuccessfulJobSubmission() throws Exception { final Path jobGraphFile = TEMPORARY_FOLDER.newFile().toPath(); try (ObjectOutputStream objectOut = new ObjectOutputStream(Files.newOutputStream(jobGraphFile))) { objectOut.writeObject(new JobGraph("testjob")); } TestingDispatcherGateway.Builder builder = new TestingDispatcherGateway.Builder(); builder .setBlobServerPort(blobServer.getPort()) .setSubmitFunction(jobGraph -> CompletableFuture.completedFuture(Acknowledge.get())) .setHostname("localhost"); DispatcherGateway mockGateway = builder.build(); JobSubmitHandler handler = new JobSubmitHandler( () -> CompletableFuture.completedFuture(mockGateway), RpcUtils.INF_TIMEOUT, Collections.emptyMap(), TestingUtils.defaultExecutor(), configuration); JobSubmitRequestBody request = new JobSubmitRequestBody(jobGraphFile.getFileName().toString(), Collections.emptyList(), Collections.emptyList()); handler.handleRequest(new HandlerRequest<>(request, EmptyMessageParameters.getInstance(), Collections.emptyMap(), Collections.emptyMap(), Collections.singleton(jobGraphFile.toFile())), mockGateway) .get(); }
Example #4
Source File: JobSubmitHandlerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testSerializationFailureHandling() throws Exception { final Path jobGraphFile = TEMPORARY_FOLDER.newFile().toPath(); DispatcherGateway mockGateway = new TestingDispatcherGateway.Builder() .setSubmitFunction(jobGraph -> CompletableFuture.completedFuture(Acknowledge.get())) .build(); JobSubmitHandler handler = new JobSubmitHandler( () -> CompletableFuture.completedFuture(mockGateway), RpcUtils.INF_TIMEOUT, Collections.emptyMap(), TestingUtils.defaultExecutor(), configuration); JobSubmitRequestBody request = new JobSubmitRequestBody(jobGraphFile.toString(), Collections.emptyList(), Collections.emptyList()); try { handler.handleRequest(new HandlerRequest<>(request, EmptyMessageParameters.getInstance()), mockGateway); Assert.fail(); } catch (RestHandlerException rhe) { Assert.assertEquals(HttpResponseStatus.BAD_REQUEST, rhe.getHttpResponseStatus()); } }
Example #5
Source File: JobSubmitHandlerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testSuccessfulJobSubmission() throws Exception { final Path jobGraphFile = TEMPORARY_FOLDER.newFile().toPath(); try (ObjectOutputStream objectOut = new ObjectOutputStream(Files.newOutputStream(jobGraphFile))) { objectOut.writeObject(new JobGraph("testjob")); } TestingDispatcherGateway.Builder builder = new TestingDispatcherGateway.Builder(); builder .setBlobServerPort(blobServer.getPort()) .setSubmitFunction(jobGraph -> CompletableFuture.completedFuture(Acknowledge.get())) .setHostname("localhost"); DispatcherGateway mockGateway = builder.build(); JobSubmitHandler handler = new JobSubmitHandler( () -> CompletableFuture.completedFuture(mockGateway), RpcUtils.INF_TIMEOUT, Collections.emptyMap(), TestingUtils.defaultExecutor(), configuration); JobSubmitRequestBody request = new JobSubmitRequestBody(jobGraphFile.getFileName().toString(), Collections.emptyList(), Collections.emptyList()); handler.handleRequest(new HandlerRequest<>(request, EmptyMessageParameters.getInstance(), Collections.emptyMap(), Collections.emptyMap(), Collections.singleton(jobGraphFile.toFile())), mockGateway) .get(); }
Example #6
Source File: JobSubmitHandlerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testSerializationFailureHandling() throws Exception { final Path jobGraphFile = TEMPORARY_FOLDER.newFile().toPath(); DispatcherGateway mockGateway = new TestingDispatcherGateway.Builder() .setSubmitFunction(jobGraph -> CompletableFuture.completedFuture(Acknowledge.get())) .build(); JobSubmitHandler handler = new JobSubmitHandler( () -> CompletableFuture.completedFuture(mockGateway), RpcUtils.INF_TIMEOUT, Collections.emptyMap(), TestingUtils.defaultExecutor(), configuration); JobSubmitRequestBody request = new JobSubmitRequestBody(jobGraphFile.toString(), Collections.emptyList(), Collections.emptyList()); try { handler.handleRequest(new HandlerRequest<>(request, EmptyMessageParameters.getInstance()), mockGateway); Assert.fail(); } catch (RestHandlerException rhe) { Assert.assertEquals(HttpResponseStatus.BAD_REQUEST, rhe.getHttpResponseStatus()); } }
Example #7
Source File: JobSubmitHandler.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private static Collection<Tuple2<String, Path>> getArtifactFilesToUpload( Collection<JobSubmitRequestBody.DistributedCacheFile> artifactEntries, Map<String, Path> nameToFileMap) throws MissingFileException { Collection<Tuple2<String, Path>> artifacts = new ArrayList<>(artifactEntries.size()); for (JobSubmitRequestBody.DistributedCacheFile artifactFileName : artifactEntries) { Path artifactFile = getPathAndAssertUpload(artifactFileName.fileName, FILE_TYPE_ARTIFACT, nameToFileMap); artifacts.add(Tuple2.of(artifactFileName.entryName, new Path(artifactFile.toString()))); } return artifacts; }
Example #8
Source File: JobSubmitHandlerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testFailedJobSubmission() throws Exception { final String errorMessage = "test"; DispatcherGateway mockGateway = new TestingDispatcherGateway.Builder() .setSubmitFunction(jobgraph -> FutureUtils.completedExceptionally(new Exception(errorMessage))) .build(); JobSubmitHandler handler = new JobSubmitHandler( () -> CompletableFuture.completedFuture(mockGateway), RpcUtils.INF_TIMEOUT, Collections.emptyMap(), TestingUtils.defaultExecutor(), configuration); final Path jobGraphFile = TEMPORARY_FOLDER.newFile().toPath(); JobGraph jobGraph = new JobGraph("testjob"); try (ObjectOutputStream objectOut = new ObjectOutputStream(Files.newOutputStream(jobGraphFile))) { objectOut.writeObject(jobGraph); } JobSubmitRequestBody request = new JobSubmitRequestBody(jobGraphFile.getFileName().toString(), Collections.emptyList(), Collections.emptyList()); try { handler.handleRequest(new HandlerRequest<>( request, EmptyMessageParameters.getInstance(), Collections.emptyMap(), Collections.emptyMap(), Collections.singletonList(jobGraphFile.toFile())), mockGateway) .get(); } catch (Exception e) { Throwable t = ExceptionUtils.stripExecutionException(e); Assert.assertEquals(errorMessage, t.getMessage()); } }
Example #9
Source File: JobSubmitHandlerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testRejectionOnCountMismatch() throws Exception { final Path jobGraphFile = TEMPORARY_FOLDER.newFile().toPath(); try (ObjectOutputStream objectOut = new ObjectOutputStream(Files.newOutputStream(jobGraphFile))) { objectOut.writeObject(new JobGraph("testjob")); } final Path countExceedingFile = TEMPORARY_FOLDER.newFile().toPath(); TestingDispatcherGateway.Builder builder = new TestingDispatcherGateway.Builder(); builder .setBlobServerPort(blobServer.getPort()) .setSubmitFunction(jobGraph -> CompletableFuture.completedFuture(Acknowledge.get())) .setHostname("localhost"); DispatcherGateway mockGateway = builder.build(); JobSubmitHandler handler = new JobSubmitHandler( () -> CompletableFuture.completedFuture(mockGateway), RpcUtils.INF_TIMEOUT, Collections.emptyMap(), TestingUtils.defaultExecutor(), configuration); JobSubmitRequestBody request = new JobSubmitRequestBody(jobGraphFile.getFileName().toString(), Collections.emptyList(), Collections.emptyList()); try { handler.handleRequest(new HandlerRequest<>(request, EmptyMessageParameters.getInstance(), Collections.emptyMap(), Collections.emptyMap(), Arrays.asList(jobGraphFile.toFile(), countExceedingFile.toFile())), mockGateway) .get(); } catch (Exception e) { ExceptionUtils.findThrowable(e, candidate -> candidate instanceof RestHandlerException && candidate.getMessage().contains("count")); } }
Example #10
Source File: JobSubmitRequestBodyTest.java From flink with Apache License 2.0 | 5 votes |
@Override protected JobSubmitRequestBody getTestRequestInstance() throws IOException { return new JobSubmitRequestBody( "jobgraph", Arrays.asList("jar1", "jar2"), Arrays.asList( new JobSubmitRequestBody.DistributedCacheFile("entry1", "artifact1"), new JobSubmitRequestBody.DistributedCacheFile("entry2", "artifact2"))); }
Example #11
Source File: JobSubmitHandler.java From flink with Apache License 2.0 | 5 votes |
private static Collection<Tuple2<String, Path>> getArtifactFilesToUpload( Collection<JobSubmitRequestBody.DistributedCacheFile> artifactEntries, Map<String, Path> nameToFileMap) throws MissingFileException { Collection<Tuple2<String, Path>> artifacts = new ArrayList<>(artifactEntries.size()); for (JobSubmitRequestBody.DistributedCacheFile artifactFileName : artifactEntries) { Path artifactFile = getPathAndAssertUpload(artifactFileName.fileName, FILE_TYPE_ARTIFACT, nameToFileMap); artifacts.add(Tuple2.of(artifactFileName.entryName, new Path(artifactFile.toString()))); } return artifacts; }
Example #12
Source File: JobSubmitHandler.java From flink with Apache License 2.0 | 5 votes |
@Override protected CompletableFuture<JobSubmitResponseBody> handleRequest(@Nonnull HandlerRequest<JobSubmitRequestBody, EmptyMessageParameters> request, @Nonnull DispatcherGateway gateway) throws RestHandlerException { final Collection<File> uploadedFiles = request.getUploadedFiles(); final Map<String, Path> nameToFile = uploadedFiles.stream().collect(Collectors.toMap( File::getName, Path::fromLocalFile )); if (uploadedFiles.size() != nameToFile.size()) { throw new RestHandlerException( String.format("The number of uploaded files was %s than the expected count. Expected: %s Actual %s", uploadedFiles.size() < nameToFile.size() ? "lower" : "higher", nameToFile.size(), uploadedFiles.size()), HttpResponseStatus.BAD_REQUEST ); } final JobSubmitRequestBody requestBody = request.getRequestBody(); if (requestBody.jobGraphFileName == null) { throw new RestHandlerException( String.format("The %s field must not be omitted or be null.", JobSubmitRequestBody.FIELD_NAME_JOB_GRAPH), HttpResponseStatus.BAD_REQUEST); } CompletableFuture<JobGraph> jobGraphFuture = loadJobGraph(requestBody, nameToFile); Collection<Path> jarFiles = getJarFilesToUpload(requestBody.jarFileNames, nameToFile); Collection<Tuple2<String, Path>> artifacts = getArtifactFilesToUpload(requestBody.artifactFileNames, nameToFile); CompletableFuture<JobGraph> finalizedJobGraphFuture = uploadJobGraphFiles(gateway, jobGraphFuture, jarFiles, artifacts, configuration); CompletableFuture<Acknowledge> jobSubmissionFuture = finalizedJobGraphFuture.thenCompose(jobGraph -> gateway.submitJob(jobGraph, timeout)); return jobSubmissionFuture.thenCombine(jobGraphFuture, (ack, jobGraph) -> new JobSubmitResponseBody("/jobs/" + jobGraph.getJobID())); }
Example #13
Source File: JobSubmitHandlerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testFailedJobSubmission() throws Exception { final String errorMessage = "test"; DispatcherGateway mockGateway = new TestingDispatcherGateway.Builder() .setSubmitFunction(jobgraph -> FutureUtils.completedExceptionally(new Exception(errorMessage))) .build(); JobSubmitHandler handler = new JobSubmitHandler( () -> CompletableFuture.completedFuture(mockGateway), RpcUtils.INF_TIMEOUT, Collections.emptyMap(), TestingUtils.defaultExecutor(), configuration); final Path jobGraphFile = TEMPORARY_FOLDER.newFile().toPath(); JobGraph jobGraph = new JobGraph("testjob"); try (ObjectOutputStream objectOut = new ObjectOutputStream(Files.newOutputStream(jobGraphFile))) { objectOut.writeObject(jobGraph); } JobSubmitRequestBody request = new JobSubmitRequestBody(jobGraphFile.getFileName().toString(), Collections.emptyList(), Collections.emptyList()); try { handler.handleRequest(new HandlerRequest<>( request, EmptyMessageParameters.getInstance(), Collections.emptyMap(), Collections.emptyMap(), Collections.singletonList(jobGraphFile.toFile())), mockGateway) .get(); } catch (Exception e) { Throwable t = ExceptionUtils.stripExecutionException(e); Assert.assertEquals(errorMessage, t.getMessage()); } }
Example #14
Source File: JobSubmitHandlerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testRejectionOnCountMismatch() throws Exception { final Path jobGraphFile = TEMPORARY_FOLDER.newFile().toPath(); try (ObjectOutputStream objectOut = new ObjectOutputStream(Files.newOutputStream(jobGraphFile))) { objectOut.writeObject(new JobGraph("testjob")); } final Path countExceedingFile = TEMPORARY_FOLDER.newFile().toPath(); TestingDispatcherGateway.Builder builder = new TestingDispatcherGateway.Builder(); builder .setBlobServerPort(blobServer.getPort()) .setSubmitFunction(jobGraph -> CompletableFuture.completedFuture(Acknowledge.get())) .setHostname("localhost"); DispatcherGateway mockGateway = builder.build(); JobSubmitHandler handler = new JobSubmitHandler( () -> CompletableFuture.completedFuture(mockGateway), RpcUtils.INF_TIMEOUT, Collections.emptyMap(), TestingUtils.defaultExecutor(), configuration); JobSubmitRequestBody request = new JobSubmitRequestBody(jobGraphFile.getFileName().toString(), Collections.emptyList(), Collections.emptyList()); try { handler.handleRequest(new HandlerRequest<>(request, EmptyMessageParameters.getInstance(), Collections.emptyMap(), Collections.emptyMap(), Arrays.asList(jobGraphFile.toFile(), countExceedingFile.toFile())), mockGateway) .get(); } catch (Exception e) { ExceptionUtils.findThrowable(e, candidate -> candidate instanceof RestHandlerException && candidate.getMessage().contains("count")); } }
Example #15
Source File: JobSubmitRequestBodyTest.java From flink with Apache License 2.0 | 5 votes |
@Override protected JobSubmitRequestBody getTestRequestInstance() throws IOException { return new JobSubmitRequestBody( "jobgraph", Arrays.asList("jar1", "jar2"), Arrays.asList( new JobSubmitRequestBody.DistributedCacheFile("entry1", "artifact1"), new JobSubmitRequestBody.DistributedCacheFile("entry2", "artifact2"))); }
Example #16
Source File: JobSubmitHandler.java From flink with Apache License 2.0 | 5 votes |
private static Collection<Tuple2<String, Path>> getArtifactFilesToUpload( Collection<JobSubmitRequestBody.DistributedCacheFile> artifactEntries, Map<String, Path> nameToFileMap) throws MissingFileException { Collection<Tuple2<String, Path>> artifacts = new ArrayList<>(artifactEntries.size()); for (JobSubmitRequestBody.DistributedCacheFile artifactFileName : artifactEntries) { Path artifactFile = getPathAndAssertUpload(artifactFileName.fileName, FILE_TYPE_ARTIFACT, nameToFileMap); artifacts.add(Tuple2.of(artifactFileName.entryName, new Path(artifactFile.toString()))); } return artifacts; }
Example #17
Source File: JobSubmitHandler.java From flink with Apache License 2.0 | 5 votes |
@Override protected CompletableFuture<JobSubmitResponseBody> handleRequest(@Nonnull HandlerRequest<JobSubmitRequestBody, EmptyMessageParameters> request, @Nonnull DispatcherGateway gateway) throws RestHandlerException { final Collection<File> uploadedFiles = request.getUploadedFiles(); final Map<String, Path> nameToFile = uploadedFiles.stream().collect(Collectors.toMap( File::getName, Path::fromLocalFile )); if (uploadedFiles.size() != nameToFile.size()) { throw new RestHandlerException( String.format("The number of uploaded files was %s than the expected count. Expected: %s Actual %s", uploadedFiles.size() < nameToFile.size() ? "lower" : "higher", nameToFile.size(), uploadedFiles.size()), HttpResponseStatus.BAD_REQUEST ); } final JobSubmitRequestBody requestBody = request.getRequestBody(); if (requestBody.jobGraphFileName == null) { throw new RestHandlerException( String.format("The %s field must not be omitted or be null.", JobSubmitRequestBody.FIELD_NAME_JOB_GRAPH), HttpResponseStatus.BAD_REQUEST); } CompletableFuture<JobGraph> jobGraphFuture = loadJobGraph(requestBody, nameToFile); Collection<Path> jarFiles = getJarFilesToUpload(requestBody.jarFileNames, nameToFile); Collection<Tuple2<String, Path>> artifacts = getArtifactFilesToUpload(requestBody.artifactFileNames, nameToFile); CompletableFuture<JobGraph> finalizedJobGraphFuture = uploadJobGraphFiles(gateway, jobGraphFuture, jarFiles, artifacts, configuration); CompletableFuture<Acknowledge> jobSubmissionFuture = finalizedJobGraphFuture.thenCompose(jobGraph -> gateway.submitJob(jobGraph, timeout)); return jobSubmissionFuture.thenCombine(jobGraphFuture, (ack, jobGraph) -> new JobSubmitResponseBody("/jobs/" + jobGraph.getJobID())); }
Example #18
Source File: JobSubmitHandlerTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testFailedJobSubmission() throws Exception { final String errorMessage = "test"; DispatcherGateway mockGateway = new TestingDispatcherGateway.Builder() .setSubmitFunction(jobgraph -> FutureUtils.completedExceptionally(new Exception(errorMessage))) .build(); JobSubmitHandler handler = new JobSubmitHandler( () -> CompletableFuture.completedFuture(mockGateway), RpcUtils.INF_TIMEOUT, Collections.emptyMap(), TestingUtils.defaultExecutor(), configuration); final Path jobGraphFile = TEMPORARY_FOLDER.newFile().toPath(); JobGraph jobGraph = new JobGraph("testjob"); try (ObjectOutputStream objectOut = new ObjectOutputStream(Files.newOutputStream(jobGraphFile))) { objectOut.writeObject(jobGraph); } JobSubmitRequestBody request = new JobSubmitRequestBody(jobGraphFile.getFileName().toString(), Collections.emptyList(), Collections.emptyList()); try { handler.handleRequest(new HandlerRequest<>( request, EmptyMessageParameters.getInstance(), Collections.emptyMap(), Collections.emptyMap(), Collections.singletonList(jobGraphFile.toFile())), mockGateway) .get(); } catch (Exception e) { Throwable t = ExceptionUtils.stripExecutionException(e); Assert.assertEquals(errorMessage, t.getMessage()); } }
Example #19
Source File: JobSubmitHandlerTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testRejectionOnCountMismatch() throws Exception { final Path jobGraphFile = TEMPORARY_FOLDER.newFile().toPath(); try (ObjectOutputStream objectOut = new ObjectOutputStream(Files.newOutputStream(jobGraphFile))) { objectOut.writeObject(new JobGraph("testjob")); } final Path countExceedingFile = TEMPORARY_FOLDER.newFile().toPath(); TestingDispatcherGateway.Builder builder = new TestingDispatcherGateway.Builder(); builder .setBlobServerPort(blobServer.getPort()) .setSubmitFunction(jobGraph -> CompletableFuture.completedFuture(Acknowledge.get())) .setHostname("localhost"); DispatcherGateway mockGateway = builder.build(); JobSubmitHandler handler = new JobSubmitHandler( () -> CompletableFuture.completedFuture(mockGateway), RpcUtils.INF_TIMEOUT, Collections.emptyMap(), TestingUtils.defaultExecutor(), configuration); JobSubmitRequestBody request = new JobSubmitRequestBody(jobGraphFile.getFileName().toString(), Collections.emptyList(), Collections.emptyList()); try { handler.handleRequest(new HandlerRequest<>(request, EmptyMessageParameters.getInstance(), Collections.emptyMap(), Collections.emptyMap(), Arrays.asList(jobGraphFile.toFile(), countExceedingFile.toFile())), mockGateway) .get(); } catch (Exception e) { ExceptionUtils.findThrowable(e, candidate -> candidate instanceof RestHandlerException && candidate.getMessage().contains("count")); } }
Example #20
Source File: JobSubmitRequestBodyTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override protected JobSubmitRequestBody getTestRequestInstance() throws IOException { return new JobSubmitRequestBody( "jobgraph", Arrays.asList("jar1", "jar2"), Arrays.asList( new JobSubmitRequestBody.DistributedCacheFile("entry1", "artifact1"), new JobSubmitRequestBody.DistributedCacheFile("entry2", "artifact2"))); }
Example #21
Source File: JobSubmitHandler.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override protected CompletableFuture<JobSubmitResponseBody> handleRequest(@Nonnull HandlerRequest<JobSubmitRequestBody, EmptyMessageParameters> request, @Nonnull DispatcherGateway gateway) throws RestHandlerException { final Collection<File> uploadedFiles = request.getUploadedFiles(); final Map<String, Path> nameToFile = uploadedFiles.stream().collect(Collectors.toMap( File::getName, Path::fromLocalFile )); if (uploadedFiles.size() != nameToFile.size()) { throw new RestHandlerException( String.format("The number of uploaded files was %s than the expected count. Expected: %s Actual %s", uploadedFiles.size() < nameToFile.size() ? "lower" : "higher", nameToFile.size(), uploadedFiles.size()), HttpResponseStatus.BAD_REQUEST ); } final JobSubmitRequestBody requestBody = request.getRequestBody(); if (requestBody.jobGraphFileName == null) { throw new RestHandlerException( String.format("The %s field must not be omitted or be null.", JobSubmitRequestBody.FIELD_NAME_JOB_GRAPH), HttpResponseStatus.BAD_REQUEST); } CompletableFuture<JobGraph> jobGraphFuture = loadJobGraph(requestBody, nameToFile); Collection<Path> jarFiles = getJarFilesToUpload(requestBody.jarFileNames, nameToFile); Collection<Tuple2<String, Path>> artifacts = getArtifactFilesToUpload(requestBody.artifactFileNames, nameToFile); CompletableFuture<JobGraph> finalizedJobGraphFuture = uploadJobGraphFiles(gateway, jobGraphFuture, jarFiles, artifacts, configuration); CompletableFuture<Acknowledge> jobSubmissionFuture = finalizedJobGraphFuture.thenCompose(jobGraph -> gateway.submitJob(jobGraph, timeout)); return jobSubmissionFuture.thenCombine(jobGraphFuture, (ack, jobGraph) -> new JobSubmitResponseBody("/jobs/" + jobGraph.getJobID())); }
Example #22
Source File: JobSubmitRequestBodyTest.java From flink with Apache License 2.0 | 4 votes |
@Override protected Class<JobSubmitRequestBody> getTestRequestClass() { return JobSubmitRequestBody.class; }
Example #23
Source File: RestClusterClientTest.java From flink with Apache License 2.0 | 4 votes |
@Override protected CompletableFuture<JobSubmitResponseBody> handleRequest(@Nonnull HandlerRequest<JobSubmitRequestBody, EmptyMessageParameters> request, @Nonnull DispatcherGateway gateway) throws RestHandlerException { jobSubmitted = true; return CompletableFuture.completedFuture(new JobSubmitResponseBody("/url")); }
Example #24
Source File: RestClusterClientTest.java From flink with Apache License 2.0 | 4 votes |
@Override protected CompletableFuture<JobSubmitResponseBody> handleRequest( @Nonnull HandlerRequest<JobSubmitRequestBody, EmptyMessageParameters> request, @Nonnull DispatcherGateway gateway) throws RestHandlerException { throw new RestHandlerException("expected", HttpResponseStatus.INTERNAL_SERVER_ERROR); }
Example #25
Source File: RestClusterClientTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override protected CompletableFuture<JobSubmitResponseBody> handleRequest( @Nonnull HandlerRequest<JobSubmitRequestBody, EmptyMessageParameters> request, @Nonnull DispatcherGateway gateway) throws RestHandlerException { throw new RestHandlerException("expected", HttpResponseStatus.INTERNAL_SERVER_ERROR); }
Example #26
Source File: RestClusterClientTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override protected CompletableFuture<JobSubmitResponseBody> handleRequest(@Nonnull HandlerRequest<JobSubmitRequestBody, EmptyMessageParameters> request, @Nonnull DispatcherGateway gateway) throws RestHandlerException { jobSubmitted = true; return CompletableFuture.completedFuture(new JobSubmitResponseBody("/url")); }
Example #27
Source File: JobSubmitRequestBodyTest.java From flink with Apache License 2.0 | 4 votes |
@Override protected Class<JobSubmitRequestBody> getTestRequestClass() { return JobSubmitRequestBody.class; }
Example #28
Source File: JobSubmitRequestBodyTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override protected Class<JobSubmitRequestBody> getTestRequestClass() { return JobSubmitRequestBody.class; }
Example #29
Source File: RestClusterClientTest.java From flink with Apache License 2.0 | 4 votes |
@Override protected CompletableFuture<JobSubmitResponseBody> handleRequest(@Nonnull HandlerRequest<JobSubmitRequestBody, EmptyMessageParameters> request, @Nonnull DispatcherGateway gateway) throws RestHandlerException { jobSubmitted = true; return CompletableFuture.completedFuture(new JobSubmitResponseBody("/url")); }
Example #30
Source File: RestClusterClientTest.java From flink with Apache License 2.0 | 4 votes |
@Override protected CompletableFuture<JobSubmitResponseBody> handleRequest( @Nonnull HandlerRequest<JobSubmitRequestBody, EmptyMessageParameters> request, @Nonnull DispatcherGateway gateway) throws RestHandlerException { throw new RestHandlerException("expected", HttpResponseStatus.INTERNAL_SERVER_ERROR); }