Search in sources :

Example 1 with ChannelStateWriteResult

use of org.apache.flink.runtime.checkpoint.channel.ChannelStateWriter.ChannelStateWriteResult in project flink by apache.

the class SyncChannelStateWriteRequestExecutor method testAbort.

@Test
public void testAbort() throws Exception {
    NetworkBuffer buffer = getBuffer();
    runWithSyncWorker((writer, worker) -> {
        callStart(writer);
        ChannelStateWriteResult result = writer.getAndRemoveWriteResult(CHECKPOINT_ID);
        callAddInputData(writer, buffer);
        callAbort(writer);
        worker.processAllRequests();
        assertTrue(result.isDone());
        assertTrue(buffer.isRecycled());
    });
}
Also used : NetworkBuffer(org.apache.flink.runtime.io.network.buffer.NetworkBuffer) ChannelStateWriteResult(org.apache.flink.runtime.checkpoint.channel.ChannelStateWriter.ChannelStateWriteResult) Test(org.junit.Test)

Example 2 with ChannelStateWriteResult

use of org.apache.flink.runtime.checkpoint.channel.ChannelStateWriter.ChannelStateWriteResult in project flink by apache.

the class SyncChannelStateWriteRequestExecutor method testResultCompletion.

@Test
public void testResultCompletion() throws IOException {
    ChannelStateWriteResult result;
    try (ChannelStateWriterImpl writer = openWriter()) {
        callStart(writer);
        result = writer.getAndRemoveWriteResult(CHECKPOINT_ID);
        assertFalse(result.resultSubpartitionStateHandles.isDone());
        assertFalse(result.inputChannelStateHandles.isDone());
    }
    assertTrue(result.inputChannelStateHandles.isDone());
    assertTrue(result.resultSubpartitionStateHandles.isDone());
}
Also used : ChannelStateWriteResult(org.apache.flink.runtime.checkpoint.channel.ChannelStateWriter.ChannelStateWriteResult) Test(org.junit.Test)

Example 3 with ChannelStateWriteResult

use of org.apache.flink.runtime.checkpoint.channel.ChannelStateWriter.ChannelStateWriteResult in project flink by apache.

the class ChannelStateCheckpointWriterTest method testSmallFilesNotWritten.

@Test
@SuppressWarnings("ConstantConditions")
public void testSmallFilesNotWritten() throws Exception {
    int threshold = 100;
    File checkpointsDir = temporaryFolder.newFolder("checkpointsDir");
    File sharedStateDir = temporaryFolder.newFolder("sharedStateDir");
    FsCheckpointStreamFactory checkpointStreamFactory = new FsCheckpointStreamFactory(getSharedInstance(), fromLocalFile(checkpointsDir), fromLocalFile(sharedStateDir), threshold, threshold);
    ChannelStateWriteResult result = new ChannelStateWriteResult();
    ChannelStateCheckpointWriter writer = createWriter(result, checkpointStreamFactory.createCheckpointStateOutputStream(EXCLUSIVE));
    NetworkBuffer buffer = new NetworkBuffer(MemorySegmentFactory.allocateUnpooledSegment(threshold / 2), FreeingBufferRecycler.INSTANCE);
    writer.writeInput(new InputChannelInfo(1, 2), buffer);
    writer.completeOutput();
    writer.completeInput();
    assertTrue(result.isDone());
    assertEquals(0, checkpointsDir.list().length);
    assertEquals(0, sharedStateDir.list().length);
}
Also used : FsCheckpointStreamFactory(org.apache.flink.runtime.state.filesystem.FsCheckpointStreamFactory) NetworkBuffer(org.apache.flink.runtime.io.network.buffer.NetworkBuffer) File(java.io.File) Path.fromLocalFile(org.apache.flink.core.fs.Path.fromLocalFile) ChannelStateWriteResult(org.apache.flink.runtime.checkpoint.channel.ChannelStateWriter.ChannelStateWriteResult) Test(org.junit.Test)

Example 4 with ChannelStateWriteResult

use of org.apache.flink.runtime.checkpoint.channel.ChannelStateWriter.ChannelStateWriteResult in project flink by apache.

