This is an automated email from the ASF dual-hosted git repository. pnowojski pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/flink.git
commit a64c00b9d6e3c39ddbf064f69a01a50231ad82b5 Author: Piotr Nowojski <piotr.nowoj...@gmail.com> AuthorDate: Tue Mar 19 13:59:16 2024 +0100 [FLINK-20217][task] Introduce YieldingOperator to get access to MailboxExecutor for V1 operators --- .../api/operators/StreamOperatorFactoryUtil.java | 3 ++ .../streaming/api/operators/YieldingOperator.java | 32 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/StreamOperatorFactoryUtil.java b/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/StreamOperatorFactoryUtil.java index 0bf3883417e..6f6ff1c2de2 100644 --- a/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/StreamOperatorFactoryUtil.java +++ b/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/StreamOperatorFactoryUtil.java @@ -87,6 +87,9 @@ public class StreamOperatorFactoryUtil { ? () -> processingTimeService : processingTimeServiceFactory, operatorEventDispatcher)); + if (op instanceof YieldingOperator) { + ((YieldingOperator<?>) operatorFactory).setMailboxExecutor(mailboxExecutor); + } return new Tuple2<>(op, Optional.ofNullable(processingTimeService)); } } diff --git a/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/YieldingOperator.java b/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/YieldingOperator.java new file mode 100644 index 00000000000..f01ae2b5676 --- /dev/null +++ b/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/YieldingOperator.java @@ -0,0 +1,32 @@ +/* + * 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.api.operators; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.api.common.operators.MailboxExecutor; + +/** + * A V1 operator that needs access to the {@link MailboxExecutor} should implement this interface. + * Note, this interface is not needed when using {@link StreamOperatorFactory} or {@link + * AbstractStreamOperatorV2} as those have access to the {@link MailboxExecutor} via {@link + * StreamOperatorParameters#getMailboxExecutor()} + */ +@Internal +public interface YieldingOperator<OUT> extends StreamOperator<OUT> { + void setMailboxExecutor(MailboxExecutor mailboxExecutor); +}