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 eea363a  Add instance type for compute node in registry center (#14535)
eea363a is described below

commit eea363a585894c8d2f55a1941f4e23d80492160e
Author: Haoran Meng <[email protected]>
AuthorDate: Wed Jan 5 15:26:22 2022 +0800

    Add instance type for compute node in registry center (#14535)
    
    * Add instance type for compute node in registry center
    
    * Add instance type for compute node in registry center
    
    Co-authored-by: menghaoran <[email protected]>
---
 .../shardingsphere/infra/instance/InstanceType.java | 21 ++++-----------------
 .../core/datasource/ShardingSphereDataSource.java   |  3 ++-
 .../manager/ContextManagerBuilderParameter.java     |  3 +++
 .../metadata/persist/MetaDataPersistService.java    | 20 ++++++++++----------
 .../mode/metadata/persist/node/ComputeNode.java     | 12 ++++++++----
 .../persist/service/ComputeNodePersistService.java  |  8 +++++---
 .../cluster/ClusterContextManagerBuilder.java       |  6 +++---
 .../manager/cluster/coordinator/RegistryCenter.java |  7 +++++--
 .../compute/service/ComputeNodeStatusService.java   |  7 +++++--
 .../ClusterContextManagerCoordinatorTest.java       |  3 ++-
 .../service/ComputeNodeStatusServiceTest.java       |  5 +++--
 .../proxy/initializer/BootstrapInitializer.java     |  4 +++-
 12 files changed, 53 insertions(+), 46 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/registry/status/compute/service/ComputeNodeStatusService.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/InstanceType.java
similarity index 53%
copy from 
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
copy to 
shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/InstanceType.java
index 0a0a544..605ac17 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-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/InstanceType.java
@@ -15,25 +15,12 @@
  * limitations under the License.
  */
 
-package 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.service;
-
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.instance.Instance;
-import org.apache.shardingsphere.mode.metadata.persist.node.ComputeNode;
-import 
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
+package org.apache.shardingsphere.infra.instance;
 
 /**
- * Compute node status service.
+ * Instance type.
  */
-@RequiredArgsConstructor
-public final class ComputeNodeStatusService {
-    
-    private final ClusterPersistRepository repository;
+public enum InstanceType {
     
-    /**
-     * Register online.
-     */
-    public void registerOnline() {
-        
repository.persistEphemeral(ComputeNode.getOnlineInstanceNodePath(Instance.getInstance().getId()),
 "");
-    }
+    PROXY, JDBC
 }
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
 
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
index 3db3041..7e9b455 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
@@ -25,6 +25,7 @@ import 
org.apache.shardingsphere.infra.config.checker.RuleConfigurationCheckerFa
 import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
 import org.apache.shardingsphere.infra.config.scope.GlobalRuleConfiguration;
 import org.apache.shardingsphere.infra.config.scope.SchemaRuleConfiguration;
+import org.apache.shardingsphere.infra.instance.InstanceType;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.mode.manager.ContextManagerBuilderFactory;
 import org.apache.shardingsphere.mode.manager.ContextManagerBuilderParameter;
@@ -74,7 +75,7 @@ public final class ShardingSphereDataSource extends 
AbstractDataSourceAdapter im
                 schemaName, ruleConfigs.stream().filter(each -> each 
instanceof SchemaRuleConfiguration).collect(Collectors.toList()));
         Collection<RuleConfiguration> globalRuleConfigs = 
ruleConfigs.stream().filter(each -> each instanceof 
GlobalRuleConfiguration).collect(Collectors.toList());
         ContextManagerBuilderParameter parameter = 
ContextManagerBuilderParameter.builder().modeConfig(modeConfig).dataSourcesMap(dataSourcesMap).schemaRuleConfigs(schemaRuleConfigs)
-                
.globalRuleConfigs(globalRuleConfigs).props(props).isOverwrite(isOverwrite).schemaName(schemaName).build();
+                
.globalRuleConfigs(globalRuleConfigs).props(props).isOverwrite(isOverwrite).schemaName(schemaName).instanceType(InstanceType.JDBC).build();
         return 
ContextManagerBuilderFactory.newInstance(modeConfig).build(parameter);
     }
     
diff --git 
a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameter.java
 
b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameter.java
index e3ef3cb..fe7bdcc 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameter.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameter.java
@@ -21,6 +21,7 @@ import lombok.Builder;
 import lombok.Getter;
 import org.apache.shardingsphere.infra.config.RuleConfiguration;
 import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
+import org.apache.shardingsphere.infra.instance.InstanceType;
 
 import javax.sql.DataSource;
 import java.util.Collection;
@@ -51,4 +52,6 @@ public final class ContextManagerBuilderParameter {
     private String schemaName;
     
     private Collection<String> labels;
+    
+    private InstanceType instanceType;
 }
diff --git 
a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/MetaDataPersistService.java
 
b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/MetaDataPersistService.java
index 90083c4..a964642 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/MetaDataPersistService.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/MetaDataPersistService.java
@@ -22,7 +22,7 @@ import 
org.apache.shardingsphere.authority.config.AuthorityRuleConfiguration;
 import org.apache.shardingsphere.infra.config.RuleConfiguration;
 import 
org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
 import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
-import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
+import org.apache.shardingsphere.infra.instance.InstanceType;
 import 
org.apache.shardingsphere.mode.metadata.persist.service.ComputeNodePersistService;
 import 
org.apache.shardingsphere.mode.metadata.persist.service.SchemaMetaDataPersistService;
 import 
org.apache.shardingsphere.mode.metadata.persist.service.impl.DataSourcePersistService;
@@ -37,6 +37,7 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Optional;
 import java.util.Properties;
+import java.util.stream.Collectors;
 
 /**
  * Meta data persist service.
@@ -99,21 +100,20 @@ public final class MetaDataPersistService {
     }
     
     /**
-     * Load compute node instances by labels.
+     * Load compute node instances by instance type and labels.
      * 
+     * @param instanceType instance type
      * @param labels collection of label
      * @return collection of compute node instance
      */
-    public Collection<ComputeNodeInstance> loadComputeNodeInstances(final 
Collection<String> labels) {
-        Collection<ComputeNodeInstance> result = 
computeNodePersistService.loadAllComputeNodeInstances();
+    public Collection<ComputeNodeInstance> loadComputeNodeInstances(final 
InstanceType instanceType, final Collection<String> labels) {
+        Collection<ComputeNodeInstance> computeNodeInstances = 
computeNodePersistService.loadAllComputeNodeInstances(instanceType);
+        Collection<ComputeNodeInstance> result = new 
ArrayList<>(computeNodeInstances.size());
+        result.addAll(computeNodeInstances.stream().filter(each -> 
each.getLabels().stream().anyMatch(labels::contains)).collect(Collectors.toList()));
         if (!result.isEmpty()) {
-            final Collection<ShardingSphereUser> users = new ArrayList<>();
-            Optional<AuthorityRuleConfiguration> optional = 
globalRuleService.load().stream().filter(each -> each instanceof 
AuthorityRuleConfiguration)
+            Optional<AuthorityRuleConfiguration> authorityRuleConfig = 
globalRuleService.load().stream().filter(each -> each instanceof 
AuthorityRuleConfiguration)
                     .map(each -> (AuthorityRuleConfiguration) 
each).findFirst();
-            if (optional.isPresent()) {
-                users.addAll(optional.get().getUsers());
-            }
-            result.forEach(each -> each.setUsers(users));
+            authorityRuleConfig.ifPresent(optional -> result.forEach(each -> 
each.setUsers(optional.getUsers())));
         }
         return result;
     }
diff --git 
a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/node/ComputeNode.java
 
b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/node/ComputeNode.java
index a2a197b..40ef324 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/node/ComputeNode.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/node/ComputeNode.java
@@ -17,6 +17,8 @@
 
 package org.apache.shardingsphere.mode.metadata.persist.node;
 
+import org.apache.shardingsphere.infra.instance.InstanceType;
+
 /**
  * Compute node.
  */
@@ -37,20 +39,22 @@ public final class ComputeNode {
     /**
      * Get online compute node path.
      * 
+     * @param instanceType instance type
      * @return path of online compute node
      */
-    public static String getOnlineNodePath() {
-        return String.join("/", "", ROOT_NODE, COMPUTE_NODE, ONLINE_NODE);
+    public static String getOnlineNodePath(final InstanceType instanceType) {
+        return String.join("/", "", ROOT_NODE, COMPUTE_NODE, ONLINE_NODE, 
instanceType.name().toLowerCase());
     }
     
     /**
      * Get online compute node instance path.
      *
      * @param instanceId instance id
+     * @param instanceType instance type
      * @return path of online compute node instance
      */
-    public static String getOnlineInstanceNodePath(final String instanceId) {
-        return String.join("/", "", ROOT_NODE, COMPUTE_NODE, ONLINE_NODE, 
instanceId);
+    public static String getOnlineInstanceNodePath(final String instanceId, 
final InstanceType instanceType) {
+        return String.join("/", "", ROOT_NODE, COMPUTE_NODE, ONLINE_NODE, 
instanceType.name().toLowerCase(), instanceId);
     }
     
     /**
diff --git 
a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/service/ComputeNodePersistService.java
 
b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/service/ComputeNodePersistService.java
index d2c7c00..030eb42 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/service/ComputeNodePersistService.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/service/ComputeNodePersistService.java
@@ -21,6 +21,7 @@ import com.google.common.base.Splitter;
 import com.google.common.base.Strings;
 import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
+import org.apache.shardingsphere.infra.instance.InstanceType;
 import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
 import org.apache.shardingsphere.mode.metadata.persist.node.ComputeNode;
 import org.apache.shardingsphere.mode.persist.PersistRepository;
@@ -59,12 +60,13 @@ public final class ComputeNodePersistService {
     }
     
     /**
-     * Load all compute node instances.
+     * Load all compute node instances by instance type.
      * 
+     * @param instanceType instance type     
      * @return collection of compute node instance
      */
-    public Collection<ComputeNodeInstance> loadAllComputeNodeInstances() {
-        Collection<String> onlineComputeNodes = 
repository.getChildrenKeys(ComputeNode.getOnlineNodePath());
+    public Collection<ComputeNodeInstance> loadAllComputeNodeInstances(final 
InstanceType instanceType) {
+        Collection<String> onlineComputeNodes = 
repository.getChildrenKeys(ComputeNode.getOnlineNodePath(instanceType));
         List<ComputeNodeInstance> result = new 
ArrayList<>(onlineComputeNodes.size());
         onlineComputeNodes.forEach(each -> {
             ComputeNodeInstance instance = new ComputeNodeInstance();
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
index e606307..6488762 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
@@ -82,7 +82,7 @@ public final class ClusterContextManagerBuilder implements 
ContextManagerBuilder
         beforeBuildContextManager(parameter);
         contextManager = new ContextManager();
         contextManager.init(metaDataContexts, transactionContexts, null);
-        afterBuildContextManager();
+        afterBuildContextManager(parameter);
         return contextManager;
     }
     
@@ -106,10 +106,10 @@ public final class ClusterContextManagerBuilder 
implements ContextManagerBuilder
         transactionContexts = new 
TransactionContextsBuilder(metaDataContexts.getMetaDataMap(), 
metaDataContexts.getGlobalRuleMetaData().getRules()).build();
     }
     
-    private void afterBuildContextManager() {
+    private void afterBuildContextManager(final ContextManagerBuilderParameter 
parameter) {
         new ClusterContextManagerCoordinator(metaDataPersistService, 
contextManager);
         disableDataSources();
-        registryCenter.onlineInstance();
+        registryCenter.onlineInstance(parameter.getInstanceType());
     }
     
     private ClusterPersistRepository createClusterPersistRepository(final 
ClusterPersistRepositoryConfiguration config) {
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 e19472e..04662e5 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
@@ -19,6 +19,7 @@ package 
org.apache.shardingsphere.mode.manager.cluster.coordinator;
 
 import lombok.Getter;
 import org.apache.shardingsphere.infra.instance.Instance;
+import org.apache.shardingsphere.infra.instance.InstanceType;
 import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.lock.service.LockRegistryService;
 import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.GovernanceWatcherFactory;
 import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.cache.subscriber.ScalingRegistrySubscriber;
@@ -71,9 +72,11 @@ public final class RegistryCenter {
     
     /**
      * Online instance.
+     * 
+     * @param instanceType instance type
      */
-    public void onlineInstance() {
-        computeNodeStatusService.registerOnline();
+    public void onlineInstance(final InstanceType instanceType) {
+        computeNodeStatusService.registerOnline(instanceType);
         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 0a0a544..db8ec9d 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
@@ -19,6 +19,7 @@ package 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.stat
 
 import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.infra.instance.Instance;
+import org.apache.shardingsphere.infra.instance.InstanceType;
 import org.apache.shardingsphere.mode.metadata.persist.node.ComputeNode;
 import 
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
 
@@ -32,8 +33,10 @@ public final class ComputeNodeStatusService {
     
     /**
      * Register online.
+     * 
+     * @param instanceType instance type
      */
-    public void registerOnline() {
-        
repository.persistEphemeral(ComputeNode.getOnlineInstanceNodePath(Instance.getInstance().getId()),
 "");
+    public void registerOnline(final InstanceType instanceType) {
+        
repository.persistEphemeral(ComputeNode.getOnlineInstanceNodePath(Instance.getInstance().getId(),
 instanceType), "");
     }
 }
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/ClusterContextManagerCoordinatorTest.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
index eb1d5b7..280bf90 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
@@ -31,6 +31,7 @@ import 
org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKe
 import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
 import 
org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
 import 
org.apache.shardingsphere.infra.federation.optimizer.metadata.FederationSchemaMetaData;
+import org.apache.shardingsphere.infra.instance.InstanceType;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
 import 
org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
 import 
org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
@@ -110,7 +111,7 @@ public final class ClusterContextManagerCoordinatorTest {
         ModeConfiguration configuration = new ModeConfiguration("Cluster", 
persistRepositoryConfiguration, false);
         ClusterContextManagerBuilder builder = new 
ClusterContextManagerBuilder();
         contextManager = 
builder.build(ContextManagerBuilderParameter.builder().modeConfig(configuration).dataSourcesMap(new
 HashMap<>()).schemaRuleConfigs(new HashMap<>())
-                .globalRuleConfigs(new LinkedList<>()).props(new 
Properties()).isOverwrite(false).build());
+                .globalRuleConfigs(new LinkedList<>()).props(new 
Properties()).isOverwrite(false).instanceType(InstanceType.PROXY).build());
         contextManager.renewMetaDataContexts(new 
MetaDataContexts(contextManager.getMetaDataContexts().getMetaDataPersistService().get(),
 createMetaDataMap(), globalRuleMetaData, 
                 mock(ExecutorEngine.class),
                 new ConfigurationProperties(new Properties()), 
createOptimizerContext()));
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 4632329..c169b76 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
@@ -18,6 +18,7 @@
 package 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.service;
 
 import org.apache.shardingsphere.infra.instance.Instance;
+import org.apache.shardingsphere.infra.instance.InstanceType;
 import 
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
 import org.junit.Before;
 import org.junit.Test;
@@ -40,7 +41,7 @@ public final class ComputeNodeStatusServiceTest {
     
     @Test
     public void assertRegisterOnline() {
-        new ComputeNodeStatusService(repository).registerOnline();
-        verify(repository).persistEphemeral("/nodes/compute_nodes/online/" + 
Instance.getInstance().getId(), "");
+        new 
ComputeNodeStatusService(repository).registerOnline(InstanceType.PROXY);
+        
verify(repository).persistEphemeral("/nodes/compute_nodes/online/proxy/" + 
Instance.getInstance().getId(), "");
     }
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java
 
b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java
index 8ae4825..00dc9cf 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java
@@ -29,6 +29,7 @@ import 
org.apache.shardingsphere.infra.autogen.version.ShardingSphereVersion;
 import org.apache.shardingsphere.infra.config.datasource.DataSourceParameter;
 import 
org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourcePoolCreatorUtil;
 import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
+import org.apache.shardingsphere.infra.instance.InstanceType;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
 import 
org.apache.shardingsphere.infra.yaml.config.swapper.mode.ModeConfigurationYamlSwapper;
 import org.apache.shardingsphere.mode.manager.ContextManager;
@@ -76,7 +77,8 @@ public final class BootstrapInitializer {
         boolean isOverwrite = null == modeConfig || modeConfig.isOverwrite();
         Map<String, Map<String, DataSource>> dataSourcesMap = 
getDataSourcesMap(proxyConfig.getSchemaDataSources());
         ContextManagerBuilderParameter parameter = 
ContextManagerBuilderParameter.builder().modeConfig(modeConfig).dataSourcesMap(dataSourcesMap).schemaRuleConfigs(proxyConfig.getSchemaRules())
-                
.globalRuleConfigs(proxyConfig.getGlobalRules()).props(proxyConfig.getProps()).isOverwrite(isOverwrite).port(port).labels(proxyConfig.getLabels()).build();
+                
.globalRuleConfigs(proxyConfig.getGlobalRules()).props(proxyConfig.getProps()).isOverwrite(isOverwrite).port(port).labels(proxyConfig.getLabels())
+                .instanceType(InstanceType.PROXY).build();
         ContextManager contextManager = 
ContextManagerBuilderFactory.newInstance(modeConfig).build(parameter);
         ProxyContext.getInstance().init(contextManager);
     }

Reply via email to