You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "zooo-code (via GitHub)" <gi...@apache.org> on 2026/04/03 10:12:12 UTC

[PR] [Docs][Core] Add Javadoc to SupportResourceShare and MultiTableResourceManager [seatunnel]

zooo-code opened a new pull request, #10707:
URL: https://github.com/apache/seatunnel/pull/10707

   <!--
   
   Thank you for contributing to SeaTunnel! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   ## Contribution Checklist
     - Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/seatunnel/issues).
     - Name the pull request in the form "[Feature] [component] Title of the pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
     - Minor fixes should be named following this pattern: `[hotfix] [docs] Fix typo in README.md doc`.
   -->
   
   ### Purpose of this pull request
   
   Add method-level and interface-level Javadoc to `SupportResourceShare` and `MultiTableResourceManager` as described in #10535.
   
   Closes #10535
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. Documentation only change.
   
   ### How was this patch tested?
   
   - `./mvnw spotless:apply` — formatting verified
   - `./mvnw -pl seatunnel-api -q -DskipTests verify` — build verified
   
   
   ### Check list
   
   * [x] If any new Jar binary package adding in your PR, please add License Notice according
     [New License Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md)
   * [x] If necessary, please update the documentation to describe the new feature. https://github.com/apache/seatunnel/tree/dev/docs
   * [x] If necessary, please update `incompatible-changes.md` to describe the incompatibility caused by this PR.
   * [x] If you are contributing the connector code, please check that the following files are updated:
     1. Update [plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties) and add new connector information in it
     2. Update the pom file of [seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
     3. Add ci label in [label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml)
     4. Add e2e testcase in [seatunnel-e2e](https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/)
     5. Update connector [plugin_config](https://github.com/apache/seatunnel/blob/dev/config/plugin_config)


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Docs][Core] Add Javadoc to SupportResourceShare and MultiTableResourceManager [seatunnel]

Posted by "corgy-w (via GitHub)" <gi...@apache.org>.
corgy-w merged PR #10707:
URL: https://github.com/apache/seatunnel/pull/10707


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Docs][Core] Add Javadoc to SupportResourceShare and MultiTableResourceManager [seatunnel]

Posted by "zooo-code (via GitHub)" <gi...@apache.org>.
zooo-code commented on code in PR #10707:
URL: https://github.com/apache/seatunnel/pull/10707#discussion_r3033134619


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/SupportResourceShare.java:
##########
@@ -17,13 +17,52 @@
 
 package org.apache.seatunnel.api.sink;
 
