Interface ShuffleEnvironment<P extends ResultPartitionWriter,​G extends IndexedInputGate>

    • Method Detail

      • start

        int start()
           throws IOException
        Start the internal related services before using the shuffle service environment.
        Returns:
        a port to connect for the shuffle data exchange, -1 if only local connection is possible.
        Throws:
        IOException
      • createShuffleIOOwnerContext

        ShuffleIOOwnerContext createShuffleIOOwnerContext​(String ownerName,
                                                          ExecutionAttemptID executionAttemptID,
                                                          MetricGroup parentGroup)
        Create a context of the shuffle input/output owner used to create partitions or gates belonging to the owner.

        This method has to be called only once to avoid duplicated internal metric group registration.

        Parameters:
        ownerName - the owner name, used for logs
        executionAttemptID - execution attempt id of the producer or consumer
        parentGroup - parent of shuffle specific metric group
        Returns:
        context of the shuffle input/output owner used to create partitions or gates belonging to the owner
      • releasePartitionsLocally

        void releasePartitionsLocally​(Collection<ResultPartitionID> partitionIds)
        Release local resources occupied by the given partitions.

        This is called for partitions which occupy resources locally (can be checked by ShuffleDescriptor.storesLocalResourcesOn()).

        Parameters:
        partitionIds - identifying the partitions to be released
      • getPartitionsOccupyingLocalResources

        Collection<ResultPartitionID> getPartitionsOccupyingLocalResources()
        Report partitions which still occupy some resources locally.
        Returns:
        collection of partitions which still occupy some resources locally and have not been released yet.
      • getMetricsIfPartitionOccupyingLocalResource

        default Optional<ShuffleMetrics> getMetricsIfPartitionOccupyingLocalResource​(ResultPartitionID partitionId)
        Get metrics of the partition if it still occupies some resources locally and have not been released yet.
        Parameters:
        partitionId - the partition id
        Returns:
        An Optional of ShuffleMetrics, if found, of the given partition
      • createInputGates

        List<G> createInputGates​(ShuffleIOOwnerContext ownerContext,
                                 PartitionProducerStateProvider partitionProducerStateProvider,
                                 List<InputGateDeploymentDescriptor> inputGateDeploymentDescriptors)
        Factory method for the InputGates 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.

        Parameters:
        ownerContext - the owner context relevant for gate creation
        partitionProducerStateProvider - producer state provider to query whether the producer is ready for consumption
        inputGateDeploymentDescriptors - descriptors of the input gates to consume
        Returns:
        list of the InputGates
      • updatePartitionInfo

        boolean updatePartitionInfo​(ExecutionAttemptID consumerID,
                                    PartitionInfo partitionInfo)
                             throws IOException,
                                    InterruptedException
        Update a gate with the newly available partition information, previously unknown.
        Parameters:
        consumerID - execution id to distinguish gates with the same id from the different consumer executions
        partitionInfo - information needed to consume the updated partition, e.g. network location
        Returns:
        true if the partition has been updated or false if the partition is not available anymore.
        Throws:
        IOException - IO problem by the update
        InterruptedException - potentially blocking operation was interrupted