Search in sources :

Example 66 with BufferOrEvent

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

the class CheckpointBarrierTrackerTest method testInterleavedCancellationBarriers.

/**
 * Tests that each checkpoint is only aborted once in case of an interleaved cancellation
 * barrier arrival of two consecutive checkpoints.
 */
@Test
public void testInterleavedCancellationBarriers() throws Exception {
    BufferOrEvent[] sequence = { createBarrier(1L, 0), createCancellationBarrier(2L, 0), createCancellationBarrier(1L, 1), createCancellationBarrier(2L, 1), createCancellationBarrier(1L, 2), createCancellationBarrier(2L, 2), createBuffer(0) };
    CheckpointSequenceValidator validator = new CheckpointSequenceValidator(-1, -2);
    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 67 with BufferOrEvent

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

the class CheckpointedInputGateTest method testUpstreamResumedUponEndOfRecovery.

@Test
public void testUpstreamResumedUponEndOfRecovery() throws Exception {
    int numberOfChannels = 11;
    NetworkBufferPool bufferPool = new NetworkBufferPool(numberOfChannels * 3, 1024);
    try {
        ResumeCountingConnectionManager resumeCounter = new ResumeCountingConnectionManager();
        CheckpointedInputGate gate = setupInputGate(numberOfChannels, bufferPool, resumeCounter);
        assertFalse(gate.pollNext().isPresent());
        for (int channelIndex = 0; channelIndex < numberOfChannels - 1; channelIndex++) {
            enqueueEndOfState(gate, channelIndex);
            Optional<BufferOrEvent> bufferOrEvent = gate.pollNext();
            while (bufferOrEvent.isPresent() && bufferOrEvent.get().getEvent() instanceof EndOfChannelStateEvent && !gate.allChannelsRecovered()) {
                bufferOrEvent = gate.pollNext();
            }
            assertFalse("should align (block all channels)", bufferOrEvent.isPresent());
        }
        enqueueEndOfState(gate, numberOfChannels - 1);
        Optional<BufferOrEvent> polled = gate.pollNext();
        assertTrue(polled.isPresent());
        assertTrue(polled.get().isEvent());
        assertEquals(EndOfChannelStateEvent.INSTANCE, polled.get().getEvent());
        assertEquals(numberOfChannels, resumeCounter.getNumResumed());
        assertFalse("should only be a single event no matter of what is the number of channels", gate.pollNext().isPresent());
    } finally {
        bufferPool.destroy();
    }
}
Also used : EndOfChannelStateEvent(org.apache.flink.runtime.io.network.partition.consumer.EndOfChannelStateEvent) NetworkBufferPool(org.apache.flink.runtime.io.network.buffer.NetworkBufferPool) BufferOrEvent(org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent) Test(org.junit.Test)

Example 68 with BufferOrEvent

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

the class AlignedCheckpointsTest method testSingleChannelWithBarriers.

/**
 * Validates that the buffer preserved the order of elements for a input with a single input
 * channel, and checkpoint events.
 */
@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), createEndOfPartition(0) };
    ValidatingCheckpointHandler handler = new ValidatingCheckpointHandler();
    inputGate = createCheckpointedInputGate(1, sequence, handler);
    handler.setNextExpectedCheckpointId(1L);
    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 69 with BufferOrEvent

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

the class AlignedCheckpointsTest method testTriggerCheckpointsWithEndOfPartition.

@Test
public void testTriggerCheckpointsWithEndOfPartition() throws Exception {
    BufferOrEvent[] sequence = { createBarrier(1, 0), createBarrier(1, 1), createEndOfPartition(2) };
    ValidatingCheckpointHandler validator = new ValidatingCheckpointHandler(-1L);
    inputGate = createCheckpointedInputGate(3, sequence, validator);
    for (BufferOrEvent bufferOrEvent : sequence) {
        check(bufferOrEvent, inputGate.pollNext().get(), PAGE_SIZE);
    }
    assertThat(validator.triggeredCheckpoints, contains(1L));
    assertEquals(0, validator.getAbortedCheckpointCounter());
    assertThat(inputGate.getCheckpointBarrierHandler().isCheckpointPending(), equalTo(false));
}
Also used : BufferOrEvent(org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent) Test(org.junit.Test)

Example 70 with BufferOrEvent

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

the class AlignedCheckpointsTest method testTriggerCheckpointsAfterReceivedEndOfPartition.

@Test
public void testTriggerCheckpointsAfterReceivedEndOfPartition() throws Exception {
    BufferOrEvent[] sequence = { /* 0 */
    createEndOfPartition(2), /* 2 */
    createBarrier(6, 0), /* 3 */
    createBarrier(6, 1), /* 4 */
    createEndOfPartition(1), /* 5 */
    createBarrier(7, 0) };
    ValidatingCheckpointHandler validator = new ValidatingCheckpointHandler(-1L);
    inputGate = createCheckpointedInputGate(3, sequence, validator);
    for (BufferOrEvent bufferOrEvent : sequence) {
        check(bufferOrEvent, inputGate.pollNext().get(), PAGE_SIZE);
    }
    assertThat(validator.triggeredCheckpoints, contains(6L, 7L));
    assertEquals(0, validator.getAbortedCheckpointCounter());
    assertThat(inputGate.getCheckpointBarrierHandler().isCheckpointPending(), equalTo(false));
}
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