Search in sources :

Example 26 with BufferOrEvent

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

the class CheckpointBarrierTrackerTest method testNoFastPathWithChannelFinishedDuringCheckpoints.

@Test
public void testNoFastPathWithChannelFinishedDuringCheckpoints() throws Exception {
    BufferOrEvent[] sequence = { createBarrier(1, 0), createEndOfPartition(0), createBarrier(1, 1) };
    ValidatingCheckpointHandler validator = new ValidatingCheckpointHandler();
    inputGate = createCheckpointedInputGate(2, sequence, validator);
    for (BufferOrEvent boe : sequence) {
        assertEquals(boe, inputGate.pollNext().get());
    }
    // The last barrier should finish the pending checkpoint instead of trigger a "new" one.
    assertEquals(1, validator.getTriggeredCheckpointCounter());
    assertFalse(inputGate.getCheckpointBarrierHandler().isCheckpointPending());
}
Also used : BufferOrEvent(org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent) Test(org.junit.Test)

Example 27 with BufferOrEvent

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

the class CheckpointBarrierTrackerTest method testCompleteCheckpointsOnLateBarriers.

/**
 * This test validates that the barrier tracker does not immediately discard a pending
 * checkpoint as soon as it sees a barrier from a later checkpoint from some channel.
 *
 * <p>This behavior is crucial, otherwise topologies where different inputs have different
 * latency (and that latency is close to or higher than the checkpoint interval) may skip many
 * checkpoints, or fail to complete a checkpoint all together.
 */
@Test
public void testCompleteCheckpointsOnLateBarriers() throws Exception {
    BufferOrEvent[] sequence = { // checkpoint 2
    createBuffer(1), createBuffer(1), createBuffer(0), createBuffer(2), createBarrier(2, 1), createBarrier(2, 0), createBarrier(2, 2), // incomplete checkpoint 3
    createBuffer(1), createBuffer(0), createBarrier(3, 1), createBarrier(3, 2), // some barriers from checkpoint 4
    createBuffer(1), createBuffer(0), createBarrier(4, 2), createBarrier(4, 1), createBuffer(1), createBuffer(2), // last barrier from checkpoint 3
    createBarrier(3, 0), // complete checkpoint 4
    createBuffer(0), createBarrier(4, 0), // regular checkpoint 5
    createBuffer(1), createBuffer(2), createBarrier(5, 1), createBuffer(0), createBarrier(5, 0), createBuffer(1), createBarrier(5, 2), // checkpoint 6 (incomplete),
    createBuffer(1), createBarrier(6, 1), createBuffer(0), createBarrier(6, 0), // checkpoint 7, with early barriers for checkpoints 8 and 9
    createBuffer(1), createBarrier(7, 1), createBuffer(0), createBarrier(7, 2), createBuffer(2), createBarrier(8, 2), createBuffer(0), createBarrier(8, 1), createBuffer(1), createBarrier(9, 1), // complete checkpoint 7, first barriers from checkpoint 10
    createBarrier(7, 0), createBuffer(0), createBarrier(9, 2), createBuffer(2), createBarrier(10, 2), // complete checkpoint 8 and 9
    createBarrier(8, 0), createBuffer(1), createBuffer(2), createBarrier(9, 0), // trailing data
    createBuffer(1), createBuffer(0), createBuffer(2), // complete checkpoint 10
    createBarrier(10, 0), createBarrier(10, 1) };
    CheckpointSequenceValidator validator = new CheckpointSequenceValidator(2, 3, 4, 5, 7, 8, 9, 10);
    inputGate = createCheckpointedInputGate(3, sequence, validator);
    for (BufferOrEvent boe : sequence) {
        assertEquals(boe, inputGate.pollNext().get());
    }
}
Also used : BufferOrEvent(org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent) Test(org.junit.Test)

Example 28 with BufferOrEvent

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

the class CheckpointBarrierTrackerTest method testNoFastPathWithChannelFinishedDuringCheckpointsCancel.

