From a3faa2b30a9d266f94b05c2afad3638aa02378b0 Mon Sep 17 00:00:00 2001 From: zhangliang Date: Sun, 22 Dec 2024 11:54:46 +0800 Subject: [PATCH] Refactor ClusterLockContext --- .../manager/cluster/lock/ClusterLockContext.java | 13 +++++++------ .../standalone/lock/StandaloneLockContext.java | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/lock/ClusterLockContext.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/lock/ClusterLockContext.java index 533642f862d21..10e978989b8d0 100644 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/lock/ClusterLockContext.java +++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/lock/ClusterLockContext.java @@ -19,24 +19,25 @@ import lombok.RequiredArgsConstructor; import org.apache.shardingsphere.infra.lock.LockContext; +import org.apache.shardingsphere.infra.lock.LockDefinition; import org.apache.shardingsphere.mode.lock.LockPersistService; import org.apache.shardingsphere.mode.lock.global.GlobalLockDefinition; /** - * Cluster global lock context. + * Cluster lock context. */ @RequiredArgsConstructor -public final class ClusterLockContext implements LockContext { +public final class ClusterLockContext implements LockContext { private final LockPersistService globalLockPersistService; @Override - public boolean tryLock(final GlobalLockDefinition lockDefinition, final long timeoutMillis) { - return globalLockPersistService.tryLock(lockDefinition, timeoutMillis); + public boolean tryLock(final LockDefinition lockDefinition, final long timeoutMillis) { + return globalLockPersistService.tryLock((GlobalLockDefinition) lockDefinition, timeoutMillis); } @Override - public void unlock(final GlobalLockDefinition lockDefinition) { - globalLockPersistService.unlock(lockDefinition); + public void unlock(final LockDefinition lockDefinition) { + globalLockPersistService.unlock((GlobalLockDefinition) lockDefinition); } } diff --git a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/lock/StandaloneLockContext.java b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/lock/StandaloneLockContext.java index f790342744e1b..6b5e5a603dff1 100644 --- a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/lock/StandaloneLockContext.java +++ b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/lock/StandaloneLockContext.java @@ -21,7 +21,7 @@ import org.apache.shardingsphere.infra.lock.LockDefinition; /** - * Standalone global lock context. + * Standalone lock context. */ public final class StandaloneLockContext implements LockContext {