zentol commented on a change in pull request #8857: [FLINK-12960][coordination][shuffle] Move ResultPartitionDeploymentDescriptor#releasedOnConsumption to PartitionDescriptor#releasedOnConsumption URL: https://github.com/apache/flink/pull/8857#discussion_r296727228
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/shuffle/NettyShuffleUtils.java ########## @@ -0,0 +1,50 @@ +/* + * 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.shuffle; + +import org.apache.flink.runtime.deployment.ResultPartitionDeploymentDescriptor; +import org.apache.flink.util.Preconditions; + +/** + * Common utility methods for default Netty implementation of Shuffle Service. + */ +public enum NettyShuffleUtils { + ; + + public static void checkReleaseOnConsumptionIsSupportedForPartition(PartitionDescriptor partitionDescriptor) { + checkReleaseOnConsumptionIsSupportedForPartition( + partitionDescriptor.isReleasedOnConsumption(), + partitionDescriptor.getPartitionType().isBlocking()); + } + + public static void checkReleaseOnConsumptionIsSupportedForPartition( + ResultPartitionDeploymentDescriptor resultPartitionDeploymentDescriptor) { + checkReleaseOnConsumptionIsSupportedForPartition( + resultPartitionDeploymentDescriptor.isReleasedOnConsumption(), + resultPartitionDeploymentDescriptor.getPartitionType().isBlocking()); + } + + public static void checkReleaseOnConsumptionIsSupportedForPartition( + boolean isReleasedOnConsumption, + boolean isBlockingPartition) { + Preconditions.checkArgument( + !isReleasedOnConsumption || isBlockingPartition, Review comment: Long-term we probably want to change this a bit; this kind of setup forces users of the shuffle service (i.e. the ones creating a PartitionDescriptor) to be fully aware of it's capabilities. Basically, both the partition and shuffle descriptor describe an is-state; this partition must be released on consumption, and we expect the shuffle service to fail if it can't fulfill that. I'd like to see this changed at some point so that the partition descriptor (or some other form of input) describes a wish instead, to facilitate something like: Scheduler: "hey shuffle service, if you could persist this partition, that would be great." ShuffleService: "Sorry kiddo, this one must be released on consumption." Scheduler: "oh alright then, I'll just adjust my scheduling." The usefulness of this can be easily shown with a simple though experiment: assume there exists a shuffle service implementation that supports pipelined partitions that are consumable multiple times. Currently, it would be impossible for the runtime to ever make use of this flag, so long as we don't resort to type checks. ---------------------------------------------------------------- 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
