This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 470b013e16e Refactor ClusterLockContext (#34170)
470b013e16e is described below
commit 470b013e16ebc84f017afc3a6d1dae2a198e14ad
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Dec 26 23:13:20 2024 +0800
Refactor ClusterLockContext (#34170)
---
.../mode/manager/cluster/lock/ClusterLockContext.java | 4 ++--
.../mode/manager/cluster/lock/ClusterLockContextTest.java | 10 +++++-----
2 files changed, 7 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 7bac7d79e61..2f51761835a 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
@@ -20,8 +20,8 @@ package org.apache.shardingsphere.mode.manager.cluster.lock;
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;
+import
org.apache.shardingsphere.mode.manager.cluster.persist.service.GlobalLockPersistService;
/**
* Cluster lock context.
@@ -29,7 +29,7 @@ import
org.apache.shardingsphere.mode.lock.global.GlobalLockDefinition;
@RequiredArgsConstructor
public final class ClusterLockContext implements LockContext {
- private final LockPersistService<GlobalLockDefinition>
globalLockPersistService;
+ private final GlobalLockPersistService globalLockPersistService;
@Override
public boolean tryLock(final LockDefinition lockDefinition, final long
timeoutMillis) {
diff --git
a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/lock/ClusterLockContextTest.java
b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/lock/ClusterLockContextTest.java
index 8b168bad457..1f5b3d304ad 100644
---
a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/lock/ClusterLockContextTest.java
+++
b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/lock/ClusterLockContextTest.java
@@ -17,9 +17,9 @@
package org.apache.shardingsphere.mode.manager.cluster.lock;
-import org.apache.shardingsphere.mode.lock.LockPersistService;
import org.apache.shardingsphere.mode.lock.global.GlobalLock;
import org.apache.shardingsphere.mode.lock.global.GlobalLockDefinition;
+import
org.apache.shardingsphere.mode.manager.cluster.persist.service.GlobalLockPersistService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -37,7 +37,7 @@ class ClusterLockContextTest {
private GlobalLock globalLock;
@Mock
- private LockPersistService<GlobalLockDefinition> lockPersistService;
+ private GlobalLockPersistService globalLockPersistService;
private GlobalLockDefinition lockDefinition;
@@ -47,18 +47,18 @@ class ClusterLockContextTest {
void init() {
when(globalLock.getName()).thenReturn("foo_lock");
lockDefinition = new GlobalLockDefinition(globalLock);
- lockContext = new ClusterLockContext(lockPersistService);
+ lockContext = new ClusterLockContext(globalLockPersistService);
}
@Test
void assertTryLock() {
- when(lockPersistService.tryLock(lockDefinition,
3000L)).thenReturn(true);
+ when(globalLockPersistService.tryLock(lockDefinition,
3000L)).thenReturn(true);
assertTrue(lockContext.tryLock(lockDefinition, 3000L));
}
@Test
void assertUnlock() {
lockContext.unlock(lockDefinition);
- verify(lockPersistService).unlock(lockDefinition);
+ verify(globalLockPersistService).unlock(lockDefinition);
}
}