Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Apache Flink Async Sink Framework

From Leeroopedia


Knowledge Sources
Domains Async_Sink, Table_API
Last Updated 2026-02-09 00:00 GMT

Overview

Description

The Async Sink Table Integration Framework provides the table-level integration layer that bridges the AsyncSinkBase runtime implementation with Flink's SQL and Table API. Located in the flink-connector-base module under the org.apache.flink.connector.base.table and org.apache.flink.connector.base.table.sink packages, this framework enables connector developers to expose asynchronous sinks as dynamic table sinks with minimal boilerplate.

The framework consists of four principal components:

  • AsyncDynamicTableSinkFactory -- An abstract @PublicEvolving class implementing DynamicTableSinkFactory. It automatically registers the five AsyncSinkConnectorOptions as optional table options, provides addAsyncOptionsToBuilder() to wire configuration properties into a builder, and includes the inner AsyncDynamicSinkContext class to encapsulate catalog table metadata such as encoding format, physical data type, and partition keys.
  • AsyncSinkConnectorOptions -- A @PublicEvolving constants class defining five ConfigOption entries that map to AsyncSinkBase tuning parameters: sink.batch.max-size, sink.requests.max-inflight, sink.requests.max-buffered, sink.flush-buffer.size, and sink.flush-buffer.timeout.
  • AsyncDynamicTableSink -- An abstract @PublicEvolving class implementing DynamicTableSink that stores the five async sink parameters. It provides addAsyncOptionsToSinkBuilder() to propagate these parameters into an AsyncSinkBaseBuilder at runtime, along with proper equals/hashCode implementations.
  • AsyncDynamicTableSinkBuilder -- An abstract @PublicEvolving builder class parameterized by request entry type and a self-referential builder type. It provides fluent setter methods for all five async sink parameters and an abstract build() method that concrete implementations override to construct the final sink.

Theoretical Basis

This framework applies the Abstract Factory pattern at the table layer. AsyncDynamicTableSinkFactory serves as the abstract factory that Flink's FactoryUtil discovers through Java SPI. The factory creates AsyncDynamicTableSink instances, which in turn produce the underlying AsyncSinkBase operator at execution time. This two-stage creation (factory produces table sink, table sink produces runtime operator) cleanly separates SQL/Table API concerns from DataStream-level execution.

The Builder pattern is employed by AsyncDynamicTableSinkBuilder to handle the nullable, optional nature of the five configuration parameters. Each parameter can be independently set, and Optional.ofNullable chains ensure that only explicitly specified values are propagated to the underlying AsyncSinkBaseBuilder. This design allows connector-specific defaults to remain in effect for any parameter the user does not override.

The framework also implements a Layered Configuration principle: configuration flows from SQL DDL properties through AsyncSinkConnectorOptions into the factory, then through the builder into the runtime sink. Each layer validates and transforms values appropriate to its level of abstraction.

Component Role Key Methods
AsyncDynamicTableSinkFactory Abstract factory for table sink creation optionalOptions(), addAsyncOptionsToBuilder()
AsyncSinkConnectorOptions Configuration option definitions Five static ConfigOption constants
AsyncDynamicTableSink Table sink wrapper for async sinks addAsyncOptionsToSinkBuilder()
AsyncDynamicTableSinkBuilder Fluent builder for table sinks setMaxBatchSize(), setMaxInFlightRequests(), build()

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment