use of org.apache.flink.runtime.io.network.partition.ResultSubpartitionView in project flink by apache.
the class LocalInputChannel method requestSubpartition.
// ------------------------------------------------------------------------
// Consume
// ------------------------------------------------------------------------
@Override
void requestSubpartition(int subpartitionIndex) throws IOException, InterruptedException {
boolean retriggerRequest = false;
// The lock is required to request only once in the presence of retriggered requests.
synchronized (requestLock) {
checkState(!isReleased, "LocalInputChannel has been released already");
if (subpartitionView == null) {
LOG.debug("{}: Requesting LOCAL subpartition {} of partition {}.", this, subpartitionIndex, partitionId);
try {
ResultSubpartitionView subpartitionView = partitionManager.createSubpartitionView(partitionId, subpartitionIndex, inputGate.getBufferProvider(), this);
if (subpartitionView == null) {
throw new IOException("Error requesting subpartition.");
}
// make the subpartition view visible
this.subpartitionView = subpartitionView;
// check if the channel was released in the meantime
if (isReleased) {
subpartitionView.releaseAllResources();
this.subpartitionView = null;
}
} catch (PartitionNotFoundException notFound) {
if (increaseBackoff()) {
retriggerRequest = true;
} else {
throw notFound;
}
}
}
}
// input gate.
if (retriggerRequest) {
inputGate.retriggerPartitionRequest(partitionId.getPartitionId());
}
}
use of org.apache.flink.runtime.io.network.partition.ResultSubpartitionView in project flink by apache.
the class SequentialChannelStateReaderImplTest method collectBuffers.
private Map<ResultSubpartitionInfo, List<Buffer>> collectBuffers(BufferWritingResultPartition[] resultPartitions) throws IOException {
Map<ResultSubpartitionInfo, List<Buffer>> actual = new HashMap<>();
for (BufferWritingResultPartition resultPartition : resultPartitions) {
for (int i = 0; i < resultPartition.getNumberOfSubpartitions(); i++) {
ResultSubpartitionInfo info = resultPartition.getAllPartitions()[i].getSubpartitionInfo();
ResultSubpartitionView view = resultPartition.createSubpartitionView(info.getSubPartitionIdx(), new NoOpBufferAvailablityListener());
for (BufferAndBacklog buffer = view.getNextBuffer(); buffer != null; buffer = view.getNextBuffer()) {
if (buffer.buffer().isBuffer()) {
actual.computeIfAbsent(info, unused -> new ArrayList<>()).add(buffer.buffer());
}
}
}
}
return actual;
}
use of org.apache.flink.runtime.io.network.partition.ResultSubpartitionView in project flink by apache.
the class LocalInputChannel method releaseAllResources.
/**
* Releases the partition reader.
*/
@Override
void releaseAllResources() throws IOException {
if (!isReleased) {
isReleased = true;
ResultSubpartitionView view = subpartitionView;
if (view != null) {
view.releaseAllResources();
subpartitionView = null;
}
}
}
use of org.apache.flink.runtime.io.network.partition.ResultSubpartitionView in project flink by apache.
the class LocalInputChannel method announceBufferSize.
@Override
void announceBufferSize(int newBufferSize) {
checkState(!isReleased, "Channel released.");
ResultSubpartitionView view = this.subpartitionView;
if (view != null) {
view.notifyNewBufferSize(newBufferSize);
}
}
use of org.apache.flink.runtime.io.network.partition.ResultSubpartitionView in project flink by apache.
the class LocalInputChannel method requestSubpartition.
@Override
protected void requestSubpartition() throws IOException {
boolean retriggerRequest = false;
boolean notifyDataAvailable = false;
// The lock is required to request only once in the presence of retriggered requests.
synchronized (requestLock) {
checkState(!isReleased, "LocalInputChannel has been released already");
if (subpartitionView == null) {
LOG.debug("{}: Requesting LOCAL subpartition {} of partition {}. {}", this, consumedSubpartitionIndex, partitionId, channelStatePersister);
try {
ResultSubpartitionView subpartitionView = partitionManager.createSubpartitionView(partitionId, consumedSubpartitionIndex, this);
if (subpartitionView == null) {
throw new IOException("Error requesting subpartition.");
}
// make the subpartition view visible
this.subpartitionView = subpartitionView;
// check if the channel was released in the meantime
if (isReleased) {
subpartitionView.releaseAllResources();
this.subpartitionView = null;
} else {
notifyDataAvailable = true;
}
} catch (PartitionNotFoundException notFound) {
if (increaseBackoff()) {
retriggerRequest = true;
} else {
throw notFound;
}
}
}
}
if (notifyDataAvailable) {
notifyDataAvailable();
}
// input gate.
if (retriggerRequest) {
inputGate.retriggerPartitionRequest(partitionId.getPartitionId(), consumedSubpartitionIndex);
}
}
Aggregations