Search in sources :

Example 26 with ResultPartitionManager

use of org.apache.flink.runtime.io.network.partition.ResultPartitionManager in project flink by apache.

the class PartitionRequestServerHandlerTest method testAcknowledgeAllRecordsProcessed.

@Test
public void testAcknowledgeAllRecordsProcessed() throws IOException {
    InputChannelID inputChannelID = new InputChannelID();
    ResultPartition resultPartition = PartitionTestUtils.createPartition(ResultPartitionType.PIPELINED_BOUNDED);
    ResultPartitionProvider partitionProvider = (partitionId, index, availabilityListener) -> resultPartition.createSubpartitionView(index, availabilityListener);
    // Creates the netty network handler stack.
    PartitionRequestQueue partitionRequestQueue = new PartitionRequestQueue();
    final PartitionRequestServerHandler serverHandler = new PartitionRequestServerHandler(new ResultPartitionManager(), new TaskEventDispatcher(), partitionRequestQueue);
    final EmbeddedChannel channel = new EmbeddedChannel(serverHandler, partitionRequestQueue);
    // Creates and registers the view to netty.
    NetworkSequenceViewReader viewReader = new CreditBasedSequenceNumberingViewReader(inputChannelID, 2, partitionRequestQueue);
    viewReader.requestSubpartitionView(partitionProvider, resultPartition.getPartitionId(), 0);
    partitionRequestQueue.notifyReaderCreated(viewReader);
    // Write the message to acknowledge all records are processed to server
    resultPartition.notifyEndOfData(StopMode.DRAIN);
    CompletableFuture<Void> allRecordsProcessedFuture = resultPartition.getAllDataProcessedFuture();
    assertFalse(allRecordsProcessedFuture.isDone());
    channel.writeInbound(new NettyMessage.AckAllUserRecordsProcessed(inputChannelID));
    channel.runPendingTasks();
    assertTrue(allRecordsProcessedFuture.isDone());
    assertFalse(allRecordsProcessedFuture.isCompletedExceptionally());
}
Also used : PartitionRequest(org.apache.flink.runtime.io.network.netty.NettyMessage.PartitionRequest) ResultPartitionType(org.apache.flink.runtime.io.network.partition.ResultPartitionType) CompletableFuture(java.util.concurrent.CompletableFuture) NetworkSequenceViewReader(org.apache.flink.runtime.io.network.NetworkSequenceViewReader) ResultPartition(org.apache.flink.runtime.io.network.partition.ResultPartition) Assert.assertThat(org.junit.Assert.assertThat) ResultPartitionID(org.apache.flink.runtime.io.network.partition.ResultPartitionID) ErrorResponse(org.apache.flink.runtime.io.network.netty.NettyMessage.ErrorResponse) TestLogger(org.apache.flink.util.TestLogger) TaskEventDispatcher(org.apache.flink.runtime.io.network.TaskEventDispatcher) Assert.assertTrue(org.junit.Assert.assertTrue) ResumeConsumption(org.apache.flink.runtime.io.network.netty.NettyMessage.ResumeConsumption) Test(org.junit.Test) IOException(java.io.IOException) PartitionNotFoundException(org.apache.flink.runtime.io.network.partition.PartitionNotFoundException) StopMode(org.apache.flink.runtime.io.network.api.StopMode) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) Assert.assertFalse(org.junit.Assert.assertFalse) PartitionTestUtils(org.apache.flink.runtime.io.network.partition.PartitionTestUtils) Matchers.is(org.hamcrest.Matchers.is) ResultPartitionManager(org.apache.flink.runtime.io.network.partition.ResultPartitionManager) EmbeddedChannel(org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel) ResultPartitionProvider(org.apache.flink.runtime.io.network.partition.ResultPartitionProvider) InputChannelID(org.apache.flink.runtime.io.network.partition.consumer.InputChannelID) Assert.assertEquals(org.junit.Assert.assertEquals) EmbeddedChannel(org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel) ResultPartitionManager(org.apache.flink.runtime.io.network.partition.ResultPartitionManager) ResultPartition(org.apache.flink.runtime.io.network.partition.ResultPartition) InputChannelID(org.apache.flink.runtime.io.network.partition.consumer.InputChannelID) NetworkSequenceViewReader(org.apache.flink.runtime.io.network.NetworkSequenceViewReader) ResultPartitionProvider(org.apache.flink.runtime.io.network.partition.ResultPartitionProvider) TaskEventDispatcher(org.apache.flink.runtime.io.network.TaskEventDispatcher) Test(org.junit.Test)

Example 27 with ResultPartitionManager

use of org.apache.flink.runtime.io.network.partition.ResultPartitionManager in project flink by apache.

the class PartitionRequestServerHandlerTest method testResumeConsumption.

@Test
public void testResumeConsumption() {
    final InputChannelID inputChannelID = new InputChannelID();
    final PartitionRequestQueue partitionRequestQueue = new PartitionRequestQueue();
    final TestViewReader testViewReader = new TestViewReader(inputChannelID, 2, partitionRequestQueue);
    final PartitionRequestServerHandler serverHandler = new PartitionRequestServerHandler(new ResultPartitionManager(), new TaskEventDispatcher(), partitionRequestQueue);
    final EmbeddedChannel channel = new EmbeddedChannel(serverHandler);
    partitionRequestQueue.notifyReaderCreated(testViewReader);
    // Write the message of resume consumption to server
    channel.writeInbound(new ResumeConsumption(inputChannelID));
    channel.runPendingTasks();
    assertTrue(testViewReader.consumptionResumed);
}
Also used : ResumeConsumption(org.apache.flink.runtime.io.network.netty.NettyMessage.ResumeConsumption) InputChannelID(org.apache.flink.runtime.io.network.partition.consumer.InputChannelID) EmbeddedChannel(org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel) TaskEventDispatcher(org.apache.flink.runtime.io.network.TaskEventDispatcher) ResultPartitionManager(org.apache.flink.runtime.io.network.partition.ResultPartitionManager) Test(org.junit.Test)

Aggregations

ResultPartitionManager (org.apache.flink.runtime.io.network.partition.ResultPartitionManager)27 Test (org.junit.Test)22 TaskEventDispatcher (org.apache.flink.runtime.io.network.TaskEventDispatcher)13 ResultPartitionID (org.apache.flink.runtime.io.network.partition.ResultPartitionID)12 InputChannelID (org.apache.flink.runtime.io.network.partition.consumer.InputChannelID)9 InputChannelTestUtils.createLocalInputChannel (org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createLocalInputChannel)7 PartitionNotFoundException (org.apache.flink.runtime.io.network.partition.PartitionNotFoundException)7 TestingResultPartitionManager (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateTest.TestingResultPartitionManager)7 IOException (java.io.IOException)6 NetworkEnvironment (org.apache.flink.runtime.io.network.NetworkEnvironment)6 NetworkBufferPool (org.apache.flink.runtime.io.network.buffer.NetworkBufferPool)6 BufferAvailabilityListener (org.apache.flink.runtime.io.network.partition.BufferAvailabilityListener)6 InputChannelTestUtils.createSingleInputGate (org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createSingleInputGate)6 ResultPartition (org.apache.flink.runtime.io.network.partition.ResultPartition)6 ResultSubpartitionView (org.apache.flink.runtime.io.network.partition.ResultSubpartitionView)6 EmbeddedChannel (org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel)6 CompletableFuture (java.util.concurrent.CompletableFuture)5 JobID (org.apache.flink.api.common.JobID)5 IntermediateResultPartitionID (org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID)5 Executor (java.util.concurrent.Executor)4