use of org.apache.flink.runtime.io.network.partition.BufferWritingResultPartition in project flink by apache.
the class ChannelPersistenceITCase method testReadWritten.
@Test
public void testReadWritten() throws Exception {
byte[] inputChannelInfoData = randomBytes(1024);
byte[] resultSubpartitionInfoData = randomBytes(1024);
int partitionIndex = 0;
SequentialChannelStateReader reader = new SequentialChannelStateReaderImpl(toTaskStateSnapshot(write(1L, singletonMap(new InputChannelInfo(0, 0), inputChannelInfoData), singletonMap(new ResultSubpartitionInfo(partitionIndex, 0), resultSubpartitionInfoData))));
NetworkBufferPool networkBufferPool = new NetworkBufferPool(4, 1024);
try {
int numChannels = 1;
InputGate gate = buildGate(networkBufferPool, numChannels);
reader.readInputData(new InputGate[] { gate });
assertArrayEquals(inputChannelInfoData, collectBytes(gate::pollNext, BufferOrEvent::getBuffer));
BufferWritingResultPartition resultPartition = buildResultPartition(networkBufferPool, ResultPartitionType.PIPELINED, partitionIndex, numChannels);
reader.readOutputData(new BufferWritingResultPartition[] { resultPartition }, false);
ResultSubpartitionView view = resultPartition.createSubpartitionView(0, new NoOpBufferAvailablityListener());
assertArrayEquals(resultSubpartitionInfoData, collectBytes(() -> Optional.ofNullable(view.getNextBuffer()), BufferAndBacklog::buffer));
} finally {
networkBufferPool.destroy();
}
}
use of org.apache.flink.runtime.io.network.partition.BufferWritingResultPartition in project flink by apache.
the class ChannelPersistenceITCase method buildResultPartition.
private BufferWritingResultPartition buildResultPartition(NetworkBufferPool networkBufferPool, ResultPartitionType resultPartitionType, int index, int numberOfSubpartitions) throws IOException {
ResultPartition resultPartition = new ResultPartitionBuilder().setResultPartitionIndex(index).setResultPartitionType(resultPartitionType).setNumberOfSubpartitions(numberOfSubpartitions).setBufferPoolFactory(() -> networkBufferPool.createBufferPool(numberOfSubpartitions, Integer.MAX_VALUE, numberOfSubpartitions, Integer.MAX_VALUE)).build();
resultPartition.setup();
return (BufferWritingResultPartition) resultPartition;
}
Aggregations