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 ExclusiveOperatorEngine Execute

From Leeroopedia


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

Overview

Engine for executing operations under exclusive distributed locks with timeout handling.

Description

ExclusiveOperatorEngine manages the execution of operations that require exclusive access in a ShardingSphere deployment. It acquires an exclusive lock from ExclusiveOperatorContext, executes a callback, and releases the lock afterward. Supports both void callbacks and callbacks that return a result. Uses ExclusiveOperationNodePath to define the lock scope.

Usage

Use this engine when performing operations that must be mutually exclusive across nodes, such as metadata schema changes or storage unit modifications.

Code Reference

Source Location

Signature

@RequiredArgsConstructor
public final class ExclusiveOperatorEngine {

    private final ExclusiveOperatorContext exclusiveOperatorContext;

    public void executeInExclusive(ExclusiveOperation operation, ExclusiveOperationVoidCallback callback);

    public <T> T executeInExclusive(ExclusiveOperation operation, ExclusiveOperationCallback<T> callback);
}

Import

import org.apache.shardingsphere.mode.exclusive.ExclusiveOperatorEngine;

I/O Contract

Inputs

Name Type Required Description
operation ExclusiveOperation Yes Defines the operation scope and lock path
callback ExclusiveOperationVoidCallback or ExclusiveOperationCallback<T> Yes The operation to execute under lock

Outputs

Name Type Description
void or T — or generic type Void for void callbacks; returns result for typed callbacks

Usage Examples

ExclusiveOperatorEngine engine = new ExclusiveOperatorEngine(exclusiveOperatorContext);

// Void exclusive operation
engine.executeInExclusive(new RefreshStatisticsOperation(), () -> {
    // Critical section: only one node executes at a time
    statisticsManager.refreshAll();
});

// Exclusive operation with return value
boolean result = engine.executeInExclusive(new RefreshStatisticsOperation(), () -> {
    return statisticsManager.tryRefresh();
});

Related Pages

Page Connections

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