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());
}
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);
}
Aggregations