Search in sources :

Example 26 with InputChannel

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

the class InputGateMetrics method refreshAndGetAvg.

/**
 * Iterates over all input channels and collects the average number of queued buffers in a
 * channel in a best-effort way.
 *
 * @return average number of queued buffers per channel
 */
float refreshAndGetAvg() {
    long total = 0;
    int count = 0;
    for (InputChannel channel : inputGate.getInputChannels().values()) {
        if (channel instanceof RemoteInputChannel) {
            RemoteInputChannel rc = (RemoteInputChannel) channel;
            int size = rc.unsynchronizedGetNumberOfQueuedBuffers();
            total += size;
            ++count;
        }
    }
    return count == 0 ? 0 : total / (float) count;
}
Also used : InputChannel(org.apache.flink.runtime.io.network.partition.consumer.InputChannel) RemoteInputChannel(org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel) RemoteInputChannel(org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel)

Example 27 with InputChannel

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

the class InputGateMetrics method refreshAndGetMin.

/**
 * Iterates over all input channels and collects the minimum number of queued buffers in a
 * channel in a best-effort way.
 *
 * @return minimum number of queued buffers per channel (<tt>0</tt> if no channels exist)
 */
int refreshAndGetMin() {
    int min = Integer.MAX_VALUE;
    Collection<InputChannel> channels = inputGate.getInputChannels().values();
    for (InputChannel channel : channels) {
        if (channel instanceof RemoteInputChannel) {
            RemoteInputChannel rc = (RemoteInputChannel) channel;
            int size = rc.unsynchronizedGetNumberOfQueuedBuffers();
            min = Math.min(min, size);
        }
    }
    if (min == Integer.MAX_VALUE) {
        // was empty
        return 0;
    }
    return min;
}
Also used : InputChannel(org.apache.flink.runtime.io.network.partition.consumer.InputChannel) RemoteInputChannel(org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel) RemoteInputChannel(org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel)

Example 28 with InputChannel

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

the class InputGateMetrics method refreshAndGetMax.

/**
 * Iterates over all input channels and collects the maximum number of queued buffers in a
 * channel in a best-effort way.
 *
 * @return maximum number of queued buffers per channel
 */
int refreshAndGetMax() {
    int max = 0;
    for (InputChannel channel : inputGate.getInputChannels().values()) {
        if (channel instanceof RemoteInputChannel) {
            RemoteInputChannel rc = (RemoteInputChannel) channel;
            int size = rc.unsynchronizedGetNumberOfQueuedBuffers();
            max = Math.max(max, size);
        }
    }
    return max;
}
Also used : InputChannel(org.apache.flink.runtime.io.network.partition.consumer.InputChannel) RemoteInputChannel(org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel) RemoteInputChannel(org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel)

Example 29 with InputChannel

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

the class NettyShuffleUtilsTest method calculateBuffersConsumption.

private int calculateBuffersConsumption(SingleInputGate inputGate) throws Exception {
    inputGate.setChannelStateWriter(ChannelStateWriter.NO_OP);
    inputGate.finishReadRecoveredState();
    while (!inputGate.getStateConsumedFuture().isDone()) {
        inputGate.pollNext();
    }
    inputGate.convertRecoveredInputChannels();
    int ret = 0;
    for (InputChannel ch : inputGate.getInputChannels().values()) {
        RemoteInputChannel rChannel = (RemoteInputChannel) ch;
        ret += rChannel.getNumberOfAvailableBuffers();
    }
    ret += inputGate.getBufferPool().getMaxNumberOfMemorySegments();
    return ret;
}
Also used : InputChannel(org.apache.flink.runtime.io.network.partition.consumer.InputChannel) RemoteInputChannel(org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel) RemoteInputChannel(org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel)

Example 30 with InputChannel

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

the class AlternatingCheckpointsTest method testBarrierHandling.

private void testBarrierHandling(SnapshotType checkpointType) throws Exception {
    final long barrierId = 123L;
    ValidatingCheckpointHandler target = new ValidatingCheckpointHandler();
    SingleInputGate gate = new SingleInputGateBuilder().setNumberOfChannels(2).build();
    TestInputChannel fast = new TestInputChannel(gate, 0, false, true);
    TestInputChannel slow = new TestInputChannel(gate, 1, false, true);
    gate.setInputChannels(fast, slow);
    SingleCheckpointBarrierHandler barrierHandler = getTestBarrierHandlerFactory(target).create(gate);
    CheckpointedInputGate checkpointedGate = new CheckpointedInputGate(gate, barrierHandler, new SyncMailboxExecutor());
    if (checkpointType.isSavepoint()) {
        fast.setBlocked(true);
        slow.setBlocked(true);
    }
    CheckpointOptions options = checkpointType.isSavepoint() ? alignedNoTimeout(checkpointType, getDefault()) : unaligned(CheckpointType.CHECKPOINT, getDefault());
    Buffer barrier = barrier(barrierId, 1, options);
    send(barrier.retainBuffer(), fast, checkpointedGate);
    assertEquals(checkpointType.isSavepoint(), target.triggeredCheckpoints.isEmpty());
    send(barrier.retainBuffer(), slow, checkpointedGate);
    assertEquals(singletonList(barrierId), target.triggeredCheckpoints);
    if (checkpointType.isSavepoint()) {
        for (InputChannel channel : gate.getInputChannels().values()) {
            assertFalse(String.format("channel %d should be resumed", channel.getChannelIndex()), ((TestInputChannel) channel).isBlocked());
        }
    }
}
Also used : TestBufferFactory.createBuffer(org.apache.flink.runtime.io.network.util.TestBufferFactory.createBuffer) Buffer(org.apache.flink.runtime.io.network.buffer.Buffer) EventSerializer.toBuffer(org.apache.flink.runtime.io.network.api.serialization.EventSerializer.toBuffer) SingleInputGateBuilder(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder) TestInputChannel(org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel) SyncMailboxExecutor(org.apache.flink.runtime.mailbox.SyncMailboxExecutor) CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) InputChannel(org.apache.flink.runtime.io.network.partition.consumer.InputChannel) TestInputChannel(org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel) RemoteInputChannel(org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate)

Aggregations

InputChannel (org.apache.flink.runtime.io.network.partition.consumer.InputChannel)34 RemoteInputChannel (org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel)34 SingleInputGate (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate)15 HashSet (java.util.HashSet)9 Buffer (org.apache.flink.runtime.io.network.buffer.Buffer)9 BufferPool (org.apache.flink.runtime.io.network.buffer.BufferPool)9 InputChannelTestUtils.createDummyConnectionManager (org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createDummyConnectionManager)9 SingleInputGateBuilder (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder)9 EndOfPartitionEvent (org.apache.flink.runtime.io.network.api.EndOfPartitionEvent)7 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 Arrays (java.util.Arrays)6 Collection (java.util.Collection)6 Collections (java.util.Collections)6 Optional (java.util.Optional)6 IntStream (java.util.stream.IntStream)6 SubpartitionIndexRange (org.apache.flink.runtime.deployment.SubpartitionIndexRange)6 ConnectionManager (org.apache.flink.runtime.io.network.ConnectionManager)6 EventSerializer (org.apache.flink.runtime.io.network.api.serialization.EventSerializer)6 BufferBuilderTestUtils.createFilledFinishedBufferConsumer (org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createFilledFinishedBufferConsumer)6