Search in sources :

Example 1 with JobPlanInfo

use of org.apache.flink.runtime.rest.messages.JobPlanInfo in project flink by apache.

the class JarPlanHandlerParameterTest method setup.

@BeforeClass
public static void setup() throws Exception {
    init();
    handler = new JarPlanHandler(gatewayRetriever, timeout, responseHeaders, JarPlanGetHeaders.getInstance(), jarDir, new Configuration(), executor, jobGraph -> {
        LAST_SUBMITTED_JOB_GRAPH_REFERENCE.set(jobGraph);
        return new JobPlanInfo(JsonPlanGenerator.generatePlan(jobGraph));
    });
}
Also used : JobPlanInfo(org.apache.flink.runtime.rest.messages.JobPlanInfo) Arrays(java.util.Arrays) List(java.util.List) JobID(org.apache.flink.api.common.JobID) BeforeClass(org.junit.BeforeClass) Configuration(org.apache.flink.configuration.Configuration) HandlerRequest(org.apache.flink.runtime.rest.handler.HandlerRequest) JsonPlanGenerator(org.apache.flink.runtime.jobgraph.jsonplan.JsonPlanGenerator) Collections(java.util.Collections) Collectors(java.util.stream.Collectors) ParameterProgram(org.apache.flink.runtime.webmonitor.testutils.ParameterProgram) Configuration(org.apache.flink.configuration.Configuration) JobPlanInfo(org.apache.flink.runtime.rest.messages.JobPlanInfo) BeforeClass(org.junit.BeforeClass)

Example 2 with JobPlanInfo

use of org.apache.flink.runtime.rest.messages.JobPlanInfo in project flink by apache.

the class JarSubmissionITCase method testJarSubmission.

@Test
public void testJarSubmission() throws Exception {
    final TestingDispatcherGateway restfulGateway = TestingDispatcherGateway.newBuilder().setBlobServerPort(blobServerResource.getBlobServerPort()).setSubmitFunction(jobGraph -> CompletableFuture.completedFuture(Acknowledge.get())).build();
    final JarHandlers handlers = new JarHandlers(temporaryFolder.newFolder().toPath(), restfulGateway);
    final JarUploadHandler uploadHandler = handlers.uploadHandler;
    final JarListHandler listHandler = handlers.listHandler;
    final JarPlanHandler planHandler = handlers.planHandler;
    final JarRunHandler runHandler = handlers.runHandler;
    final JarDeleteHandler deleteHandler = handlers.deleteHandler;
    // targetDir property is set via surefire configuration
    final Path originalJar = Paths.get(System.getProperty("targetDir")).resolve("test-program.jar");
    final Path jar = Files.copy(originalJar, temporaryFolder.getRoot().toPath().resolve("test-program.jar"));
    final String storedJarPath = uploadJar(uploadHandler, jar, restfulGateway);
    final String storedJarName = Paths.get(storedJarPath).getFileName().toString();
    final JarListInfo postUploadListResponse = listJars(listHandler, restfulGateway);
    Assert.assertEquals(1, postUploadListResponse.jarFileList.size());
    final JarListInfo.JarFileInfo listEntry = postUploadListResponse.jarFileList.iterator().next();
    Assert.assertEquals(jar.getFileName().toString(), listEntry.name);
    Assert.assertEquals(storedJarName, listEntry.id);
    final JobPlanInfo planResponse = showPlan(planHandler, storedJarName, restfulGateway);
    // we're only interested in the core functionality so checking for a small detail is
    // sufficient
    Assert.assertThat(planResponse.getJsonPlan(), containsString("TestProgram.java:28"));
    runJar(runHandler, storedJarName, restfulGateway);
    deleteJar(deleteHandler, storedJarName, restfulGateway);
    final JarListInfo postDeleteListResponse = listJars(listHandler, restfulGateway);
    Assert.assertEquals(0, postDeleteListResponse.jarFileList.size());
}
Also used : JarHandlers.deleteJar(org.apache.flink.runtime.webmonitor.handlers.JarHandlers.deleteJar) Files(java.nio.file.Files) JarHandlers.showPlan(org.apache.flink.runtime.webmonitor.handlers.JarHandlers.showPlan) Test(org.junit.Test) CompletableFuture(java.util.concurrent.CompletableFuture) BlobServerResource(org.apache.flink.runtime.util.BlobServerResource) Acknowledge(org.apache.flink.runtime.messages.Acknowledge) JobPlanInfo(org.apache.flink.runtime.rest.messages.JobPlanInfo) JarHandlers.listJars(org.apache.flink.runtime.webmonitor.handlers.JarHandlers.listJars) Rule(org.junit.Rule) JarHandlers.uploadJar(org.apache.flink.runtime.webmonitor.handlers.JarHandlers.uploadJar) Paths(java.nio.file.Paths) TestLogger(org.apache.flink.util.TestLogger) TestingDispatcherGateway(org.apache.flink.runtime.webmonitor.TestingDispatcherGateway) Assert(org.junit.Assert) Path(java.nio.file.Path) JarHandlers.runJar(org.apache.flink.runtime.webmonitor.handlers.JarHandlers.runJar) Matchers.containsString(org.hamcrest.Matchers.containsString) TemporaryFolder(org.junit.rules.TemporaryFolder) Path(java.nio.file.Path) TestingDispatcherGateway(org.apache.flink.runtime.webmonitor.TestingDispatcherGateway) JobPlanInfo(org.apache.flink.runtime.rest.messages.JobPlanInfo) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Aggregations

JobPlanInfo (org.apache.flink.runtime.rest.messages.JobPlanInfo)2 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Collectors (java.util.stream.Collectors)1 JobID (org.apache.flink.api.common.JobID)1 Configuration (org.apache.flink.configuration.Configuration)1 JsonPlanGenerator (org.apache.flink.runtime.jobgraph.jsonplan.JsonPlanGenerator)1 Acknowledge (org.apache.flink.runtime.messages.Acknowledge)1 HandlerRequest (org.apache.flink.runtime.rest.handler.HandlerRequest)1 BlobServerResource (org.apache.flink.runtime.util.BlobServerResource)1 TestingDispatcherGateway (org.apache.flink.runtime.webmonitor.TestingDispatcherGateway)1 JarHandlers.deleteJar (org.apache.flink.runtime.webmonitor.handlers.JarHandlers.deleteJar)1 JarHandlers.listJars (org.apache.flink.runtime.webmonitor.handlers.JarHandlers.listJars)1 JarHandlers.runJar (org.apache.flink.runtime.webmonitor.handlers.JarHandlers.runJar)1 JarHandlers.showPlan (org.apache.flink.runtime.webmonitor.handlers.JarHandlers.showPlan)1