use of org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder in project flink by apache.
the class TestCheckpointedInputGateBuilder method buildRemoteGate.
private SingleInputGate buildRemoteGate() throws IOException {
int maxUsedBuffers = 10;
NetworkBufferPool networkBufferPool = new NetworkBufferPool(numChannels * maxUsedBuffers, 4096);
SingleInputGate gate = new SingleInputGateBuilder().setChannelFactory(InputChannelBuilder::buildRemoteChannel).setNumberOfChannels(numChannels).setSegmentProvider(networkBufferPool).setBufferPoolFactory(networkBufferPool.createBufferPool(numChannels, maxUsedBuffers)).setChannelStateWriter(channelStateWriter).build();
gate.setup();
gate.requestPartitions();
return gate;
}
use of org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder in project flink by apache.
the class CreditBasedPartitionRequestClientHandlerTest method testReceiveCompressedBuffer.
/**
* Verifies that {@link BufferResponse} of compressed {@link Buffer} can be handled correctly.
*/
@Test
public void testReceiveCompressedBuffer() throws Exception {
int bufferSize = 1024;
String compressionCodec = "LZ4";
BufferCompressor compressor = new BufferCompressor(bufferSize, compressionCodec);
BufferDecompressor decompressor = new BufferDecompressor(bufferSize, compressionCodec);
NetworkBufferPool networkBufferPool = new NetworkBufferPool(10, bufferSize);
SingleInputGate inputGate = new SingleInputGateBuilder().setBufferDecompressor(decompressor).setSegmentProvider(networkBufferPool).build();
RemoteInputChannel inputChannel = createRemoteInputChannel(inputGate, null);
inputGate.setInputChannels(inputChannel);
try {
BufferPool bufferPool = networkBufferPool.createBufferPool(8, 8);
inputGate.setBufferPool(bufferPool);
inputGate.setupChannels();
CreditBasedPartitionRequestClientHandler handler = new CreditBasedPartitionRequestClientHandler();
handler.addInputChannel(inputChannel);
Buffer buffer = compressor.compressToOriginalBuffer(TestBufferFactory.createBuffer(bufferSize));
BufferResponse bufferResponse = createBufferResponse(buffer, 0, inputChannel.getInputChannelId(), 2, new NetworkBufferAllocator(handler));
assertTrue(bufferResponse.isCompressed);
handler.channelRead(null, bufferResponse);
Buffer receivedBuffer = inputChannel.getNextReceivedBuffer();
assertNotNull(receivedBuffer);
assertTrue(receivedBuffer.isCompressed());
receivedBuffer.recycleBuffer();
} finally {
releaseResource(inputGate, networkBufferPool);
}
}
Aggregations