Java Code Examples for org.apache.flink.runtime.jobgraph.JobVertex#setResources()
The following examples show how to use
org.apache.flink.runtime.jobgraph.JobVertex#setResources() .
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: VertexSlotSharingTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testSlotSharingGroupWithSpecifiedResources() { final ResourceSpec resource1 = ResourceSpec.newBuilder(0.1, 100).build(); final ResourceSpec resource2 = ResourceSpec.newBuilder(0.2, 200).build(); final JobVertex v1 = new JobVertex("v1"); final JobVertex v2 = new JobVertex("v2"); v1.setResources(resource1, resource1); v2.setResources(resource2, resource2); final SlotSharingGroup group1 = new SlotSharingGroup(); final SlotSharingGroup group2 = new SlotSharingGroup(); v1.setSlotSharingGroup(group1); assertEquals(resource1, group1.getResourceSpec()); v2.setSlotSharingGroup(group1); assertEquals(resource1.merge(resource2), group1.getResourceSpec()); // v1 is moved from group1 to group2 v1.setSlotSharingGroup(group2); assertEquals(resource1, group2.getResourceSpec()); assertEquals(resource2, group1.getResourceSpec()); }
Example 2
Source File: JobGraphGenerator.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private JobVertex createDualInputVertex(DualInputPlanNode node) throws CompilerException { final String taskName = node.getNodeName(); final DriverStrategy ds = node.getDriverStrategy(); final JobVertex vertex = new JobVertex(taskName); final TaskConfig config = new TaskConfig(vertex.getConfiguration()); vertex.setResources(node.getMinResources(), node.getPreferredResources()); vertex.setInvokableClass( (this.currentIteration != null && node.isOnDynamicPath()) ? IterationIntermediateTask.class : BatchTask.class); // set user code config.setStubWrapper(node.getProgramOperator().getUserCodeWrapper()); config.setStubParameters(node.getProgramOperator().getParameters()); // set the driver strategy config.setDriver(ds.getDriverClass()); config.setDriverStrategy(ds); if (node.getComparator1() != null) { config.setDriverComparator(node.getComparator1(), 0); } if (node.getComparator2() != null) { config.setDriverComparator(node.getComparator2(), 1); } if (node.getPairComparator() != null) { config.setDriverPairComparator(node.getPairComparator()); } // assign memory, file-handles, etc. assignDriverResources(node, config); return vertex; }
Example 3
Source File: DispatcherTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that we can submit a job to the Dispatcher which then spawns a * new JobManagerRunner. */ @Test public void testJobSubmissionWithPartialResourceConfigured() throws Exception { dispatcher = createAndStartDispatcher(heartbeatServices, haServices, new ExpectedJobIdJobManagerRunnerFactory(TEST_JOB_ID, createdJobManagerRunnerLatch)); CompletableFuture<UUID> leaderFuture = dispatcherLeaderElectionService.isLeader(UUID.randomUUID()); // wait for the leader to be elected leaderFuture.get(); DispatcherGateway dispatcherGateway = dispatcher.getSelfGateway(DispatcherGateway.class); ResourceSpec resourceSpec = ResourceSpec.newBuilder().setCpuCores(2).build(); final JobVertex firstVertex = new JobVertex("firstVertex"); firstVertex.setInvokableClass(NoOpInvokable.class); firstVertex.setResources(resourceSpec, resourceSpec); final JobVertex secondVertex = new JobVertex("secondVertex"); secondVertex.setInvokableClass(NoOpInvokable.class); JobGraph jobGraphWithTwoVertices = new JobGraph(TEST_JOB_ID, "twoVerticesJob", firstVertex, secondVertex); jobGraphWithTwoVertices.setAllowQueuedScheduling(true); CompletableFuture<Acknowledge> acknowledgeFuture = dispatcherGateway.submitJob(jobGraphWithTwoVertices, TIMEOUT); try { acknowledgeFuture.get(); fail("job submission should have failed"); } catch (ExecutionException e) { assertTrue(ExceptionUtils.findThrowable(e, JobSubmissionException.class).isPresent()); } }
Example 4
Source File: JobGraphGenerator.java From flink with Apache License 2.0 | 5 votes |
private JobVertex createDualInputVertex(DualInputPlanNode node) throws CompilerException { final String taskName = node.getNodeName(); final DriverStrategy ds = node.getDriverStrategy(); final JobVertex vertex = new JobVertex(taskName); final TaskConfig config = new TaskConfig(vertex.getConfiguration()); vertex.setResources(node.getMinResources(), node.getPreferredResources()); vertex.setInvokableClass( (this.currentIteration != null && node.isOnDynamicPath()) ? IterationIntermediateTask.class : BatchTask.class); // set user code config.setStubWrapper(node.getProgramOperator().getUserCodeWrapper()); config.setStubParameters(node.getProgramOperator().getParameters()); // set the driver strategy config.setDriver(ds.getDriverClass()); config.setDriverStrategy(ds); if (node.getComparator1() != null) { config.setDriverComparator(node.getComparator1(), 0); } if (node.getComparator2() != null) { config.setDriverComparator(node.getComparator2(), 1); } if (node.getPairComparator() != null) { config.setDriverPairComparator(node.getPairComparator()); } // assign memory, file-handles, etc. assignDriverResources(node, config); return vertex; }
Example 5
Source File: DispatcherTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that we can submit a job to the Dispatcher which then spawns a * new JobManagerRunner. */ @Test public void testJobSubmissionWithPartialResourceConfigured() throws Exception { dispatcher = createAndStartDispatcher(heartbeatServices, haServices, new ExpectedJobIdJobManagerRunnerFactory(TEST_JOB_ID, createdJobManagerRunnerLatch)); DispatcherGateway dispatcherGateway = dispatcher.getSelfGateway(DispatcherGateway.class); ResourceSpec resourceSpec = ResourceSpec.newBuilder(2.0, 0).build(); final JobVertex firstVertex = new JobVertex("firstVertex"); firstVertex.setInvokableClass(NoOpInvokable.class); firstVertex.setResources(resourceSpec, resourceSpec); final JobVertex secondVertex = new JobVertex("secondVertex"); secondVertex.setInvokableClass(NoOpInvokable.class); JobGraph jobGraphWithTwoVertices = new JobGraph(TEST_JOB_ID, "twoVerticesJob", firstVertex, secondVertex); CompletableFuture<Acknowledge> acknowledgeFuture = dispatcherGateway.submitJob(jobGraphWithTwoVertices, TIMEOUT); try { acknowledgeFuture.get(); fail("job submission should have failed"); } catch (ExecutionException e) { assertTrue(ExceptionUtils.findThrowable(e, JobSubmissionException.class).isPresent()); } }
Example 6
Source File: VertexSlotSharingTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testSlotSharingGroupWithUnknownResources() { final JobVertex v1 = new JobVertex("v1"); v1.setResources(ResourceSpec.UNKNOWN, ResourceSpec.UNKNOWN); final SlotSharingGroup group1 = new SlotSharingGroup(); v1.setSlotSharingGroup(group1); assertEquals(ResourceSpec.UNKNOWN, group1.getResourceSpec()); }
Example 7
Source File: JobGraphGenerator.java From flink with Apache License 2.0 | 5 votes |
private JobVertex createDualInputVertex(DualInputPlanNode node) throws CompilerException { final String taskName = node.getNodeName(); final DriverStrategy ds = node.getDriverStrategy(); final JobVertex vertex = new JobVertex(taskName); final TaskConfig config = new TaskConfig(vertex.getConfiguration()); vertex.setResources(node.getMinResources(), node.getPreferredResources()); vertex.setInvokableClass( (this.currentIteration != null && node.isOnDynamicPath()) ? IterationIntermediateTask.class : BatchTask.class); // set user code config.setStubWrapper(node.getProgramOperator().getUserCodeWrapper()); config.setStubParameters(node.getProgramOperator().getParameters()); // set the driver strategy config.setDriver(ds.getDriverClass()); config.setDriverStrategy(ds); if (node.getComparator1() != null) { config.setDriverComparator(node.getComparator1(), 0); } if (node.getComparator2() != null) { config.setDriverComparator(node.getComparator2(), 1); } if (node.getPairComparator() != null) { config.setDriverPairComparator(node.getPairComparator()); } // assign memory, file-handles, etc. assignDriverResources(node, config); return vertex; }