use of org.apache.flink.runtime.io.network.partition.consumer.RecoveredInputChannel in project flink by apache.
the class ResultSubpartitionRecoveredStateHandler method calculateMapping.
private List<RecoveredInputChannel> calculateMapping(InputChannelInfo info) {
final RescaleMappings oldToNewMapping = oldToNewMappings.computeIfAbsent(info.getGateIdx(), idx -> channelMapping.getChannelMapping(idx).invert());
final List<RecoveredInputChannel> channels = Arrays.stream(oldToNewMapping.getMappedIndexes(info.getInputChannelIdx())).mapToObj(newChannelIndex -> getChannel(info.getGateIdx(), newChannelIndex)).collect(Collectors.toList());
if (channels.isEmpty()) {
throw new IllegalStateException("Recovered a buffer from old " + info + " that has no mapping in " + channelMapping.getChannelMapping(info.getGateIdx()));
}
return channels;
}
use of org.apache.flink.runtime.io.network.partition.consumer.RecoveredInputChannel in project flink by apache.
the class ResultSubpartitionRecoveredStateHandler method getBuffer.
@Override
public BufferWithContext<Buffer> getBuffer(InputChannelInfo channelInfo) throws IOException, InterruptedException {
// request the buffer from any mapped channel as they all will receive the same buffer
RecoveredInputChannel channel = getMappedChannels(channelInfo).get(0);
Buffer buffer = channel.requestBufferBlocking();
return new BufferWithContext<>(wrap(buffer), buffer);
}
use of org.apache.flink.runtime.io.network.partition.consumer.RecoveredInputChannel in project flink by apache.
the class ResultSubpartitionRecoveredStateHandler method recover.
@Override
public void recover(InputChannelInfo channelInfo, int oldSubtaskIndex, BufferWithContext<Buffer> bufferWithContext) throws IOException {
Buffer buffer = bufferWithContext.context;
try {
if (buffer.readableBytes() > 0) {
for (final RecoveredInputChannel channel : getMappedChannels(channelInfo)) {
channel.onRecoveredStateBuffer(EventSerializer.toBuffer(new SubtaskConnectionDescriptor(oldSubtaskIndex, channelInfo.getInputChannelIdx()), false));
channel.onRecoveredStateBuffer(buffer.retainBuffer());
}
}
} finally {
buffer.recycleBuffer();
}
}
Aggregations