public class NettyShuffleEnvironment extends Object implements ShuffleEnvironment<ResultPartition,SingleInputGate>
ShuffleEnvironment based on netty network communication, local
memory and disk files. The network environment contains the data structures that keep track of
all intermediate results and shuffle data exchanges.| Modifier and Type | Method and Description |
|---|---|
void |
close()
Tries to shut down all network I/O components.
|
List<SingleInputGate> |
createInputGates(ShuffleIOOwnerContext ownerContext,
PartitionProducerStateProvider partitionProducerStateProvider,
List<InputGateDeploymentDescriptor> inputGateDeploymentDescriptors)
Factory method for the
InputGates to consume result partitions. |
List<ResultPartition> |
createResultPartitionWriters(ShuffleIOOwnerContext ownerContext,
List<ResultPartitionDeploymentDescriptor> resultPartitionDeploymentDescriptors)
Factory method for the
ResultPartitionWriters to produce result
partitions. |
ShuffleIOOwnerContext |
createShuffleIOOwnerContext(String ownerName,
ExecutionAttemptID executionAttemptID,
org.apache.flink.metrics.MetricGroup parentGroup)
Create a context of the shuffle input/output owner used to create partitions or gates
belonging to the owner.
|
BatchShuffleReadBufferPool |
getBatchShuffleReadBufferPool() |
ScheduledExecutorService |
getBatchShuffleReadIOExecutor() |
NettyShuffleEnvironmentConfiguration |
getConfiguration() |
ConnectionManager |
getConnectionManager() |
Optional<Collection<SingleInputGate>> |
getInputGate(InputGateID id) |
Optional<ShuffleMetrics> |
getMetricsIfPartitionOccupyingLocalResource(ResultPartitionID partitionId)
Get metrics of the partition if it still occupies some resources locally and have not been
released yet.
|
NetworkBufferPool |
getNetworkBufferPool() |
Collection<ResultPartitionID> |
getPartitionsOccupyingLocalResources()
Report unreleased partitions.
|
ResultPartitionManager |
getResultPartitionManager() |
boolean |
isClosed() |
void |
registerLegacyNetworkMetrics(org.apache.flink.metrics.MetricGroup metricGroup,
ResultPartitionWriter[] producedPartitions,
InputGate[] inputGates)
Deprecated.
should be removed in future
|
void |
releasePartitionsLocally(Collection<ResultPartitionID> partitionIds)
Release local resources occupied by the given partitions.
|
int |
start()
Start the internal related services before using the shuffle service environment.
|
boolean |
updatePartitionInfo(ExecutionAttemptID consumerID,
PartitionInfo partitionInfo)
Update a gate with the newly available partition information, previously unknown.
|
@VisibleForTesting public ResultPartitionManager getResultPartitionManager()
@VisibleForTesting public ConnectionManager getConnectionManager()
@VisibleForTesting public NetworkBufferPool getNetworkBufferPool()
@VisibleForTesting public BatchShuffleReadBufferPool getBatchShuffleReadBufferPool()
@VisibleForTesting public ScheduledExecutorService getBatchShuffleReadIOExecutor()
@VisibleForTesting public NettyShuffleEnvironmentConfiguration getConfiguration()
@VisibleForTesting public Optional<Collection<SingleInputGate>> getInputGate(InputGateID id)
public void releasePartitionsLocally(Collection<ResultPartitionID> partitionIds)
ShuffleEnvironmentThis is called for partitions which occupy resources locally (can be checked by ShuffleDescriptor.storesLocalResourcesOn()).
releasePartitionsLocally in interface ShuffleEnvironment<ResultPartition,SingleInputGate>partitionIds - identifying the partitions to be releasedpublic Collection<ResultPartitionID> getPartitionsOccupyingLocalResources()
getPartitionsOccupyingLocalResources in interface ShuffleEnvironment<ResultPartition,SingleInputGate>public Optional<ShuffleMetrics> getMetricsIfPartitionOccupyingLocalResource(ResultPartitionID partitionId)
ShuffleEnvironmentgetMetricsIfPartitionOccupyingLocalResource in interface ShuffleEnvironment<ResultPartition,SingleInputGate>partitionId - the partition idShuffleMetrics, if found, of the given partitionpublic ShuffleIOOwnerContext createShuffleIOOwnerContext(String ownerName, ExecutionAttemptID executionAttemptID, org.apache.flink.metrics.MetricGroup parentGroup)
ShuffleEnvironmentThis method has to be called only once to avoid duplicated internal metric group registration.
createShuffleIOOwnerContext in interface ShuffleEnvironment<ResultPartition,SingleInputGate>ownerName - the owner name, used for logsexecutionAttemptID - execution attempt id of the producer or consumerparentGroup - parent of shuffle specific metric grouppublic List<ResultPartition> createResultPartitionWriters(ShuffleIOOwnerContext ownerContext, List<ResultPartitionDeploymentDescriptor> resultPartitionDeploymentDescriptors)
ShuffleEnvironmentResultPartitionWriters to produce result
partitions.
The order of the ResultPartitionWriters in the returned
collection should be the same as the iteration order of the passed resultPartitionDeploymentDescriptors.
createResultPartitionWriters in interface ShuffleEnvironment<ResultPartition,SingleInputGate>ownerContext - the owner context relevant for partition creationresultPartitionDeploymentDescriptors - descriptors of the partition, produced by the
ownerResultPartitionWriterspublic List<SingleInputGate> createInputGates(ShuffleIOOwnerContext ownerContext, PartitionProducerStateProvider partitionProducerStateProvider, List<InputGateDeploymentDescriptor> inputGateDeploymentDescriptors)
ShuffleEnvironmentInputGates to consume result partitions.
The order of the InputGates in the returned collection should be the
same as the iteration order of the passed inputGateDeploymentDescriptors.
createInputGates in interface ShuffleEnvironment<ResultPartition,SingleInputGate>ownerContext - the owner context relevant for gate creationpartitionProducerStateProvider - producer state provider to query whether the producer
is ready for consumptioninputGateDeploymentDescriptors - descriptors of the input gates to consumeInputGates@Deprecated public void registerLegacyNetworkMetrics(org.apache.flink.metrics.MetricGroup metricGroup, ResultPartitionWriter[] producedPartitions, InputGate[] inputGates)
Registers legacy metric groups if shuffle service implementation is original default one.
public boolean updatePartitionInfo(ExecutionAttemptID consumerID, PartitionInfo partitionInfo) throws IOException, InterruptedException
ShuffleEnvironmentupdatePartitionInfo in interface ShuffleEnvironment<ResultPartition,SingleInputGate>consumerID - execution id to distinguish gates with the same id from the different
consumer executionspartitionInfo - information needed to consume the updated partition, e.g. network
locationtrue if the partition has been updated or false if the partition is
not available anymore.IOException - IO problem by the updateInterruptedException - potentially blocking operation was interruptedpublic int start()
throws IOException
ShuffleEnvironmentstart in interface ShuffleEnvironment<ResultPartition,SingleInputGate>IOExceptionpublic void close()
close in interface AutoCloseablepublic boolean isClosed()
Copyright © 2014–2025 The Apache Software Foundation. All rights reserved.