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());
});
}
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());
}
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);
}
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());
}
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;
}
Aggregations