This is an automated email from the ASF dual-hosted git repository.
menghaoran 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 faaa9f6 Inline cluster instance for
ComputeNodeStatusService.registerOnline (#12577)
faaa9f6 is described below
commit faaa9f6f9a094475b890192d0edef1aa7346d981
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Sep 19 07:09:22 2021 +0800
Inline cluster instance for ComputeNodeStatusService.registerOnline (#12577)
---
.../mode/manager/cluster/coordinator/RegistryCenter.java | 2 +-
.../registry/status/compute/service/ComputeNodeStatusService.java | 7 +++----
.../status/compute/service/ComputeNodeStatusServiceTest.java | 5 ++---
3 files changed, 6 insertions(+), 8 deletions(-)
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/RegistryCenter.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/RegistryCenter.java
index 112ec69..2644394 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/RegistryCenter.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/RegistryCenter.java
@@ -70,7 +70,7 @@ public final class RegistryCenter {
* Online instance.
*/
public void onlineInstance() {
-
computeNodeStatusService.registerOnline(ClusterInstance.getInstance().getId());
+ computeNodeStatusService.registerOnline();
listenerFactory.watchListeners();
}
}
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusService.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusService.java
index d80a199..734dcbd 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusService.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusService.java
@@ -18,6 +18,7 @@
package
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.service;
import lombok.RequiredArgsConstructor;
+import
org.apache.shardingsphere.mode.manager.cluster.coordinator.ClusterInstance;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.ComputeNodeStatus;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.node.ComputeStatusNode;
import
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
@@ -32,10 +33,8 @@ public final class ComputeNodeStatusService {
/**
* Register online.
- *
- * @param instanceId instance ID
*/
- public void registerOnline(final String instanceId) {
-
repository.persistEphemeral(ComputeStatusNode.getStatusPath(ComputeNodeStatus.ONLINE,
instanceId), "");
+ public void registerOnline() {
+
repository.persistEphemeral(ComputeStatusNode.getStatusPath(ComputeNodeStatus.ONLINE,
ClusterInstance.getInstance().getId()), "");
}
}
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusServiceTest.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusServi
[...]
index d4b31ae..cb72476 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusServiceTest.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusServiceTest.java
@@ -23,7 +23,6 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
-import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.verify;
@RunWith(MockitoJUnitRunner.class)
@@ -34,7 +33,7 @@ public final class ComputeNodeStatusServiceTest {
@Test
public void assertRegisterOnline() {
- new ComputeNodeStatusService(repository).registerOnline("foo");
- verify(repository).persistEphemeral(anyString(), anyString());
+ new ComputeNodeStatusService(repository).registerOnline();
+
verify(repository).persistEphemeral("/status/compute_nodes/online/null", "");
}
}