From df3eb8b7b6e32fe286f1a74c6674d3ec9b4bb5ae Mon Sep 17 00:00:00 2001 From: zhangliang Date: Tue, 24 Dec 2024 22:01:23 +0800 Subject: [PATCH] Rename global lock's key from /lock/exclusive/locks to /lock/global/locks --- .../shardingsphere/mode/lock/global/GlobalLockDefinition.java | 2 +- .../mode/lock/global/GlobalLockDefinitionTest.java | 2 +- .../cluster/persist/service/GlobalLockPersistServiceTest.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/lock/global/GlobalLockDefinition.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/lock/global/GlobalLockDefinition.java index 76376151d59f1..77f2d032c7af1 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/lock/global/GlobalLockDefinition.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/lock/global/GlobalLockDefinition.java @@ -26,7 +26,7 @@ @Getter public final class GlobalLockDefinition implements LockDefinition { - private static final String KEY_PATTERN = "/lock/exclusive/locks/%s"; + private static final String KEY_PATTERN = "/lock/global/locks/%s"; private final String lockKey; diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/lock/global/GlobalLockDefinitionTest.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/lock/global/GlobalLockDefinitionTest.java index 82ee55f24a609..ee6bb5b62f6da 100644 --- a/mode/core/src/test/java/org/apache/shardingsphere/mode/lock/global/GlobalLockDefinitionTest.java +++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/lock/global/GlobalLockDefinitionTest.java @@ -30,6 +30,6 @@ class GlobalLockDefinitionTest { void assertGetLockKey() { GlobalLock globalLock = mock(GlobalLock.class); when(globalLock.getName()).thenReturn("foo_lock"); - assertThat(new GlobalLockDefinition(globalLock).getLockKey(), is("/lock/exclusive/locks/foo_lock")); + assertThat(new GlobalLockDefinition(globalLock).getLockKey(), is("/lock/global/locks/foo_lock")); } } diff --git a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/persist/service/GlobalLockPersistServiceTest.java b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/persist/service/GlobalLockPersistServiceTest.java index 6a34617d5b2bf..ddc86c196835c 100644 --- a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/persist/service/GlobalLockPersistServiceTest.java +++ b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/persist/service/GlobalLockPersistServiceTest.java @@ -47,7 +47,7 @@ void setUp() { @Test void assertTryLock() { - when(repository.getDistributedLockHolder().getDistributedLock("/lock/exclusive/locks/foo_lock").tryLock(1000L)).thenReturn(true); + when(repository.getDistributedLockHolder().getDistributedLock("/lock/global/locks/foo_lock").tryLock(1000L)).thenReturn(true); GlobalLockDefinition lockDefinition = new GlobalLockDefinition(globalLock); assertTrue(new GlobalLockPersistService(repository).tryLock(lockDefinition, 1000L)); } @@ -56,6 +56,6 @@ void assertTryLock() { void assertUnlock() { GlobalLockDefinition lockDefinition = new GlobalLockDefinition(globalLock); new GlobalLockPersistService(repository).unlock(lockDefinition); - verify(repository.getDistributedLockHolder().getDistributedLock("/lock/exclusive/locks/foo_lock")).unlock(); + verify(repository.getDistributedLockHolder().getDistributedLock("/lock/global/locks/foo_lock")).unlock(); } }