@Test
public void testNoFastPathWithChannelFinishedDuringCheckpointsCancel() throws Exception {
    BufferOrEvent[] sequence = { createBarrier(1, 0, 0), createEndOfPartition(0), createCancellationBarrier(1, 1) };
    ValidatingCheckpointHandler checkpointHandler = new ValidatingCheckpointHandler();
    inputGate = createCheckpointedInputGate(2, sequence, checkpointHandler);
    for (BufferOrEvent boe : sequence) {
        assertEquals(boe, inputGate.pollNext().get());
    }
    assertEquals(1, checkpointHandler.getLastCanceledCheckpointId());
    // If go with the fast path, the pending checkpoint would not be removed normally.
    assertFalse(inputGate.getCheckpointBarrierHandler().isCheckpointPending());
}
Also used : BufferOrEvent(org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent) Test(org.junit.Test)

Example 29 with BufferOrEvent

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

the class AlignedCheckpointsTest method testMultiChannelNoBarriers.

/**
 * Validates that the buffer behaves correctly if no checkpoint barriers come, for an input with
 * multiple input channels.
 */
@Test
public void testMultiChannelNoBarriers() throws Exception {
    BufferOrEvent[] sequence = { createBuffer(2), createBuffer(2), createBuffer(0), createBuffer(1), createBuffer(0), createEndOfPartition(0), createBuffer(3), createBuffer(1), createEndOfPartition(3), createBuffer(1), createEndOfPartition(1), createBuffer(2), createEndOfPartition(2) };
    inputGate = createCheckpointedInputGate(4, sequence);
    for (BufferOrEvent boe : sequence) {
        assertEquals(boe, inputGate.pollNext().get());
    }
    assertEquals(0L, inputGate.getAlignmentDurationNanos());
}
Also used : BufferOrEvent(org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent) Test(org.junit.Test)

Example 30 with BufferOrEvent

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

the class AlignedCheckpointsTest method testMissingCancellationBarriers.

@Test
public void testMissingCancellationBarriers() throws Exception {
    BufferOrEvent[] sequence = { createBarrier(1L, 0), createCancellationBarrier(3L, 1), createCancellationBarrier(2L, 0), createCancellationBarrier(3L, 0), createBuffer(0) };
    AbstractInvokable validator = new ValidatingCheckpointHandler();
    inputGate = createCheckpointedInputGate(2, sequence, validator);
    for (BufferOrEvent boe : sequence) {
        assertEquals(boe, inputGate.pollNext().get());
    }
    assertThat(mockInputGate.getBlockedChannels(), empty());
}
Also used : AbstractInvokable(org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable) BufferOrEvent(org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent) Test(org.junit.Test)

Aggregations

BufferOrEvent (org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent)73 Test (org.junit.Test)57 CheckpointBarrier (org.apache.flink.runtime.io.network.api.CheckpointBarrier)11 CheckpointOptions (org.apache.flink.runtime.checkpoint.CheckpointOptions)9 StatefulTask (org.apache.flink.runtime.jobgraph.tasks.StatefulTask)9 IOException (java.io.IOException)8 CheckpointMetrics (org.apache.flink.runtime.checkpoint.CheckpointMetrics)8 CheckpointDeclineOnCancellationBarrierException (org.apache.flink.runtime.checkpoint.decline.CheckpointDeclineOnCancellationBarrierException)8 Random (java.util.Random)7 ArrayList (java.util.ArrayList)6 CheckpointDeclineSubsumedException (org.apache.flink.runtime.checkpoint.decline.CheckpointDeclineSubsumedException)5 CheckpointMetaData (org.apache.flink.runtime.checkpoint.CheckpointMetaData)4 InputChannelInfo (org.apache.flink.runtime.checkpoint.channel.InputChannelInfo)4 Buffer (org.apache.flink.runtime.io.network.buffer.Buffer)4 MemorySegment (org.apache.flink.core.memory.MemorySegment)3 AbstractEvent (org.apache.flink.runtime.event.AbstractEvent)3 CancelCheckpointMarker (org.apache.flink.runtime.io.network.api.CancelCheckpointMarker)3 EndOfPartitionEvent (org.apache.flink.runtime.io.network.api.EndOfPartitionEvent)3 DeserializationResult (org.apache.flink.runtime.io.network.api.serialization.RecordDeserializer.DeserializationResult)3 NetworkBufferPool (org.apache.flink.runtime.io.network.buffer.NetworkBufferPool)3