Search in sources :

Example 46 with SingleInputGate

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

the class TestCheckpointedInputGateBuilder method buildTestGate.

private SingleInputGate buildTestGate() {
    SingleInputGate gate = new SingleInputGateBuilder().setNumberOfChannels(numChannels).build();
    TestInputChannel[] channels = new TestInputChannel[numChannels];
    for (int i = 0; i < numChannels; i++) {
        channels[i] = new TestInputChannel(gate, i, false, true);
    }
    gate.setInputChannels(channels);
    return gate;
}
Also used : SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) TestInputChannel(org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate)

Example 47 with SingleInputGate

use of org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate 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;
}
Also used : SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate) NetworkBufferPool(org.apache.flink.runtime.io.network.buffer.NetworkBufferPool)

Example 48 with SingleInputGate

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

the class NettyShuffleMetricFactory method registerLegacyNetworkMetrics.

/**
 * Registers legacy network metric groups before shuffle service refactoring.
 *
 * <p>Registers legacy metric groups if shuffle service implementation is original default one.
 *
 * @deprecated should be removed in future
 */
@SuppressWarnings("DeprecatedIsStillUsed")
@Deprecated
public static void registerLegacyNetworkMetrics(boolean isDetailedMetrics, MetricGroup metricGroup, ResultPartitionWriter[] producedPartitions, InputGate[] inputGates) {
    checkNotNull(metricGroup);
    checkNotNull(producedPartitions);
    checkNotNull(inputGates);
    // add metrics for buffers
    final MetricGroup buffersGroup = metricGroup.addGroup(METRIC_GROUP_BUFFERS_DEPRECATED);
    // similar to MetricUtils.instantiateNetworkMetrics() but inside this IOMetricGroup
    // (metricGroup)
    final MetricGroup networkGroup = metricGroup.addGroup(METRIC_GROUP_NETWORK_DEPRECATED);
    final MetricGroup outputGroup = networkGroup.addGroup(METRIC_GROUP_OUTPUT);
    final MetricGroup inputGroup = networkGroup.addGroup(METRIC_GROUP_INPUT);
    ResultPartition[] resultPartitions = Arrays.copyOf(producedPartitions, producedPartitions.length, ResultPartition[].class);
    registerOutputMetrics(isDetailedMetrics, outputGroup, buffersGroup, resultPartitions);
    SingleInputGate[] singleInputGates = Arrays.copyOf(inputGates, inputGates.length, SingleInputGate[].class);
    registerInputMetrics(isDetailedMetrics, inputGroup, buffersGroup, singleInputGates);
}
Also used : MetricGroup(org.apache.flink.metrics.MetricGroup) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate) ResultPartition(org.apache.flink.runtime.io.network.partition.ResultPartition)

Example 49 with SingleInputGate

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

the class AbstractBuffersUsageGauge method getValue.

@Override
public Float getValue() {
    int usedBuffers = 0;
    int totalBuffers = 0;
    for (SingleInputGate inputGate : inputGates) {
        usedBuffers += calculateUsedBuffers(inputGate);
        totalBuffers += calculateTotalBuffers(inputGate);
    }
    if (totalBuffers != 0) {
        return ((float) usedBuffers) / totalBuffers;
    } else {
        return 0.0f;
    }
}
Also used : SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate)

Example 50 with SingleInputGate

use of org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate 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);
    }
}
Also used : Buffer(org.apache.flink.runtime.io.network.buffer.Buffer) InputChannelTestUtils.createSingleInputGate(org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createSingleInputGate) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate) BufferDecompressor(org.apache.flink.runtime.io.network.buffer.BufferDecompressor) NetworkBufferPool(org.apache.flink.runtime.io.network.buffer.NetworkBufferPool) RemoteInputChannel(org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel) InputChannelTestUtils.createRemoteInputChannel(org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createRemoteInputChannel) SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) NetworkBufferPool(org.apache.flink.runtime.io.network.buffer.NetworkBufferPool) BufferPool(org.apache.flink.runtime.io.network.buffer.BufferPool) BufferCompressor(org.apache.flink.runtime.io.network.buffer.BufferCompressor) BufferResponse(org.apache.flink.runtime.io.network.netty.NettyMessage.BufferResponse) Test(org.junit.Test)

Aggregations

SingleInputGate (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate)56 Test (org.junit.Test)32 RemoteInputChannel (org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel)30 SingleInputGateBuilder (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder)22 NetworkBufferPool (org.apache.flink.runtime.io.network.buffer.NetworkBufferPool)21 InputChannelTestUtils.createRemoteInputChannel (org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createRemoteInputChannel)15 InputChannelTestUtils.createSingleInputGate (org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createSingleInputGate)15 BufferPool (org.apache.flink.runtime.io.network.buffer.BufferPool)14 IntermediateDataSetID (org.apache.flink.runtime.jobgraph.IntermediateDataSetID)11 EmbeddedChannel (org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel)10 InputChannelInfo (org.apache.flink.runtime.checkpoint.channel.InputChannelInfo)8 IOException (java.io.IOException)7 ConnectionManager (org.apache.flink.runtime.io.network.ConnectionManager)7 PartitionRequestClient (org.apache.flink.runtime.io.network.PartitionRequestClient)7 Buffer (org.apache.flink.runtime.io.network.buffer.Buffer)7 BufferResponse (org.apache.flink.runtime.io.network.netty.NettyMessage.BufferResponse)7 InputChannelTestUtils.createDummyConnectionManager (org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createDummyConnectionManager)7 InputChannelBuilder (org.apache.flink.runtime.io.network.partition.consumer.InputChannelBuilder)7 TestInputChannel (org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel)6 CheckpointOptions (org.apache.flink.runtime.checkpoint.CheckpointOptions)5