Search in sources :

Example 11 with CheckpointStorageLocationReference

use of org.apache.flink.runtime.state.CheckpointStorageLocationReference 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 12 with CheckpointStorageLocationReference

use of org.apache.flink.runtime.state.CheckpointStorageLocationReference 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 13 with CheckpointStorageLocationReference

use of org.apache.flink.runtime.state.CheckpointStorageLocationReference in project flink by apache.

the class CheckpointOptionsTest method testForceAlignmentIsReversable.

@Test
public void testForceAlignmentIsReversable() {
    CheckpointStorageLocationReference location = CheckpointStorageLocationReference.getDefault();
    assertReversable(CheckpointOptions.alignedWithTimeout(CheckpointType.CHECKPOINT, location, 10), true);
    assertReversable(CheckpointOptions.unaligned(CheckpointType.CHECKPOINT, location), true);
    assertReversable(CheckpointOptions.alignedNoTimeout(CHECKPOINT, location), false);
    assertReversable(CheckpointOptions.alignedNoTimeout(SavepointType.savepoint(SavepointFormatType.CANONICAL), location), false);
    assertReversable(CheckpointOptions.notExactlyOnce(CHECKPOINT, location), false);
    assertReversable(CheckpointOptions.notExactlyOnce(SavepointType.savepoint(SavepointFormatType.CANONICAL), location), false);
}
Also used : CheckpointStorageLocationReference(org.apache.flink.runtime.state.CheckpointStorageLocationReference) Test(org.junit.Test)

Example 14 with CheckpointStorageLocationReference

use of org.apache.flink.runtime.state.CheckpointStorageLocationReference in project flink by apache.

the class CheckpointOptionsTest method testCheckpointNeedsAlignment.

@Test
public void testCheckpointNeedsAlignment() {
    CheckpointStorageLocationReference location = CheckpointStorageLocationReference.getDefault();
    assertFalse(new CheckpointOptions(CHECKPOINT, location, AlignmentType.UNALIGNED, NO_ALIGNED_CHECKPOINT_TIME_OUT).needsAlignment());
    assertTrue(new CheckpointOptions(CHECKPOINT, location, AlignmentType.ALIGNED, NO_ALIGNED_CHECKPOINT_TIME_OUT).needsAlignment());
    assertTrue(new CheckpointOptions(CHECKPOINT, location, AlignmentType.FORCED_ALIGNED, NO_ALIGNED_CHECKPOINT_TIME_OUT).needsAlignment());
    assertFalse(new CheckpointOptions(CHECKPOINT, location, AlignmentType.AT_LEAST_ONCE, NO_ALIGNED_CHECKPOINT_TIME_OUT).needsAlignment());
}
Also used : CheckpointStorageLocationReference(org.apache.flink.runtime.state.CheckpointStorageLocationReference) Test(org.junit.Test)

Example 15 with CheckpointStorageLocationReference

use of org.apache.flink.runtime.state.CheckpointStorageLocationReference in project flink by apache.

the class CheckpointOptionsTest method testSavepoint.

@Test
public void testSavepoint() throws Exception {
    final Random rnd = new Random();
    final byte[] locationBytes = new byte[rnd.nextInt(41) + 1];
    rnd.nextBytes(locationBytes);
    final SnapshotType[] snapshotTypes = { CHECKPOINT, FULL_CHECKPOINT, SavepointType.savepoint(SavepointFormatType.CANONICAL), SavepointType.suspend(SavepointFormatType.CANONICAL), SavepointType.terminate(SavepointFormatType.CANONICAL) };
    final CheckpointOptions options = new CheckpointOptions(snapshotTypes[rnd.nextInt(snapshotTypes.length)], new CheckpointStorageLocationReference(locationBytes));
    final CheckpointOptions copy = CommonTestUtils.createCopySerializable(options);
    assertEquals(options.getCheckpointType(), copy.getCheckpointType());
    assertArrayEquals(locationBytes, copy.getTargetLocation().getReferenceBytes());
}
Also used : Random(java.util.Random) CheckpointStorageLocationReference(org.apache.flink.runtime.state.CheckpointStorageLocationReference) Test(org.junit.Test)

Aggregations

CheckpointStorageLocationReference (org.apache.flink.runtime.state.CheckpointStorageLocationReference)19 Test (org.junit.Test)16 CheckpointOptions (org.apache.flink.runtime.checkpoint.CheckpointOptions)12 CheckpointBarrier (org.apache.flink.runtime.io.network.api.CheckpointBarrier)4 Random (java.util.Random)2 Path (org.apache.flink.core.fs.Path)2 CheckpointMetaData (org.apache.flink.runtime.checkpoint.CheckpointMetaData)2 RecordingChannelStateWriter (org.apache.flink.runtime.checkpoint.channel.RecordingChannelStateWriter)2 Buffer (org.apache.flink.runtime.io.network.buffer.Buffer)2 BufferBuilderTestUtils.createEventBufferConsumer (org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createEventBufferConsumer)2 BufferBuilderTestUtils.createFilledFinishedBufferConsumer (org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createFilledFinishedBufferConsumer)2 BufferBuilderTestUtils.createFilledUnfinishedBufferConsumer (org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createFilledUnfinishedBufferConsumer)2 BufferConsumer (org.apache.flink.runtime.io.network.buffer.BufferConsumer)2 IOException (java.io.IOException)1 JobID (org.apache.flink.api.common.JobID)1 DuplicatingFileSystem (org.apache.flink.core.fs.DuplicatingFileSystem)1 FileSystem (org.apache.flink.core.fs.FileSystem)1 LocalFileSystem (org.apache.flink.core.fs.local.LocalFileSystem)1 CheckpointException (org.apache.flink.runtime.checkpoint.CheckpointException)1 SnapshotType (org.apache.flink.runtime.checkpoint.SnapshotType)1