Search in sources :

Example 1 with NettyShuffleEnvironmentBuilder

use of org.apache.flink.runtime.io.network.NettyShuffleEnvironmentBuilder in project flink by apache.

the class SingleInputGateTest method testSingleInputGateWithSubpartitionIndexRange.

@Test
public void testSingleInputGateWithSubpartitionIndexRange() throws IOException, InterruptedException {
    IntermediateResultPartitionID[] partitionIds = new IntermediateResultPartitionID[] { new IntermediateResultPartitionID(), new IntermediateResultPartitionID(), new IntermediateResultPartitionID() };
    SubpartitionIndexRange subpartitionIndexRange = new SubpartitionIndexRange(0, 1);
    final NettyShuffleEnvironment netEnv = new NettyShuffleEnvironmentBuilder().build();
    ResourceID localLocation = ResourceID.generate();
    SingleInputGate gate = createSingleInputGate(partitionIds, ResultPartitionType.BLOCKING, subpartitionIndexRange, netEnv, localLocation, new TestingConnectionManager(), new TestingResultPartitionManager(new NoOpResultSubpartitionView()));
    for (InputChannel channel : gate.getInputChannels().values()) {
        if (channel instanceof ChannelStateHolder) {
            ((ChannelStateHolder) channel).setChannelStateWriter(ChannelStateWriter.NO_OP);
        }
    }
    SubpartitionInfo info1 = createSubpartitionInfo(partitionIds[0], 0);
    SubpartitionInfo info2 = createSubpartitionInfo(partitionIds[0], 1);
    SubpartitionInfo info3 = createSubpartitionInfo(partitionIds[1], 0);
    SubpartitionInfo info4 = createSubpartitionInfo(partitionIds[1], 1);
    SubpartitionInfo info5 = createSubpartitionInfo(partitionIds[2], 0);
    SubpartitionInfo info6 = createSubpartitionInfo(partitionIds[2], 1);
    assertThat(gate.getInputChannels().size(), is(6));
    assertThat(gate.getInputChannels().get(info1).getConsumedSubpartitionIndex(), is(0));
    assertThat(gate.getInputChannels().get(info2).getConsumedSubpartitionIndex(), is(1));
    assertThat(gate.getInputChannels().get(info3).getConsumedSubpartitionIndex(), is(0));
    assertThat(gate.getInputChannels().get(info4).getConsumedSubpartitionIndex(), is(1));
    assertThat(gate.getInputChannels().get(info5).getConsumedSubpartitionIndex(), is(0));
    assertThat(gate.getInputChannels().get(info6).getConsumedSubpartitionIndex(), is(1));
    assertChannelsType(gate, LocalRecoveredInputChannel.class, Arrays.asList(info1, info2));
    assertChannelsType(gate, RemoteRecoveredInputChannel.class, Arrays.asList(info3, info4));
    assertChannelsType(gate, UnknownInputChannel.class, Arrays.asList(info5, info6));
    // test setup
    gate.setup();
    assertNotNull(gate.getBufferPool());
    assertEquals(1, gate.getBufferPool().getNumberOfRequiredMemorySegments());
    gate.finishReadRecoveredState();
    while (!gate.getStateConsumedFuture().isDone()) {
        gate.pollNext();
    }
    // test request partitions
    gate.requestPartitions();
    gate.pollNext();
    assertChannelsType(gate, LocalInputChannel.class, Arrays.asList(info1, info2));
    assertChannelsType(gate, RemoteInputChannel.class, Arrays.asList(info3, info4));
    assertChannelsType(gate, UnknownInputChannel.class, Arrays.asList(info5, info6));
    for (InputChannel inputChannel : gate.getInputChannels().values()) {
        if (inputChannel instanceof RemoteInputChannel) {
            assertNotNull(((RemoteInputChannel) inputChannel).getPartitionRequestClient());
            assertEquals(2, ((RemoteInputChannel) inputChannel).getInitialCredit());
        } else if (inputChannel instanceof LocalInputChannel) {
            assertNotNull(((LocalInputChannel) inputChannel).getSubpartitionView());
        }
    }
    // test update channels
    gate.updateInputChannel(localLocation, createRemoteWithIdAndLocation(partitionIds[2], localLocation));
    assertChannelsType(gate, LocalInputChannel.class, Arrays.asList(info1, info2));
    assertChannelsType(gate, RemoteInputChannel.class, Arrays.asList(info3, info4));
    assertChannelsType(gate, LocalInputChannel.class, Arrays.asList(info5, info6));
}
Also used : TestingConnectionManager(org.apache.flink.runtime.io.network.TestingConnectionManager) SubpartitionInfo(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate.SubpartitionInfo) NettyShuffleEnvironmentBuilder(org.apache.flink.runtime.io.network.NettyShuffleEnvironmentBuilder) NettyShuffleEnvironment(org.apache.flink.runtime.io.network.NettyShuffleEnvironment) ChannelStateHolder(org.apache.flink.runtime.io.network.partition.ChannelStateHolder) InputChannelTestUtils.createRemoteInputChannel(org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createRemoteInputChannel) NoOpResultSubpartitionView(org.apache.flink.runtime.io.network.partition.NoOpResultSubpartitionView) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) InputChannelTestUtils.createRemoteInputChannel(org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createRemoteInputChannel) InputChannelTestUtils.createLocalInputChannel(org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createLocalInputChannel) InputChannelTestUtils.createLocalInputChannel(org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createLocalInputChannel) SubpartitionIndexRange(org.apache.flink.runtime.deployment.SubpartitionIndexRange) IntermediateResultPartitionID(org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID) Test(org.junit.Test)

