Search in sources :

Example 21 with BufferOrEvent

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

the class CheckpointBarrierTrackerTest method testSingleChannelWithBarriers.

@Test
public void testSingleChannelWithBarriers() throws Exception {
    BufferOrEvent[] sequence = { createBuffer(0), createBuffer(0), createBuffer(0), createBarrier(1, 0), createBuffer(0), createBuffer(0), createBuffer(0), createBuffer(0), createBarrier(2, 0), createBarrier(3, 0), createBuffer(0), createBuffer(0), createBarrier(4, 0), createBarrier(5, 0), createBarrier(6, 0), createBuffer(0) };
    CheckpointSequenceValidator validator = new CheckpointSequenceValidator(1, 2, 3, 4, 5, 6);
    inputGate = createCheckpointedInputGate(1, 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 22 with BufferOrEvent

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

the class CheckpointBarrierTrackerTest method testNextFirstCheckpointBarrierOvertakesCancellationBarrier.

@Test
public void testNextFirstCheckpointBarrierOvertakesCancellationBarrier() throws Exception {
    BufferOrEvent[] sequence = { // start checkpoint 1
    createBarrier(1, 1), // start checkpoint 2(just suppose checkpoint 1 was canceled)
    createBarrier(2, 1), // cancellation barrier of checkpoint 1
    createCancellationBarrier(1, 0), // finish the checkpoint 2
    createBarrier(2, 0) };
    ValidatingCheckpointHandler validator = new ValidatingCheckpointHandler();
    ManualClock manualClock = new ManualClock();
    inputGate = createCheckpointedInputGate(2, sequence, validator, manualClock);
    for (BufferOrEvent boe : sequence) {
        assertEquals(boe, inputGate.pollNext().get());
        manualClock.advanceTime(Duration.ofSeconds(1));
    }
    assertEquals(Duration.ofSeconds(2).toNanos(), validator.lastAlignmentDurationNanos.get().longValue());
}
Also used : ManualClock(org.apache.flink.util.clock.ManualClock) BufferOrEvent(org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent) Test(org.junit.Test)

Example 23 with BufferOrEvent

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

the class CheckpointBarrierTrackerTest method testMultiChannelAbortCheckpoint.

@Test
public void testMultiChannelAbortCheckpoint() throws Exception {
    BufferOrEvent[] sequence = { // some buffers and a successful checkpoint
    createBuffer(0), createBuffer(2), createBuffer(0), createBarrier(1, 1), createBarrier(1, 2), createBuffer(2), createBuffer(1), createBarrier(1, 0), // aborted on last barrier
    createBuffer(0), createBuffer(2), createBarrier(2, 0), createBarrier(2, 2), createBuffer(0), createBuffer(2), createCancellationBarrier(2, 1), // successful checkpoint
    createBuffer(2), createBuffer(1), createBarrier(3, 1), createBarrier(3, 2), createBarrier(3, 0), // abort on first barrier
    createBuffer(0), createBuffer(1), createCancellationBarrier(4, 1), createBarrier(4, 2), createBuffer(0), createBarrier(4, 0), // another successful checkpoint
    createBuffer(0), createBuffer(1), createBuffer(2), createBarrier(5, 2), createBarrier(5, 1), createBarrier(5, 0), // abort multiple cancellations and a barrier after the cancellations
    createBuffer(0), createBuffer(1), createCancellationBarrier(6, 1), createCancellationBarrier(6, 2), createBarrier(6, 0), createBuffer(0) };
    // negative values mean an expected cancellation call!
    CheckpointSequenceValidator validator = new CheckpointSequenceValidator(1, -2, 3, -4, 5, -6);
    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 24 with BufferOrEvent

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

the class CheckpointBarrierTrackerTest method testTriggerCheckpointsWithEndOfPartition.

@Test
public void testTriggerCheckpointsWithEndOfPartition() throws Exception {
    BufferOrEvent[] sequence = { createBarrier(1, 0), createBarrier(2, 0), createBarrier(2, 1), createBarrier(3, 0), createBarrier(4, 0), createBarrier(4, 1), createBarrier(5, 1), createEndOfPartition(2) };
    ValidatingCheckpointHandler validator = new ValidatingCheckpointHandler(4);
    inputGate = createCheckpointedInputGate(3, sequence, validator);
    CheckpointBarrierTracker checkpointBarrierTracker = (CheckpointBarrierTracker) inputGate.getCheckpointBarrierHandler();
    for (BufferOrEvent boe : sequence) {
        assertEquals(boe, inputGate.pollNext().get());
    }
    // Only checkpoints 4 is triggered and the previous checkpoints are ignored.
    assertThat(validator.triggeredCheckpoints, contains(4L));
    assertEquals(0, validator.getAbortedCheckpointCounter());
    assertThat(checkpointBarrierTracker.getPendingCheckpointIds(), contains(5L));
    assertEquals(2, checkpointBarrierTracker.getNumOpenChannels());
}
Also used : BufferOrEvent(org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent) Test(org.junit.Test)

Example 25 with BufferOrEvent

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

the class CheckpointBarrierTrackerTest method testSingleChannelAbortCheckpoint.

@Test
public void testSingleChannelAbortCheckpoint() throws Exception {
    BufferOrEvent[] sequence = { createBuffer(0), createBarrier(1, 0), createBuffer(0), createBarrier(2, 0), createCancellationBarrier(4, 0), createBarrier(5, 0), createBuffer(0), createCancellationBarrier(6, 0), createBuffer(0) };
    // negative values mean an expected cancellation call!
    CheckpointSequenceValidator validator = new CheckpointSequenceValidator(1, 2, -4, 5, -6);
    inputGate = createCheckpointedInputGate(1, 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)

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