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 ResourceSwitchManager Switch

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


Knowledge Sources
Domains Mode_Management, Data_Source
Last Updated 2026-02-10 00:00 GMT

Overview

Utility class that creates resource switching transitions for registering, altering, and unregistering storage units.

Description

ResourceSwitchManager provides static-like utility methods for building SwitchingResource objects from storage unit operations. Each method takes the current database context and the desired changes, then produces a SwitchingResource containing the new data source map, stale data sources to close, and updated storage unit properties.

Usage

Called by StorageUnitManager when processing storage unit registration, alteration, or unregistration requests.

Code Reference

Source Location

Signature

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ResourceSwitchManager {

    public static SwitchingResource registerStorageUnit(ResourceMetaData resourceMetaData,
        Map<String, DataSourcePoolProperties> toBeRegistered);

    public static SwitchingResource alterStorageUnit(ResourceMetaData resourceMetaData,
        Map<String, DataSourcePoolProperties> toBeAltered);

    public static SwitchingResource unregisterStorageUnit(ResourceMetaData resourceMetaData,
        Collection<String> toBeDropped);
}

Import

import org.apache.shardingsphere.mode.metadata.manager.resource.ResourceSwitchManager;

I/O Contract

Inputs

Name Type Required Description
resourceMetaData ResourceMetaData Yes Current resource metadata state
toBeRegistered/toBeAltered Map<String, DataSourcePoolProperties> Varies Storage units to register or alter
toBeDropped Collection<String> Varies Storage unit names to unregister

Outputs

Name Type Description
returns SwitchingResource Contains new data sources, stale data sources, and updated properties

Usage Examples

// Register new storage units
SwitchingResource switching = ResourceSwitchManager.registerStorageUnit(
    database.getResourceMetaData(), newStorageUnits);

// Apply the switching result
database.switchResource(switching);

Related Pages

Page Connections

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