Example 2 with NettyShuffleEnvironmentBuilder

use of org.apache.flink.runtime.io.network.NettyShuffleEnvironmentBuilder in project flink by apache.

the class PartitionRequestQueueTest method createResultPartition.

private static ResultPartition createResultPartition() throws IOException {
    NettyShuffleEnvironment network = new NettyShuffleEnvironmentBuilder().setNumNetworkBuffers(10).setBufferSize(BUFFER_SIZE).build();
    ResultPartition resultPartition = createPartition(network, NoOpFileChannelManager.INSTANCE, ResultPartitionType.PIPELINED, 2);
    resultPartition.setup();
    return resultPartition;
}
Also used : NettyShuffleEnvironmentBuilder(org.apache.flink.runtime.io.network.NettyShuffleEnvironmentBuilder) NettyShuffleEnvironment(org.apache.flink.runtime.io.network.NettyShuffleEnvironment) ResultPartition(org.apache.flink.runtime.io.network.partition.ResultPartition)

Example 3 with NettyShuffleEnvironmentBuilder

use of org.apache.flink.runtime.io.network.NettyShuffleEnvironmentBuilder in project flink by apache.

the class PartitionRequestQueueTest method createFinishedPartitionWithFilledData.

private static ResultPartition createFinishedPartitionWithFilledData(ResultPartitionManager partitionManager) throws Exception {
    NettyShuffleEnvironment environment = new NettyShuffleEnvironmentBuilder().setResultPartitionManager(partitionManager).build();
    ResultPartition partition = createPartition(environment, fileChannelManager, ResultPartitionType.BLOCKING, 1);
    partition.setup();
    partition.emitRecord(ByteBuffer.allocate(BUFFER_SIZE), 0);
    partition.finish();
    return partition;
}
Also used : NettyShuffleEnvironmentBuilder(org.apache.flink.runtime.io.network.NettyShuffleEnvironmentBuilder) NettyShuffleEnvironment(org.apache.flink.runtime.io.network.NettyShuffleEnvironment) ResultPartition(org.apache.flink.runtime.io.network.partition.ResultPartition)

Example 4 with NettyShuffleEnvironmentBuilder

use of org.apache.flink.runtime.io.network.NettyShuffleEnvironmentBuilder in project flink by apache.

the class InputBuffersMetricsTest method testCalculateTotalBuffersSize.

