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.

Implementation:Apache Shardingsphere MetaDataManagerPersistService Contract

From Leeroopedia
Revision as of 14:24, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Apache_Shardingsphere_MetaDataManagerPersistService_Contract.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Persistence, SPI
Last Updated 2026-02-10 00:00 GMT

Overview

MetaDataManagerPersistService defines the SPI interface contract for all metadata persistence operations including database, schema, table, view, storage unit, and rule configuration management.

Description

MetaDataManagerPersistService is an interface in the mode/core module that declares methods for creating, dropping, altering, and renaming databases, schemas, tables, and views. It also provides methods for registering, altering, and unregistering storage units, as well as altering and removing rule configurations at both database and global levels. Implementations of this interface handle how configuration changes are initiated and persisted in different modes (standalone vs. cluster).

Usage

Use this interface as an SPI contract when implementing mode-specific metadata persistence. Standalone and cluster modes each provide their own implementation. Invoke these methods when processing DistSQL commands or DDL operations that require metadata changes to be persisted.

Code Reference

Source Location

Signature

public interface MetaDataManagerPersistService {

    void createDatabase(String databaseName);
    void dropDatabase(ShardingSphereDatabase database);
    void createSchema(ShardingSphereDatabase database, String schemaName);
    void renameSchema(ShardingSphereDatabase database, String schemaName, String renameSchemaName);
    void dropSchema(ShardingSphereDatabase database, Collection<String> schemaNames);
    void createTable(ShardingSphereDatabase database, String schemaName, ShardingSphereTable table);
    void dropTables(ShardingSphereDatabase database, String schemaName, Collection<String> tableNames);
    void alterTables(ShardingSphereDatabase database, String schemaName, Collection<ShardingSphereTable> alteredTables);
    void alterViews(ShardingSphereDatabase database, String schemaName, Collection<ShardingSphereView> alteredViews);
    void dropViews(ShardingSphereDatabase database, String schemaName, Collection<String> droppedViews);
    void registerStorageUnits(String databaseName, Map<String, DataSourcePoolProperties> toBeRegisteredProps);
    void alterStorageUnits(ShardingSphereDatabase database, Map<String, DataSourcePoolProperties> toBeUpdatedProps);
    void unregisterStorageUnits(ShardingSphereDatabase database, Collection<String> toBeDroppedStorageUnitNames);
    void alterSingleRuleConfiguration(ShardingSphereDatabase database, RuleMetaData ruleMetaData);
    void alterRuleConfiguration(ShardingSphereDatabase database, RuleConfiguration toBeAlteredRuleConfig);
    void removeRuleConfigurationItem(ShardingSphereDatabase database, RuleConfiguration toBeRemovedRuleItemConfig);
    void removeRuleConfiguration(ShardingSphereDatabase database, RuleConfiguration toBeRemovedRuleConfig, String ruleType);
    void alterGlobalRuleConfiguration(RuleConfiguration globalRuleConfig);
    void alterProperties(Properties props);
}

Import

import org.apache.shardingsphere.mode.persist.service.MetaDataManagerPersistService;

I/O Contract

Inputs

Name Type Required Description
databaseName String Yes Name of the database to create or target
database ShardingSphereDatabase Yes Database object for operations requiring existing database context
schemaName String Yes Schema name for schema/table/view operations
table ShardingSphereTable Yes Table metadata for create operations
toBeRegisteredProps Map<String, DataSourcePoolProperties> Yes Storage unit properties for registration
toBeAlteredRuleConfig RuleConfiguration Yes Rule configuration to alter
props Properties Yes System properties to alter

Outputs

Name Type Description
void void All methods are void; side effects are persisted to the repository

Usage Examples

// Create a new database via the persist service
metaDataManagerPersistService.createDatabase("new_database");

// Register storage units
Map<String, DataSourcePoolProperties> props = new HashMap<>();
props.put("ds_0", dataSourcePoolProperties);
metaDataManagerPersistService.registerStorageUnits("my_database", props);

// Alter a rule configuration
metaDataManagerPersistService.alterRuleConfiguration(database, shardingRuleConfig);

Related Pages

Page Connections

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