public class SingleInputGate extends Object implements InputGate
Each intermediate result is partitioned over its producing parallel subtasks; each of these partitions is furthermore partitioned into one or more subpartitions.
As an example, consider a map-reduce program, where the map operator produces data and the reduce operator consumes the produced data.
+-----+ +---------------------+ +--------+
| Map | = produce => | Intermediate Result | <= consume = | Reduce |
+-----+ +---------------------+ +--------+
When deploying such a program in parallel, the intermediate result will be partitioned over its producing parallel subtasks; each of these partitions is furthermore partitioned into one or more subpartitions.
Intermediate result
+-----------------------------------------+
| +----------------+ | +-----------------------+
+-------+ | +-------------+ +=> | Subpartition 1 | | <=======+=== | Input Gate | Reduce 1 |
| Map 1 | ==> | | Partition 1 | =| +----------------+ | | +-----------------------+
+-------+ | +-------------+ +=> | Subpartition 2 | | <==+ |
| +----------------+ | | | Subpartition request
| | | |
| +----------------+ | | |
+-------+ | +-------------+ +=> | Subpartition 1 | | <==+====+
| Map 2 | ==> | | Partition 2 | =| +----------------+ | | +-----------------------+
+-------+ | +-------------+ +=> | Subpartition 2 | | <==+======== | Input Gate | Reduce 2 |
| +----------------+ | +-----------------------+
+-----------------------------------------+
In the above example, two map subtasks produce the intermediate result in parallel, resulting in two partitions (Partition 1 and 2). Each of these partitions is further partitioned into two subpartitions -- one for each parallel reduce subtask.
| Constructor and Description |
|---|
SingleInputGate(String owningTaskName,
org.apache.flink.api.common.JobID jobId,
IntermediateDataSetID consumedResultId,
ResultPartitionType consumedPartitionType,
int consumedSubpartitionIndex,
int numberOfInputChannels,
TaskActions taskActions,
TaskIOMetricGroup metrics,
boolean isCreditBased) |
| Modifier and Type | Method and Description |
|---|---|
void |
assignExclusiveSegments(NetworkBufferPool networkBufferPool,
int networkBuffersPerChannel)
Assign the exclusive buffers to all remote input channels directly for credit-based mode.
|
static SingleInputGate |
create(String owningTaskName,
org.apache.flink.api.common.JobID jobId,
ExecutionAttemptID executionId,
InputGateDeploymentDescriptor igdd,
NetworkEnvironment networkEnvironment,
TaskActions taskActions,
TaskIOMetricGroup metrics)
Creates an input gate and all of its input channels.
|
BufferPool |
getBufferPool() |
ResultPartitionType |
getConsumedPartitionType()
Returns the type of this input channel's consumed result partition.
|
IntermediateDataSetID |
getConsumedResultId() |
Optional<BufferOrEvent> |
getNextBufferOrEvent()
Blocking call waiting for next
BufferOrEvent. |
int |
getNumberOfInputChannels() |
int |
getNumberOfQueuedBuffers() |
String |
getOwningTaskName() |
int |
getPageSize() |
boolean |
isFinished() |
Optional<BufferOrEvent> |
pollNextBufferOrEvent()
Poll the
BufferOrEvent. |
void |
registerListener(InputGateListener inputGateListener) |
void |
releaseAllResources() |
void |
requestPartitions() |
void |
retriggerPartitionRequest(IntermediateResultPartitionID partitionId)
Retriggers a partition request.
|
void |
returnExclusiveSegments(List<org.apache.flink.core.memory.MemorySegment> segments)
The exclusive segments are recycled to network buffer pool directly when input channel is released.
|
void |
sendTaskEvent(TaskEvent event) |
void |
setBufferPool(BufferPool bufferPool) |
void |
setInputChannel(IntermediateResultPartitionID partitionId,
InputChannel inputChannel) |
void |
updateInputChannel(InputChannelDeploymentDescriptor icdd) |
public SingleInputGate(String owningTaskName, org.apache.flink.api.common.JobID jobId, IntermediateDataSetID consumedResultId, ResultPartitionType consumedPartitionType, int consumedSubpartitionIndex, int numberOfInputChannels, TaskActions taskActions, TaskIOMetricGroup metrics, boolean isCreditBased)
public int getNumberOfInputChannels()
getNumberOfInputChannels in interface InputGatepublic IntermediateDataSetID getConsumedResultId()
public ResultPartitionType getConsumedPartitionType()
public BufferPool getBufferPool()
public int getPageSize()
getPageSize in interface InputGatepublic int getNumberOfQueuedBuffers()
public String getOwningTaskName()
getOwningTaskName in interface InputGatepublic void setBufferPool(BufferPool bufferPool)
public void assignExclusiveSegments(NetworkBufferPool networkBufferPool, int networkBuffersPerChannel) throws IOException
networkBufferPool - The global pool to request and recycle exclusive buffersnetworkBuffersPerChannel - The number of exclusive buffers for each channelIOExceptionpublic void returnExclusiveSegments(List<org.apache.flink.core.memory.MemorySegment> segments) throws IOException
segments - The exclusive segments need to be recycledIOExceptionpublic void setInputChannel(IntermediateResultPartitionID partitionId, InputChannel inputChannel)
public void updateInputChannel(InputChannelDeploymentDescriptor icdd) throws IOException, InterruptedException
IOExceptionInterruptedExceptionpublic void retriggerPartitionRequest(IntermediateResultPartitionID partitionId) throws IOException, InterruptedException
IOExceptionInterruptedExceptionpublic void releaseAllResources()
throws IOException
IOExceptionpublic boolean isFinished()
isFinished in interface InputGatepublic void requestPartitions()
throws IOException,
InterruptedException
requestPartitions in interface InputGateIOExceptionInterruptedExceptionpublic Optional<BufferOrEvent> getNextBufferOrEvent() throws IOException, InterruptedException
InputGateBufferOrEvent.getNextBufferOrEvent in interface InputGateOptional.empty() if InputGate.isFinished() returns true.IOExceptionInterruptedExceptionpublic Optional<BufferOrEvent> pollNextBufferOrEvent() throws IOException, InterruptedException
InputGateBufferOrEvent.pollNextBufferOrEvent in interface InputGateOptional.empty() if there is no data to return or if InputGate.isFinished() returns true.IOExceptionInterruptedExceptionpublic void sendTaskEvent(TaskEvent event) throws IOException
sendTaskEvent in interface InputGateIOExceptionpublic void registerListener(InputGateListener inputGateListener)
registerListener in interface InputGatepublic static SingleInputGate create(String owningTaskName, org.apache.flink.api.common.JobID jobId, ExecutionAttemptID executionId, InputGateDeploymentDescriptor igdd, NetworkEnvironment networkEnvironment, TaskActions taskActions, TaskIOMetricGroup metrics)
Copyright © 2014–2019 The Apache Software Foundation. All rights reserved.