@Test
public void testCalculateTotalBuffersSize() throws Exception {
    int numberOfRemoteChannels = 2;
    int numberOfLocalChannels = 0;
    int numberOfBufferPerChannel = 2;
    int numberOfBuffersPerGate = 8;
    NettyShuffleEnvironment network = new NettyShuffleEnvironmentBuilder().setNetworkBuffersPerChannel(numberOfBufferPerChannel).setFloatingNetworkBuffersPerGate(numberOfBuffersPerGate).build();
    closeableRegistry.registerCloseable(network::close);
    SingleInputGate inputGate1 = buildInputGate(network, numberOfRemoteChannels, numberOfLocalChannels).f0;
    closeableRegistry.registerCloseable(inputGate1::close);
    inputGate1.setup();
    SingleInputGate[] inputGates = new SingleInputGate[] { inputGate1 };
    FloatingBuffersUsageGauge floatingBuffersUsageGauge = new FloatingBuffersUsageGauge(inputGates);
    ExclusiveBuffersUsageGauge exclusiveBuffersUsageGauge = new ExclusiveBuffersUsageGauge(inputGates);
    CreditBasedInputBuffersUsageGauge inputBufferPoolUsageGauge = new CreditBasedInputBuffersUsageGauge(floatingBuffersUsageGauge, exclusiveBuffersUsageGauge, inputGates);
    closeableRegistry.registerCloseable(network::close);
    closeableRegistry.registerCloseable(inputGate1::close);
    assertEquals(numberOfBuffersPerGate, floatingBuffersUsageGauge.calculateTotalBuffers(inputGate1));
    assertEquals(numberOfRemoteChannels * numberOfBufferPerChannel, exclusiveBuffersUsageGauge.calculateTotalBuffers(inputGate1));
    assertEquals(numberOfRemoteChannels * numberOfBufferPerChannel + numberOfBuffersPerGate, inputBufferPoolUsageGauge.calculateTotalBuffers(inputGate1));
}
Also used : ExclusiveBuffersUsageGauge(org.apache.flink.runtime.io.network.metrics.ExclusiveBuffersUsageGauge) FloatingBuffersUsageGauge(org.apache.flink.runtime.io.network.metrics.FloatingBuffersUsageGauge) NettyShuffleEnvironmentBuilder(org.apache.flink.runtime.io.network.NettyShuffleEnvironmentBuilder) NettyShuffleEnvironment(org.apache.flink.runtime.io.network.NettyShuffleEnvironment) CreditBasedInputBuffersUsageGauge(org.apache.flink.runtime.io.network.metrics.CreditBasedInputBuffersUsageGauge) Test(org.junit.Test)

Example 5 with NettyShuffleEnvironmentBuilder

use of org.apache.flink.runtime.io.network.NettyShuffleEnvironmentBuilder in project flink by apache.

the class InputBuffersMetricsTest method testExclusiveBuffersUsage.

