This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 09ce87f Split compute_nodes and storage_nodes, make the concept more
clear. (#12323)
09ce87f is described below
commit 09ce87f780977f0c4a566c74b33c5bb9dfb1e290
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Sep 10 06:49:31 2021 +0800
Split compute_nodes and storage_nodes, make the concept more clear. (#12323)
* Rename datanodes to storage_nodes
* Rename proxynodes to compute_nodes
---
.../governance/management/registry-center.cn.md | 14 ++++----
.../governance/management/registry-center.en.md | 16 ++++-----
.../lock/service/LockRegistryService.java | 2 +-
.../registry/status/node/StatusNode.java | 38 ++++++++--------------
.../service/InstanceStatusRegistryService.java | 4 +--
.../watcher/DataSourceStateChangedWatcher.java | 2 +-
.../watcher/TerminalStateChangedWatcher.java | 2 +-
.../registry/status/node/StatusNodeTest.java | 10 +++---
.../service/InstanceStatusRegistryServiceTest.java | 2 +-
.../watcher/DataSourceStateChangedWatcherTest.java | 2 +-
10 files changed, 41 insertions(+), 51 deletions(-)
diff --git
a/docs/document/content/features/governance/management/registry-center.cn.md
b/docs/document/content/features/governance/management/registry-center.cn.md
index ccccd38..3aba8b0 100644
--- a/docs/document/content/features/governance/management/registry-center.cn.md
+++ b/docs/document/content/features/governance/management/registry-center.cn.md
@@ -30,12 +30,12 @@ namespace
├ ├ ├──dataSources # 数据源配置
├ ├ ├──rules # 规则配置
├ ├ ├──schema # 表结构配置
- ├──states
- ├ ├──proxynodes
+ ├──status
+ ├ ├──compute_nodes
├ ├ ├──${your_instance_ip_a}@${your_instance_pid_x}@${UUID}
├ ├ ├──${your_instance_ip_b}@${your_instance_pid_y}@${UUID}
├ ├ ├──....
- ├ ├──datanodes
+ ├ ├──storage_nodes
├ ├ ├──${schema_1}
├ ├ ├ ├──${ds_0}
├ ├ ├ ├──${ds_1}
@@ -144,13 +144,13 @@ tables: # 表
primaryKey: false
```
-### /states/proxynodes
+### /status/compute_nodes
数据库访问对象运行实例信息,子节点是当前运行实例的标识。
运行实例标识由运行服务器的 IP 地址和 PID 构成。运行实例标识均为临时节点,当实例上线时注册,下线时自动清理。
注册中心监控这些节点的变化来治理运行中实例对数据库的访问等。
-### /states/datanodes
+### /status/storage_nodes
可以治理读写分离从库,可动态添加删除以及禁用。
@@ -167,7 +167,7 @@ tables: # 表
Zookeeper 命令如下:
```
-[zk: localhost:2181(CONNECTED) 0] set
/${your_zk_namespace}/states/proxynodes/${your_instance_ip_a}@${your_instance_pid_x}@${UUID}
DISABLED
+[zk: localhost:2181(CONNECTED) 0] set
/${your_zk_namespace}/status/compute_nodes/${your_instance_ip_a}@${your_instance_pid_x}@${UUID}
DISABLED
```
### 禁用从库
@@ -177,5 +177,5 @@ Zookeeper 命令如下:
Zookeeper 命令如下:
```
-[zk: localhost:2181(CONNECTED) 0] set
/${your_zk_namespace}/states/datanodes/${your_schema_name}/${your_replica_datasource_name}
DISABLED
+[zk: localhost:2181(CONNECTED) 0] set
/${your_zk_namespace}/status/storage_nodes/${your_schema_name}/${your_replica_datasource_name}
DISABLED
```
diff --git
a/docs/document/content/features/governance/management/registry-center.en.md
b/docs/document/content/features/governance/management/registry-center.en.md
index c536cdb..b247232 100644
--- a/docs/document/content/features/governance/management/registry-center.en.md
+++ b/docs/document/content/features/governance/management/registry-center.en.md
@@ -15,7 +15,7 @@ weight = 1
## Data Structure in Registry Center
-Under defined namespace, `rules`, `props` and `metadata` nodes persist in
YAML, modifying nodes can dynamically refresh configurations. `states` node
persist the runtime node of database access object, to distinguish different
database access instances.
+Under defined namespace, `rules`, `props` and `metadata` nodes persist in
YAML, modifying nodes can dynamically refresh configurations. `status` node
persist the runtime node of database access object, to distinguish different
database access instances.
```
namespace
@@ -30,12 +30,12 @@ namespace
├ ├ ├──dataSources # Datasource configuration
├ ├ ├──rules # Rule configuration
├ ├ ├──schema # Table configuration
- ├──states
- ├ ├──proxynodes
+ ├──status
+ ├ ├──compute_nodes
├ ├ ├──${your_instance_ip_a}@${your_instance_pid_x}@${UUID}
├ ├ ├──${your_instance_ip_b}@${your_instance_pid_y}@${UUID}
├ ├ ├──....
- ├ ├──datanodes
+ ├ ├──storage_nodes
├ ├ ├──${schema_1}
├ ├ ├ ├──${ds_0}
├ ├ ├ ├──${ds_1}
@@ -144,11 +144,11 @@ tables: # Tables
primaryKey: false
```
-### /states/proxynodes
+### /status/compute_nodes
It includes running instance information of database access object, with
sub-nodes as the identifiers of currently running instance, which consist of IP
and PID. Those identifiers are temporary nodes, which are registered when
instances are on-line and cleared when instances are off-line. The registry
center monitors the change of those nodes to govern the database access of
running instances and other things.
-### /states/datanodes
+### /status/storage_nodes
It is able to orchestrate replica database, delete or disable data dynamically.
@@ -165,7 +165,7 @@ Write `DISABLED` (case insensitive) to `IP@PID@UUID` to
disable that instance; d
Zookeeper command is as follows:
```
-[zk: localhost:2181(CONNECTED) 0] set
/${your_zk_namespace}/states/proxynodes/${your_instance_ip_a}@${your_instance_pid_x}@${UUID}
DISABLED
+[zk: localhost:2181(CONNECTED) 0] set
/${your_zk_namespace}/status/compute_nodes/${your_instance_ip_a}@${your_instance_pid_x}@${UUID}
DISABLED
```
### Disable Replica Database
@@ -175,5 +175,5 @@ Under replica query scenarios, users can write `DISABLED`
(case insensitive) to
Zookeeper command is as follows:
```
-[zk: localhost:2181(CONNECTED) 0] set
/${your_zk_namespace}/states/datanodes/${your_schema_name}/${your_replica_datasource_name}
DISABLED
+[zk: localhost:2181(CONNECTED) 0] set
/${your_zk_namespace}/status/storage_nodes/${your_schema_name}/${your_replica_datasource_name}
DISABLED
```
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/lock/service/LockRegistryService.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/lock/service/LockRegistryService.java
index 9b89e61..8d74fe5 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/lock/service/LockRegistryService.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/lock/service/LockRegistryService.java
@@ -111,7 +111,7 @@ public final class LockRegistryService {
}
private boolean checkAck(final String lockName, final String ackValue,
final long timeoutMilliseconds) {
- Collection<String> instanceIds =
repository.getChildrenKeys(StatusNode.getProxyNodesPath());
+ Collection<String> instanceIds =
repository.getChildrenKeys(StatusNode.getComputeNodesPath());
long checkMilliseconds = timeoutMilliseconds;
while (checkMilliseconds > 0) {
long start = System.currentTimeMillis();
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/node/StatusNode.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/node/StatusNode.java
index b485edb..fd27126 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/node/StatusNode.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/node/StatusNode.java
@@ -34,31 +34,31 @@ public final class StatusNode {
private static final String ROOT_NODE = "status";
- private static final String PROXY_NODE = "proxynodes";
+ private static final String COMPUTE_NODE = "compute_nodes";
- private static final String DATA_NODE = "datanodes";
+ private static final String STORAGE_NODE = "storage_nodes";
private static final String PRIMARY_NODE = "primarynodes";
private static final String PRIVILEGE_NODE = "privilegenode";
/**
- * Get proxy node path.
+ * Get compute node path.
*
* @param instanceId instance id
- * @return proxy node path
+ * @return compute node path
*/
- public static String getProxyNodePath(final String instanceId) {
- return Joiner.on("/").join("", ROOT_NODE, PROXY_NODE, instanceId);
+ public static String getComputeNodePath(final String instanceId) {
+ return Joiner.on("/").join("", ROOT_NODE, COMPUTE_NODE, instanceId);
}
/**
- * Get data nodes path.
+ * Get storage nodes path.
*
- * @return data nodes path
+ * @return storage nodes path
*/
- public static String getDataNodesPath() {
- return Joiner.on("/").join("", ROOT_NODE, DATA_NODE);
+ public static String getStorageNodePath() {
+ return Joiner.on("/").join("", ROOT_NODE, STORAGE_NODE);
}
/**
@@ -81,16 +81,6 @@ public final class StatusNode {
}
/**
- * Get primary nodes schema path.
- *
- * @param schemaName schema name
- * @return schema path
- */
- public static String getPrimaryNodesSchemaPath(final String schemaName) {
- return Joiner.on("/").join("", ROOT_NODE, PRIMARY_NODE, schemaName);
- }
-
- /**
* Get data source path.
*
* @param schemaName schema name
@@ -98,7 +88,7 @@ public final class StatusNode {
* @return data source path
*/
public static String getDataSourcePath(final String schemaName, final
String dataSourceName) {
- return Joiner.on("/").join("", ROOT_NODE, DATA_NODE, schemaName,
dataSourceName);
+ return Joiner.on("/").join("", ROOT_NODE, STORAGE_NODE, schemaName,
dataSourceName);
}
/**
@@ -119,7 +109,7 @@ public final class StatusNode {
* @return cluster schema
*/
public static Optional<ClusterSchema> getClusterSchema(final String
dataSourceNodeFullPath) {
- Pattern pattern = Pattern.compile(getDataNodesPath() + "/" +
"(\\w+)/(\\S+)$", Pattern.CASE_INSENSITIVE);
+ Pattern pattern = Pattern.compile(getStorageNodePath() + "/" +
"(\\w+)/(\\S+)$", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(dataSourceNodeFullPath);
return matcher.find() ? Optional.of(new
ClusterSchema(matcher.group(1), matcher.group(2))) : Optional.empty();
}
@@ -153,8 +143,8 @@ public final class StatusNode {
*
* @return proxy nodes path
*/
- public static String getProxyNodesPath() {
- return Joiner.on("/").join("", ROOT_NODE, PROXY_NODE);
+ public static String getComputeNodesPath() {
+ return Joiner.on("/").join("", ROOT_NODE, COMPUTE_NODE);
}
/**
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/service/InstanceStatusRegistryService.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/service/InstanceStatusRegistryService.java
index 542b659..c28ec7a 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/service/InstanceStatusRegistryService.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/service/InstanceStatusRegistryService.java
@@ -35,8 +35,8 @@ public final class InstanceStatusRegistryService {
* @param instanceId instance ID
*/
public void registerInstanceOnline(final String instanceId) {
- repository.persist(StatusNode.getDataNodesPath(), "");
+ repository.persist(StatusNode.getStorageNodePath(), "");
repository.persist(StatusNode.getPrimaryNodesPath(), "");
- repository.persistEphemeral(StatusNode.getProxyNodePath(instanceId),
"");
+ repository.persistEphemeral(StatusNode.getComputeNodePath(instanceId),
"");
}
}
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/watcher/DataSourceStateChangedWatcher.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/watcher/DataSourceStateChangedWatcher.java
index bbc96eb..e7bbe7c 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/watcher/DataSourceStateChangedWatcher.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/watcher/DataSourceStateChangedWatcher.java
@@ -37,7 +37,7 @@ public final class DataSourceStateChangedWatcher implements
GovernanceWatcher<Go
@Override
public Collection<String> getWatchingKeys() {
- return Arrays.asList(StatusNode.getPrimaryNodesPath(),
StatusNode.getDataNodesPath());
+ return Arrays.asList(StatusNode.getPrimaryNodesPath(),
StatusNode.getStorageNodePath());
}
@Override
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/watcher/TerminalStateChangedWatcher.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/watcher/TerminalStateChangedWatcher.java
index 1ae0efc..dab33e6 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/watcher/TerminalStateChangedWatcher.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/watcher/TerminalStateChangedWatcher.java
@@ -35,7 +35,7 @@ public final class TerminalStateChangedWatcher implements
GovernanceWatcher<Stat
@Override
public Collection<String> getWatchingKeys() {
- return Collections.singleton(StatusNode.getProxyNodesPath());
+ return Collections.singleton(StatusNode.getComputeNodesPath());
}
@Override
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/node/StatusNodeTest.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/node/StatusNodeTest.java
index d27392a..d6c6df8 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/node/StatusNodeTest.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/node/StatusNodeTest.java
@@ -30,17 +30,17 @@ public final class StatusNodeTest {
@Test
public void assertGetProxyNodePath() {
- assertThat(StatusNode.getProxyNodePath("testId"),
is("/status/proxynodes/testId"));
+ assertThat(StatusNode.getComputeNodePath("testId"),
is("/status/compute_nodes/testId"));
}
@Test
public void assertGetDataNodesPath() {
- assertThat(StatusNode.getDataNodesPath(), is("/status/datanodes"));
+ assertThat(StatusNode.getStorageNodePath(),
is("/status/storage_nodes"));
}
@Test
public void assertGetClusterSchema() {
- Optional<ClusterSchema> actual =
StatusNode.getClusterSchema("/status/datanodes/replica_query_db/replica_ds_0");
+ Optional<ClusterSchema> actual =
StatusNode.getClusterSchema("/status/storage_nodes/replica_query_db/replica_ds_0");
assertTrue(actual.isPresent());
assertThat(actual.get().getSchemaName(), is("replica_query_db"));
assertThat(actual.get().getDataSourceName(), is("replica_ds_0"));
@@ -48,7 +48,7 @@ public final class StatusNodeTest {
@Test
public void assertGetClusterSchemaForIpDataSourceName() {
- Optional<ClusterSchema> actual =
StatusNode.getClusterSchema("/status/datanodes/replica_query_db/127.0.0.1");
+ Optional<ClusterSchema> actual =
StatusNode.getClusterSchema("/status/storage_nodes/replica_query_db/127.0.0.1");
assertTrue(actual.isPresent());
assertThat(actual.get().getSchemaName(), is("replica_query_db"));
assertThat(actual.get().getDataSourceName(), is("127.0.0.1"));
@@ -56,7 +56,7 @@ public final class StatusNodeTest {
@Test
public void assertGetDataSourcePath() {
- assertThat(StatusNode.getDataSourcePath("replica_query_db",
"replica_ds_0"), is("/status/datanodes/replica_query_db/replica_ds_0"));
+ assertThat(StatusNode.getDataSourcePath("replica_query_db",
"replica_ds_0"), is("/status/storage_nodes/replica_query_db/replica_ds_0"));
}
@Test
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/service/InstanceStatusRegistryServiceTest.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/service/InstanceStatusRegistryServiceTest.java
index fc4ca01..40ce418 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/service/InstanceStatusRegistryServiceTest.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/service/InstanceStatusRegistryServiceTest.java
@@ -35,7 +35,7 @@ public final class InstanceStatusRegistryServiceTest {
@Test
public void assertRegisterInstanceOnline() {
new
InstanceStatusRegistryService(repository).registerInstanceOnline("foo");
- verify(repository).persist("/status/datanodes", "");
+ verify(repository).persist("/status/storage_nodes", "");
verify(repository).persist("/status/primarynodes", "");
verify(repository).persistEphemeral(anyString(), anyString());
}
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/watcher/DataSourceStateChangedWatcherTest.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/watcher/DataSourceStateChangedWatcherTest.java
index e20856c..a0aea7f 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/watcher/DataSourceStateChangedWatcherTest.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/watcher/DataSourceStateChangedWatcherTest.java
@@ -35,7 +35,7 @@ public final class DataSourceStateChangedWatcherTest {
@Test
public void assertCreateEvent() {
Optional<GovernanceEvent> actual = new
DataSourceStateChangedWatcher().createGovernanceEvent(
- new
DataChangedEvent("/status/datanodes/replica_query_db/replica_ds_0", "disabled",
Type.UPDATED));
+ new
DataChangedEvent("/status/storage_nodes/replica_query_db/replica_ds_0",
"disabled", Type.UPDATED));
assertTrue(actual.isPresent());
assertThat(((DisabledStateChangedEvent)
actual.get()).getClusterSchema().getSchemaName(), is(new
ClusterSchema("replica_query_db", "replica_ds_0").getSchemaName()));
}