use of org.apache.flink.runtime.checkpoint.channel.SequentialChannelStateReaderImpl in project flink by apache.
the class ChannelPersistenceITCase method upstreamBlocksAfterRecoveringState.
private void upstreamBlocksAfterRecoveringState(ResultPartitionType type) throws Exception {
NetworkBufferPool networkBufferPool = new NetworkBufferPool(4, 1024);
byte[] dataAfterRecovery = randomBytes(1024);
try {
BufferWritingResultPartition resultPartition = buildResultPartition(networkBufferPool, type, 0, 1);
new SequentialChannelStateReaderImpl(new TaskStateSnapshot()).readOutputData(new BufferWritingResultPartition[] { resultPartition }, true);
resultPartition.emitRecord(ByteBuffer.wrap(dataAfterRecovery), 0);
ResultSubpartitionView view = resultPartition.createSubpartitionView(0, new NoOpBufferAvailablityListener());
if (type != ResultPartitionType.PIPELINED_APPROXIMATE) {
assertEquals(RECOVERY_COMPLETION, view.getNextBuffer().buffer().getDataType());
assertNull(view.getNextBuffer());
view.resumeConsumption();
}
assertArrayEquals(dataAfterRecovery, collectBytes(view.getNextBuffer().buffer()));
} finally {
networkBufferPool.destroy();
}
}
use of org.apache.flink.runtime.checkpoint.channel.SequentialChannelStateReaderImpl 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();
}
}
Aggregations