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 MetaDataContexts Container

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


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

Overview

Thread-safe container holding the runtime metadata and statistics contexts for a ShardingSphere instance.

Description

MetaDataContexts wraps ShardingSphereMetaData and ShardingSphereStatistics in AtomicReference objects for thread-safe access. It provides atomic update methods for both metadata and statistics, used throughout the ShardingSphere runtime when configurations change or metadata is refreshed.

Usage

This is the central runtime state object accessed by all components. It is created during context initialization and updated atomically when rule configurations, schemas, or statistics change.

Code Reference

Source Location

Signature

public final class MetaDataContexts {

    private final AtomicReference<ShardingSphereMetaData> metaData;
    private final AtomicReference<ShardingSphereStatistics> statistics;

    public MetaDataContexts(ShardingSphereMetaData metaData, ShardingSphereStatistics statistics);

    public ShardingSphereMetaData getMetaData();
    public ShardingSphereStatistics getStatistics();
    public void update(ShardingSphereMetaData metaData);
    public void update(ShardingSphereStatistics statistics);
}

Import

import org.apache.shardingsphere.mode.metadata.MetaDataContexts;

I/O Contract

Inputs

Name Type Required Description
metaData ShardingSphereMetaData Yes Runtime metadata (databases, rules, props)
statistics ShardingSphereStatistics Yes Runtime statistics data

Outputs

Name Type Description
getMetaData() ShardingSphereMetaData Current metadata reference
getStatistics() ShardingSphereStatistics Current statistics reference

Usage Examples

import org.apache.shardingsphere.mode.metadata.MetaDataContexts;

// Created during initialization
MetaDataContexts contexts = new MetaDataContexts(metaData, statistics);

// Thread-safe read
ShardingSphereMetaData currentMeta = contexts.getMetaData();

// Atomic update after rule change
contexts.update(newMetaData);

Related Pages

Page Connections

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