the class ChannelStateCheckpointWriterTest method testResultCompletion.

@Test
public void testResultCompletion() throws Exception {
    ChannelStateWriteResult result = new ChannelStateWriteResult();
    ChannelStateCheckpointWriter writer = createWriter(result);
    writer.completeInput();
    assertFalse(result.isDone());
    writer.completeOutput();
    assertTrue(result.isDone());
}
Also used : ChannelStateWriteResult(org.apache.flink.runtime.checkpoint.channel.ChannelStateWriter.ChannelStateWriteResult) Test(org.junit.Test)

Example 5 with ChannelStateWriteResult

use of org.apache.flink.runtime.checkpoint.channel.ChannelStateWriter.ChannelStateWriteResult in project flink by apache.

the class SubtaskCheckpointCoordinatorImpl method takeSnapshotSync.

private boolean takeSnapshotSync(Map<OperatorID, OperatorSnapshotFutures> operatorSnapshotsInProgress, CheckpointMetaData checkpointMetaData, CheckpointMetricsBuilder checkpointMetrics, CheckpointOptions checkpointOptions, OperatorChain<?, ?> operatorChain, Supplier<Boolean> isRunning) throws Exception {
    checkState(!operatorChain.isClosed(), "OperatorChain and Task should never be closed at this point");
    long checkpointId = checkpointMetaData.getCheckpointId();
    long started = System.nanoTime();
    ChannelStateWriteResult channelStateWriteResult = checkpointOptions.isUnalignedCheckpoint() ? channelStateWriter.getAndRemoveWriteResult(checkpointId) : ChannelStateWriteResult.EMPTY;
    CheckpointStreamFactory storage = checkpointStorage.resolveCheckpointStorageLocation(checkpointId, checkpointOptions.getTargetLocation());
    try {
        operatorChain.snapshotState(operatorSnapshotsInProgress, checkpointMetaData, checkpointOptions, isRunning, channelStateWriteResult, storage);
    } finally {
        checkpointStorage.clearCacheFor(checkpointId);
    }
    LOG.debug("{} - finished synchronous part of checkpoint {}. Alignment duration: {} ms, snapshot duration {} ms, is unaligned checkpoint : {}", taskName, checkpointId, checkpointMetrics.getAlignmentDurationNanosOrDefault() / 1_000_000, checkpointMetrics.getSyncDurationMillis(), checkpointOptions.isUnalignedCheckpoint());
    checkpointMetrics.setSyncDurationMillis((System.nanoTime() - started) / 1_000_000);
    checkpointMetrics.setUnalignedCheckpoint(checkpointOptions.isUnalignedCheckpoint());
    return true;
}
Also used : CheckpointStreamFactory(org.apache.flink.runtime.state.CheckpointStreamFactory) ChannelStateWriteResult(org.apache.flink.runtime.checkpoint.channel.ChannelStateWriter.ChannelStateWriteResult)

Aggregations

ChannelStateWriteResult (org.apache.flink.runtime.checkpoint.channel.ChannelStateWriter.ChannelStateWriteResult)12 Test (org.junit.Test)9 NetworkBuffer (org.apache.flink.runtime.io.network.buffer.NetworkBuffer)6 Map (java.util.Map)3 MemoryCheckpointOutputStream (org.apache.flink.runtime.state.memory.MemCheckpointStreamFactory.MemoryCheckpointOutputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 DataOutputStream (java.io.DataOutputStream)2 File (java.io.File)2 HashMap (java.util.HashMap)2 Path.fromLocalFile (org.apache.flink.core.fs.Path.fromLocalFile)2 Buffer (org.apache.flink.runtime.io.network.buffer.Buffer)2 InputChannelStateHandle (org.apache.flink.runtime.state.InputChannelStateHandle)2 FsCheckpointStreamFactory (org.apache.flink.runtime.state.filesystem.FsCheckpointStreamFactory)2 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 Collections.singletonList (java.util.Collections.singletonList)1 Collections.singletonMap (java.util.Collections.singletonMap)1 Random (java.util.Random)1 IntStream (java.util.stream.IntStream)1 JobID (org.apache.flink.api.common.JobID)1