@Test
public void testExclusiveBuffersUsage() throws Exception {
    int numberOfRemoteChannelsGate1 = 2;
    int numberOfLocalChannelsGate1 = 0;
    int numberOfRemoteChannelsGate2 = 1;
    int numberOfLocalChannelsGate2 = 1;
    int totalNumberOfRemoteChannels = numberOfRemoteChannelsGate1 + numberOfRemoteChannelsGate2;
    int buffersPerChannel = 2;
    int extraNetworkBuffersPerGate = 8;
    NettyShuffleEnvironment network = new NettyShuffleEnvironmentBuilder().setNetworkBuffersPerChannel(buffersPerChannel).setFloatingNetworkBuffersPerGate(extraNetworkBuffersPerGate).build();
    closeableRegistry.registerCloseable(network::close);
    Tuple2<SingleInputGate, List<RemoteInputChannel>> tuple1 = buildInputGate(network, numberOfRemoteChannelsGate1, numberOfLocalChannelsGate1);
    Tuple2<SingleInputGate, List<RemoteInputChannel>> tuple2 = buildInputGate(network, numberOfRemoteChannelsGate2, numberOfLocalChannelsGate2);
    SingleInputGate inputGate1 = tuple1.f0;
    SingleInputGate inputGate2 = tuple2.f0;
    closeableRegistry.registerCloseable(inputGate1::close);
    closeableRegistry.registerCloseable(inputGate2::close);
    inputGate1.setup();
    inputGate2.setup();
    List<RemoteInputChannel> remoteInputChannels = tuple1.f1;
    SingleInputGate[] inputGates = new SingleInputGate[] { tuple1.f0, tuple2.f0 };
    FloatingBuffersUsageGauge floatingBuffersUsageGauge = new FloatingBuffersUsageGauge(inputGates);
    ExclusiveBuffersUsageGauge exclusiveBuffersUsageGauge = new ExclusiveBuffersUsageGauge(inputGates);
    CreditBasedInputBuffersUsageGauge inputBuffersUsageGauge = new CreditBasedInputBuffersUsageGauge(floatingBuffersUsageGauge, exclusiveBuffersUsageGauge, inputGates);
    assertEquals(0.0, exclusiveBuffersUsageGauge.getValue(), 0.0);
    assertEquals(0.0, inputBuffersUsageGauge.getValue(), 0.0);
    int totalBuffers = extraNetworkBuffersPerGate * inputGates.length + buffersPerChannel * totalNumberOfRemoteChannels;
    int channelIndex = 1;
    for (RemoteInputChannel channel : remoteInputChannels) {
        drainAndValidate(buffersPerChannel, buffersPerChannel * channelIndex++, channel, totalBuffers, buffersPerChannel * totalNumberOfRemoteChannels, exclusiveBuffersUsageGauge, inputBuffersUsageGauge, inputGate1);
    }
}
Also used : NettyShuffleEnvironmentBuilder(org.apache.flink.runtime.io.network.NettyShuffleEnvironmentBuilder) NettyShuffleEnvironment(org.apache.flink.runtime.io.network.NettyShuffleEnvironment) CreditBasedInputBuffersUsageGauge(org.apache.flink.runtime.io.network.metrics.CreditBasedInputBuffersUsageGauge) ExclusiveBuffersUsageGauge(org.apache.flink.runtime.io.network.metrics.ExclusiveBuffersUsageGauge) FloatingBuffersUsageGauge(org.apache.flink.runtime.io.network.metrics.FloatingBuffersUsageGauge) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Aggregations

NettyShuffleEnvironmentBuilder (org.apache.flink.runtime.io.network.NettyShuffleEnvironmentBuilder)42 NettyShuffleEnvironment (org.apache.flink.runtime.io.network.NettyShuffleEnvironment)28 Test (org.junit.Test)24 Configuration (org.apache.flink.configuration.Configuration)16 Task (org.apache.flink.runtime.taskmanager.Task)16 StreamConfig (org.apache.flink.streaming.api.graph.StreamConfig)12 OperatorID (org.apache.flink.runtime.jobgraph.OperatorID)11 JobID (org.apache.flink.api.common.JobID)10 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)7 ExecutionAttemptID (org.apache.flink.runtime.executiongraph.ExecutionAttemptID)7 CompletableFuture (java.util.concurrent.CompletableFuture)6 OneShotLatch (org.apache.flink.core.testutils.OneShotLatch)6 PartitionProducerStateChecker (org.apache.flink.runtime.taskexecutor.PartitionProducerStateChecker)6 TaskManagerActions (org.apache.flink.runtime.taskmanager.TaskManagerActions)6 BroadcastVariableManager (org.apache.flink.runtime.broadcast.BroadcastVariableManager)5 AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)5 JobInformation (org.apache.flink.runtime.executiongraph.JobInformation)5 TaskInformation (org.apache.flink.runtime.executiongraph.TaskInformation)5 FileCache (org.apache.flink.runtime.filecache.FileCache)5 TaskEventDispatcher (org.apache.flink.runtime.io.network.TaskEventDispatcher)5