zhijiangW commented on a change in pull request #8687: [FLINK-12612][coordination] Track stored partition on the TaskExecutor URL: https://github.com/apache/flink/pull/8687#discussion_r292780892
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/partition/JobAwareShuffleEnvironment.java ########## @@ -0,0 +1,141 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.runtime.taskexecutor.partition; + +import org.apache.flink.api.common.JobID; +import org.apache.flink.metrics.MetricGroup; +import org.apache.flink.runtime.deployment.InputGateDeploymentDescriptor; +import org.apache.flink.runtime.deployment.ResultPartitionDeploymentDescriptor; +import org.apache.flink.runtime.executiongraph.ExecutionAttemptID; +import org.apache.flink.runtime.executiongraph.PartitionInfo; +import org.apache.flink.runtime.io.network.api.writer.ResultPartitionWriter; +import org.apache.flink.runtime.io.network.partition.PartitionProducerStateProvider; +import org.apache.flink.runtime.io.network.partition.ResultPartitionID; +import org.apache.flink.runtime.io.network.partition.consumer.InputGate; +import org.apache.flink.runtime.shuffle.ShuffleEnvironment; +import org.apache.flink.runtime.taskexecutor.TaskExecutor; + +import java.io.IOException; +import java.util.Collection; + +/** + * Job-aware variation of the {@link ShuffleEnvironment} interface. + * + * @see ShuffleEnvironment + */ +public interface JobAwareShuffleEnvironment<P extends ResultPartitionWriter, G extends InputGate> extends AutoCloseable { + + /** + * Start the internal related services upon {@link TaskExecutor}'s startup. + * + * @return a port to connect to the task executor for shuffle data exchange, -1 if only local connection is possible. + */ + int start() throws IOException; + + /** + * Factory method for the task's {@link ResultPartitionWriter}s. + * + * @parem jobId the job id, used for tracking which job the created partitions belongs to + * @param taskName the task name, used for logs + * @param executionAttemptID execution attempt id of the task + * @param resultPartitionDeploymentDescriptors descriptors of the partition, produced by the task + * @param outputGroup shuffle specific group for output metrics + * @param buffersGroup shuffle specific group for buffer metrics + * @return collection of the task's {@link ResultPartitionWriter}s + */ + Collection<P> createResultPartitionWriters( + JobID jobId, + String taskName, + ExecutionAttemptID executionAttemptID, + Collection<ResultPartitionDeploymentDescriptor> resultPartitionDeploymentDescriptors, + MetricGroup outputGroup, + MetricGroup buffersGroup); + + /** + * Release local resources occupied with the given partitions. + * + * @param partitionIds partition ids to release + */ + void releaseFinishedPartitions(JobID jobId, Collection<ResultPartitionID> partitionIds); + + /** + * Release all local resources occupied with partitions belonging to the given job. + * + * @param jobId + */ + void releaseAllFinishedPartitionsForJobAndMarkJobInactive(JobID jobId); + + /** + * Report partitions which still occupy some resources locally. + * + * @return collection of partitions which still occupy some resources locally + * and have not been released yet. + */ + Collection<ResultPartitionID> getPartitionsOccupyingLocalResources(); Review comment: ditto : this method could be removed if `JobAwareShuffleEnvironment` extends `ShuffleEnvironment` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
