Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Risingwavelabs Risingwave DatabaseValidator

From Leeroopedia


Knowledge Sources
Domains Connectors, CDC, Validation
Last Updated 2026-02-09 07:00 GMT

Overview

Abstract base class defining the template method pattern for CDC source database validation.

Description

The DatabaseValidator class provides the foundational validation framework for all database-specific CDC source validators. It defines four abstract methods that subclasses must implement:

  • validateDbConfig() -- Validates the configuration and connectivity of the upstream database.
  • validateUserPrivilege() -- Validates that the configured user has the required privileges for CDC replication.
  • validateTable() -- Validates the properties and schema of the source table.
  • isCdcSourceJob() -- Returns whether the validation is for a shared CDC source job (which captures events from multiple tables).

The concrete validateAll() method orchestrates these checks in sequence: database config first, then user privileges, and finally table validation (skipped for CDC source jobs since they capture from multiple tables and individual table schema validation is not applicable).

Usage

This class is extended by database-specific validators: PostgresValidator, MySqlValidator, SqlServerValidator, CitusValidator, and MongoDbValidator. The SourceValidateHandler creates the appropriate subclass and calls validateAll().

Code Reference

Source Location

  • Repository: risingwave
  • File: java/connector-node/risingwave-connector-service/src/main/java/com/risingwave/connector/source/common/DatabaseValidator.java
  • Lines: 42

Signature

public abstract class DatabaseValidator {

    public void validateAll() { ... }

    /** Validate the config of the upstream database */
    abstract void validateDbConfig();

    /** Validate the required privileges to start the connector */
    abstract void validateUserPrivilege();

    /** Validate the properties of the source table */
    abstract void validateTable();

    /** Check if the validation is for CDC source job */
    abstract boolean isCdcSourceJob();
}

Import

import com.risingwave.connector.source.common.DatabaseValidator;

I/O Contract

Inputs

Name Type Required Description
(constructor arguments) Varies by subclass Yes Each subclass receives database connection properties, table schema, and CDC source job flag

Outputs

Name Type Description
(void) -- validateAll() returns void on success
Exception RuntimeException / StatusRuntimeException Thrown if any validation step fails, with a descriptive error message

Validation Sequence

The validateAll() method executes the following steps:

  1. Call validateDbConfig() to verify database connectivity and configuration.
  2. Call validateUserPrivilege() to verify replication permissions.
  3. If isCdcSourceJob() returns false, call validateTable() to verify table schema compatibility.

Usage Examples

Subclass Implementation Pattern

public class PostgresValidator extends DatabaseValidator implements AutoCloseable {
    @Override
    void validateDbConfig() {
        // Check PostgreSQL WAL level, replication slot, etc.
    }

    @Override
    void validateUserPrivilege() {
        // Check replication role privilege
    }

    @Override
    void validateTable() {
        // Check table existence and column schema compatibility
    }

    @Override
    boolean isCdcSourceJob() {
        return this.isCdcSourceJob;
    }
}

Related Pages

Implements Principle

Requires Environment

Related Implementations

Page Connections

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