Search in sources :

Example 31 with CheckpointOptions

use of org.apache.flink.runtime.checkpoint.CheckpointOptions in project flink by apache.

the class RemoteInputChannelTest method testNotifyOnPriority.

@Test
public void testNotifyOnPriority() throws IOException {
    SingleInputGate inputGate = new SingleInputGateBuilder().build();
    RemoteInputChannel channel = InputChannelTestUtils.createRemoteInputChannel(inputGate, 0);
    CheckpointOptions options = new CheckpointOptions(CHECKPOINT, getDefault());
    assertPriorityAvailability(inputGate, false, false, () -> assertAvailability(inputGate, false, true, () -> {
        channel.onBuffer(toBuffer(new CheckpointBarrier(1L, 123L, options), false), 0, 0);
    }));
    assertPriorityAvailability(inputGate, false, true, () -> assertAvailability(inputGate, true, true, () -> {
        channel.onBuffer(toBuffer(new CheckpointBarrier(2L, 123L, options), true), 1, 0);
    }));
}
Also used : CheckpointBarrier(org.apache.flink.runtime.io.network.api.CheckpointBarrier) CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) InputChannelTestUtils.createSingleInputGate(org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createSingleInputGate) Test(org.junit.Test)

Example 32 with CheckpointOptions

use of org.apache.flink.runtime.checkpoint.CheckpointOptions in project flink by apache.

the class PipelinedSubpartitionWithReadViewTest method testBarrierOvertaking.

@Test
public void testBarrierOvertaking() throws Exception {
    final RecordingChannelStateWriter channelStateWriter = new RecordingChannelStateWriter();
    subpartition.setChannelStateWriter(channelStateWriter);
    subpartition.add(createFilledFinishedBufferConsumer(1));
    assertEquals(0, availablityListener.getNumNotifications());
    assertEquals(0, availablityListener.getNumPriorityEvents());
    subpartition.add(createFilledFinishedBufferConsumer(2));
    assertEquals(1, availablityListener.getNumNotifications());
    assertEquals(0, availablityListener.getNumPriorityEvents());
    BufferConsumer eventBuffer = EventSerializer.toBufferConsumer(EndOfSuperstepEvent.INSTANCE, false);
    subpartition.add(eventBuffer);
    assertEquals(1, availablityListener.getNumNotifications());
    assertEquals(0, availablityListener.getNumPriorityEvents());
    subpartition.add(createFilledFinishedBufferConsumer(4));
    assertEquals(1, availablityListener.getNumNotifications());
    assertEquals(0, availablityListener.getNumPriorityEvents());
    CheckpointOptions options = CheckpointOptions.unaligned(CheckpointType.CHECKPOINT, new CheckpointStorageLocationReference(new byte[] { 0, 1, 2 }));
    channelStateWriter.start(0, options);
    BufferConsumer barrierBuffer = EventSerializer.toBufferConsumer(new CheckpointBarrier(0, 0, options), true);
    subpartition.add(barrierBuffer);
    assertEquals(1, availablityListener.getNumNotifications());
    assertEquals(1, availablityListener.getNumPriorityEvents());
    final List<Buffer> inflight = channelStateWriter.getAddedOutput().get(subpartition.getSubpartitionInfo());
    assertEquals(Arrays.asList(1, 2, 4), inflight.stream().map(Buffer::getSize).collect(Collectors.toList()));
    inflight.forEach(Buffer::recycleBuffer);
    assertNextEvent(readView, barrierBuffer.getWrittenBytes(), CheckpointBarrier.class, true, 2, false, true);
    assertNextBuffer(readView, 1, true, 1, false, true);
    assertNextBuffer(readView, 2, true, 0, true, true);
    assertNextEvent(readView, eventBuffer.getWrittenBytes(), EndOfSuperstepEvent.class, false, 0, false, true);
    assertNextBuffer(readView, 4, false, 0, false, true);
    assertNoNextBuffer(readView);
}
Also used : CheckpointBarrier(org.apache.flink.runtime.io.network.api.CheckpointBarrier) Buffer(org.apache.flink.runtime.io.network.buffer.Buffer) CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) RecordingChannelStateWriter(org.apache.flink.runtime.checkpoint.channel.RecordingChannelStateWriter) BufferConsumer(org.apache.flink.runtime.io.network.buffer.BufferConsumer) BufferBuilderTestUtils.createEventBufferConsumer(org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createEventBufferConsumer) BufferBuilderTestUtils.createFilledFinishedBufferConsumer(org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createFilledFinishedBufferConsumer) BufferBuilderTestUtils.createFilledUnfinishedBufferConsumer(org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createFilledUnfinishedBufferConsumer) CheckpointStorageLocationReference(org.apache.flink.runtime.state.CheckpointStorageLocationReference) Test(org.junit.Test)

Example 33 with CheckpointOptions

use of org.apache.flink.runtime.checkpoint.CheckpointOptions in project flink by apache.

the class PipelinedSubpartitionWithReadViewTest method testAvailabilityAfterPriority.

@Test
public void testAvailabilityAfterPriority() throws Exception {
    subpartition.setChannelStateWriter(ChannelStateWriter.NO_OP);
    CheckpointOptions options = CheckpointOptions.unaligned(CheckpointType.CHECKPOINT, new CheckpointStorageLocationReference(new byte[] { 0, 1, 2 }));
    BufferConsumer barrierBuffer = EventSerializer.toBufferConsumer(new CheckpointBarrier(0, 0, options), true);
    subpartition.add(barrierBuffer);
    assertEquals(1, availablityListener.getNumNotifications());
    assertEquals(1, availablityListener.getNumPriorityEvents());
    subpartition.add(createFilledFinishedBufferConsumer(1));
    assertEquals(2, availablityListener.getNumNotifications());
    assertEquals(1, availablityListener.getNumPriorityEvents());
    subpartition.add(createFilledFinishedBufferConsumer(2));
    assertEquals(2, availablityListener.getNumNotifications());
    assertEquals(1, availablityListener.getNumPriorityEvents());
    assertNextEvent(readView, barrierBuffer.getWrittenBytes(), CheckpointBarrier.class, true, 1, false, true);
    assertNextBuffer(readView, 1, false, 0, false, true);
    assertNextBuffer(readView, 2, false, 0, false, true);
    assertNoNextBuffer(readView);
}
Also used : CheckpointBarrier(org.apache.flink.runtime.io.network.api.CheckpointBarrier) CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) BufferConsumer(org.apache.flink.runtime.io.network.buffer.BufferConsumer) BufferBuilderTestUtils.createEventBufferConsumer(org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createEventBufferConsumer) BufferBuilderTestUtils.createFilledFinishedBufferConsumer(org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createFilledFinishedBufferConsumer) BufferBuilderTestUtils.createFilledUnfinishedBufferConsumer(org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createFilledUnfinishedBufferConsumer) CheckpointStorageLocationReference(org.apache.flink.runtime.state.CheckpointStorageLocationReference) Test(org.junit.Test)

Example 34 with CheckpointOptions

use of org.apache.flink.runtime.checkpoint.CheckpointOptions in project flink by apache.

the class TaskTest method assertCheckpointDeclined.

private void assertCheckpointDeclined(Task task, TestCheckpointResponder testCheckpointResponder, long checkpointId, CheckpointFailureReason failureReason) {
    CheckpointOptions checkpointOptions = CheckpointOptions.alignedNoTimeout(CheckpointType.CHECKPOINT, CheckpointStorageLocationReference.getDefault());
    task.triggerCheckpointBarrier(checkpointId, 1, checkpointOptions);
    assertEquals(1, testCheckpointResponder.getDeclineReports().size());
    assertEquals(checkpointId, testCheckpointResponder.getDeclineReports().get(0).getCheckpointId());
    assertEquals(failureReason, testCheckpointResponder.getDeclineReports().get(0).getCause().getCheckpointFailureReason());
    testCheckpointResponder.clear();
}
Also used : CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions)

