Search in sources :

Example 1 with ChannelStateWriterImpl

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

the class SubtaskCheckpointCoordinatorImpl method openChannelStateWriter.

private static ChannelStateWriter openChannelStateWriter(String taskName, CheckpointStorageWorkerView checkpointStorage, Environment env) {
    ChannelStateWriterImpl writer = new ChannelStateWriterImpl(taskName, env.getTaskInfo().getIndexOfThisSubtask(), checkpointStorage);
    writer.open();
    return writer;
}
Also used : ChannelStateWriterImpl(org.apache.flink.runtime.checkpoint.channel.ChannelStateWriterImpl)

Example 2 with ChannelStateWriterImpl

use of org.apache.flink.runtime.checkpoint.channel.ChannelStateWriterImpl 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

ChannelStateWriterImpl (org.apache.flink.runtime.checkpoint.channel.ChannelStateWriterImpl)2 ByteBuffer (java.nio.ByteBuffer)1 Collections.singletonMap (java.util.Collections.singletonMap)1 Map (java.util.Map)1 CheckpointOptions (org.apache.flink.runtime.checkpoint.CheckpointOptions)1 ChannelStateWriteResult (org.apache.flink.runtime.checkpoint.channel.ChannelStateWriter.ChannelStateWriteResult)1 InputChannelInfo (org.apache.flink.runtime.checkpoint.channel.InputChannelInfo)1 ResultSubpartitionInfo (org.apache.flink.runtime.checkpoint.channel.ResultSubpartitionInfo)1 Buffer (org.apache.flink.runtime.io.network.buffer.Buffer)1 NetworkBuffer (org.apache.flink.runtime.io.network.buffer.NetworkBuffer)1