sunhaibotb 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_r378005602
########## File path: flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamOperatorWrapper.java ########## @@ -0,0 +1,228 @@ +/* + * 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.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.Nonnull; + +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import static org.apache.flink.util.Preconditions.checkNotNull; + +/** + * This class handles the close, endInput and other related logic of a {@link StreamOperator}. + * It also automatically propagates the close operation to the next wrapper that the {@link #next} + * points to, so we can use {@link #next} to link all operator wrappers in the operator chain and + * close all operators only by calling the {@link #close(StreamTaskActionExecutor)} method of the + * header operator wrapper. + */ +@Internal +public class StreamOperatorWrapper<OUT, OP extends StreamOperator<OUT>> { + + private final OP wrapped; + + @SuppressWarnings("OptionalUsedAsFieldOrParameterType") + private final Optional<ProcessingTimeService> processingTimeService; + + private final MailboxExecutor mailboxExecutor; + + private StreamOperatorWrapper<?, ?> previous; + + private StreamOperatorWrapper<?, ?> next; + + StreamOperatorWrapper( + OP wrapped, + Optional<ProcessingTimeService> processingTimeService, + MailboxExecutor mailboxExecutor) { + + this(wrapped, processingTimeService.orElse(null), mailboxExecutor); + } + + StreamOperatorWrapper(OP wrapped, ProcessingTimeService processingTimeService, MailboxExecutor mailboxExecutor) { + this.wrapped = checkNotNull(wrapped); + this.processingTimeService = Optional.ofNullable(processingTimeService); Review comment: Sure. ---------------------------------------------------------------- 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
