Implementation:Apache Shardingsphere VersionNodePath Resolve
| Knowledge Sources | |
|---|---|
| Domains | Mode_Management, Registry_Path |
| Last Updated | 2026-02-10 00:00 GMT |
Overview
VersionNodePath provides version-related path operations for resolving active version paths and version history paths within the registry.
Description
VersionNodePath is a final class that wraps a NodePath and uses NodePathGenerator to produce a base path string. It appends active_version or versions segments to construct paths for querying the current active version and version history. The class also provides pattern-based matching methods to determine whether a given path corresponds to an active version path or a versions path using regex matching.
Usage
Use this class when working with versioned configuration items in the registry. It is used during configuration change processing to resolve where version data is stored and to determine if incoming event paths relate to version changes.
Code Reference
Source Location
- Repository: Apache_Shardingsphere
- File: VersionNodePath.java
- Lines: 1-95
Signature
public final class VersionNodePath {
public VersionNodePath(final NodePath nodePath)
public String getActiveVersionPath()
public String getVersionsPath()
public String getVersionPath(final int version)
public boolean isActiveVersionPath(final String path)
public boolean isVersionsPath(final String path)
}
Import
import org.apache.shardingsphere.mode.node.path.version.VersionNodePath;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| nodePath | NodePath | Yes | Base node path to derive version paths from |
| version | int | Yes | Specific version number for getVersionPath |
| path | String | Yes | Path to check against for matching methods |
Outputs
| Name | Type | Description |
|---|---|---|
| activeVersionPath | String | Path ending with /active_version |
| versionsPath | String | Path ending with /versions |
| versionPath | String | Path ending with /versions/{version} |
| isActiveVersionPath | boolean | Whether path matches the active version pattern |
| isVersionsPath | boolean | Whether path matches the versions pattern |
Usage Examples
// Create version path from a node path
VersionNodePath versionNodePath = new VersionNodePath(databaseRuleNodePath);
// Get the active version path
String activeVersionPath = versionNodePath.getActiveVersionPath();
// e.g., "/metadata/my_db/rules/sharding/tables/t_order/active_version"
// Get a specific version path
String v1Path = versionNodePath.getVersionPath(1);
// e.g., "/metadata/my_db/rules/sharding/tables/t_order/versions/1"
// Check if an event path is an active version change
boolean isActiveVersion = versionNodePath.isActiveVersionPath(event.getKey());