Search in sources :

Example 11 with TestInputChannel

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

the class AlternatingCheckpointsTest method testActiveTimeoutAfterLocalBarrierPassiveTimeout.

@Test
public void testActiveTimeoutAfterLocalBarrierPassiveTimeout() throws Exception {
    int numChannels = 2;
    ValidatingCheckpointHandler target = new ValidatingCheckpointHandler();
    try (CheckpointedInputGate gate = new TestCheckpointedInputGateBuilder(numChannels, getTestBarrierHandlerFactory(target)).withMixedChannels(0).withMailboxExecutor().build()) {
        long alignmentTimeout = 10;
        Buffer checkpointBarrier = withTimeout(alignmentTimeout);
        ((TestInputChannel) gate.getChannel(0)).read(checkpointBarrier.retainBuffer());
        ((TestInputChannel) gate.getChannel(0)).read(dataBuffer());
        assertBarrier(gate);
        getChannel(gate, 1).onBuffer(dataBuffer(), 0, 0);
        getChannel(gate, 1).onBuffer(checkpointBarrier.retainBuffer(), 1, 0);
        assertEquals(0, target.getTriggeredCheckpointCounter());
        clock.advanceTimeWithoutRunningCallables(alignmentTimeout + 1, TimeUnit.MILLISECONDS);
        // the announcement should passively time out causing the barriers to overtake the data
        // buffers
        assertAnnouncement(gate);
        // we simulate active time out firing after the passive one
        clock.executeCallables();
        assertBarrier(gate);
        assertEquals(1, target.getTriggeredCheckpointCounter());
        assertThat(target.getTriggeredCheckpointOptions(), contains(unaligned(CheckpointType.CHECKPOINT, getDefault())));
        // Followed by overtaken buffers
        assertData(gate);
        assertData(gate);
    }
}
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) TestInputChannel(org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel) TestCheckpointedInputGateBuilder(org.apache.flink.streaming.util.TestCheckpointedInputGateBuilder) Test(org.junit.Test)

Example 12 with TestInputChannel

use of org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel 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)

Aggregations

TestInputChannel (org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel)12 Test (org.junit.Test)8 CheckpointOptions (org.apache.flink.runtime.checkpoint.CheckpointOptions)6 SingleInputGate (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate)6 EventSerializer.toBuffer (org.apache.flink.runtime.io.network.api.serialization.EventSerializer.toBuffer)5 Buffer (org.apache.flink.runtime.io.network.buffer.Buffer)5 SingleInputGateBuilder (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder)5 TestBufferFactory.createBuffer (org.apache.flink.runtime.io.network.util.TestBufferFactory.createBuffer)5 TestCheckpointedInputGateBuilder (org.apache.flink.streaming.util.TestCheckpointedInputGateBuilder)4 InputChannelInfo (org.apache.flink.runtime.checkpoint.channel.InputChannelInfo)3 CheckpointBarrier (org.apache.flink.runtime.io.network.api.CheckpointBarrier)3 Closeable (java.io.Closeable)1 IOException (java.io.IOException)1 ObjectInputStream (java.io.ObjectInputStream)1 Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Arrays.asList (java.util.Arrays.asList)1 Collections (java.util.Collections)1 Collections.singletonList (java.util.Collections.singletonList)1