Example 35 with CheckpointOptions

use of org.apache.flink.runtime.checkpoint.CheckpointOptions in project flink by apache.

the class ChannelPersistenceITCase method write.

private ChannelStateWriteResult write(long checkpointId, Map<InputChannelInfo, byte[]> icMap, Map<ResultSubpartitionInfo, byte[]> rsMap) throws Exception {
    int maxStateSize = sizeOfBytes(icMap) + sizeOfBytes(rsMap) + Long.BYTES * 2;
    Map<InputChannelInfo, Buffer> icBuffers = wrapWithBuffers(icMap);
    Map<ResultSubpartitionInfo, Buffer> rsBuffers = wrapWithBuffers(rsMap);
    try (ChannelStateWriterImpl writer = new ChannelStateWriterImpl("test", 0, getStreamFactoryFactory(maxStateSize))) {
        writer.open();
        writer.start(checkpointId, new CheckpointOptions(CHECKPOINT, new CheckpointStorageLocationReference("poly".getBytes())));
        for (Map.Entry<InputChannelInfo, Buffer> e : icBuffers.entrySet()) {
            writer.addInputData(checkpointId, e.getKey(), SEQUENCE_NUMBER_UNKNOWN, ofElements(Buffer::recycleBuffer, e.getValue()));
        }
        writer.finishInput(checkpointId);
        for (Map.Entry<ResultSubpartitionInfo, Buffer> e : rsBuffers.entrySet()) {
            writer.addOutputData(checkpointId, e.getKey(), SEQUENCE_NUMBER_UNKNOWN, e.getValue());
        }
        writer.finishOutput(checkpointId);
        ChannelStateWriteResult result = writer.getAndRemoveWriteResult(checkpointId);
        // prevent abnormal complete in close
        result.getResultSubpartitionStateHandles().join();
        return result;
    }
}
Also used : NetworkBuffer(org.apache.flink.runtime.io.network.buffer.NetworkBuffer) ByteBuffer(java.nio.ByteBuffer) Buffer(org.apache.flink.runtime.io.network.buffer.Buffer) InputChannelInfo(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo) ChannelStateWriterImpl(org.apache.flink.runtime.checkpoint.channel.ChannelStateWriterImpl) ChannelStateWriteResult(org.apache.flink.runtime.checkpoint.channel.ChannelStateWriter.ChannelStateWriteResult) ResultSubpartitionInfo(org.apache.flink.runtime.checkpoint.channel.ResultSubpartitionInfo) CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap)

Aggregations

CheckpointOptions (org.apache.flink.runtime.checkpoint.CheckpointOptions)43 Test (org.junit.Test)23 CheckpointBarrier (org.apache.flink.runtime.io.network.api.CheckpointBarrier)14 CheckpointStorageLocationReference (org.apache.flink.runtime.state.CheckpointStorageLocationReference)13 CheckpointMetaData (org.apache.flink.runtime.checkpoint.CheckpointMetaData)12 IOException (java.io.IOException)7 CheckpointMetricsBuilder (org.apache.flink.runtime.checkpoint.CheckpointMetricsBuilder)5 InputChannelInfo (org.apache.flink.runtime.checkpoint.channel.InputChannelInfo)5 TestInputChannel (org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel)5 List (java.util.List)4 Map (java.util.Map)4 Buffer (org.apache.flink.runtime.io.network.buffer.Buffer)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 SnapshotType (org.apache.flink.runtime.checkpoint.SnapshotType)3 EndOfData (org.apache.flink.runtime.io.network.api.EndOfData)3 SingleInputGate (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate)3 SingleInputGateBuilder (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGateBuilder)3 StreamConfig (org.apache.flink.streaming.api.graph.StreamConfig)3 ByteBuffer (java.nio.ByteBuffer)2