+/**
+ * SPI interface for sink writers that need to share resources (e.g., connection pools) across
+ * multiple tables in a multi-table sink scenario.
+ *
+ * <p>The methods in this interface are called by {@link
+ * org.apache.seatunnel.api.sink.multitablesink.MultiTableSinkWriter} during initialization in the
+ * following order:
+ *
+ * <ol>
+ *   <li>{@link #initMultiTableResourceManager(int, int)} is called once to create the shared
+ *       resource manager.
+ *   <li>{@link #setMultiTableResourceManager(MultiTableResourceManager, int)} is called on each
+ *       per-table writer to inject the shared resource manager.

Review Comment:
   Fixed



##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/SupportResourceShare.java:
##########
@@ -17,13 +17,52 @@
 
 package org.apache.seatunnel.api.sink;
 
+/**
+ * SPI interface for sink writers that need to share resources (e.g., connection pools) across
+ * multiple tables in a multi-table sink scenario.
+ *
+ * <p>The methods in this interface are called by {@link
+ * org.apache.seatunnel.api.sink.multitablesink.MultiTableSinkWriter} during initialization in the
+ * following order:
+ *
+ * <ol>
+ *   <li>{@link #initMultiTableResourceManager(int, int)} is called once to create the shared
+ *       resource manager.
+ *   <li>{@link #setMultiTableResourceManager(MultiTableResourceManager, int)} is called on each
+ *       per-table writer to inject the shared resource manager.
+ * </ol>
+ *
+ * @param <T> the type of shared resource (e.g., a connection pool)
+ */
 public interface SupportResourceShare<T> {
 
+    /**
+     * Creates and returns a {@link MultiTableResourceManager} that holds the shared resource.
+     *
+     * <p>Called once per subtask by the {@link
+     * org.apache.seatunnel.api.sink.multitablesink.MultiTableSinkWriter} constructor. The first
+     * writer in the map is used to create the resource manager.

Review Comment:
   Fixed



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Docs][Core] Add Javadoc to SupportResourceShare and MultiTableResourceManager [seatunnel]

Posted by "zooo-code (via GitHub)" <gi...@apache.org>.
zooo-code commented on code in PR #10707:
URL: https://github.com/apache/seatunnel/pull/10707#discussion_r3033135336


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/SupportResourceShare.java:
##########
@@ -17,13 +17,52 @@
 
 package org.apache.seatunnel.api.sink;
 
+/**
+ * SPI interface for sink writers that need to share resources (e.g., connection pools) across
+ * multiple tables in a multi-table sink scenario.
+ *
+ * <p>The methods in this interface are called by {@link
+ * org.apache.seatunnel.api.sink.multitablesink.MultiTableSinkWriter} during initialization in the
+ * following order:
+ *
+ * <ol>
+ *   <li>{@link #initMultiTableResourceManager(int, int)} is called once to create the shared
+ *       resource manager.
+ *   <li>{@link #setMultiTableResourceManager(MultiTableResourceManager, int)} is called on each
+ *       per-table writer to inject the shared resource manager.
+ * </ol>
+ *
+ * @param <T> the type of shared resource (e.g., a connection pool)
+ */
 public interface SupportResourceShare<T> {
 
+    /**
+     * Creates and returns a {@link MultiTableResourceManager} that holds the shared resource.
+     *
+     * <p>Called once per subtask by the {@link
+     * org.apache.seatunnel.api.sink.multitablesink.MultiTableSinkWriter} constructor. The first
+     * writer in the map is used to create the resource manager.
+     *
+     * @param tableSize the number of target tables managed by this sink
+     * @param queueSize the number of parallel write queues (thread pool size = queueSize * 2)
+     * @return a resource manager instance, or {@code null} if resource sharing is not needed
+     */
     default MultiTableResourceManager<T> initMultiTableResourceManager(
             int tableSize, int queueSize) {
         return null;
     }
 
+    /**
+     * Injects the shared {@link MultiTableResourceManager} into the implementing writer.
+     *
+     * <p>Called after {@link #initMultiTableResourceManager(int, int)} on each per-table writer.
+     * Implementations should store the resource manager and use {@code queueIndex} to retrieve the
+     * appropriate shared resource.
+     *
+     * @param multiTableResourceManager the shared resource manager created by {@link
+     *     #initMultiTableResourceManager(int, int)}

Review Comment:
   Fixed



##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/SupportResourceShare.java:
##########
@@ -17,13 +17,52 @@
 
 package org.apache.seatunnel.api.sink;
 
+/**
+ * SPI interface for sink writers that need to share resources (e.g., connection pools) across
+ * multiple tables in a multi-table sink scenario.
+ *
+ * <p>The methods in this interface are called by {@link
+ * org.apache.seatunnel.api.sink.multitablesink.MultiTableSinkWriter} during initialization in the
+ * following order:
+ *
+ * <ol>
+ *   <li>{@link #initMultiTableResourceManager(int, int)} is called once to create the shared
+ *       resource manager.
+ *   <li>{@link #setMultiTableResourceManager(MultiTableResourceManager, int)} is called on each
+ *       per-table writer to inject the shared resource manager.
+ * </ol>
+ *
+ * @param <T> the type of shared resource (e.g., a connection pool)
+ */
 public interface SupportResourceShare<T> {
 
+    /**
+     * Creates and returns a {@link MultiTableResourceManager} that holds the shared resource.
+     *
+     * <p>Called once per subtask by the {@link
+     * org.apache.seatunnel.api.sink.multitablesink.MultiTableSinkWriter} constructor. The first
+     * writer in the map is used to create the resource manager.
+     *
+     * @param tableSize the number of target tables managed by this sink
+     * @param queueSize the number of parallel write queues (thread pool size = queueSize * 2)

Review Comment:
   Fixed



##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/MultiTableResourceManager.java:
##########
@@ -19,12 +19,43 @@
 
 import java.util.Optional;
 
-/** The multi table resource manager */
+/**
+ * Manages a shared resource (e.g., a connection pool) across multiple per-table sink writers in a
+ * multi-table sink scenario.
+ *
+ * <p>Created by {@link SupportResourceShare#initMultiTableResourceManager(int, int)} and closed by
+ * {@link org.apache.seatunnel.api.sink.multitablesink.MultiTableSinkWriter#close()} after all
+ * per-table writers are closed.

Review Comment:
   Fixed



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Docs][Core] Add Javadoc to SupportResourceShare and MultiTableResourceManager [seatunnel]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #10707:
URL: https://github.com/apache/seatunnel/pull/10707#discussion_r3032928564


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/MultiTableResourceManager.java:
##########
@@ -19,12 +19,43 @@
 
 import java.util.Optional;
 
-/** The multi table resource manager */
+/**
+ * Manages a shared resource (e.g., a connection pool) across multiple per-table sink writers in a
+ * multi-table sink scenario.
+ *
+ * <p>Created by {@link SupportResourceShare#initMultiTableResourceManager(int, int)} and closed by
+ * {@link org.apache.seatunnel.api.sink.multitablesink.MultiTableSinkWriter#close()} after all
+ * per-table writers are closed.

Review Comment:
   The type Javadoc states the manager is “closed by MultiTableSinkWriter#close()”, but MultiTableResourceManager is also closed by MultiTableSinkAggregatedCommitter#close() (seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkAggregatedCommitter.java:160-182). Please update the Javadoc to include both call sites (or phrase it generically as “closed by the multi-table sink runtime”).



##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/SupportResourceShare.java:
##########
@@ -17,13 +17,52 @@
 
 package org.apache.seatunnel.api.sink;
 
+/**
+ * SPI interface for sink writers that need to share resources (e.g., connection pools) across
+ * multiple tables in a multi-table sink scenario.
+ *
+ * <p>The methods in this interface are called by {@link
+ * org.apache.seatunnel.api.sink.multitablesink.MultiTableSinkWriter} during initialization in the
+ * following order:
+ *
+ * <ol>
+ *   <li>{@link #initMultiTableResourceManager(int, int)} is called once to create the shared
+ *       resource manager.
+ *   <li>{@link #setMultiTableResourceManager(MultiTableResourceManager, int)} is called on each
+ *       per-table writer to inject the shared resource manager.

Review Comment:
   The class-level Javadoc frames this SPI as being for “sink writers” and only describes invocation by MultiTableSinkWriter. However, SupportResourceShare is also used by multi-table aggregated committers via SupportMultiTableSinkAggregatedCommitter (see seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/SupportMultiTableSinkAggregatedCommitter.java:21 and MultiTableSinkAggregatedCommitter.initResourceManager()). Consider broadening the wording and/or mentioning MultiTableSinkAggregatedCommitter as another caller so the contract is accurate for all implementers.
   ```suggestion
    * SPI interface for multi-table sink components that need to share resources (e.g., connection
    * pools) across multiple tables in a multi-table sink scenario.
    *
    * <p>The methods in this interface are invoked during initialization by framework components such
    * as {@link org.apache.seatunnel.api.sink.multitablesink.MultiTableSinkWriter} and {@link
    * org.apache.seatunnel.api.sink.multitablesink.MultiTableSinkAggregatedCommitter} to create and
    * distribute a shared resource manager.
    *
    * <p>A typical initialization flow is:
    *
    * <ol>
    *   <li>{@link #initMultiTableResourceManager(int, int)} is called once to create the shared
    *       resource manager.
    *   <li>{@link #setMultiTableResourceManager(MultiTableResourceManager, int)} is called on each
    *       participating component to inject the shared resource manager.
   ```



##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/SupportResourceShare.java:
##########
@@ -17,13 +17,52 @@
 
 package org.apache.seatunnel.api.sink;
 
+/**
+ * SPI interface for sink writers that need to share resources (e.g., connection pools) across
+ * multiple tables in a multi-table sink scenario.
+ *
+ * <p>The methods in this interface are called by {@link
+ * org.apache.seatunnel.api.sink.multitablesink.MultiTableSinkWriter} during initialization in the
+ * following order:
+ *
+ * <ol>
+ *   <li>{@link #initMultiTableResourceManager(int, int)} is called once to create the shared
+ *       resource manager.
+ *   <li>{@link #setMultiTableResourceManager(MultiTableResourceManager, int)} is called on each
+ *       per-table writer to inject the shared resource manager.
+ * </ol>
+ *
+ * @param <T> the type of shared resource (e.g., a connection pool)
+ */
 public interface SupportResourceShare<T> {
 
+    /**
+     * Creates and returns a {@link MultiTableResourceManager} that holds the shared resource.
+     *
+     * <p>Called once per subtask by the {@link
+     * org.apache.seatunnel.api.sink.multitablesink.MultiTableSinkWriter} constructor. The first
+     * writer in the map is used to create the resource manager.
+     *
+     * @param tableSize the number of target tables managed by this sink
+     * @param queueSize the number of parallel write queues (thread pool size = queueSize * 2)
+     * @return a resource manager instance, or {@code null} if resource sharing is not needed
+     */
     default MultiTableResourceManager<T> initMultiTableResourceManager(
             int tableSize, int queueSize) {
         return null;
     }
 
+    /**
+     * Injects the shared {@link MultiTableResourceManager} into the implementing writer.
+     *
+     * <p>Called after {@link #initMultiTableResourceManager(int, int)} on each per-table writer.
+     * Implementations should store the resource manager and use {@code queueIndex} to retrieve the
+     * appropriate shared resource.
+     *
+     * @param multiTableResourceManager the shared resource manager created by {@link
+     *     #initMultiTableResourceManager(int, int)}

Review Comment:
   The Javadoc says initMultiTableResourceManager may return null when sharing isn’t needed, but setMultiTableResourceManager’s parameter description implies it is always a valid manager “created by init…”. In MultiTableSinkWriter.initResourceManager, setMultiTableResourceManager is called even when resourceManager is null. Please document that multiTableResourceManager may be null (and what implementations should do in that case).
   ```suggestion
        * If {@link #initMultiTableResourceManager(int, int)} returns {@code null}, this method is
        * still called with {@code multiTableResourceManager == null}. Implementations should handle
        * that case gracefully by treating it as "resource sharing is not needed", avoiding
        * dereferencing the manager, and falling back to writer-local resources or no shared-resource
        * initialization as appropriate. When non-null, implementations should store the resource
        * manager and use {@code queueIndex} to retrieve the appropriate shared resource.
        *
        * @param multiTableResourceManager the shared resource manager created by {@link
        *     #initMultiTableResourceManager(int, int)}, or {@code null} if resource sharing is not
        *     needed
   ```



##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/SupportResourceShare.java:
##########
@@ -17,13 +17,52 @@
 
 package org.apache.seatunnel.api.sink;
 
+/**
+ * SPI interface for sink writers that need to share resources (e.g., connection pools) across
+ * multiple tables in a multi-table sink scenario.
+ *
+ * <p>The methods in this interface are called by {@link
+ * org.apache.seatunnel.api.sink.multitablesink.MultiTableSinkWriter} during initialization in the
+ * following order:
+ *
+ * <ol>
+ *   <li>{@link #initMultiTableResourceManager(int, int)} is called once to create the shared
+ *       resource manager.
+ *   <li>{@link #setMultiTableResourceManager(MultiTableResourceManager, int)} is called on each
+ *       per-table writer to inject the shared resource manager.
+ * </ol>
+ *
+ * @param <T> the type of shared resource (e.g., a connection pool)
+ */
 public interface SupportResourceShare<T> {
 
+    /**
+     * Creates and returns a {@link MultiTableResourceManager} that holds the shared resource.
+     *
+     * <p>Called once per subtask by the {@link
+     * org.apache.seatunnel.api.sink.multitablesink.MultiTableSinkWriter} constructor. The first
+     * writer in the map is used to create the resource manager.

Review Comment:
   “The first writer in the map is used to create the resource manager” is misleading because MultiTableSinkWriter iterates sinkWriters.keySet() and breaks immediately, so the selected writer is effectively arbitrary and depends on the map’s iteration order (often non-deterministic for HashMap). Please rephrase to avoid implying a stable “first” element and clarify that implementations must not rely on which writer instance performs initialization.
   ```suggestion
        * org.apache.seatunnel.api.sink.multitablesink.MultiTableSinkWriter} constructor. One writer
        * instance from the map is used to create the resource manager, based on the map's iteration
        * order. Implementations must not rely on which writer instance performs this initialization.
   ```



##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/SupportResourceShare.java:
##########
@@ -17,13 +17,52 @@
 
 package org.apache.seatunnel.api.sink;
 
+/**
+ * SPI interface for sink writers that need to share resources (e.g., connection pools) across
+ * multiple tables in a multi-table sink scenario.
+ *
+ * <p>The methods in this interface are called by {@link
+ * org.apache.seatunnel.api.sink.multitablesink.MultiTableSinkWriter} during initialization in the
+ * following order:
+ *
+ * <ol>
+ *   <li>{@link #initMultiTableResourceManager(int, int)} is called once to create the shared
+ *       resource manager.
+ *   <li>{@link #setMultiTableResourceManager(MultiTableResourceManager, int)} is called on each
+ *       per-table writer to inject the shared resource manager.
+ * </ol>
+ *
+ * @param <T> the type of shared resource (e.g., a connection pool)
+ */
 public interface SupportResourceShare<T> {
 
+    /**
+     * Creates and returns a {@link MultiTableResourceManager} that holds the shared resource.
+     *
+     * <p>Called once per subtask by the {@link
+     * org.apache.seatunnel.api.sink.multitablesink.MultiTableSinkWriter} constructor. The first
+     * writer in the map is used to create the resource manager.
+     *
+     * @param tableSize the number of target tables managed by this sink
+     * @param queueSize the number of parallel write queues (thread pool size = queueSize * 2)

Review Comment:
   queueSize’s description includes “thread pool size = queueSize * 2”, which is an internal MultiTableSinkWriter implementation detail and could change without being an SPI contract. Consider softening this (e.g., “currently used to size internal thread pools”) or limiting the description to the meaning of queueSize (number of parallel write queues).
   ```suggestion
        * @param queueSize the number of parallel write queues
   ```



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org