rkhachatryan commented on a change in pull request #10151: [FLINK-14231] Handle the pending processing-time timers to make endInput semantics on the operator chain strict URL: https://github.com/apache/flink/pull/10151#discussion_r362478462
########## File path: flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamOperatorWrapper.java ########## @@ -0,0 +1,253 @@ +/* + * 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.streaming.runtime.tasks; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.annotation.VisibleForTesting; +import org.apache.flink.streaming.api.operators.BoundedMultiInput; +import org.apache.flink.streaming.api.operators.BoundedOneInput; +import org.apache.flink.streaming.api.operators.MailboxExecutor; +import org.apache.flink.streaming.api.operators.StreamOperator; + +import javax.annotation.Nullable; + +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; +import java.util.concurrent.ExecutionException; + +import static org.apache.flink.util.Preconditions.checkNotNull; + +/** + * This class wraps a {@link StreamOperator} and handles its close, endInput and other related logic. + * It also supports automatically transmitting the close operation to all operators on the operator chain + * behind it in the topological order. + * + * <p>Before closing the wrapped operator, it quiesces its processing time service, cancels the timers + * which registered but not yet scheduled for execution, and waits for all pending (executing) timers to + * finish. + */ +@Internal +public class StreamOperatorWrapper<OUT, OP extends StreamOperator<OUT>> { + + @Nullable Review comment: Ok, I see: previously, we were adding *null* into the chain, and now it is a *wrapper around null*. But what's the point of it? Can we avoid adding null or null wrapper into the chain? If not, can we use null object pattern? There are at least 6 null checks for this field. Most of them were added previously, so probably it can be done in a separate PR. WDYT, @sunhaibotb, @pnowojski? ---------------------------------------------------------------- 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
