Implementation:Apache Shardingsphere ShowProcessListHandler Handle
| Knowledge Sources | |
|---|---|
| Domains | Cluster, Process_Management |
| Last Updated | 2026-02-10 00:00 GMT |
Overview
ShowProcessListHandler handles distributed show process list events by collecting local process information for matching cluster instances.
Description
ShowProcessListHandler implements GlobalDataChangedEventHandler and subscribes to ShowProcessListTriggerNodePath for ADDED and DELETED event types. On an ADDED event, it extracts the instance ID and process ID (task ID) from the event path. If the local instance matches, it delegates to ClusterProcessPersistCoordinator.reportLocalProcesses to persist local process information into the shared repository under the task ID. On a DELETED event, it notifies ProcessOperationLockRegistry to release any waiting locks, signaling the requesting node that process collection is complete.
Usage
This handler is auto-loaded via SPI in cluster mode. When a SHOW PROCESSLIST command is executed, trigger paths are persisted for all online instances. Each instance's handler responds by reporting its local processes, enabling the requesting node to aggregate results from all cluster members.
Code Reference
Source Location
- Repository: Apache_Shardingsphere
- File: ShowProcessListHandler.java
- Lines: 1-67
Signature
public final class ShowProcessListHandler implements GlobalDataChangedEventHandler {
public NodePath getSubscribedNodePath()
public Collection<Type> getSubscribedTypes()
public void handle(final ContextManager contextManager, final DataChangedEvent event)
}
Import
import org.apache.shardingsphere.mode.manager.cluster.dispatch.handler.global.node.process.ShowProcessListHandler;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| contextManager | ContextManager | Yes | Provides access to instance context and persist services |
| event | DataChangedEvent | Yes | Contains the event key (path), value, and type (ADDED/DELETED) |
Outputs
| Name | Type | Description |
|---|---|---|
| void | void | Side effects: reports local processes to the shared repository or notifies lock registry |
Usage Examples
// Trigger show process list by persisting trigger paths for all online instances:
String triggerPath = NodePathGenerator.toPath(
new ShowProcessListTriggerNodePath(new InstanceProcessNodeValue(instanceId, taskId)));
repository.persist(triggerPath, "");
// Each instance's ShowProcessListHandler reports its local processes under the taskId path.