You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fluss.apache.org by "loserwang1024 (via GitHub)" <gi...@apache.org> on 2025/09/03 08:08:56 UTC
[PR] [flink] Fluss enumerator partition discovery in fixed delay rather than fixed rate. [fluss]
loserwang1024 opened a new pull request, #1633:
URL: https://github.com/apache/fluss/pull/1633
<!--
*Thank you very much for contributing to Fluss - we are happy that you want to help us improve Fluss. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
## Contribution Checklist
- Make sure that the pull request corresponds to a [GitHub issue](https://github.com/apache/fluss/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no issue.
- Name the pull request in the format "[component] Title of the pull request", where *[component]* should be replaced by the name of the component being changed. Typically, this corresponds to the component label assigned to the issue (e.g., [kv], [log], [client], [flink]). Skip *[component]* if you are unsure about which is the best component.
- Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
- Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes.
- Each pull request should address only one issue, not mix up code from multiple issues.
**(The sections below can be removed for hotfixes or typos)**
-->
### Purpose
<!-- Linking this pull request to the issue -->
Linked issue: close #1632
<!-- What is the purpose of the change -->
### Brief change log
<!-- Please describe the changes made in this pull request and explain how they address the issue -->
### Tests
<!-- List UT and IT cases to verify this change -->
### API and Format
<!-- Does this change affect API or storage format -->
### Documentation
<!-- Does this change introduce a new feature -->
--
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.
To unsubscribe, e-mail: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] Fluss enumerator partition discovery in fixed delay rather than fixed rate. [fluss]
Posted by "wuchong (via GitHub)" <gi...@apache.org>.
wuchong commented on code in PR #1633:
URL: https://github.com/apache/fluss/pull/1633#discussion_r2335785247
##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/source/enumerator/WorkerExecutor.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * 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.fluss.flink.source.enumerator;
+
+import org.apache.fluss.annotation.Internal;
+import org.apache.fluss.flink.source.split.SourceSplitBase;
+
+import org.apache.flink.api.connector.source.SplitEnumeratorContext;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.function.BiConsumer;
+
+/**
+ * A worker executor that is used to schedule asynchronous tasks to extend {@link
+ * SplitEnumeratorContext} with fixed delay capabilities. This class serves as a workaround until
+ * {@link SplitEnumeratorContext} natively supports asynchronous calls with fixed delay scheduling.
+ *
+ * <p>This executor wraps a single-threaded {@link ScheduledExecutorService} to handle async
+ * operations and route their results back to the coordinator thread through the {@link
+ * SplitEnumeratorContext#callAsync} methods.
+ */
+@Internal
+public class WorkerExecutor {
+ protected final SplitEnumeratorContext<SourceSplitBase> context;
+ private final ScheduledExecutorService workerExecutor;
+
+ public WorkerExecutor(SplitEnumeratorContext<SourceSplitBase> context) {
+ this.context = context;
+ this.workerExecutor = Executors.newScheduledThreadPool(1);
+ }
+
+ public <T> void callAsync(Callable<T> callable, BiConsumer<T, Throwable> handler) {
+ workerExecutor.execute(
+ () -> {
+ try {
+ T result = callable.call();
+ // reuse the context async call to notify coordinator thread.
+ context.callAsync(() -> result, handler);
+ } catch (Throwable t) {
+ context.callAsync(
+ () -> {
+ throw t;
+ },
+ handler);
+ }
+ });
+ }
+
+ public <T> void callAsyncAtFixedDelay(
+ Callable<T> callable, BiConsumer<T, Throwable> handler, long initialDelay, long delay) {
+ workerExecutor.scheduleWithFixedDelay(
+ () -> {
+ try {
+ T result = callable.call();
+ // reuse the context async call to notify coordinator thread.
+ context.callAsync(() -> result, handler);
+ } catch (Throwable t) {
+ context.callAsync(
+ () -> {
+ throw t;
+ },
+ handler);
+ }
+ },
+ initialDelay,
+ delay,
+ TimeUnit.MILLISECONDS);
Review Comment:
We can wrap the `callable` with a `CompleteFuture` to blocking wait in the `Runnable` of `workerExecutor.scheduleWithFixedDelay`.
##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/source/enumerator/WorkerExecutor.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * 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.fluss.flink.source.enumerator;
+
+import org.apache.fluss.annotation.Internal;
+import org.apache.fluss.flink.source.split.SourceSplitBase;
+
+import org.apache.flink.api.connector.source.SplitEnumeratorContext;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.function.BiConsumer;
+
+/**
+ * A worker executor that is used to schedule asynchronous tasks to extend {@link
+ * SplitEnumeratorContext} with fixed delay capabilities. This class serves as a workaround until
+ * {@link SplitEnumeratorContext} natively supports asynchronous calls with fixed delay scheduling.
+ *
+ * <p>This executor wraps a single-threaded {@link ScheduledExecutorService} to handle async
+ * operations and route their results back to the coordinator thread through the {@link
+ * SplitEnumeratorContext#callAsync} methods.
+ */
+@Internal
+public class WorkerExecutor {
+ protected final SplitEnumeratorContext<SourceSplitBase> context;
+ private final ScheduledExecutorService workerExecutor;
Review Comment:
Use another variable name like `scheduledExecutor` to avoid naming conflict with the class name.
##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/source/enumerator/WorkerExecutor.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * 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.fluss.flink.source.enumerator;
+
+import org.apache.fluss.annotation.Internal;
+import org.apache.fluss.flink.source.split.SourceSplitBase;
+
+import org.apache.flink.api.connector.source.SplitEnumeratorContext;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.function.BiConsumer;
+
+/**
+ * A worker executor that is used to schedule asynchronous tasks to extend {@link
+ * SplitEnumeratorContext} with fixed delay capabilities. This class serves as a workaround until
+ * {@link SplitEnumeratorContext} natively supports asynchronous calls with fixed delay scheduling.
Review Comment:
please explain why we can't use `SplitEnumeratorContext#callAsync(java.util.concurrent.Callable<T>, java.util.function.BiConsumer<T,java.lang.Throwable>, long, long)`
##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/source/enumerator/FlinkSourceEnumerator.java:
##########
@@ -85,11 +86,14 @@
* will be assigned to same reader.
* </ul>
*/
+@Internal
public class FlinkSourceEnumerator
implements SplitEnumerator<SourceSplitBase, SourceEnumeratorState> {
+ // TODO: remove it until SplitEnumeratorContext.callAsync supports fixed delay.
Review Comment:
move this comment with the `workerExecutor`. Besides, you can add the FLIP or JIRA id if there is already one.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] Fluss enumerator partition discovery in fixed delay rather than fixed rate. [fluss]
Posted by "wuchong (via GitHub)" <gi...@apache.org>.
wuchong merged PR #1633:
URL: https://github.com/apache/fluss/pull/1633
--
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.
To unsubscribe, e-mail: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org