Repository: apache/shardingsphere
Issue: Registry can not watch changes from sharding proxy clients.

## Bug Report

**For English only**, other languages will not accept.

Before report a bug, make sure you have:

- Searched open and closed [GitHub issues](https://github.com/sharding-sphere/sharding-sphere/issues).
- Read documentation: [Sharding-Sphere Doc](http://shardingsphere.io/document/current/en/overview/).

Please pay attention on issues you submitted, because we maybe need more details. 
If no response **more than 7 days** and we cannot reproduce it on current information, we will **close it**.

Please answer these questions before submitting your issue. Thanks!

### Which version of Sharding-Sphere did you use?

### Which project did you use? Sharding-JDBC or Sharding-Proxy?

Sharding-Proxy

### Reason analyze (If you can)

The registry can not watch changes from clients, if sharding proxy loads configurations from local. So it is necessary to modify some APIs of orchestration.


Changed files:
sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/OrchestrationFacade.java
sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/config/OrchestrationType.java
sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/datasource/OrchestrationShardingDataSource.java
sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/datasource/OrchestrationMasterSlaveDataSource.java
sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/Bootstrap.java

diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/datasource/OrchestrationMasterSlaveDataSource.java b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/datasource/OrchestrationMasterSlaveDataSource.java
index 7582b696e3f..e0e6b225af4 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/datasource/OrchestrationMasterSlaveDataSource.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/datasource/OrchestrationMasterSlaveDataSource.java
@@ -25,6 +25,7 @@ import io.shardingsphere.api.config.MasterSlaveRuleConfiguration;
 import io.shardingsphere.core.constant.properties.ShardingProperties;
 import io.shardingsphere.core.rule.MasterSlaveRule;
 import io.shardingsphere.orchestration.config.OrchestrationConfiguration;
+import io.shardingsphere.orchestration.config.OrchestrationType;
 import io.shardingsphere.orchestration.internal.OrchestrationFacade;
 import io.shardingsphere.orchestration.internal.config.ConfigurationService;
 import io.shardingsphere.orchestration.internal.event.config.MasterSlaveConfigurationEventBusEvent;
@@ -58,7 +59,7 @@ public class OrchestrationMasterSlaveDataSource extends AbstractOrchestrationDat
         Preconditions.checkState(null != masterSlaveRuleConfig && !Strings.isNullOrEmpty(masterSlaveRuleConfig.getMasterDataSourceName()), "No available master slave rule configuration to load.");
         dataSource = new MasterSlaveDataSource(configService.loadDataSourceMap(), new OrchestrationMasterSlaveRule(masterSlaveRuleConfig), configService.loadMasterSlaveConfigMap(),
                 new ShardingProperties(configService.loadMasterSlaveProperties()));
-        initOrchestrationFacade(dataSource);
+        getOrchestrationFacade().init(OrchestrationType.MASTER_SLAVE);
     }
     
     private void initOrchestrationFacade(final MasterSlaveDataSource masterSlaveDataSource) {
diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/datasource/OrchestrationShardingDataSource.java b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/datasource/OrchestrationShardingDataSource.java
index c20bf3aa2e2..94ae1c3b659 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/datasource/OrchestrationShardingDataSource.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/datasource/OrchestrationShardingDataSource.java
@@ -22,6 +22,7 @@ import com.google.common.eventbus.Subscribe;
 import io.shardingsphere.api.ConfigMapContext;
 import io.shardingsphere.api.config.ShardingRuleConfiguration;
 import io.shardingsphere.orchestration.config.OrchestrationConfiguration;
+import io.shardingsphere.orchestration.config.OrchestrationType;
 import io.shardingsphere.orchestration.internal.OrchestrationFacade;
 import io.shardingsphere.orchestration.internal.config.ConfigurationService;
 import io.shardingsphere.orchestration.internal.event.config.ShardingConfigurationEventBusEvent;
@@ -56,7 +57,7 @@ public class OrchestrationShardingDataSource extends AbstractOrchestrationDataSo
         Preconditions.checkState(null != shardingRuleConfig && !shardingRuleConfig.getTableRuleConfigs().isEmpty(), "Missing the sharding rule configuration on register center");
         dataSource = new ShardingDataSource(configService.loadDataSourceMap(),
                 new OrchestrationShardingRule(shardingRuleConfig, configService.loadDataSourceMap().keySet()), configService.loadShardingConfigMap(), configService.loadShardingProperties());
-        initOrchestrationFacade(dataSource);
+        getOrchestrationFacade().init(OrchestrationType.SHARDING);
     }
     
     private void initOrchestrationFacade(final ShardingDataSource shardingDataSource) {
diff --git a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/config/OrchestrationType.java b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/config/OrchestrationType.java
index 78b457f5921..367cf330a0f 100644
--- a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/config/OrchestrationType.java
+++ b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/config/OrchestrationType.java
@@ -25,5 +25,5 @@ package io.shardingsphere.orchestration.config;
  */
 public enum OrchestrationType {
     
-    SHARDING, MASTER_SLAVE
+    SHARDING, MASTER_SLAVE, PROXY
 }
diff --git a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/OrchestrationFacade.java b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/OrchestrationFacade.java
index 5b4690e9af0..8c30ba08c91 100644
--- a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/OrchestrationFacade.java
+++ b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/OrchestrationFacade.java
@@ -24,6 +24,7 @@ import io.shardingsphere.core.rule.DataSourceParameter;
 import io.shardingsphere.core.yaml.YamlRuleConfiguration;
 import io.shardingsphere.core.yaml.other.YamlServerConfiguration;
 import io.shardingsphere.orchestration.config.OrchestrationConfiguration;
+import io.shardingsphere.orchestration.config.OrchestrationType;
 import io.shardingsphere.orchestration.internal.config.ConfigurationService;
 import io.shardingsphere.orchestration.internal.listener.ListenerFactory;
 import io.shardingsphere.orchestration.internal.state.datasource.DataSourceService;
@@ -137,6 +138,27 @@ public final class OrchestrationFacade implements AutoCloseable {
         listenerManager.initProxyListeners();
     }
     
+    /**
+     * Initialize for proxy orchestration.
+     *
+     *@param orchestrationType orchestration type
+     */
+    public void init(final OrchestrationType orchestrationType) {
+        switch (orchestrationType) {
+            case MASTER_SLAVE:
+                listenerManager.initMasterSlaveListeners();
+                break;
+            case SHARDING:
+                listenerManager.initShardingListeners();
+                break;
+            case PROXY:
+                listenerManager.initProxyListeners();
+                break;
+            default:
+                throw new UnsupportedOperationException(orchestrationType.name());
+        }
+    }
+    
     private void reviseShardingRuleConfigurationForMasterSlave(final Map<String, DataSource> dataSourceMap, final ShardingRuleConfiguration shardingRuleConfig) {
         for (Entry<String, DataSource> entry : dataSourceMap.entrySet()) {
             if (entry.getValue() instanceof MasterSlaveDataSource) {
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/Bootstrap.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/Bootstrap.java
index 935e5577efb..4984905b5fa 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/Bootstrap.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/Bootstrap.java
@@ -21,6 +21,7 @@ import io.shardingsphere.core.rule.DataSourceParameter;
 import io.shardingsphere.core.yaml.YamlRuleConfiguration;
 import io.shardingsphere.core.yaml.other.YamlServerConfiguration;
 import io.shardingsphere.opentracing.ShardingTracer;
+import io.shardingsphere.orchestration.config.OrchestrationType;
 import io.shardingsphere.orchestration.internal.OrchestrationFacade;
 import io.shardingsphere.shardingproxy.config.ShardingConfiguration;
 import io.shardingsphere.shardingproxy.config.ShardingConfigurationLoader;
@@ -87,10 +88,9 @@ public final class Bootstrap {
     
     private static void startWithRegistryCenter(
             final ProxyYamlServerConfiguration serverConfig, final Map<String, ProxyYamlRuleConfiguration> ruleConfigs, final int port) throws InterruptedException {
+        
         try (OrchestrationFacade orchestrationFacade = new OrchestrationFacade(serverConfig.getOrchestration().getOrchestrationConfiguration())) {
-            if (!ruleConfigs.isEmpty()) {
-                orchestrationFacade.init(getYamlServerConfiguration(serverConfig), getSchemaDataSourceMap(ruleConfigs), getRuleConfiguration(ruleConfigs));
-            }
+            initOrchestrationFacade(serverConfig, ruleConfigs, orchestrationFacade);
             GlobalRegistry.getInstance().init(orchestrationFacade.getConfigService().loadYamlServerConfiguration(), 
                     orchestrationFacade.getConfigService().loadProxyDataSources(), orchestrationFacade.getConfigService().loadProxyConfiguration(), true);
             initOpenTracing();
@@ -98,6 +98,14 @@ public final class Bootstrap {
         }
     }
     
+    private static void initOrchestrationFacade(final ProxyYamlServerConfiguration serverConfig, final Map<String, ProxyYamlRuleConfiguration> ruleConfigs, final OrchestrationFacade orchestrationFacade) {
+        if (ruleConfigs.isEmpty()) {
+            orchestrationFacade.init(OrchestrationType.PROXY);
+        } else {
+            orchestrationFacade.init(getYamlServerConfiguration(serverConfig), getSchemaDataSourceMap(ruleConfigs), getRuleConfiguration(ruleConfigs));
+        }
+    }
+    
     private static void initOpenTracing() {
         if (GlobalRegistry.getInstance().isOpenTracingEnable()) {
             ShardingTracer.init();