[Docs][Core] Add Javadoc to MultiTableWriterRunnable#10583
[Docs][Core] Add Javadoc to MultiTableWriterRunnable#10583LiJie20190102 wants to merge 2 commits intoapache:devfrom
Conversation
Issue 1: Incomplete JavaDoc (missing @return and @throws tags)Location: /**
* Returns first unhandled exception from the run loop; null means the worker is healthy;
* checked by MultiTableSinkWriter.subSinkErrorCheck()
*/
public Throwable getThrowable() {
return throwable;
}
/**
* Diagnostic field: the tableId of the row currently being written; may be null or stale
* between rows
*/
public String getCurrentTableId() {
return currentTableId;
}Related context:
Problem description: Potential risks:
Scope of impact:
Severity: MINOR Improvement suggestions: /**
* Returns first unhandled exception from the run loop.
*
* <p>A null return value means the worker is healthy. This method is regularly called by
* {@link MultiTableSinkWriter#subSinkErrorCheck()} to detect failures in the async worker.
*
* @return the first unhandled exception, or {@code null} if the worker is healthy
*/
public Throwable getThrowable() {
return throwable;
}
/**
* Returns the table identifier of the row currently being processed.
*
* <p>This is a diagnostic field that may be useful for debugging. The value may be
* {@code null} when no row is being processed, or may be stale between rows.
*
* @return the current table identifier, or {@code null} if not available
*/
public String getCurrentTableId() {
return currentTableId;
}
/**
* Runs the async worker loop, continuously draining the queue and writing rows.
*
* <p>This method runs an infinite loop that:
* <ul>
* <li>Polls from the queue with a 100ms timeout</li>
* <li>Skips control rows with zero arity (schema evolution events)</li>
* <li>Dispatches data rows to the appropriate {@link SinkWriter}</li>
* <li>Stops on {@link InterruptedException} or any {@link Throwable}</li>
* </ul>
*
* <p>The method terminates when the thread is interrupted or an unhandled exception occurs.
* Errors are captured in the {@code throwable} field for later inspection.
*/
@Override
public void run() {
// ... existing code ...
}Rationale:
Issue 2: Class-level JavaDoc lacks detailed explanation of concurrency semanticsLocation: /**
* MultiTableWriterRunnable is the async worker that drains a {@link BlockingQueue} of {@link
* SeaTunnelRow} and dispatches rows to per-table {@link SinkWriter} instances.
*/Related context:
Problem description: Potential risks:
Scope of impact:
Severity: MINOR Improvement suggestions: /**
* An async worker thread that drains a {@link BlockingQueue} of {@link SeaTunnelRow} and
* dispatches rows to per-table {@link SinkWriter} instances.
*
* <h3>Concurrency Model</h3>
*
* <p>Each {@code MultiTableWriterRunnable} owns a single {@link BlockingQueue} and runs in a
* dedicated thread. The thread continuously polls the queue (with 100ms timeout) and writes
* rows to the appropriate sub-writer. Multiple instances are created by
* {@link MultiTableSinkWriter} to parallelize writes across different queues.
*
* <h3>Checkpoint Coordination</h3>
*
* <p>To ensure consistent snapshots, the {@code write()} operation is protected by
* {@code synchronized(this)}. This allows {@link MultiTableSinkWriter} to coordinate
* checkpoints by acquiring the same lock before calling
* {@link SinkWriter#snapshotState(long)}. The coordination points are:
* <ul>
* <li>{@code snapshotState()}: drains queues, then locks each runnable</li>
* <li>{@code prepareCommit()}: drains queues, then locks each runnable</li>
* <li>{@code applySchemaChange()}: locks the specific runnable handling the table</li>
* <li>{@code close()}: drains queues, shuts down executor, then locks each runnable</li>
* </ul>
*
* <h3>Control Signals</h3>
*
* <p>Rows with {@code getArity() == 0} are treated as control signals for schema evolution
* and coordination events. These are created by upstream components (e.g.,
* {@code SchemaOperator}) and skipped during normal write processing.
*
* <h3>Error Handling</h3>
*
* <p>Exceptions are captured in the {@code throwable} field rather than propagated,
* allowing the thread to terminate gracefully. The parent {@link MultiTableSinkWriter}
* periodically checks this field via {@link #getThrowable()} to detect failures.
*
* @see MultiTableSinkWriter
* @see SinkWriter
*/Rationale:
Issue 3: Change to .asf.yaml is unrelated to PR themeLocation: - - chl-wxp
- LiJie20190102
+ - chl-wxpProblem description: Potential risks:
Scope of impact:
Severity: MINOR Improvement suggestions: Rationale:
|
Purpose of this pull request
Implement issue #10538
Does this PR introduce any user-facing change?
How was this patch tested?
Check list
New License Guide
incompatible-changes.mdto describe the incompatibility caused by this PR.