org.apache.flink.runtime.jobgraph.DistributionPattern Java Examples
The following examples show how to use
org.apache.flink.runtime.jobgraph.DistributionPattern.
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: DefaultSchedulerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testInputConstraintALLPerf() throws Exception { final int parallelism = 1000; final JobVertex v1 = createVertexWithAllInputConstraints("vertex1", parallelism); final JobVertex v2 = createVertexWithAllInputConstraints("vertex2", parallelism); final JobVertex v3 = createVertexWithAllInputConstraints("vertex3", parallelism); v2.connectNewDataSetAsInput(v1, DistributionPattern.ALL_TO_ALL, ResultPartitionType.BLOCKING); v2.connectNewDataSetAsInput(v3, DistributionPattern.ALL_TO_ALL, ResultPartitionType.BLOCKING); final JobGraph jobGraph = new JobGraph(v1, v2, v3); final DefaultScheduler scheduler = createSchedulerAndStartScheduling(jobGraph); final AccessExecutionJobVertex ejv1 = scheduler.requestJob().getAllVertices().get(v1.getID()); for (int i = 0; i < parallelism - 1; i++) { finishSubtask(scheduler, ejv1, i); } final long startTime = System.nanoTime(); finishSubtask(scheduler, ejv1, parallelism - 1); final Duration duration = Duration.ofNanos(System.nanoTime() - startTime); final Duration timeout = Duration.ofSeconds(5); assertThat(duration, lessThan(timeout)); }
Example #2
Source File: JobExecutionITCase.java From flink with Apache License 2.0 | 6 votes |
private JobGraph createJobGraph(int parallelism) { final JobVertex sender = new JobVertex("Sender"); sender.setParallelism(parallelism); sender.setInvokableClass(TestingAbstractInvokables.Sender.class); final JobVertex receiver = new JobVertex("Receiver"); receiver.setParallelism(parallelism); receiver.setInvokableClass(TestingAbstractInvokables.Receiver.class); // In order to make testCoLocationConstraintJobExecution fail, one needs to // remove the co-location constraint and the slot sharing groups, because then // the receivers will have to wait for the senders to finish and the slot // assignment order to the receivers is non-deterministic (depending on the // order in which the senders finish). final SlotSharingGroup slotSharingGroup = new SlotSharingGroup(); receiver.setSlotSharingGroup(slotSharingGroup); sender.setSlotSharingGroup(slotSharingGroup); receiver.setStrictlyCoLocatedWith(sender); receiver.connectNewDataSetAsInput(sender, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED); final JobGraph jobGraph = new JobGraph(getClass().getSimpleName(), sender, receiver); return jobGraph; }
Example #3
Source File: AdaptedRestartPipelinedRegionStrategyNGFailoverTest.java From flink with Apache License 2.0 | 6 votes |
/** * Creating job graph as below (execution view). * It's a representative of streaming job. * <pre> * (v11) -+-> (v21) * * (v12) -+-> (v22) * * ^ * | * (pipelined) * </pre> * 2 regions. Each has 2 pipelined connected vertices. */ private JobGraph createStreamingJobGraph() { final JobVertex v1 = new JobVertex("vertex1"); final JobVertex v2 = new JobVertex("vertex2"); v1.setParallelism(2); v2.setParallelism(2); v1.setInvokableClass(AbstractInvokable.class); v2.setInvokableClass(AbstractInvokable.class); v2.connectNewDataSetAsInput(v1, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED); final JobGraph jobGraph = new JobGraph(TEST_JOB_ID, "Testjob", v1, v2); jobGraph.setScheduleMode(ScheduleMode.EAGER); return jobGraph; }
Example #4
Source File: JobRecoveryITCase.java From flink with Apache License 2.0 | 6 votes |
private JobGraph createjobGraph(boolean slotSharingEnabled) throws IOException { final JobVertex sender = new JobVertex("Sender"); sender.setParallelism(PARALLELISM); sender.setInvokableClass(TestingAbstractInvokables.Sender.class); final JobVertex receiver = new JobVertex("Receiver"); receiver.setParallelism(PARALLELISM); receiver.setInvokableClass(FailingOnceReceiver.class); FailingOnceReceiver.reset(); if (slotSharingEnabled) { final SlotSharingGroup slotSharingGroup = new SlotSharingGroup(); receiver.setSlotSharingGroup(slotSharingGroup); sender.setSlotSharingGroup(slotSharingGroup); } receiver.connectNewDataSetAsInput(sender, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED); final ExecutionConfig executionConfig = new ExecutionConfig(); executionConfig.setRestartStrategy(RestartStrategies.fixedDelayRestart(1, 0L)); final JobGraph jobGraph = new JobGraph(getClass().getSimpleName(), sender, receiver); jobGraph.setExecutionConfig(executionConfig); return jobGraph; }
Example #5
Source File: ShuffleCompressionITCase.java From flink with Apache License 2.0 | 6 votes |
private static JobGraph createJobGraph( ScheduleMode scheduleMode, ResultPartitionType resultPartitionType, ExecutionMode executionMode) throws IOException { SlotSharingGroup slotSharingGroup = new SlotSharingGroup(); JobVertex source = new JobVertex("source"); source.setInvokableClass(LongValueSource.class); source.setParallelism(PARALLELISM); source.setSlotSharingGroup(slotSharingGroup); JobVertex sink = new JobVertex("sink"); sink.setInvokableClass(ResultVerifyingSink.class); sink.setParallelism(PARALLELISM); sink.setSlotSharingGroup(slotSharingGroup); sink.connectNewDataSetAsInput(source, DistributionPattern.ALL_TO_ALL, resultPartitionType); JobGraph jobGraph = new JobGraph(source, sink); jobGraph.setScheduleMode(scheduleMode); ExecutionConfig executionConfig = new ExecutionConfig(); executionConfig.setExecutionMode(executionMode); jobGraph.setExecutionConfig(executionConfig); return jobGraph; }
Example #6
Source File: TaskExecutorITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private JobGraph createJobGraph(int parallelism) { final JobVertex sender = new JobVertex("Sender"); sender.setParallelism(parallelism); sender.setInvokableClass(TestingAbstractInvokables.Sender.class); final JobVertex receiver = new JobVertex("Blocking receiver"); receiver.setParallelism(parallelism); receiver.setInvokableClass(BlockingOperator.class); BlockingOperator.reset(); receiver.connectNewDataSetAsInput(sender, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED); final SlotSharingGroup slotSharingGroup = new SlotSharingGroup(); sender.setSlotSharingGroup(slotSharingGroup); receiver.setSlotSharingGroup(slotSharingGroup); return new JobGraph("Blocking test job with slot sharing", sender, receiver); }
Example #7
Source File: FileBufferReaderITCase.java From flink with Apache License 2.0 | 6 votes |
private static JobGraph createJobGraph() { final SlotSharingGroup group1 = new SlotSharingGroup(); final SlotSharingGroup group2 = new SlotSharingGroup(); final JobVertex source = new JobVertex("source"); source.setInvokableClass(TestSourceInvokable.class); source.setParallelism(parallelism); source.setSlotSharingGroup(group1); final JobVertex sink = new JobVertex("sink"); sink.setInvokableClass(TestSinkInvokable.class); sink.setParallelism(parallelism); sink.setSlotSharingGroup(group2); sink.connectNewDataSetAsInput(source, DistributionPattern.ALL_TO_ALL, ResultPartitionType.BLOCKING); final JobGraph jobGraph = new JobGraph(source, sink); jobGraph.setScheduleMode(ScheduleMode.LAZY_FROM_SOURCES); return jobGraph; }
Example #8
Source File: ExecutionGraphRescalingTest.java From flink with Apache License 2.0 | 6 votes |
private static JobVertex[] createVerticesForSimpleBipartiteJobGraph(int parallelism, int maxParallelism) { JobVertex v1 = new JobVertex("vertex1"); JobVertex v2 = new JobVertex("vertex2"); JobVertex v3 = new JobVertex("vertex3"); JobVertex v4 = new JobVertex("vertex4"); JobVertex v5 = new JobVertex("vertex5"); JobVertex[] jobVertices = new JobVertex[]{v1, v2, v3, v4, v5}; for (JobVertex jobVertex : jobVertices) { jobVertex.setInvokableClass(AbstractInvokable.class); jobVertex.setParallelism(parallelism); jobVertex.setMaxParallelism(maxParallelism); } v2.connectNewDataSetAsInput(v1, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED); v4.connectNewDataSetAsInput(v2, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED); v4.connectNewDataSetAsInput(v3, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED); v5.connectNewDataSetAsInput(v4, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED); v5.connectNewDataSetAsInput(v3, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED); return jobVertices; }
Example #9
Source File: PartialConsumePipelinedResultTest.java From flink with Apache License 2.0 | 6 votes |
/** * Tests a fix for FLINK-1930. * * <p>When consuming a pipelined result only partially, is is possible that local channels * release the buffer pool, which is associated with the result partition, too early. If the * producer is still producing data when this happens, it runs into an IllegalStateException, * because of the destroyed buffer pool. * * @see <a href="https://issues.apache.org/jira/browse/FLINK-1930">FLINK-1930</a> */ @Test public void testPartialConsumePipelinedResultReceiver() throws Exception { final JobVertex sender = new JobVertex("Sender"); sender.setInvokableClass(SlowBufferSender.class); sender.setParallelism(PARALLELISM); final JobVertex receiver = new JobVertex("Receiver"); receiver.setInvokableClass(SingleBufferReceiver.class); receiver.setParallelism(PARALLELISM); // The partition needs to be pipelined, otherwise the original issue does not occur, because // the sender and receiver are not online at the same time. receiver.connectNewDataSetAsInput( sender, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED); final JobGraph jobGraph = new JobGraph("Partial Consume of Pipelined Result", sender, receiver); final SlotSharingGroup slotSharingGroup = new SlotSharingGroup(); sender.setSlotSharingGroup(slotSharingGroup); receiver.setSlotSharingGroup(slotSharingGroup); MINI_CLUSTER_RESOURCE.getMiniCluster().executeJobBlocking(jobGraph); }
Example #10
Source File: ExecutionGraphRescalingTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private static JobVertex[] createVerticesForSimpleBipartiteJobGraph(int parallelism, int maxParallelism) { JobVertex v1 = new JobVertex("vertex1"); JobVertex v2 = new JobVertex("vertex2"); JobVertex v3 = new JobVertex("vertex3"); JobVertex v4 = new JobVertex("vertex4"); JobVertex v5 = new JobVertex("vertex5"); JobVertex[] jobVertices = new JobVertex[]{v1, v2, v3, v4, v5}; for (JobVertex jobVertex : jobVertices) { jobVertex.setInvokableClass(AbstractInvokable.class); jobVertex.setParallelism(parallelism); jobVertex.setMaxParallelism(maxParallelism); } v2.connectNewDataSetAsInput(v1, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED); v4.connectNewDataSetAsInput(v2, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED); v4.connectNewDataSetAsInput(v3, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED); v5.connectNewDataSetAsInput(v4, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED); v5.connectNewDataSetAsInput(v3, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED); return jobVertices; }
Example #11
Source File: PartialConsumePipelinedResultTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Tests a fix for FLINK-1930. * * <p>When consuming a pipelined result only partially, is is possible that local channels * release the buffer pool, which is associated with the result partition, too early. If the * producer is still producing data when this happens, it runs into an IllegalStateException, * because of the destroyed buffer pool. * * @see <a href="https://issues.apache.org/jira/browse/FLINK-1930">FLINK-1930</a> */ @Test public void testPartialConsumePipelinedResultReceiver() throws Exception { final JobVertex sender = new JobVertex("Sender"); sender.setInvokableClass(SlowBufferSender.class); sender.setParallelism(PARALLELISM); final JobVertex receiver = new JobVertex("Receiver"); receiver.setInvokableClass(SingleBufferReceiver.class); receiver.setParallelism(PARALLELISM); // The partition needs to be pipelined, otherwise the original issue does not occur, because // the sender and receiver are not online at the same time. receiver.connectNewDataSetAsInput( sender, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED); final JobGraph jobGraph = new JobGraph("Partial Consume of Pipelined Result", sender, receiver); final SlotSharingGroup slotSharingGroup = new SlotSharingGroup( sender.getID(), receiver.getID()); sender.setSlotSharingGroup(slotSharingGroup); receiver.setSlotSharingGroup(slotSharingGroup); MINI_CLUSTER_RESOURCE.getMiniCluster().executeJobBlocking(jobGraph); }
Example #12
Source File: ExecutionVertexInputConstraintTest.java From flink with Apache License 2.0 | 5 votes |
private static List<JobVertex> createOrderedVertices() { JobVertex v1 = new JobVertex("vertex1"); JobVertex v2 = new JobVertex("vertex2"); JobVertex v3 = new JobVertex("vertex3"); v1.setParallelism(2); v2.setParallelism(2); v3.setParallelism(2); v1.setInvokableClass(AbstractInvokable.class); v2.setInvokableClass(AbstractInvokable.class); v3.setInvokableClass(AbstractInvokable.class); v3.connectNewDataSetAsInput(v1, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED); v3.connectNewDataSetAsInput(v2, DistributionPattern.ALL_TO_ALL, ResultPartitionType.BLOCKING); return Arrays.asList(v1, v2, v3); }
Example #13
Source File: PipelinedFailoverRegionBuildingTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that validates that a single pipelined component via a sequence of all-to-all * connections works correctly. * * <pre> * (a1) -+-> (b1) -+-> (c1) * X X * (a2) -+-> (b2) -+-> (c2) * X X * (a3) -+-> (b3) -+-> (c3) * * ... * </pre> */ @Test public void testOneComponentViaTwoExchanges() throws Exception { final JobVertex vertex1 = new JobVertex("vertex1"); vertex1.setInvokableClass(NoOpInvokable.class); vertex1.setParallelism(3); final JobVertex vertex2 = new JobVertex("vertex2"); vertex2.setInvokableClass(NoOpInvokable.class); vertex2.setParallelism(5); final JobVertex vertex3 = new JobVertex("vertex3"); vertex3.setInvokableClass(NoOpInvokable.class); vertex3.setParallelism(2); vertex2.connectNewDataSetAsInput(vertex1, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED); vertex3.connectNewDataSetAsInput(vertex2, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED); final JobGraph jobGraph = new JobGraph("test job", vertex1, vertex2, vertex3); final ExecutionGraph eg = createExecutionGraph(jobGraph); RestartPipelinedRegionStrategy failoverStrategy = (RestartPipelinedRegionStrategy) eg.getFailoverStrategy(); FailoverRegion region1 = failoverStrategy.getFailoverRegion(eg.getJobVertex(vertex1.getID()).getTaskVertices()[1]); FailoverRegion region2 = failoverStrategy.getFailoverRegion(eg.getJobVertex(vertex2.getID()).getTaskVertices()[4]); FailoverRegion region3 = failoverStrategy.getFailoverRegion(eg.getJobVertex(vertex3.getID()).getTaskVertices()[0]); assertTrue(region1 == region2); assertTrue(region2 == region3); }
Example #14
Source File: PointwisePatternTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void test3NToN() throws Exception { final int N = 17; JobVertex v1 = new JobVertex("vertex1"); JobVertex v2 = new JobVertex("vertex2"); v1.setParallelism(3 * N); v2.setParallelism(N); v1.setInvokableClass(AbstractInvokable.class); v2.setInvokableClass(AbstractInvokable.class); v2.connectNewDataSetAsInput(v1, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED); List<JobVertex> ordered = new ArrayList<JobVertex>(Arrays.asList(v1, v2)); ExecutionGraph eg = getDummyExecutionGraph(); try { eg.attachJobGraph(ordered); } catch (JobException e) { e.printStackTrace(); fail("Job failed with exception: " + e.getMessage()); } ExecutionJobVertex target = eg.getAllVertices().get(v2.getID()); for (ExecutionVertex ev : target.getTaskVertices()) { assertEquals(1, ev.getNumberOfInputs()); ExecutionEdge[] inEdges = ev.getInputEdges(0); assertEquals(3, inEdges.length); assertEquals(ev.getParallelSubtaskIndex() * 3, inEdges[0].getSource().getPartitionNumber()); assertEquals(ev.getParallelSubtaskIndex() * 3 + 1, inEdges[1].getSource().getPartitionNumber()); assertEquals(ev.getParallelSubtaskIndex() * 3 + 2, inEdges[2].getSource().getPartitionNumber()); } }
Example #15
Source File: MiniClusterITCase.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testBipartiteJob() throws Exception { final int parallelism = 31; final MiniClusterConfiguration cfg = new MiniClusterConfiguration.Builder() .setNumTaskManagers(1) .setNumSlotsPerTaskManager(parallelism) .setConfiguration(getDefaultConfiguration()) .build(); try (final MiniCluster miniCluster = new MiniCluster(cfg)) { miniCluster.start(); final JobVertex sender = new JobVertex("Sender"); sender.setInvokableClass(Sender.class); sender.setParallelism(parallelism); final JobVertex receiver = new JobVertex("Receiver"); receiver.setInvokableClass(AgnosticReceiver.class); receiver.setParallelism(parallelism); receiver.connectNewDataSetAsInput(sender, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED); final JobGraph jobGraph = new JobGraph("Bipartite Job", sender, receiver); miniCluster.executeJobBlocking(jobGraph); } }
Example #16
Source File: ExecutionVertexLocalityTest.java From flink with Apache License 2.0 | 5 votes |
/** * Creates a simple 2 vertex graph with a parallel source and a parallel target. */ private ExecutionGraph createTestGraph(int parallelism, boolean allToAll) throws Exception { JobVertex source = new JobVertex("source", sourceVertexId); source.setParallelism(parallelism); source.setInvokableClass(NoOpInvokable.class); JobVertex target = new JobVertex("source", targetVertexId); target.setParallelism(parallelism); target.setInvokableClass(NoOpInvokable.class); DistributionPattern connectionPattern = allToAll ? DistributionPattern.ALL_TO_ALL : DistributionPattern.POINTWISE; target.connectNewDataSetAsInput(source, connectionPattern, ResultPartitionType.PIPELINED); JobGraph testJob = new JobGraph(jobId, "test job", source, target); final Time timeout = Time.seconds(10L); return ExecutionGraphBuilder.buildGraph( null, testJob, new Configuration(), TestingUtils.defaultExecutor(), TestingUtils.defaultExecutor(), mock(SlotProvider.class), getClass().getClassLoader(), new StandaloneCheckpointRecoveryFactory(), timeout, new FixedDelayRestartStrategy(10, 0L), new UnregisteredMetricsGroup(), VoidBlobWriter.getInstance(), timeout, log, NettyShuffleMaster.INSTANCE, NoOpPartitionTracker.INSTANCE); }
Example #17
Source File: PointwisePatternTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void test3NToN() throws Exception { final int N = 17; JobVertex v1 = new JobVertex("vertex1"); JobVertex v2 = new JobVertex("vertex2"); v1.setParallelism(3 * N); v2.setParallelism(N); v1.setInvokableClass(AbstractInvokable.class); v2.setInvokableClass(AbstractInvokable.class); v2.connectNewDataSetAsInput(v1, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED); List<JobVertex> ordered = new ArrayList<JobVertex>(Arrays.asList(v1, v2)); ExecutionGraph eg = getDummyExecutionGraph(); try { eg.attachJobGraph(ordered); } catch (JobException e) { e.printStackTrace(); fail("Job failed with exception: " + e.getMessage()); } ExecutionJobVertex target = eg.getAllVertices().get(v2.getID()); for (ExecutionVertex ev : target.getTaskVertices()) { assertEquals(1, ev.getNumberOfInputs()); ExecutionEdge[] inEdges = ev.getInputEdges(0); assertEquals(3, inEdges.length); assertEquals(ev.getParallelSubtaskIndex() * 3, inEdges[0].getSource().getPartitionNumber()); assertEquals(ev.getParallelSubtaskIndex() * 3 + 1, inEdges[1].getSource().getPartitionNumber()); assertEquals(ev.getParallelSubtaskIndex() * 3 + 2, inEdges[2].getSource().getPartitionNumber()); } }
Example #18
Source File: SlotCountExceedingParallelismTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private JobGraph createTestJobGraph( String jobName, int senderParallelism, int receiverParallelism) { // The sender and receiver invokable logic ensure that each subtask gets the expected data final JobVertex sender = new JobVertex("Sender"); sender.setInvokableClass(RoundRobinSubtaskIndexSender.class); sender.getConfiguration().setInteger(RoundRobinSubtaskIndexSender.CONFIG_KEY, receiverParallelism); sender.setParallelism(senderParallelism); final JobVertex receiver = new JobVertex("Receiver"); receiver.setInvokableClass(SubtaskIndexReceiver.class); receiver.getConfiguration().setInteger(SubtaskIndexReceiver.CONFIG_KEY, senderParallelism); receiver.setParallelism(receiverParallelism); receiver.connectNewDataSetAsInput( sender, DistributionPattern.ALL_TO_ALL, ResultPartitionType.BLOCKING); final JobGraph jobGraph = new JobGraph(jobName, sender, receiver); // We need to allow queued scheduling, because there are not enough slots available // to run all tasks at once. We queue tasks and then let them finish/consume the blocking // result one after the other. jobGraph.setAllowQueuedScheduling(true); return jobGraph; }
Example #19
Source File: PointwisePatternTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testNToN() throws Exception { final int N = 23; JobVertex v1 = new JobVertex("vertex1"); JobVertex v2 = new JobVertex("vertex2"); v1.setParallelism(N); v2.setParallelism(N); v1.setInvokableClass(AbstractInvokable.class); v2.setInvokableClass(AbstractInvokable.class); v2.connectNewDataSetAsInput(v1, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED); List<JobVertex> ordered = new ArrayList<JobVertex>(Arrays.asList(v1, v2)); ExecutionGraph eg = getDummyExecutionGraph(); try { eg.attachJobGraph(ordered); } catch (JobException e) { e.printStackTrace(); fail("Job failed with exception: " + e.getMessage()); } ExecutionJobVertex target = eg.getAllVertices().get(v2.getID()); for (ExecutionVertex ev : target.getTaskVertices()) { assertEquals(1, ev.getNumberOfInputs()); ExecutionEdge[] inEdges = ev.getInputEdges(0); assertEquals(1, inEdges.length); assertEquals(ev.getParallelSubtaskIndex(), inEdges[0].getSource().getPartitionNumber()); } }
Example #20
Source File: PipelinedFailoverRegionBuildingTest.java From flink with Apache License 2.0 | 5 votes |
/** * This test checks that are strictly co-located vertices are in the same failover region, * even through they are connected via a blocking pattern. * This is currently an assumption / limitation of the scheduler. */ @Test public void testBlockingAllToAllTopologyWithCoLocation() throws Exception { final JobVertex source = new JobVertex("source"); source.setInvokableClass(NoOpInvokable.class); source.setParallelism(10); final JobVertex target = new JobVertex("target"); target.setInvokableClass(NoOpInvokable.class); target.setParallelism(13); target.connectNewDataSetAsInput(source, DistributionPattern.ALL_TO_ALL, ResultPartitionType.BLOCKING); final SlotSharingGroup sharingGroup = new SlotSharingGroup(); source.setSlotSharingGroup(sharingGroup); target.setSlotSharingGroup(sharingGroup); source.setStrictlyCoLocatedWith(target); final JobGraph jobGraph = new JobGraph("test job", source, target); final ExecutionGraph eg = createExecutionGraph(jobGraph); RestartPipelinedRegionStrategy failoverStrategy = (RestartPipelinedRegionStrategy) eg.getFailoverStrategy(); FailoverRegion region1 = failoverStrategy.getFailoverRegion(eg.getJobVertex(source.getID()).getTaskVertices()[0]); FailoverRegion region2 = failoverStrategy.getFailoverRegion(eg.getJobVertex(target.getID()).getTaskVertices()[0]); // we use 'assertTrue' here rather than 'assertEquals' because we want to test // for referential equality, to be on the safe side assertTrue(region1 == region2); }
Example #21
Source File: PipelinedFailoverRegionBuildingTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * <pre> * (a1) -+-> (b1) -+-> (c1) * X * (a2) -+-> (b2) -+-> (c2) * X * (a3) -+-> (b3) -+-> (c3) * * ^ ^ * | | * (pipelined) (blocking) * * </pre> */ @Test public void testTwoComponentsViaBlockingExchange() throws Exception { final JobVertex vertex1 = new JobVertex("vertex1"); vertex1.setInvokableClass(NoOpInvokable.class); vertex1.setParallelism(3); final JobVertex vertex2 = new JobVertex("vertex2"); vertex2.setInvokableClass(NoOpInvokable.class); vertex2.setParallelism(2); final JobVertex vertex3 = new JobVertex("vertex3"); vertex3.setInvokableClass(NoOpInvokable.class); vertex3.setParallelism(2); vertex2.connectNewDataSetAsInput(vertex1, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED); vertex3.connectNewDataSetAsInput(vertex2, DistributionPattern.POINTWISE, ResultPartitionType.BLOCKING); final JobGraph jobGraph = new JobGraph("test job", vertex1, vertex2, vertex3); final ExecutionGraph eg = createExecutionGraph(jobGraph); RestartPipelinedRegionStrategy failoverStrategy = (RestartPipelinedRegionStrategy) eg.getFailoverStrategy(); FailoverRegion region1 = failoverStrategy.getFailoverRegion(eg.getJobVertex(vertex1.getID()).getTaskVertices()[1]); FailoverRegion region2 = failoverStrategy.getFailoverRegion(eg.getJobVertex(vertex2.getID()).getTaskVertices()[0]); FailoverRegion region31 = failoverStrategy.getFailoverRegion(eg.getJobVertex(vertex3.getID()).getTaskVertices()[0]); FailoverRegion region32 = failoverStrategy.getFailoverRegion(eg.getJobVertex(vertex3.getID()).getTaskVertices()[1]); assertTrue(region1 == region2); assertTrue(region2 != region31); assertTrue(region32 != region31); }
Example #22
Source File: PointwisePatternTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void test2NToN() throws Exception { final int N = 17; JobVertex v1 = new JobVertex("vertex1"); JobVertex v2 = new JobVertex("vertex2"); v1.setParallelism(2 * N); v2.setParallelism(N); v1.setInvokableClass(AbstractInvokable.class); v2.setInvokableClass(AbstractInvokable.class); v2.connectNewDataSetAsInput(v1, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED); List<JobVertex> ordered = new ArrayList<JobVertex>(Arrays.asList(v1, v2)); ExecutionGraph eg = getDummyExecutionGraph(); try { eg.attachJobGraph(ordered); } catch (JobException e) { e.printStackTrace(); fail("Job failed with exception: " + e.getMessage()); } ExecutionJobVertex target = eg.getAllVertices().get(v2.getID()); for (ExecutionVertex ev : target.getTaskVertices()) { assertEquals(1, ev.getNumberOfInputs()); ExecutionEdge[] inEdges = ev.getInputEdges(0); assertEquals(2, inEdges.length); assertEquals(ev.getParallelSubtaskIndex() * 2, inEdges[0].getSource().getPartitionNumber()); assertEquals(ev.getParallelSubtaskIndex() * 2 + 1, inEdges[1].getSource().getPartitionNumber()); } }
Example #23
Source File: MiniClusterITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testBipartiteJob() throws Exception { final int parallelism = 31; final MiniClusterConfiguration cfg = new MiniClusterConfiguration.Builder() .setNumTaskManagers(1) .setNumSlotsPerTaskManager(parallelism) .setConfiguration(getDefaultConfiguration()) .build(); try (final MiniCluster miniCluster = new MiniCluster(cfg)) { miniCluster.start(); final JobVertex sender = new JobVertex("Sender"); sender.setInvokableClass(Sender.class); sender.setParallelism(parallelism); final JobVertex receiver = new JobVertex("Receiver"); receiver.setInvokableClass(AgnosticReceiver.class); receiver.setParallelism(parallelism); receiver.connectNewDataSetAsInput(sender, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED); final JobGraph jobGraph = new JobGraph("Bipartite Job", sender, receiver); miniCluster.executeJobBlocking(jobGraph); } }
Example #24
Source File: PipelinedFailoverRegionBuildingTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Tests that validates that a single pipelined component via a sequence of all-to-all * connections works correctly. * * <pre> * (a1) -+-> (b1) -+-> (c1) * X X * (a2) -+-> (b2) -+-> (c2) * X X * (a3) -+-> (b3) -+-> (c3) * * ... * </pre> */ @Test public void testOneComponentViaTwoExchanges() throws Exception { final JobVertex vertex1 = new JobVertex("vertex1"); vertex1.setInvokableClass(NoOpInvokable.class); vertex1.setParallelism(3); final JobVertex vertex2 = new JobVertex("vertex2"); vertex2.setInvokableClass(NoOpInvokable.class); vertex2.setParallelism(5); final JobVertex vertex3 = new JobVertex("vertex3"); vertex3.setInvokableClass(NoOpInvokable.class); vertex3.setParallelism(2); vertex2.connectNewDataSetAsInput(vertex1, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED); vertex3.connectNewDataSetAsInput(vertex2, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED); final JobGraph jobGraph = new JobGraph("test job", vertex1, vertex2, vertex3); final ExecutionGraph eg = createExecutionGraph(jobGraph); RestartPipelinedRegionStrategy failoverStrategy = (RestartPipelinedRegionStrategy) eg.getFailoverStrategy(); FailoverRegion region1 = failoverStrategy.getFailoverRegion(eg.getJobVertex(vertex1.getID()).getTaskVertices()[1]); FailoverRegion region2 = failoverStrategy.getFailoverRegion(eg.getJobVertex(vertex2.getID()).getTaskVertices()[4]); FailoverRegion region3 = failoverStrategy.getFailoverRegion(eg.getJobVertex(vertex3.getID()).getTaskVertices()[0]); assertTrue(region1 == region2); assertTrue(region2 == region3); }
Example #25
Source File: SlotCountExceedingParallelismTest.java From flink with Apache License 2.0 | 5 votes |
private JobGraph createTestJobGraph( String jobName, int senderParallelism, int receiverParallelism) { // The sender and receiver invokable logic ensure that each subtask gets the expected data final JobVertex sender = new JobVertex("Sender"); sender.setInvokableClass(RoundRobinSubtaskIndexSender.class); sender.getConfiguration().setInteger(RoundRobinSubtaskIndexSender.CONFIG_KEY, receiverParallelism); sender.setParallelism(senderParallelism); final JobVertex receiver = new JobVertex("Receiver"); receiver.setInvokableClass(SubtaskIndexReceiver.class); receiver.getConfiguration().setInteger(SubtaskIndexReceiver.CONFIG_KEY, senderParallelism); receiver.setParallelism(receiverParallelism); receiver.connectNewDataSetAsInput( sender, DistributionPattern.ALL_TO_ALL, ResultPartitionType.BLOCKING); final JobGraph jobGraph = new JobGraph(jobName, sender, receiver); // We need to allow queued scheduling, because there are not enough slots available // to run all tasks at once. We queue tasks and then let them finish/consume the blocking // result one after the other. jobGraph.setAllowQueuedScheduling(true); return jobGraph; }
Example #26
Source File: JobMasterTest.java From flink with Apache License 2.0 | 5 votes |
private JobGraph producerConsumerJobGraph() { final JobVertex producer = new JobVertex("Producer"); producer.setInvokableClass(NoOpInvokable.class); final JobVertex consumer = new JobVertex("Consumer"); consumer.setInvokableClass(NoOpInvokable.class); consumer.connectNewDataSetAsInput(producer, DistributionPattern.POINTWISE, ResultPartitionType.BLOCKING); return new JobGraph(producer, consumer); }
Example #27
Source File: PointwisePatternTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testNToN() throws Exception { final int N = 23; JobVertex v1 = new JobVertex("vertex1"); JobVertex v2 = new JobVertex("vertex2"); v1.setParallelism(N); v2.setParallelism(N); v1.setInvokableClass(AbstractInvokable.class); v2.setInvokableClass(AbstractInvokable.class); v2.connectNewDataSetAsInput(v1, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED); List<JobVertex> ordered = new ArrayList<JobVertex>(Arrays.asList(v1, v2)); ExecutionGraph eg = getDummyExecutionGraph(); try { eg.attachJobGraph(ordered); } catch (JobException e) { e.printStackTrace(); fail("Job failed with exception: " + e.getMessage()); } ExecutionJobVertex target = eg.getAllVertices().get(v2.getID()); for (ExecutionVertex ev : target.getTaskVertices()) { assertEquals(1, ev.getNumberOfInputs()); ExecutionEdge[] inEdges = ev.getInputEdges(0); assertEquals(1, inEdges.length); assertEquals(ev.getParallelSubtaskIndex(), inEdges[0].getSource().getPartitionNumber()); } }
Example #28
Source File: MiniClusterITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testJobWithSomeVerticesFailingDuringInstantiation() throws Exception { final int parallelism = 11; final MiniClusterConfiguration cfg = new MiniClusterConfiguration.Builder() .setNumTaskManagers(1) .setNumSlotsPerTaskManager(parallelism) .setConfiguration(getDefaultConfiguration()) .build(); try (final MiniCluster miniCluster = new MiniCluster(cfg)) { miniCluster.start(); final JobVertex sender = new JobVertex("Sender"); sender.setInvokableClass(SometimesInstantiationErrorSender.class); sender.setParallelism(parallelism); // set failing senders SometimesInstantiationErrorSender.configFailingSenders(parallelism); final JobVertex receiver = new JobVertex("Receiver"); receiver.setInvokableClass(Receiver.class); receiver.setParallelism(parallelism); receiver.connectNewDataSetAsInput(sender, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED); final JobGraph jobGraph = new JobGraph("Pointwise Job", sender, receiver); try { miniCluster.executeJobBlocking(jobGraph); fail("Job should fail."); } catch (JobExecutionException e) { assertTrue(findThrowable(e, Exception.class).isPresent()); assertTrue(findThrowableWithMessage(e, "Test exception in constructor").isPresent()); } } }
Example #29
Source File: MiniClusterITCase.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testJobWithAllVerticesFailingDuringInstantiation() throws Exception { final int parallelism = 11; final MiniClusterConfiguration cfg = new MiniClusterConfiguration.Builder() .setNumTaskManagers(1) .setNumSlotsPerTaskManager(parallelism) .setConfiguration(getDefaultConfiguration()) .build(); try (final MiniCluster miniCluster = new MiniCluster(cfg)) { miniCluster.start(); final JobVertex sender = new JobVertex("Sender"); sender.setInvokableClass(InstantiationErrorSender.class); sender.setParallelism(parallelism); final JobVertex receiver = new JobVertex("Receiver"); receiver.setInvokableClass(Receiver.class); receiver.setParallelism(parallelism); receiver.connectNewDataSetAsInput(sender, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED); final JobGraph jobGraph = new JobGraph("Pointwise Job", sender, receiver); try { miniCluster.executeJobBlocking(jobGraph); fail("Job should fail."); } catch (JobExecutionException e) { assertTrue(findThrowable(e, Exception.class).isPresent()); assertTrue(findThrowableWithMessage(e, "Test exception in constructor").isPresent()); } } }
Example #30
Source File: PointwisePatternTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void test3NToN() throws Exception { final int N = 17; JobVertex v1 = new JobVertex("vertex1"); JobVertex v2 = new JobVertex("vertex2"); v1.setParallelism(3 * N); v2.setParallelism(N); v1.setInvokableClass(AbstractInvokable.class); v2.setInvokableClass(AbstractInvokable.class); v2.connectNewDataSetAsInput(v1, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED); List<JobVertex> ordered = new ArrayList<JobVertex>(Arrays.asList(v1, v2)); ExecutionGraph eg = getDummyExecutionGraph(); try { eg.attachJobGraph(ordered); } catch (JobException e) { e.printStackTrace(); fail("Job failed with exception: " + e.getMessage()); } ExecutionJobVertex target = eg.getAllVertices().get(v2.getID()); for (ExecutionVertex ev : target.getTaskVertices()) { assertEquals(1, ev.getNumberOfInputs()); ExecutionEdge[] inEdges = ev.getInputEdges(0); assertEquals(3, inEdges.length); assertEquals(ev.getParallelSubtaskIndex() * 3, inEdges[0].getSource().getPartitionNumber()); assertEquals(ev.getParallelSubtaskIndex() * 3 + 1, inEdges[1].getSource().getPartitionNumber()); assertEquals(ev.getParallelSubtaskIndex() * 3 + 2, inEdges[2].getSource().getPartitionNumber()); } }