This is an automated email from the ASF dual-hosted git repository.

sunnianjun 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 29ba2143193 Rename WorkerIdReservationNode (#31325)
29ba2143193 is described below

commit 29ba2143193358b2e21c8de4d8d0831bdeb74792
Author: Liang Zhang <[email protected]>
AuthorDate: Tue May 21 15:37:50 2024 +0800

    Rename WorkerIdReservationNode (#31325)
---
 .../workerid/generator/ClusterWorkerIdGenerator.java     |  4 ++--
 .../{WorkerIdNode.java => WorkerIdReservationNode.java}  | 16 +++++++++-------
 ...rIdNodeTest.java => WorkerIdReservationNodeTest.java} |  6 +++---
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git 
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/generator/ClusterWorkerIdGenerator.java
 
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/generator/ClusterWorkerIdGenerator.java
index 9d803b5de4c..48de6201d19 100644
--- 
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/generator/ClusterWorkerIdGenerator.java
+++ 
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/generator/ClusterWorkerIdGenerator.java
@@ -23,7 +23,7 @@ import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePrecondition
 import 
org.apache.shardingsphere.infra.instance.workerid.WorkerIdAssignedException;
 import org.apache.shardingsphere.infra.instance.workerid.WorkerIdGenerator;
 import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.service.ComputeNodeStatusService;
-import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.workerid.node.WorkerIdNode;
+import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.workerid.node.WorkerIdReservationNode;
 import 
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
 import 
org.apache.shardingsphere.mode.repository.cluster.exception.ClusterPersistRepositoryException;
 
@@ -83,7 +83,7 @@ public final class ClusterWorkerIdGenerator implements 
WorkerIdGenerator {
         Integer preselectedWorkerId = availableWorkerIds.poll();
         Preconditions.checkNotNull(preselectedWorkerId, "Preselected worker-id 
can not be null.");
         try {
-            
repository.persistExclusiveEphemeral(WorkerIdNode.getWorkerIdGeneratorPath(preselectedWorkerId),
 instanceId);
+            
repository.persistExclusiveEphemeral(WorkerIdReservationNode.getWorkerIdReservationPath(preselectedWorkerId),
 instanceId);
             return Optional.of(preselectedWorkerId);
         } catch (final ClusterPersistRepositoryException ignore) {
             return Optional.empty();
diff --git 
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/node/WorkerIdNode.java
 
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/node/WorkerIdReservationNode.java
similarity index 70%
rename from 
mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/node/WorkerIdNode.java
rename to 
mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/node/WorkerIdReservationNode.java
index 00264b9dc70..0cbfa6b6127 100644
--- 
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/node/WorkerIdNode.java
+++ 
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/node/WorkerIdReservationNode.java
@@ -21,20 +21,22 @@ import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 
 /**
- * Worker id node.
+ * Worker id reservation node.
  */
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class WorkerIdNode {
+public final class WorkerIdReservationNode {
     
-    private static final String ROOT_NODE = "worker_id";
+    private static final String ROOT_NODE = "reservation";
+    
+    private static final String WORKER_ID_NODE = "worker_id";
     
     /**
-     * Get worker id generator path.
+     * Get worker id reservation path.
      *
      * @param workerId worker id
-     * @return worker id generator path
+     * @return worker id reservation path
      */
-    public static String getWorkerIdGeneratorPath(final int workerId) {
-        return String.join("/", "", ROOT_NODE, String.valueOf(workerId));
+    public static String getWorkerIdReservationPath(final int workerId) {
+        return String.join("/", "", ROOT_NODE, WORKER_ID_NODE, 
String.valueOf(workerId));
     }
 }
diff --git 
a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/node/WorkerIdNodeTest.java
 
b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/node/WorkerIdReservationNodeTest.java
similarity index 84%
rename from 
mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/node/WorkerIdNodeTest.java
rename to 
mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/node/WorkerIdReservationNodeTest.java
index 313a9dcc297..07ec342f810 100644
--- 
a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/node/WorkerIdNodeTest.java
+++ 
b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/node/WorkerIdReservationNodeTest.java
@@ -22,10 +22,10 @@ import org.junit.jupiter.api.Test;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 
-class WorkerIdNodeTest {
+class WorkerIdReservationNodeTest {
     
     @Test
-    void assertGetWorkerIdGeneratorPath() {
-        assertThat(WorkerIdNode.getWorkerIdGeneratorPath(1), 
is("/worker_id/1"));
+    void assertGetWorkerIdReservationPath() {
+        assertThat(WorkerIdReservationNode.getWorkerIdReservationPath(1), 
is("/reservation/worker_id/1"));
     }
 }

Reply via email to