From 6bb92975a3da43b918290e34b82fcfb30f8d5dc4 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Thu, 11 Oct 2018 18:27:49 +0800
Subject: [PATCH 001/100] modify dataSource()
---
.../spring/boot/OrchestrationSpringBootConfiguration.java | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
index 634cdb5a7b706..d2e2216b00c39 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
@@ -21,7 +21,6 @@
import com.google.common.base.Strings;
import io.shardingsphere.core.exception.ShardingException;
import io.shardingsphere.core.rule.ShardingRule;
-import io.shardingsphere.orchestration.config.OrchestrationType;
import io.shardingsphere.shardingjdbc.jdbc.core.datasource.MasterSlaveDataSource;
import io.shardingsphere.shardingjdbc.jdbc.core.datasource.ShardingDataSource;
import io.shardingsphere.shardingjdbc.orchestration.internal.datasource.OrchestrationMasterSlaveDataSource;
@@ -74,9 +73,7 @@ public class OrchestrationSpringBootConfiguration implements EnvironmentAware {
*/
@Bean
public DataSource dataSource() throws SQLException {
- OrchestrationType type = orchestrationProperties.getType();
- Preconditions.checkState(null != type, "Missing the type of datasource configuration in orchestration configuration");
- return OrchestrationType.SHARDING == type ? createShardingDataSource() : createMasterSlaveDataSource();
+ return shardingProperties.getTables().isEmpty() ? createMasterSlaveDataSource() : createShardingDataSource();
}
private DataSource createShardingDataSource() throws SQLException {
From 1ddbe5d679e36efe8c733ba9549f3cdfeb736895 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Thu, 11 Oct 2018 18:35:02 +0800
Subject: [PATCH 002/100] add Preconditions.checkState
---
.../spring/boot/OrchestrationSpringBootConfiguration.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
index d2e2216b00c39..8cc3c6fce46d4 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
@@ -73,9 +73,15 @@ public class OrchestrationSpringBootConfiguration implements EnvironmentAware {
*/
@Bean
public DataSource dataSource() throws SQLException {
+ Preconditions.checkState(isValidConfiguration(), "The orchestration configuration is invalid, please choose one from Sharding rule and Master-slave rule.");
return shardingProperties.getTables().isEmpty() ? createMasterSlaveDataSource() : createShardingDataSource();
}
+ private boolean isValidConfiguration() {
+ return (shardingProperties.getTables().isEmpty() && !Strings.isNullOrEmpty(masterSlaveProperties.getMasterDataSourceName()))
+ || (!shardingProperties.getTables().isEmpty() && Strings.isNullOrEmpty(masterSlaveProperties.getMasterDataSourceName()));
+ }
+
private DataSource createShardingDataSource() throws SQLException {
if (shardingProperties.getTables().isEmpty()) {
return new OrchestrationShardingDataSource(orchestrationProperties.getOrchestrationConfiguration());
From fc09c20b41e11fc7bf91b1f1954b558542abe705 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Thu, 11 Oct 2018 18:37:11 +0800
Subject: [PATCH 003/100] delete type
---
.../orchestration/config/OrchestrationConfiguration.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/config/OrchestrationConfiguration.java b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/config/OrchestrationConfiguration.java
index 09984451b6c0d..dbdfb2e326367 100644
--- a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/config/OrchestrationConfiguration.java
+++ b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/config/OrchestrationConfiguration.java
@@ -25,6 +25,7 @@
* Orchestration configuration.
*
* @author zhangliang
+ * @author panjuan
*/
@RequiredArgsConstructor
@Getter
@@ -35,6 +36,4 @@ public final class OrchestrationConfiguration {
private final RegistryCenterConfiguration regCenterConfig;
private final boolean overwrite;
-
- private final OrchestrationType type;
}
From a8951a829b0ff47b437b33cc50012b251a8203d7 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Thu, 11 Oct 2018 18:37:19 +0800
Subject: [PATCH 004/100] delete type
---
.../orchestration/yaml/YamlOrchestrationConfiguration.java | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/yaml/YamlOrchestrationConfiguration.java b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/yaml/YamlOrchestrationConfiguration.java
index 692c824866e07..670ad603e1c12 100644
--- a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/yaml/YamlOrchestrationConfiguration.java
+++ b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/yaml/YamlOrchestrationConfiguration.java
@@ -19,7 +19,6 @@
import com.google.common.base.Preconditions;
import io.shardingsphere.orchestration.config.OrchestrationConfiguration;
-import io.shardingsphere.orchestration.config.OrchestrationType;
import io.shardingsphere.orchestration.reg.etcd.EtcdConfiguration;
import io.shardingsphere.orchestration.reg.zookeeper.ZookeeperConfiguration;
import lombok.Getter;
@@ -29,6 +28,7 @@
* Orchestration configuration for yaml.
*
* @author caohao
+ * @author panjuan
*/
@Getter
@Setter
@@ -42,8 +42,6 @@ public class YamlOrchestrationConfiguration {
private boolean overwrite;
- private OrchestrationType type;
-
/**
* Get orchestration master-slave rule configuration from yaml.
*
@@ -51,6 +49,6 @@ public class YamlOrchestrationConfiguration {
*/
public OrchestrationConfiguration getOrchestrationConfiguration() {
Preconditions.checkState(null == etcd || null == zookeeper, "Can't config both zookeeper and etcd as registry center!");
- return new OrchestrationConfiguration(getName(), null != etcd ? etcd : zookeeper, overwrite, type);
+ return new OrchestrationConfiguration(getName(), null != etcd ? etcd : zookeeper, overwrite);
}
}
From a879eb71bad77269d7e3a832eb270364ad5d2dd5 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Thu, 11 Oct 2018 18:41:27 +0800
Subject: [PATCH 005/100] modify parser
---
.../spring/namespace/parser/DataSourceBeanDefinitionParser.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/namespace/parser/DataSourceBeanDefinitionParser.java b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/namespace/parser/DataSourceBeanDefinitionParser.java
index 864cd85f5b452..0d945c4aa4645 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/namespace/parser/DataSourceBeanDefinitionParser.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/namespace/parser/DataSourceBeanDefinitionParser.java
@@ -65,7 +65,6 @@ private BeanDefinition getOrchestrationConfiguration(final Element element) {
factory.addConstructorArgValue(element.getAttribute(ID_ATTRIBUTE));
factory.addConstructorArgReference(element.getAttribute(ShardingDataSourceBeanDefinitionParserTag.REG_REF_TAG));
factory.addConstructorArgValue(element.getAttribute(ShardingDataSourceBeanDefinitionParserTag.OVERWRITE_TAG));
- factory.addConstructorArgValue(orchestrationType);
return factory.getBeanDefinition();
}
}
From 3cc9083ca3fa91d32a5c9b99dde1c285890e362a Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Thu, 11 Oct 2018 19:10:39 +0800
Subject: [PATCH 006/100] delete sharding.jdbc.config.orchestration.type for ms
---
.../src/test/resources/application-masterslave.properties | 1 -
1 file changed, 1 deletion(-)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/test/resources/application-masterslave.properties b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/test/resources/application-masterslave.properties
index 0774a5a271630..d9f23e066841a 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/test/resources/application-masterslave.properties
+++ b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/test/resources/application-masterslave.properties
@@ -26,7 +26,6 @@ sharding.jdbc.config.masterslave.master-data-source-name=ds_master
sharding.jdbc.config.masterslave.slave-data-source-names=ds_slave_0,ds_slave_1
sharding.jdbc.config.orchestration.name=demo_spring_boot_ds_ms
-sharding.jdbc.config.orchestration.type=master_slave
sharding.jdbc.config.orchestration.overwrite=true
sharding.jdbc.config.orchestration.zookeeper.namespace=orchestration-spring-boot-master-slave-test
sharding.jdbc.config.orchestration.zookeeper.server-lists=localhost:3181
From b1b7fc6a733f162e6fc2484613bc96cee9e56156 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Thu, 11 Oct 2018 19:10:48 +0800
Subject: [PATCH 007/100] delete sharding.jdbc.config.orchestration.type for
sharding
---
.../src/test/resources/application-sharding.properties | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/test/resources/application-sharding.properties b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/test/resources/application-sharding.properties
index bd790e49e287f..47d59d33c4b05 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/test/resources/application-sharding.properties
+++ b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/test/resources/application-sharding.properties
@@ -36,9 +36,8 @@ sharding.jdbc.config.sharding.props.sql.show=true
sharding.jdbc.config.sharding.props.executor.size=100
sharding.jdbc.config.orchestration.name=demo_spring_boot_ds_sharding
-sharding.jdbc.config.orchestration.type=sharding
sharding.jdbc.config.orchestration.overwrite=true
sharding.jdbc.config.orchestration.zookeeper.namespace=orchestration-spring-boot-sharding-test
sharding.jdbc.config.orchestration.zookeeper.server-lists=localhost:3181
-sharding.jdbc.config.sharding.config-map.key1=value1
+sharding.jdbc.config.sharding.config-map.key1=value1
\ No newline at end of file
From 2f9da60d4fdf825643aeeafc2632f47f98961992 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Thu, 11 Oct 2018 20:23:55 +0800
Subject: [PATCH 008/100] add isValidRuleConfiguration()
---
.../spring/boot/OrchestrationSpringBootConfiguration.java | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
index 8cc3c6fce46d4..861fe36ad7579 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
@@ -78,10 +78,18 @@ public DataSource dataSource() throws SQLException {
}
private boolean isValidConfiguration() {
+ return isValidRuleConfiguration() || isValidOrchestrationConfiguration();
+ }
+
+ private boolean isValidRuleConfiguration() {
return (shardingProperties.getTables().isEmpty() && !Strings.isNullOrEmpty(masterSlaveProperties.getMasterDataSourceName()))
|| (!shardingProperties.getTables().isEmpty() && Strings.isNullOrEmpty(masterSlaveProperties.getMasterDataSourceName()));
}
+ private boolean isValidOrchestrationConfiguration() {
+ return !Strings.isNullOrEmpty(orchestrationProperties.getName());
+ }
+
private DataSource createShardingDataSource() throws SQLException {
if (shardingProperties.getTables().isEmpty()) {
return new OrchestrationShardingDataSource(orchestrationProperties.getOrchestrationConfiguration());
From 54f49629eb91fdb44658ddcd4c775887a9c26b93 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Thu, 11 Oct 2018 21:15:23 +0800
Subject: [PATCH 009/100] delete check state
---
.../orchestration/internal/config/ConfigurationService.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/config/ConfigurationService.java b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/config/ConfigurationService.java
index e401c34edd922..c794da9ada141 100644
--- a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/config/ConfigurationService.java
+++ b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/config/ConfigurationService.java
@@ -259,9 +259,7 @@ public Map> loadProxyDataSources() {
*/
public ShardingRuleConfiguration loadShardingRuleConfiguration() {
try {
- ShardingRuleConfiguration result = ShardingConfigurationConverter.shardingRuleConfigFromYaml(regCenter.getDirectly(configNode.getFullPath(ConfigurationNode.SHARDING_RULE_NODE_PATH)));
- Preconditions.checkState(null != result && !result.getTableRuleConfigs().isEmpty(), "No available sharding rule configuration to load.");
- return result;
+ return ShardingConfigurationConverter.shardingRuleConfigFromYaml(regCenter.getDirectly(configNode.getFullPath(ConfigurationNode.SHARDING_RULE_NODE_PATH)));
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
From 60232851b3167e4b36f60a4f5b363ebf00e4d7f1 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Thu, 11 Oct 2018 21:15:33 +0800
Subject: [PATCH 010/100] add check state
---
.../internal/state/datasource/DataSourceService.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/state/datasource/DataSourceService.java b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/state/datasource/DataSourceService.java
index 1086967c680e9..43462f5b0c025 100644
--- a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/state/datasource/DataSourceService.java
+++ b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/state/datasource/DataSourceService.java
@@ -17,6 +17,7 @@
package io.shardingsphere.orchestration.internal.state.datasource;
+import com.google.common.base.Preconditions;
import io.shardingsphere.api.config.MasterSlaveRuleConfiguration;
import io.shardingsphere.api.config.ShardingRuleConfiguration;
import io.shardingsphere.core.rule.DataSourceParameter;
@@ -100,6 +101,7 @@ public Map> getProxyAvailableDataSource
*/
public ShardingRuleConfiguration getAvailableShardingRuleConfiguration() {
ShardingRuleConfiguration result = configService.loadShardingRuleConfiguration();
+ Preconditions.checkState(null != result && !result.getTableRuleConfigs().isEmpty(), "Missing the sharding rule configuration on register center");
Collection disabledDataSourceNames = getDisabledDataSourceNames();
for (String each : disabledDataSourceNames) {
for (MasterSlaveRuleConfiguration masterSlaveRuleConfig : result.getMasterSlaveRuleConfigs()) {
From fc3c261c58902c9d053e0c0cff44f10d9000d0bc Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Thu, 11 Oct 2018 21:15:40 +0800
Subject: [PATCH 011/100] add check state
---
.../internal/datasource/OrchestrationShardingDataSource.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 ceeda44a5a0af..ef73934eaa8de 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
@@ -55,7 +55,7 @@ public OrchestrationShardingDataSource(final OrchestrationConfiguration orchestr
super(new OrchestrationFacade(orchestrationConfig));
ConfigurationService configService = getOrchestrationFacade().getConfigService();
ShardingRuleConfiguration shardingRuleConfig = configService.loadShardingRuleConfiguration();
- Preconditions.checkNotNull(shardingRuleConfig, "Missing the sharding rule configuration on register center");
+ Preconditions.checkState(null != shardingRuleConfig && !shardingRuleConfig.getTableRuleConfigs().isEmpty(), "Missing the sharding rule configuration on register center");
dataSource = new ShardingDataSource(configService.loadDataSourceMap(),
new ShardingRule(shardingRuleConfig, configService.loadDataSourceMap().keySet()), configService.loadShardingConfigMap(), configService.loadShardingProperties());
initOrchestrationFacade(dataSource);
From 030fbd23da3e1b0ae7d080dbfb22c375d6ed647b Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Thu, 11 Oct 2018 21:17:14 +0800
Subject: [PATCH 012/100] delete ms check state
---
.../orchestration/internal/config/ConfigurationService.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/config/ConfigurationService.java b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/config/ConfigurationService.java
index c794da9ada141..bb9d932f74c65 100644
--- a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/config/ConfigurationService.java
+++ b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/config/ConfigurationService.java
@@ -295,10 +295,8 @@ public Properties loadShardingProperties() {
*/
public MasterSlaveRuleConfiguration loadMasterSlaveRuleConfiguration() {
try {
- MasterSlaveRuleConfiguration result = MasterSlaveConfigurationConverter.masterSlaveRuleConfigFromYaml(
+ return MasterSlaveConfigurationConverter.masterSlaveRuleConfigFromYaml(
regCenter.getDirectly(configNode.getFullPath(ConfigurationNode.MASTER_SLAVE_RULE_NODE_PATH)));
- Preconditions.checkState(null != result && !Strings.isNullOrEmpty(result.getMasterDataSourceName()), "No available master slave rule configuration to load.");
- return result;
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
From 09506647370fb7a1a56f5e7e02ea82303762eb33 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Thu, 11 Oct 2018 21:17:23 +0800
Subject: [PATCH 013/100] add ms check state
---
.../internal/state/datasource/DataSourceService.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/state/datasource/DataSourceService.java b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/state/datasource/DataSourceService.java
index 43462f5b0c025..97ffdb92572a9 100644
--- a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/state/datasource/DataSourceService.java
+++ b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/state/datasource/DataSourceService.java
@@ -18,6 +18,7 @@
package io.shardingsphere.orchestration.internal.state.datasource;
import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
import io.shardingsphere.api.config.MasterSlaveRuleConfiguration;
import io.shardingsphere.api.config.ShardingRuleConfiguration;
import io.shardingsphere.core.rule.DataSourceParameter;
@@ -118,6 +119,7 @@ public ShardingRuleConfiguration getAvailableShardingRuleConfiguration() {
*/
public MasterSlaveRuleConfiguration getAvailableMasterSlaveRuleConfiguration() {
MasterSlaveRuleConfiguration result = configService.loadMasterSlaveRuleConfiguration();
+ Preconditions.checkState(null != result && !Strings.isNullOrEmpty(result.getMasterDataSourceName()), "No available master slave rule configuration to load.");
Collection disabledDataSourceNames = getDisabledDataSourceNames();
for (String each : disabledDataSourceNames) {
result.getSlaveDataSourceNames().remove(each);
From 1268653cf7760d5b510b225199649c0cab77bf09 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Thu, 11 Oct 2018 21:17:29 +0800
Subject: [PATCH 014/100] add ms check state
---
.../datasource/OrchestrationMasterSlaveDataSource.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
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 730041f9b396b..bf9891d4de5d7 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
@@ -18,6 +18,7 @@
package io.shardingsphere.shardingjdbc.orchestration.internal.datasource;
import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
import com.google.common.eventbus.Subscribe;
import io.shardingsphere.api.ConfigMapContext;
import io.shardingsphere.api.config.MasterSlaveRuleConfiguration;
@@ -55,7 +56,7 @@ public OrchestrationMasterSlaveDataSource(final OrchestrationConfiguration orche
super(new OrchestrationFacade(orchestrationConfig));
ConfigurationService configService = getOrchestrationFacade().getConfigService();
MasterSlaveRuleConfiguration masterSlaveRuleConfig = configService.loadMasterSlaveRuleConfiguration();
- Preconditions.checkNotNull(masterSlaveRuleConfig, "Missing the master-slave rule configuration on register center");
+ Preconditions.checkState(null != masterSlaveRuleConfig && !Strings.isNullOrEmpty(masterSlaveRuleConfig.getMasterDataSourceName()), "No available master slave rule configuration to load.");
dataSource = new MasterSlaveDataSource(
configService.loadDataSourceMap(), masterSlaveRuleConfig, configService.loadMasterSlaveConfigMap(), configService.loadMasterSlaveProperties());
initOrchestrationFacade(dataSource);
From 8d2a943bb3b74fed5454a26b11cf4795cbe47e13 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Thu, 11 Oct 2018 21:38:25 +0800
Subject: [PATCH 015/100] add get orchestration type
---
.../OrchestrationSpringBootConfiguration.java | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
index 861fe36ad7579..58d17404c3f77 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
@@ -19,8 +19,12 @@
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
+import io.shardingsphere.api.config.ShardingRuleConfiguration;
import io.shardingsphere.core.exception.ShardingException;
import io.shardingsphere.core.rule.ShardingRule;
+import io.shardingsphere.orchestration.config.OrchestrationType;
+import io.shardingsphere.orchestration.internal.OrchestrationFacade;
+import io.shardingsphere.orchestration.internal.config.ConfigurationService;
import io.shardingsphere.shardingjdbc.jdbc.core.datasource.MasterSlaveDataSource;
import io.shardingsphere.shardingjdbc.jdbc.core.datasource.ShardingDataSource;
import io.shardingsphere.shardingjdbc.orchestration.internal.datasource.OrchestrationMasterSlaveDataSource;
@@ -90,6 +94,21 @@ private boolean isValidOrchestrationConfiguration() {
return !Strings.isNullOrEmpty(orchestrationProperties.getName());
}
+ private OrchestrationType getOrchestrationTypeByRegistry() {
+ OrchestrationFacade orchestrationFacade = new OrchestrationFacade(orchestrationProperties.getOrchestrationConfiguration());
+ ConfigurationService configService = orchestrationFacade.getConfigService();
+ ShardingRuleConfiguration shardingRuleConfiguration = orchestrationFacade.getConfigService().loadShardingRuleConfiguration();
+ orchestrationFacade.close();
+ if (null != shardingRuleConfiguration && !shardingRuleConfiguration.getTableRuleConfigs().isEmpty()) {
+ return OrchestrationType.SHARDING;
+ }
+ return OrchestrationType.MASTER_SLAVE;
+ }
+
+ private OrchestrationType getOrchestrationTypeByLocal() {
+ return shardingProperties.getTables().isEmpty() ? OrchestrationType.MASTER_SLAVE : OrchestrationType.SHARDING;
+ }
+
private DataSource createShardingDataSource() throws SQLException {
if (shardingProperties.getTables().isEmpty()) {
return new OrchestrationShardingDataSource(orchestrationProperties.getOrchestrationConfiguration());
From 574274615bbf29da6e7baf8a6db9971b4cf38da2 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Thu, 11 Oct 2018 21:38:45 +0800
Subject: [PATCH 016/100] getOrchestrationTypeByRegistry()
---
.../spring/boot/OrchestrationSpringBootConfiguration.java | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
index 58d17404c3f77..78efc575d36b3 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
@@ -94,6 +94,13 @@ private boolean isValidOrchestrationConfiguration() {
return !Strings.isNullOrEmpty(orchestrationProperties.getName());
}
+ private OrchestrationType getOrchestrationType() {
+ if (isValidRuleConfiguration()) {
+ return getOrchestrationTypeByLocal();
+ }
+ return getOrchestrationTypeByRegistry();
+ }
+
private OrchestrationType getOrchestrationTypeByRegistry() {
OrchestrationFacade orchestrationFacade = new OrchestrationFacade(orchestrationProperties.getOrchestrationConfiguration());
ConfigurationService configService = orchestrationFacade.getConfigService();
From 507ef5fef580cdf8670cb3e061bd2be20190eaec Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Thu, 11 Oct 2018 21:38:56 +0800
Subject: [PATCH 017/100] ConfigurationService configService =
orchestrationFacade.getConfigService();
---
.../spring/boot/OrchestrationSpringBootConfiguration.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
index 78efc575d36b3..992017a68bbdc 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
@@ -103,7 +103,6 @@ private OrchestrationType getOrchestrationType() {
private OrchestrationType getOrchestrationTypeByRegistry() {
OrchestrationFacade orchestrationFacade = new OrchestrationFacade(orchestrationProperties.getOrchestrationConfiguration());
- ConfigurationService configService = orchestrationFacade.getConfigService();
ShardingRuleConfiguration shardingRuleConfiguration = orchestrationFacade.getConfigService().loadShardingRuleConfiguration();
orchestrationFacade.close();
if (null != shardingRuleConfiguration && !shardingRuleConfiguration.getTableRuleConfigs().isEmpty()) {
From 82e164c562b40b13810aac459522f089f987a04c Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Thu, 11 Oct 2018 21:39:42 +0800
Subject: [PATCH 018/100] adjust position
---
.../boot/OrchestrationSpringBootConfiguration.java | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
index 992017a68bbdc..33aecca3f4375 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
@@ -24,7 +24,6 @@
import io.shardingsphere.core.rule.ShardingRule;
import io.shardingsphere.orchestration.config.OrchestrationType;
import io.shardingsphere.orchestration.internal.OrchestrationFacade;
-import io.shardingsphere.orchestration.internal.config.ConfigurationService;
import io.shardingsphere.shardingjdbc.jdbc.core.datasource.MasterSlaveDataSource;
import io.shardingsphere.shardingjdbc.jdbc.core.datasource.ShardingDataSource;
import io.shardingsphere.shardingjdbc.orchestration.internal.datasource.OrchestrationMasterSlaveDataSource;
@@ -101,6 +100,10 @@ private OrchestrationType getOrchestrationType() {
return getOrchestrationTypeByRegistry();
}
+ private OrchestrationType getOrchestrationTypeByLocal() {
+ return shardingProperties.getTables().isEmpty() ? OrchestrationType.MASTER_SLAVE : OrchestrationType.SHARDING;
+ }
+
private OrchestrationType getOrchestrationTypeByRegistry() {
OrchestrationFacade orchestrationFacade = new OrchestrationFacade(orchestrationProperties.getOrchestrationConfiguration());
ShardingRuleConfiguration shardingRuleConfiguration = orchestrationFacade.getConfigService().loadShardingRuleConfiguration();
@@ -111,10 +114,6 @@ private OrchestrationType getOrchestrationTypeByRegistry() {
return OrchestrationType.MASTER_SLAVE;
}
- private OrchestrationType getOrchestrationTypeByLocal() {
- return shardingProperties.getTables().isEmpty() ? OrchestrationType.MASTER_SLAVE : OrchestrationType.SHARDING;
- }
-
private DataSource createShardingDataSource() throws SQLException {
if (shardingProperties.getTables().isEmpty()) {
return new OrchestrationShardingDataSource(orchestrationProperties.getOrchestrationConfiguration());
From a11f95ee5a05433df26ca5a858527354aad01b0b Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Thu, 11 Oct 2018 21:40:51 +0800
Subject: [PATCH 019/100] use getOrchestrationType
---
.../spring/boot/OrchestrationSpringBootConfiguration.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
index 33aecca3f4375..895557d4b80ef 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
@@ -77,7 +77,7 @@ public class OrchestrationSpringBootConfiguration implements EnvironmentAware {
@Bean
public DataSource dataSource() throws SQLException {
Preconditions.checkState(isValidConfiguration(), "The orchestration configuration is invalid, please choose one from Sharding rule and Master-slave rule.");
- return shardingProperties.getTables().isEmpty() ? createMasterSlaveDataSource() : createShardingDataSource();
+ return OrchestrationType.SHARDING == getOrchestrationType() ? createShardingDataSource() : createMasterSlaveDataSource() ;
}
private boolean isValidConfiguration() {
From 6e144fc1596b7bab501aa4e1c91ed197091ad146 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Thu, 11 Oct 2018 21:41:14 +0800
Subject: [PATCH 020/100] for checkstyle
---
.../spring/boot/OrchestrationSpringBootConfiguration.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
index 895557d4b80ef..acab3bf06260c 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
@@ -77,7 +77,7 @@ public class OrchestrationSpringBootConfiguration implements EnvironmentAware {
@Bean
public DataSource dataSource() throws SQLException {
Preconditions.checkState(isValidConfiguration(), "The orchestration configuration is invalid, please choose one from Sharding rule and Master-slave rule.");
- return OrchestrationType.SHARDING == getOrchestrationType() ? createShardingDataSource() : createMasterSlaveDataSource() ;
+ return OrchestrationType.SHARDING == getOrchestrationType() ? createShardingDataSource() : createMasterSlaveDataSource();
}
private boolean isValidConfiguration() {
From dbcfffcba3b6ffbf497fec36430a897898cb736c Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Thu, 11 Oct 2018 21:55:46 +0800
Subject: [PATCH 021/100] return new ShardingRuleConfiguration();
---
.../orchestration/internal/config/ConfigurationService.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/config/ConfigurationService.java b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/config/ConfigurationService.java
index bb9d932f74c65..bde5810b8caf5 100644
--- a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/config/ConfigurationService.java
+++ b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/config/ConfigurationService.java
@@ -263,7 +263,7 @@ public ShardingRuleConfiguration loadShardingRuleConfiguration() {
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
- throw new ShardingConfigurationException("No available sharding rule configuration to load.");
+ return new ShardingRuleConfiguration();
}
}
@@ -300,7 +300,7 @@ public MasterSlaveRuleConfiguration loadMasterSlaveRuleConfiguration() {
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
- throw new ShardingConfigurationException("No available master slave rule configuration to load.");
+ return new MasterSlaveRuleConfiguration();
}
}
From e0130268e8ff336753e7cb3647c36f5e6f86d12e Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Thu, 11 Oct 2018 21:59:26 +0800
Subject: [PATCH 022/100] modify RELEASE-NOTES.md
---
RELEASE-NOTES.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 84e4082ee5f5c..a0ab7b7aea296 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -50,6 +50,7 @@
1. [ISSUE #1289](https://github.com/sharding-sphere/sharding-sphere/issues/1289) Adjust Hint API
1. [ISSUE #1302](https://github.com/sharding-sphere/sharding-sphere/issues/1302) Refine package structure
1. [ISSUE #1305](https://github.com/sharding-sphere/sharding-sphere/issues/1305) Deprecated and remove sharding-jdbc-transaction-parent module
+1. [ISSUE #1382](https://github.com/sharding-sphere/sharding-sphere/issues/1328) Remove type configuration in Orchestration module
### Bug Fixes
From 65be51d4b65f21ed16a281275f73ca237d154e29 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Thu, 11 Oct 2018 21:59:36 +0800
Subject: [PATCH 023/100] modify RELEASE-NOTES-ZH.md
---
RELEASE-NOTES_ZH.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/RELEASE-NOTES_ZH.md b/RELEASE-NOTES_ZH.md
index 3691928667648..287b1914135ef 100644
--- a/RELEASE-NOTES_ZH.md
+++ b/RELEASE-NOTES_ZH.md
@@ -50,7 +50,7 @@
1. [ISSUE #1289](https://github.com/sharding-sphere/sharding-sphere/issues/1289) 调整Hint API
1. [ISSUE #1302](https://github.com/sharding-sphere/sharding-sphere/issues/1302) 调整包结构
1. [ISSUE #1305](https://github.com/sharding-sphere/sharding-sphere/issues/1305) 废弃并删除sharding-jdbc-transaction-parent模块
-
+1. [ISSUE #1382](https://github.com/sharding-sphere/sharding-sphere/issues/1328) 去除Orchestration模块中type的配置
### 缺陷修正
From 55b1895bb2073a40d5b83f95dab6bc3077f5ada2 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Fri, 12 Oct 2018 14:33:59 +0800
Subject: [PATCH 024/100] delete blank line
---
.../spring/boot/OrchestrationSpringBootConfiguration.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
index acab3bf06260c..26924db927c2a 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
@@ -46,7 +46,6 @@
import java.util.LinkedHashMap;
import java.util.Map;
-
/**
* Orchestration spring boot sharding and master-slave configuration.
*
From 59556491411d6b6a103db24281ad6df39fe533cb Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Fri, 12 Oct 2018 19:02:11 +0800
Subject: [PATCH 025/100] modify pattern
---
.../datasource/dialect/SQLServerDataSourceMetaData.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/metadata/datasource/dialect/SQLServerDataSourceMetaData.java b/sharding-core/src/main/java/io/shardingsphere/core/metadata/datasource/dialect/SQLServerDataSourceMetaData.java
index 8ec50d4048fd3..ecb4fab3412a6 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/metadata/datasource/dialect/SQLServerDataSourceMetaData.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/metadata/datasource/dialect/SQLServerDataSourceMetaData.java
@@ -41,7 +41,7 @@ public final class SQLServerDataSourceMetaData implements DataSourceMetaData {
private final String schemeName;
- private final Pattern pattern = Pattern.compile("jdbc:(microsoft:)?sqlserver://([\\w\\-\\.]+):?([0-9]*);(DatabaseName|database)=([\\w\\-]+)", Pattern.CASE_INSENSITIVE);
+ private final Pattern pattern = Pattern.compile("jdbc:(microsoft:)?sqlserver://([\\w\\-\\.]+):?([0-9]*);\\S*(DatabaseName|database)=([\\w\\-]+);", Pattern.CASE_INSENSITIVE);
public SQLServerDataSourceMetaData(final String url) {
Matcher matcher = pattern.matcher(url);
From 7c0569215c8b9837962c58984781589bfc33e1c6 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Fri, 12 Oct 2018 19:06:32 +0800
Subject: [PATCH 026/100] modify patter for mysql
---
.../metadata/datasource/dialect/MySQLDataSourceMetaData.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/metadata/datasource/dialect/MySQLDataSourceMetaData.java b/sharding-core/src/main/java/io/shardingsphere/core/metadata/datasource/dialect/MySQLDataSourceMetaData.java
index b8b0a121fb867..f9a202c76c045 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/metadata/datasource/dialect/MySQLDataSourceMetaData.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/metadata/datasource/dialect/MySQLDataSourceMetaData.java
@@ -41,7 +41,7 @@ public final class MySQLDataSourceMetaData implements DataSourceMetaData {
private final String schemeName;
- private final Pattern pattern = Pattern.compile("jdbc:mysql://([\\w\\-\\.]+):?([0-9]*)/([\\w\\-]+);?\\w*", Pattern.CASE_INSENSITIVE);
+ private final Pattern pattern = Pattern.compile("jdbc:mysql://([\\w\\-\\.]+):?([0-9]*)/([\\w\\-]+);?\\S*", Pattern.CASE_INSENSITIVE);
public MySQLDataSourceMetaData(final String url) {
Matcher matcher = pattern.matcher(url);
From 388670f2bdf29fb843c985e17d2c976cd05b5a32 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Fri, 12 Oct 2018 19:07:00 +0800
Subject: [PATCH 027/100] modify it for h2
---
.../core/metadata/datasource/dialect/H2DataSourceMetaData.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/metadata/datasource/dialect/H2DataSourceMetaData.java b/sharding-core/src/main/java/io/shardingsphere/core/metadata/datasource/dialect/H2DataSourceMetaData.java
index c3f0b37ad602b..21c2d510e2c27 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/metadata/datasource/dialect/H2DataSourceMetaData.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/metadata/datasource/dialect/H2DataSourceMetaData.java
@@ -40,7 +40,7 @@ public final class H2DataSourceMetaData implements DataSourceMetaData {
private final String schemeName;
- private final Pattern pattern = Pattern.compile("jdbc:h2:(mem|~)[:/]([\\w\\-]+);?\\w*", Pattern.CASE_INSENSITIVE);
+ private final Pattern pattern = Pattern.compile("jdbc:h2:(mem|~)[:/]([\\w\\-]+);?\\S*", Pattern.CASE_INSENSITIVE);
public H2DataSourceMetaData(final String url) {
Matcher matcher = pattern.matcher(url);
From a1fc2e8cc256aecafe58c996493bb671189f090b Mon Sep 17 00:00:00 2001
From: caohao
Date: Sat, 13 Oct 2018 10:14:31 +0800
Subject: [PATCH 028/100] for #1316, update insert_multiple_values_for_order
test case 1th.
---
.../insert_multiple_values_for_order_1_2.xml | 29 +++++++++++++++++++
1 file changed, 29 insertions(+)
create mode 100644 sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/tbl/insert_multiple_values_for_order_1_2.xml
diff --git a/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/tbl/insert_multiple_values_for_order_1_2.xml b/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/tbl/insert_multiple_values_for_order_1_2.xml
new file mode 100644
index 0000000000000..bc938e65879da
--- /dev/null
+++ b/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/tbl/insert_multiple_values_for_order_1_2.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 55713add967bc9ac4727390bbb88c19405ff7c9c Mon Sep 17 00:00:00 2001
From: caohao
Date: Sat, 13 Oct 2018 10:14:42 +0800
Subject: [PATCH 029/100] for #1316, update insert_multiple_values_for_order
test case 2th.
---
.../resources/integrate/cases/dml/dml-integrate-test-cases.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dml-integrate-test-cases.xml b/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dml-integrate-test-cases.xml
index c866ed643d232..7613851a70bc7 100644
--- a/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dml-integrate-test-cases.xml
+++ b/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dml-integrate-test-cases.xml
@@ -17,7 +17,7 @@
-
+
From b0806c77174386199eafe7f4687d8e2f83e17808 Mon Sep 17 00:00:00 2001
From: caohao
Date: Sat, 13 Oct 2018 10:16:10 +0800
Subject: [PATCH 030/100] for #1316, update datasource max total from 50 to 5.
---
.../shardingsphere/dbtest/env/datasource/DataSourceUtil.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sharding-jdbc/sharding-jdbc-core/src/test/java/io/shardingsphere/dbtest/env/datasource/DataSourceUtil.java b/sharding-jdbc/sharding-jdbc-core/src/test/java/io/shardingsphere/dbtest/env/datasource/DataSourceUtil.java
index 26f22d0150241..6ab7a73c2719c 100644
--- a/sharding-jdbc/sharding-jdbc-core/src/test/java/io/shardingsphere/dbtest/env/datasource/DataSourceUtil.java
+++ b/sharding-jdbc/sharding-jdbc-core/src/test/java/io/shardingsphere/dbtest/env/datasource/DataSourceUtil.java
@@ -78,7 +78,7 @@ private static DataSource createDBCP(final DatabaseType databaseType, final Stri
result.setUrl(null == dataSourceName ? databaseEnvironment.getURL() : databaseEnvironment.getURL(dataSourceName));
result.setUsername(databaseEnvironment.getUsername());
result.setPassword(databaseEnvironment.getPassword());
- result.setMaxTotal(50);
+ result.setMaxTotal(5);
result.setValidationQuery("SELECT 1");
if (DatabaseType.Oracle == databaseType) {
result.setConnectionInitSqls(Collections.singleton("ALTER SESSION SET CURRENT_SCHEMA = " + dataSourceName));
@@ -93,7 +93,7 @@ private static DataSource createHikariCP(final DatabaseType databaseType, final
result.setJdbcUrl(null == dataSourceName ? databaseEnvironment.getURL() : databaseEnvironment.getURL(dataSourceName));
result.setUsername(databaseEnvironment.getUsername());
result.setPassword(databaseEnvironment.getPassword());
- result.setMaximumPoolSize(50);
+ result.setMaximumPoolSize(5);
result.setTransactionIsolation("TRANSACTION_READ_COMMITTED");
result.setConnectionTestQuery("SELECT 1");
if (DatabaseType.Oracle == databaseType) {
From 1b2552500b986daa7954992d56ac495ab07532a4 Mon Sep 17 00:00:00 2001
From: caohao
Date: Sat, 13 Oct 2018 11:01:58 +0800
Subject: [PATCH 031/100] for #1316, update insert_multiple_values_for_order
test case 3th.
---
.../insert_multiple_values_for_order_1_2.xml | 49 +++++++++++++++++++
1 file changed, 49 insertions(+)
create mode 100644 sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/db/insert_multiple_values_for_order_1_2.xml
diff --git a/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/db/insert_multiple_values_for_order_1_2.xml b/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/db/insert_multiple_values_for_order_1_2.xml
new file mode 100644
index 0000000000000..1ac071d3f06e5
--- /dev/null
+++ b/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/db/insert_multiple_values_for_order_1_2.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 957f6f5207c3a155785a9fee2eb669f4578aaa67 Mon Sep 17 00:00:00 2001
From: caohao
Date: Sat, 13 Oct 2018 11:02:14 +0800
Subject: [PATCH 032/100] for #1316, update insert_multiple_values_for_order
test case 4th.
---
.../insert_multiple_values_for_order_1_2.xml | 209 ++++++++++++++++++
1 file changed, 209 insertions(+)
create mode 100644 sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/dbtbl_with_masterslave/insert_multiple_values_for_order_1_2.xml
diff --git a/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/dbtbl_with_masterslave/insert_multiple_values_for_order_1_2.xml b/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/dbtbl_with_masterslave/insert_multiple_values_for_order_1_2.xml
new file mode 100644
index 0000000000000..3424f983feadf
--- /dev/null
+++ b/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/dbtbl_with_masterslave/insert_multiple_values_for_order_1_2.xml
@@ -0,0 +1,209 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 4631dff11e35f94b6e78597ab59161d1fa464928 Mon Sep 17 00:00:00 2001
From: caohao
Date: Sat, 13 Oct 2018 11:35:12 +0800
Subject: [PATCH 033/100] for #1316, update insert_on_duplicate_key_update test
case 1th.
---
.../resources/integrate/cases/dml/dml-integrate-test-cases.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dml-integrate-test-cases.xml b/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dml-integrate-test-cases.xml
index 7613851a70bc7..1efe4ae591e5e 100644
--- a/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dml-integrate-test-cases.xml
+++ b/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dml-integrate-test-cases.xml
@@ -21,7 +21,7 @@
-
+
From 36a89baeffb8445f26488eebad607388b0602b45 Mon Sep 17 00:00:00 2001
From: caohao
Date: Sat, 13 Oct 2018 11:35:22 +0800
Subject: [PATCH 034/100] for #1316, update insert_on_duplicate_key_update test
case 2th.
---
.../tbl/insert_on_duplicate_key_update.xml | 27 +++++++++++++++++++
1 file changed, 27 insertions(+)
create mode 100644 sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/tbl/insert_on_duplicate_key_update.xml
diff --git a/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/tbl/insert_on_duplicate_key_update.xml b/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/tbl/insert_on_duplicate_key_update.xml
new file mode 100644
index 0000000000000..2562e40ccafcd
--- /dev/null
+++ b/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/tbl/insert_on_duplicate_key_update.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 16c148ac0b03a1e969bda7e3c8fe44b2be39c6f0 Mon Sep 17 00:00:00 2001
From: caohao
Date: Sat, 13 Oct 2018 11:35:32 +0800
Subject: [PATCH 035/100] for #1316, update insert_on_duplicate_key_update test
case 3th.
---
.../insert_on_duplicate_key_update.xml | 127 ++++++++++++++++++
1 file changed, 127 insertions(+)
create mode 100644 sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/masterslave/insert_on_duplicate_key_update.xml
diff --git a/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/masterslave/insert_on_duplicate_key_update.xml b/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/masterslave/insert_on_duplicate_key_update.xml
new file mode 100644
index 0000000000000..0179c323703c3
--- /dev/null
+++ b/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/masterslave/insert_on_duplicate_key_update.xml
@@ -0,0 +1,127 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From ed8965a03182c23cb79ff8f3cb63bd6d16753e9e Mon Sep 17 00:00:00 2001
From: caohao
Date: Sat, 13 Oct 2018 11:35:42 +0800
Subject: [PATCH 036/100] for #1316, update insert_on_duplicate_key_update test
case 4th.
---
.../insert_on_duplicate_key_update.xml | 207 ++++++++++++++++++
1 file changed, 207 insertions(+)
create mode 100644 sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/dbtbl_with_masterslave/insert_on_duplicate_key_update.xml
diff --git a/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/dbtbl_with_masterslave/insert_on_duplicate_key_update.xml b/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/dbtbl_with_masterslave/insert_on_duplicate_key_update.xml
new file mode 100644
index 0000000000000..e4cc67d13e7de
--- /dev/null
+++ b/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/dbtbl_with_masterslave/insert_on_duplicate_key_update.xml
@@ -0,0 +1,207 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 9faa1eb76e4e60afc335449f7db4e2e02fd9ce79 Mon Sep 17 00:00:00 2001
From: caohao
Date: Sat, 13 Oct 2018 11:35:50 +0800
Subject: [PATCH 037/100] for #1316, update insert_on_duplicate_key_update test
case 5th.
---
.../db/insert_on_duplicate_key_update.xml | 47 +++++++++++++++++++
1 file changed, 47 insertions(+)
create mode 100644 sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/db/insert_on_duplicate_key_update.xml
diff --git a/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/db/insert_on_duplicate_key_update.xml b/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/db/insert_on_duplicate_key_update.xml
new file mode 100644
index 0000000000000..7f972b435eba0
--- /dev/null
+++ b/sharding-jdbc/sharding-jdbc-core/src/test/resources/integrate/cases/dml/dataset/db/insert_on_duplicate_key_update.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 4836e161b9201f71be8955b38a563b0b912e7e61 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Sat, 13 Oct 2018 20:05:30 +0800
Subject: [PATCH 038/100] modify url
---
.../datasource/dialect/SQLServerDataSourceMetaData.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/metadata/datasource/dialect/SQLServerDataSourceMetaData.java b/sharding-core/src/main/java/io/shardingsphere/core/metadata/datasource/dialect/SQLServerDataSourceMetaData.java
index ecb4fab3412a6..c7fb32b78b7c6 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/metadata/datasource/dialect/SQLServerDataSourceMetaData.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/metadata/datasource/dialect/SQLServerDataSourceMetaData.java
@@ -41,7 +41,7 @@ public final class SQLServerDataSourceMetaData implements DataSourceMetaData {
private final String schemeName;
- private final Pattern pattern = Pattern.compile("jdbc:(microsoft:)?sqlserver://([\\w\\-\\.]+):?([0-9]*);\\S*(DatabaseName|database)=([\\w\\-]+);", Pattern.CASE_INSENSITIVE);
+ private final Pattern pattern = Pattern.compile("jdbc:(microsoft:)?sqlserver://([\\w\\-\\.]+):?([0-9]*);\\S*(DatabaseName|database)=([\\w\\-]+);?", Pattern.CASE_INSENSITIVE);
public SQLServerDataSourceMetaData(final String url) {
Matcher matcher = pattern.matcher(url);
From 90b411eee57fd7370f2a6072150c921861234d21 Mon Sep 17 00:00:00 2001
From: terrymanu
Date: Sun, 14 Oct 2018 00:43:40 +0800
Subject: [PATCH 039/100] decouple ShardingSchema & JDBCBackendDataSource
---
.../datasource/JDBCBackendDataSource.java | 50 ++++++++++---------
.../shardingproxy/runtime/GlobalRegistry.java | 2 +-
.../shardingproxy/runtime/ShardingSchema.java | 28 +----------
3 files changed, 29 insertions(+), 51 deletions(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/backend/jdbc/datasource/JDBCBackendDataSource.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/backend/jdbc/datasource/JDBCBackendDataSource.java
index 80e695873816e..6edc5d87add27 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/backend/jdbc/datasource/JDBCBackendDataSource.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/backend/jdbc/datasource/JDBCBackendDataSource.java
@@ -22,13 +22,13 @@
import io.shardingsphere.core.rule.DataSourceParameter;
import io.shardingsphere.shardingproxy.backend.BackendDataSource;
import io.shardingsphere.shardingproxy.runtime.GlobalRegistry;
-import io.shardingsphere.shardingproxy.runtime.ShardingSchema;
import javax.sql.DataSource;
import java.lang.reflect.Method;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
@@ -44,22 +44,22 @@
*/
public final class JDBCBackendDataSource implements BackendDataSource, AutoCloseable {
- private final ShardingSchema shardingSchema;
+ private final Map dataSources;
- private final Map dataSourceMap;
+ private final Map availableDataSources;
- public JDBCBackendDataSource(final ShardingSchema shardingSchema) {
- this.shardingSchema = shardingSchema;
- dataSourceMap = createDataSourceMap();
+ public JDBCBackendDataSource(final Map dataSourceParameters) {
+ dataSources = createDataSourceMap(dataSourceParameters);
+ availableDataSources = new LinkedHashMap<>(dataSources);
}
- private Map createDataSourceMap() {
+ private Map createDataSourceMap(final Map dataSourceParameters) {
// TODO getCircuitDataSourceMap if getCircuitBreakerDataSourceNames() is not empty
- return getNormalDataSourceMap(shardingSchema.getDataSources());
+ return getNormalDataSourceMap(dataSourceParameters);
}
private Map getNormalDataSourceMap(final Map dataSourceParameters) {
- Map result = new LinkedHashMap<>(dataSourceParameters.size());
+ Map result = new LinkedHashMap<>(dataSourceParameters.size(), 1);
for (Entry entry : dataSourceParameters.entrySet()) {
try {
result.put(entry.getKey(), getBackendDataSourceFactory().build(entry.getKey(), entry.getValue()));
@@ -81,6 +81,22 @@ private JDBCBackendDataSourceFactory getBackendDataSourceFactory() {
}
}
+ /**
+ * Set available data sources.
+ *
+ * @param disabledDataSourceNames disabled data source names
+ */
+ public void setAvailableDataSources(final Collection disabledDataSourceNames) {
+ synchronized (availableDataSources) {
+ availableDataSources.clear();
+ for (Entry entry : dataSources.entrySet()) {
+ if (!disabledDataSourceNames.contains(entry.getKey())) {
+ availableDataSources.put(entry.getKey(), entry.getValue());
+ }
+ }
+ }
+ }
+
/**
* Get connection.
*
@@ -103,7 +119,7 @@ public Connection getConnection(final String dataSourceName) throws SQLException
*/
@SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
public List getConnections(final ConnectionMode connectionMode, final String dataSourceName, final int connectionSize) throws SQLException {
- DataSource dataSource = getDataSourceMap().get(dataSourceName);
+ DataSource dataSource = availableDataSources.get(dataSourceName);
if (1 == connectionSize) {
return Collections.singletonList(dataSource.getConnection());
}
@@ -115,18 +131,6 @@ public List getConnections(final ConnectionMode connectionMode, fina
}
}
- private Map getDataSourceMap() {
- return shardingSchema.getDisabledDataSourceNames().isEmpty() ? dataSourceMap : getAvailableDataSourceMap();
- }
-
- private Map getAvailableDataSourceMap() {
- Map result = new LinkedHashMap<>(dataSourceMap);
- for (String each : shardingSchema.getDisabledDataSourceNames()) {
- result.remove(each);
- }
- return result;
- }
-
private List createConnections(final DataSource dataSource, final int connectionSize) throws SQLException {
List result = new ArrayList<>(connectionSize);
for (int i = 0; i < connectionSize; i++) {
@@ -141,7 +145,7 @@ public void close() {
}
private void closeOriginalDataSources() {
- for (DataSource each : dataSourceMap.values()) {
+ for (DataSource each : dataSources.values()) {
try {
Method method = each.getClass().getDeclaredMethod("close");
method.invoke(each);
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
index df49504b29dc4..c2f905f8b793e 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
@@ -196,7 +196,7 @@ public void renewCircuitBreakerDataSourceNames(final CircuitStateEventBusEvent c
@Subscribe
public void renewDisabledDataSourceNames(final ProxyDisabledStateEventBusEvent disabledStateEventBusEvent) {
for (Entry entry : shardingSchemas.entrySet()) {
- entry.getValue().setDisabledDataSourceNames(disabledStateEventBusEvent.getDisabledSchemaDataSourceMap().get(entry.getKey()));
+ entry.getValue().getBackendDataSource().setAvailableDataSources(disabledStateEventBusEvent.getDisabledSchemaDataSourceMap().get(entry.getKey()));
}
}
}
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
index bbfe3f1fa2ffb..f3ae8dd8e2e3a 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
@@ -28,11 +28,8 @@
import io.shardingsphere.shardingproxy.backend.jdbc.datasource.JDBCBackendDataSource;
import io.shardingsphere.shardingproxy.runtime.metadata.ProxyTableMetaDataConnectionManager;
import lombok.Getter;
-import lombok.Setter;
-import java.util.Collection;
import java.util.LinkedHashMap;
-import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;
@@ -60,16 +57,13 @@ public final class ShardingSchema {
private ShardingMetaData metaData;
- @Setter
- private Collection disabledDataSourceNames = new LinkedList<>();
-
public ShardingSchema(final String name, final Map dataSources, final YamlRuleConfiguration rule) {
this.name = name;
// TODO :jiaqi only use JDBC need connect db via JDBC, netty style should use SQL packet to get metadata
this.dataSources = dataSources;
shardingRule = new ShardingRule(null == rule.getShardingRule() ? new ShardingRuleConfiguration() : rule.getShardingRule().getShardingRuleConfiguration(), dataSources.keySet());
masterSlaveRule = null == rule.getMasterSlaveRule() ? null : new MasterSlaveRule(rule.getMasterSlaveRule().getMasterSlaveRuleConfiguration());
- backendDataSource = new JDBCBackendDataSource(this);
+ backendDataSource = new JDBCBackendDataSource(dataSources);
}
/**
@@ -98,24 +92,4 @@ private Map getDataSourceURLs(final Map getDataSources() {
- if (!getDisabledDataSourceNames().isEmpty()) {
- return getAvailableDataSourceConfigurationMap();
- }
- return dataSources;
- }
-
- private Map getAvailableDataSourceConfigurationMap() {
- Map result = new LinkedHashMap<>(dataSources);
- for (String each : disabledDataSourceNames) {
- result.remove(each);
- }
- return result;
- }
}
From 262e75c27d596448fee508499ac9ad1e96a79365 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Sun, 14 Oct 2018 18:12:56 +0800
Subject: [PATCH 040/100] add getDisabledDataSourceNames()
---
.../shardingproxy/runtime/GlobalRegistry.java | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
index c2f905f8b793e..5deeb2e329025 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
@@ -36,6 +36,7 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
+import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -196,7 +197,17 @@ public void renewCircuitBreakerDataSourceNames(final CircuitStateEventBusEvent c
@Subscribe
public void renewDisabledDataSourceNames(final ProxyDisabledStateEventBusEvent disabledStateEventBusEvent) {
for (Entry entry : shardingSchemas.entrySet()) {
- entry.getValue().getBackendDataSource().setAvailableDataSources(disabledStateEventBusEvent.getDisabledSchemaDataSourceMap().get(entry.getKey()));
+ entry.getValue().getBackendDataSource().setAvailableDataSources(getDisabledDataSourceNames(disabledStateEventBusEvent.getDisabledSchemaDataSourceMap(), entry));
}
}
+
+ private Collection getDisabledDataSourceNames(final Map> disabledSchemaDataSourceMap, final Entry shardingSchema) {
+ Collection result = new LinkedList<>();
+ if (disabledSchemaDataSourceMap.containsKey(shardingSchema.getKey())) {
+ result.addAll(disabledSchemaDataSourceMap.get(shardingSchema.getKey()));
+ }
+ return result;
+ }
}
+
+
From de0d0c8e17d164bd94d0b0902f4bdad3019ecb57 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Sun, 14 Oct 2018 18:13:11 +0800
Subject: [PATCH 041/100] for checkstyle
---
.../io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java | 2 --
1 file changed, 2 deletions(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
index 5deeb2e329025..a27438a70bde1 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
@@ -209,5 +209,3 @@ private Collection getDisabledDataSourceNames(final Map
Date: Sun, 14 Oct 2018 18:15:53 +0800
Subject: [PATCH 042/100] modify getDisabledDataSourceNames()
---
.../shardingproxy/runtime/GlobalRegistry.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
index a27438a70bde1..aade829a5dc14 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
@@ -197,14 +197,14 @@ public void renewCircuitBreakerDataSourceNames(final CircuitStateEventBusEvent c
@Subscribe
public void renewDisabledDataSourceNames(final ProxyDisabledStateEventBusEvent disabledStateEventBusEvent) {
for (Entry entry : shardingSchemas.entrySet()) {
- entry.getValue().getBackendDataSource().setAvailableDataSources(getDisabledDataSourceNames(disabledStateEventBusEvent.getDisabledSchemaDataSourceMap(), entry));
+ entry.getValue().getBackendDataSource().setAvailableDataSources(getDisabledDataSourceNames(disabledStateEventBusEvent.getDisabledSchemaDataSourceMap(), entry.getKey()));
}
}
- private Collection getDisabledDataSourceNames(final Map> disabledSchemaDataSourceMap, final Entry shardingSchema) {
+ private Collection getDisabledDataSourceNames(final Map> disabledSchemaDataSourceMap, final String shardingSchemaName) {
Collection result = new LinkedList<>();
- if (disabledSchemaDataSourceMap.containsKey(shardingSchema.getKey())) {
- result.addAll(disabledSchemaDataSourceMap.get(shardingSchema.getKey()));
+ if (disabledSchemaDataSourceMap.containsKey(shardingSchemaName)) {
+ result.addAll(disabledSchemaDataSourceMap.get(shardingSchemaName));
}
return result;
}
From 713b326f26ec79d8f450eb88e489fbb6a40508c9 Mon Sep 17 00:00:00 2001
From: terrymanu
Date: Mon, 15 Oct 2018 14:07:34 +0800
Subject: [PATCH 043/100] fix author
---
.../io/shardingsphere/api/config/TableRuleConfiguration.java | 2 +-
.../shardingsphere/core/routing/StatementRoutingEngine.java | 4 ++--
.../core/routing/router/masterslave/MasterSlaveRouter.java | 2 +-
.../core/routing/router/masterslave/MasterVisitedManager.java | 2 +-
.../routing/router/masterslave/ShardingMasterSlaveRouter.java | 2 +-
.../core/routing/router/sharding/DatabaseHintSQLRouter.java | 2 +-
.../core/routing/router/sharding/ParsingSQLRouter.java | 4 ++--
.../core/routing/router/sharding/ShardingRouter.java | 2 +-
.../core/routing/router/sharding/ShardingRouterFactory.java | 4 ++--
9 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/sharding-core/src/main/java/io/shardingsphere/api/config/TableRuleConfiguration.java b/sharding-core/src/main/java/io/shardingsphere/api/config/TableRuleConfiguration.java
index e76b0d3138de7..350a5cdcb46a5 100644
--- a/sharding-core/src/main/java/io/shardingsphere/api/config/TableRuleConfiguration.java
+++ b/sharding-core/src/main/java/io/shardingsphere/api/config/TableRuleConfiguration.java
@@ -25,7 +25,7 @@
/**
* Table rule configuration.
*
- * @author zhangiang
+ * @author zhangliang
*/
@Getter
@Setter
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/routing/StatementRoutingEngine.java b/sharding-core/src/main/java/io/shardingsphere/core/routing/StatementRoutingEngine.java
index 5f2884f7167a7..17cf6b06e7d93 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/routing/StatementRoutingEngine.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/routing/StatementRoutingEngine.java
@@ -18,9 +18,9 @@
package io.shardingsphere.core.routing;
import io.shardingsphere.core.constant.DatabaseType;
+import io.shardingsphere.core.metadata.datasource.ShardingDataSourceMetaData;
import io.shardingsphere.core.metadata.table.ShardingTableMetaData;
import io.shardingsphere.core.parsing.parser.sql.SQLStatement;
-import io.shardingsphere.core.metadata.datasource.ShardingDataSourceMetaData;
import io.shardingsphere.core.routing.router.masterslave.ShardingMasterSlaveRouter;
import io.shardingsphere.core.routing.router.sharding.ShardingRouter;
import io.shardingsphere.core.routing.router.sharding.ShardingRouterFactory;
@@ -31,7 +31,7 @@
/**
* Statement routing engine.
*
- * @author zhangiang
+ * @author zhangliang
* @author panjuan
*/
public final class StatementRoutingEngine {
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/routing/router/masterslave/MasterSlaveRouter.java b/sharding-core/src/main/java/io/shardingsphere/core/routing/router/masterslave/MasterSlaveRouter.java
index 533cf3ddd7ef2..b48a0df9797e0 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/routing/router/masterslave/MasterSlaveRouter.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/routing/router/masterslave/MasterSlaveRouter.java
@@ -31,7 +31,7 @@
/**
* Master slave router interface.
*
- * @author zhangiang
+ * @author zhangliang
* @author panjuan
*/
@RequiredArgsConstructor
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/routing/router/masterslave/MasterVisitedManager.java b/sharding-core/src/main/java/io/shardingsphere/core/routing/router/masterslave/MasterVisitedManager.java
index b4fbe3537b9d1..0e40dd33198a5 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/routing/router/masterslave/MasterVisitedManager.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/routing/router/masterslave/MasterVisitedManager.java
@@ -22,7 +22,7 @@
*
* Trace master data source visited or not in current thread.
*
- * @author zhangiang
+ * @author zhangliang
*/
public final class MasterVisitedManager {
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/routing/router/masterslave/ShardingMasterSlaveRouter.java b/sharding-core/src/main/java/io/shardingsphere/core/routing/router/masterslave/ShardingMasterSlaveRouter.java
index a46de6176d857..3727e231940cc 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/routing/router/masterslave/ShardingMasterSlaveRouter.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/routing/router/masterslave/ShardingMasterSlaveRouter.java
@@ -31,7 +31,7 @@
/**
* Sharding with master-slave router interface.
*
- * @author zhangiang
+ * @author zhangliang
*/
@RequiredArgsConstructor
public final class ShardingMasterSlaveRouter {
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/routing/router/sharding/DatabaseHintSQLRouter.java b/sharding-core/src/main/java/io/shardingsphere/core/routing/router/sharding/DatabaseHintSQLRouter.java
index 999bca491f976..bee615d86238d 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/routing/router/sharding/DatabaseHintSQLRouter.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/routing/router/sharding/DatabaseHintSQLRouter.java
@@ -37,7 +37,7 @@
/**
* Sharding router for hint database only.
*
- * @author zhangiang
+ * @author zhangliang
* @author maxiaoguang
*/
@RequiredArgsConstructor
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/routing/router/sharding/ParsingSQLRouter.java b/sharding-core/src/main/java/io/shardingsphere/core/routing/router/sharding/ParsingSQLRouter.java
index 384d778fd086d..d485d573bd008 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/routing/router/sharding/ParsingSQLRouter.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/routing/router/sharding/ParsingSQLRouter.java
@@ -51,9 +51,9 @@
import io.shardingsphere.core.routing.type.unicast.UnicastRoutingEngine;
import io.shardingsphere.core.rule.ShardingRule;
import io.shardingsphere.core.rule.TableRule;
+import io.shardingsphere.core.util.SQLLogger;
import io.shardingsphere.spi.parsing.ParsingHook;
import io.shardingsphere.spi.parsing.SPIParsingHook;
-import io.shardingsphere.core.util.SQLLogger;
import lombok.RequiredArgsConstructor;
import java.util.Collection;
@@ -63,7 +63,7 @@
/**
* Sharding router with parse.
*
- * @author zhangiang
+ * @author zhangliang
* @author maxiaoguang
* @author panjuan
*/
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/routing/router/sharding/ShardingRouter.java b/sharding-core/src/main/java/io/shardingsphere/core/routing/router/sharding/ShardingRouter.java
index 38e555b92890c..d64a7cc49cea6 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/routing/router/sharding/ShardingRouter.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/routing/router/sharding/ShardingRouter.java
@@ -25,7 +25,7 @@
/**
* Sharding router.
*
- * @author zhangiang
+ * @author zhangliang
*/
public interface ShardingRouter {
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/routing/router/sharding/ShardingRouterFactory.java b/sharding-core/src/main/java/io/shardingsphere/core/routing/router/sharding/ShardingRouterFactory.java
index f7345b265e39b..d684f55dda388 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/routing/router/sharding/ShardingRouterFactory.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/routing/router/sharding/ShardingRouterFactory.java
@@ -19,8 +19,8 @@
import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.hint.HintManagerHolder;
-import io.shardingsphere.core.metadata.table.ShardingTableMetaData;
import io.shardingsphere.core.metadata.datasource.ShardingDataSourceMetaData;
+import io.shardingsphere.core.metadata.table.ShardingTableMetaData;
import io.shardingsphere.core.rule.ShardingRule;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -28,7 +28,7 @@
/**
* Sharding router factory.
*
- * @author zhangiang
+ * @author zhangliang
* @author panjuan
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
From 07e0904e832b1b08e38d7f33b32ecebbd8f884d4 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 15:01:42 +0800
Subject: [PATCH 044/100] delete final
---
.../main/java/io/shardingsphere/core/rule/MasterSlaveRule.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/rule/MasterSlaveRule.java b/sharding-core/src/main/java/io/shardingsphere/core/rule/MasterSlaveRule.java
index 565f2c63fa571..c1e3481818ed6 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/rule/MasterSlaveRule.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/rule/MasterSlaveRule.java
@@ -32,7 +32,7 @@
* @author panjuan
*/
@Getter
-public final class MasterSlaveRule {
+public class MasterSlaveRule {
private final String name;
From 7d58086198a498682bb545a701730f18a771768f Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 15:01:54 +0800
Subject: [PATCH 045/100] add OrchestrationMasterSlaveRule.java
---
.../rule/OrchestrationMasterSlaveRule.java | 37 +++++++++++++++++++
1 file changed, 37 insertions(+)
create mode 100644 sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
new file mode 100644
index 0000000000000..ae9d8f02957f8
--- /dev/null
+++ b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package io.shardingsphere.shardingjdbc.orchestration.internal.rule;
+
+import io.shardingsphere.api.config.MasterSlaveRuleConfiguration;
+import io.shardingsphere.core.rule.MasterSlaveRule;
+
+import java.util.Collection;
+import java.util.LinkedList;
+
+/**
+ * Orchestration master slave rule.
+ *
+ * @author panjuan
+ */
+public class OrchestrationMasterSlaveRule extends MasterSlaveRule {
+
+ private final Collection disabledDataSourceNames = new LinkedList<>();
+
+ public OrchestrationMasterSlaveRule(final MasterSlaveRuleConfiguration config) {
+ super(config);
+ }
+}
From 91317cf08913ed9ec02d08d8daef285fdfc58d81 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 15:05:04 +0800
Subject: [PATCH 046/100] getSlaveDataSourceNames()
---
.../internal/rule/OrchestrationMasterSlaveRule.java | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
index ae9d8f02957f8..97d1027b3f58f 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
@@ -34,4 +34,13 @@ public class OrchestrationMasterSlaveRule extends MasterSlaveRule {
public OrchestrationMasterSlaveRule(final MasterSlaveRuleConfiguration config) {
super(config);
}
+
+ @Override
+ public Collection getSlaveDataSourceNames() {
+ Collection result = new LinkedList<>(super.getSlaveDataSourceNames());
+ for (String each : disabledDataSourceNames) {
+ result.remove(each);
+ }
+ return result;
+ }
}
From 6af688c1494b869d29a1aa5fa477bf4b3a11f704 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 15:06:16 +0800
Subject: [PATCH 047/100] add java doc
---
.../internal/rule/OrchestrationMasterSlaveRule.java | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
index 97d1027b3f58f..0a0289c878494 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
@@ -35,6 +35,11 @@ public OrchestrationMasterSlaveRule(final MasterSlaveRuleConfiguration config) {
super(config);
}
+ /**
+ * Get slave data source names.
+ *
+ * @return available slave data source name
+ */
@Override
public Collection getSlaveDataSourceNames() {
Collection result = new LinkedList<>(super.getSlaveDataSourceNames());
From 5a2c71a959e0208bb29c35357c2722767038244b Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 15:06:42 +0800
Subject: [PATCH 048/100] for checkstyle
---
.../internal/rule/OrchestrationMasterSlaveRule.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
index 0a0289c878494..8e8db5d2f73b3 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
@@ -14,6 +14,7 @@
* limitations under the License.
*
*/
+
package io.shardingsphere.shardingjdbc.orchestration.internal.rule;
import io.shardingsphere.api.config.MasterSlaveRuleConfiguration;
From a1f27fd124300536503548e55bf84ddee75cc8b6 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 15:14:33 +0800
Subject: [PATCH 049/100] add renew()
---
.../internal/rule/OrchestrationMasterSlaveRule.java | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
index 8e8db5d2f73b3..16bffa3c94fe8 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
@@ -17,8 +17,10 @@
package io.shardingsphere.shardingjdbc.orchestration.internal.rule;
+import com.google.common.eventbus.Subscribe;
import io.shardingsphere.api.config.MasterSlaveRuleConfiguration;
import io.shardingsphere.core.rule.MasterSlaveRule;
+import io.shardingsphere.orchestration.internal.event.state.DisabledStateEventBusEvent;
import java.util.Collection;
import java.util.LinkedList;
@@ -49,4 +51,15 @@ public Collection getSlaveDataSourceNames() {
}
return result;
}
+
+ /**
+ * Renew disable dataSource names.
+ *
+ * @param disabledStateEventBusEvent jdbc disabled event bus event
+ */
+ @Subscribe
+ public void renew(final DisabledStateEventBusEvent disabledStateEventBusEvent) {
+ disabledDataSourceNames.clear();
+ disabledDataSourceNames.addAll(disabledStateEventBusEvent.getDisabledDataSourceNames());
+ }
}
From 5caea0cbb53e6e02ba6f91c9ce43faae088d2b23 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 15:15:17 +0800
Subject: [PATCH 050/100] add final
---
.../internal/rule/OrchestrationMasterSlaveRule.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
index 16bffa3c94fe8..fdccccd5b5406 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
@@ -30,7 +30,7 @@
*
* @author panjuan
*/
-public class OrchestrationMasterSlaveRule extends MasterSlaveRule {
+public final class OrchestrationMasterSlaveRule extends MasterSlaveRule {
private final Collection disabledDataSourceNames = new LinkedList<>();
From e0dd27680efa7d8a6486480a14fd6440a808b9f1 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 15:15:40 +0800
Subject: [PATCH 051/100] add OrchestrationShardingRule
---
.../rule/OrchestrationShardingRule.java | 27 +++++++++++++++++++
1 file changed, 27 insertions(+)
create mode 100644 sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationShardingRule.java
diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationShardingRule.java b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationShardingRule.java
new file mode 100644
index 0000000000000..34ed96ede5948
--- /dev/null
+++ b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationShardingRule.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package io.shardingsphere.shardingjdbc.orchestration.internal.rule;
+
+import io.shardingsphere.core.rule.ShardingRule;
+
+/**
+ * Orchestration sharding rule.
+ *
+ * @author panjuan
+ */
+public final class OrchestrationShardingRule extends ShardingRule {
+}
From fc1cad4da2582675c58aa528263383dab20b7649 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 15:15:53 +0800
Subject: [PATCH 052/100] delete final
---
.../src/main/java/io/shardingsphere/core/rule/ShardingRule.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/rule/ShardingRule.java b/sharding-core/src/main/java/io/shardingsphere/core/rule/ShardingRule.java
index d00f09e5c9d6a..ba4e7bca538eb 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/rule/ShardingRule.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/rule/ShardingRule.java
@@ -47,7 +47,7 @@
* @author panjuan
*/
@Getter
-public final class ShardingRule {
+public class ShardingRule {
private final ShardingRuleConfiguration shardingRuleConfig;
From 402495b41443f74df8a124c1c2df2790a8ec297b Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 15:17:47 +0800
Subject: [PATCH 053/100] OrchestrationShardingRule's construction function
---
.../internal/rule/OrchestrationShardingRule.java | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationShardingRule.java b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationShardingRule.java
index 34ed96ede5948..bb092c53bda9f 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationShardingRule.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationShardingRule.java
@@ -16,12 +16,22 @@
*/
package io.shardingsphere.shardingjdbc.orchestration.internal.rule;
+import io.shardingsphere.api.config.ShardingRuleConfiguration;
import io.shardingsphere.core.rule.ShardingRule;
+import java.util.Collection;
+import java.util.LinkedList;
+
/**
* Orchestration sharding rule.
*
* @author panjuan
*/
public final class OrchestrationShardingRule extends ShardingRule {
+
+ private final Collection DisabledDataSourceNames = new LinkedList<>();
+
+ public OrchestrationShardingRule(final ShardingRuleConfiguration shardingRuleConfig, final Collection dataSourceNames) {
+ super(shardingRuleConfig, dataSourceNames);
+ }
}
From 432cb50b3249c29c78d91159efab43b9ee375d0d Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 15:29:02 +0800
Subject: [PATCH 054/100] initMasterSlaveRules()
---
.../internal/rule/OrchestrationShardingRule.java | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationShardingRule.java b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationShardingRule.java
index bb092c53bda9f..83cada03459d7 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationShardingRule.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationShardingRule.java
@@ -16,6 +16,7 @@
*/
package io.shardingsphere.shardingjdbc.orchestration.internal.rule;
+import io.shardingsphere.api.config.MasterSlaveRuleConfiguration;
import io.shardingsphere.api.config.ShardingRuleConfiguration;
import io.shardingsphere.core.rule.ShardingRule;
@@ -29,9 +30,16 @@
*/
public final class OrchestrationShardingRule extends ShardingRule {
- private final Collection DisabledDataSourceNames = new LinkedList<>();
+ private final Collection masterSlaveRules = new LinkedList<>();
public OrchestrationShardingRule(final ShardingRuleConfiguration shardingRuleConfig, final Collection dataSourceNames) {
super(shardingRuleConfig, dataSourceNames);
+ initMasterSlaveRules(shardingRuleConfig);
+ }
+
+ private void initMasterSlaveRules(final ShardingRuleConfiguration shardingRuleConfig) {
+ for (MasterSlaveRuleConfiguration each : shardingRuleConfig.getMasterSlaveRuleConfigs()) {
+ masterSlaveRules.add(new OrchestrationMasterSlaveRule(each));
+ }
}
}
From 1f8cd12b7a6bc2be985f54d3de5cd4b8a570e86b Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 15:35:25 +0800
Subject: [PATCH 055/100] add getMasterSlaveRules()
---
.../internal/rule/OrchestrationShardingRule.java | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationShardingRule.java b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationShardingRule.java
index 83cada03459d7..3d729035503cc 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationShardingRule.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationShardingRule.java
@@ -16,10 +16,14 @@
*/
package io.shardingsphere.shardingjdbc.orchestration.internal.rule;
+import com.google.common.base.Function;
+import com.google.common.collect.Collections2;
import io.shardingsphere.api.config.MasterSlaveRuleConfiguration;
import io.shardingsphere.api.config.ShardingRuleConfiguration;
+import io.shardingsphere.core.rule.MasterSlaveRule;
import io.shardingsphere.core.rule.ShardingRule;
+import javax.annotation.Nullable;
import java.util.Collection;
import java.util.LinkedList;
@@ -42,4 +46,15 @@ private void initMasterSlaveRules(final ShardingRuleConfiguration shardingRuleCo
masterSlaveRules.add(new OrchestrationMasterSlaveRule(each));
}
}
+
+ @Override
+ public Collection getMasterSlaveRules() {
+ return Collections2.transform(masterSlaveRules, new Function() {
+
+ @Override
+ public MasterSlaveRule apply(final OrchestrationMasterSlaveRule input) {
+ return input;
+ }
+ });
+ }
}
From 8c20c59968d4e79768c3e6bb42f670d649990874 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 15:35:39 +0800
Subject: [PATCH 056/100] for check style
---
.../orchestration/internal/rule/OrchestrationShardingRule.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationShardingRule.java b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationShardingRule.java
index 3d729035503cc..8cd752bfb0fe1 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationShardingRule.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationShardingRule.java
@@ -14,6 +14,7 @@
* limitations under the License.
*
*/
+
package io.shardingsphere.shardingjdbc.orchestration.internal.rule;
import com.google.common.base.Function;
@@ -23,7 +24,6 @@
import io.shardingsphere.core.rule.MasterSlaveRule;
import io.shardingsphere.core.rule.ShardingRule;
-import javax.annotation.Nullable;
import java.util.Collection;
import java.util.LinkedList;
From f2aaaf8ca6dbb58bf50be2cd3a814855a1f77e16 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 16:02:02 +0800
Subject: [PATCH 057/100] use OrchestrationShardingRule
---
.../datasource/OrchestrationShardingDataSource.java | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
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 ef73934eaa8de..6651781351929 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
@@ -21,7 +21,6 @@
import com.google.common.eventbus.Subscribe;
import io.shardingsphere.api.ConfigMapContext;
import io.shardingsphere.api.config.ShardingRuleConfiguration;
-import io.shardingsphere.core.rule.ShardingRule;
import io.shardingsphere.orchestration.config.OrchestrationConfiguration;
import io.shardingsphere.orchestration.internal.OrchestrationFacade;
import io.shardingsphere.orchestration.internal.config.ConfigurationService;
@@ -29,6 +28,7 @@
import io.shardingsphere.orchestration.internal.event.state.DisabledStateEventBusEvent;
import io.shardingsphere.shardingjdbc.jdbc.core.datasource.ShardingDataSource;
import io.shardingsphere.shardingjdbc.orchestration.internal.circuit.datasource.CircuitBreakerDataSource;
+import io.shardingsphere.shardingjdbc.orchestration.internal.rule.OrchestrationShardingRule;
import javax.sql.DataSource;
import java.sql.Connection;
@@ -47,7 +47,8 @@ public class OrchestrationShardingDataSource extends AbstractOrchestrationDataSo
public OrchestrationShardingDataSource(final ShardingDataSource shardingDataSource, final OrchestrationConfiguration orchestrationConfig) throws SQLException {
super(new OrchestrationFacade(orchestrationConfig), shardingDataSource.getDataSourceMap());
- this.dataSource = shardingDataSource;
+ this.dataSource = new ShardingDataSource(shardingDataSource.getDataSourceMap(), new OrchestrationShardingRule(shardingDataSource.getShardingContext().getShardingRule().getShardingRuleConfig(),
+ shardingDataSource.getDataSourceMap().keySet()));
initOrchestrationFacade(dataSource);
}
@@ -57,7 +58,7 @@ public OrchestrationShardingDataSource(final OrchestrationConfiguration orchestr
ShardingRuleConfiguration shardingRuleConfig = configService.loadShardingRuleConfiguration();
Preconditions.checkState(null != shardingRuleConfig && !shardingRuleConfig.getTableRuleConfigs().isEmpty(), "Missing the sharding rule configuration on register center");
dataSource = new ShardingDataSource(configService.loadDataSourceMap(),
- new ShardingRule(shardingRuleConfig, configService.loadDataSourceMap().keySet()), configService.loadShardingConfigMap(), configService.loadShardingProperties());
+ new OrchestrationShardingRule(shardingRuleConfig, configService.loadDataSourceMap().keySet()), configService.loadShardingConfigMap(), configService.loadShardingProperties());
initOrchestrationFacade(dataSource);
}
From 2e01cc9f25687f23cdc42ebc422b3632c768707d Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 16:06:10 +0800
Subject: [PATCH 058/100] delete this
---
.../internal/datasource/OrchestrationShardingDataSource.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 6651781351929..96de45a64e0a4 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
@@ -47,7 +47,7 @@ public class OrchestrationShardingDataSource extends AbstractOrchestrationDataSo
public OrchestrationShardingDataSource(final ShardingDataSource shardingDataSource, final OrchestrationConfiguration orchestrationConfig) throws SQLException {
super(new OrchestrationFacade(orchestrationConfig), shardingDataSource.getDataSourceMap());
- this.dataSource = new ShardingDataSource(shardingDataSource.getDataSourceMap(), new OrchestrationShardingRule(shardingDataSource.getShardingContext().getShardingRule().getShardingRuleConfig(),
+ dataSource = new ShardingDataSource(shardingDataSource.getDataSourceMap(), new OrchestrationShardingRule(shardingDataSource.getShardingContext().getShardingRule().getShardingRuleConfig(),
shardingDataSource.getDataSourceMap().keySet()));
initOrchestrationFacade(dataSource);
}
From 6bd359569d3cb812bc2acaeb8106a8cdb284f955 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 16:06:39 +0800
Subject: [PATCH 059/100] delete it
---
.../internal/datasource/OrchestrationMasterSlaveDataSource.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 bf9891d4de5d7..6d694ab8f7f8e 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
@@ -48,7 +48,7 @@ public class OrchestrationMasterSlaveDataSource extends AbstractOrchestrationDat
public OrchestrationMasterSlaveDataSource(final MasterSlaveDataSource masterSlaveDataSource, final OrchestrationConfiguration orchestrationConfig) throws SQLException {
super(new OrchestrationFacade(orchestrationConfig), masterSlaveDataSource.getDataSourceMap());
- this.dataSource = masterSlaveDataSource;
+ dataSource = masterSlaveDataSource;
initOrchestrationFacade(dataSource);
}
From 51fb7f5933e5e282ed9451935f0c0967cde23e22 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 16:14:58 +0800
Subject: [PATCH 060/100] add masterSlaveRuleConfiguration
---
.../main/java/io/shardingsphere/core/rule/MasterSlaveRule.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/rule/MasterSlaveRule.java b/sharding-core/src/main/java/io/shardingsphere/core/rule/MasterSlaveRule.java
index c1e3481818ed6..068cfe1beb9a8 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/rule/MasterSlaveRule.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/rule/MasterSlaveRule.java
@@ -42,6 +42,8 @@ public class MasterSlaveRule {
private final MasterSlaveLoadBalanceAlgorithm loadBalanceAlgorithm;
+ private final MasterSlaveRuleConfiguration masterSlaveRuleConfiguration;
+
public MasterSlaveRule(final MasterSlaveRuleConfiguration config) {
Preconditions.checkNotNull(config.getName(), "Master-slave rule name cannot be null.");
Preconditions.checkNotNull(config.getMasterDataSourceName(), "Master data source name cannot be null.");
@@ -51,6 +53,7 @@ public MasterSlaveRule(final MasterSlaveRuleConfiguration config) {
masterDataSourceName = config.getMasterDataSourceName();
slaveDataSourceNames = config.getSlaveDataSourceNames();
loadBalanceAlgorithm = null == config.getLoadBalanceAlgorithm() ? MasterSlaveLoadBalanceAlgorithmType.getDefaultAlgorithmType().getAlgorithm() : config.getLoadBalanceAlgorithm();
+ masterSlaveRuleConfiguration = config;
}
/**
From 1d7ec46397eecb6f47b30bf15f5586a974f429e4 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 16:20:34 +0800
Subject: [PATCH 061/100] use OrchestrationMasterSlaveRule
---
.../datasource/OrchestrationMasterSlaveDataSource.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
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 6d694ab8f7f8e..3e9f85156af5e 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
@@ -22,6 +22,7 @@
import com.google.common.eventbus.Subscribe;
import io.shardingsphere.api.ConfigMapContext;
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.internal.OrchestrationFacade;
@@ -30,6 +31,7 @@
import io.shardingsphere.orchestration.internal.event.state.DisabledStateEventBusEvent;
import io.shardingsphere.shardingjdbc.jdbc.core.datasource.MasterSlaveDataSource;
import io.shardingsphere.shardingjdbc.orchestration.internal.circuit.datasource.CircuitBreakerDataSource;
+import io.shardingsphere.shardingjdbc.orchestration.internal.rule.OrchestrationMasterSlaveRule;
import javax.sql.DataSource;
import java.sql.Connection;
@@ -48,7 +50,8 @@ public class OrchestrationMasterSlaveDataSource extends AbstractOrchestrationDat
public OrchestrationMasterSlaveDataSource(final MasterSlaveDataSource masterSlaveDataSource, final OrchestrationConfiguration orchestrationConfig) throws SQLException {
super(new OrchestrationFacade(orchestrationConfig), masterSlaveDataSource.getDataSourceMap());
- dataSource = masterSlaveDataSource;
+ dataSource = new MasterSlaveDataSource(masterSlaveDataSource.getDataSourceMap(), new OrchestrationMasterSlaveRule(masterSlaveDataSource.getMasterSlaveRule().getMasterSlaveRuleConfiguration()),
+ ConfigMapContext.getInstance().getMasterSlaveConfig(), masterSlaveDataSource.getShardingProperties());
initOrchestrationFacade(dataSource);
}
@@ -57,8 +60,8 @@ public OrchestrationMasterSlaveDataSource(final OrchestrationConfiguration orche
ConfigurationService configService = getOrchestrationFacade().getConfigService();
MasterSlaveRuleConfiguration masterSlaveRuleConfig = configService.loadMasterSlaveRuleConfiguration();
Preconditions.checkState(null != masterSlaveRuleConfig && !Strings.isNullOrEmpty(masterSlaveRuleConfig.getMasterDataSourceName()), "No available master slave rule configuration to load.");
- dataSource = new MasterSlaveDataSource(
- configService.loadDataSourceMap(), masterSlaveRuleConfig, configService.loadMasterSlaveConfigMap(), configService.loadMasterSlaveProperties());
+ dataSource = new MasterSlaveDataSource(configService.loadDataSourceMap(), new OrchestrationMasterSlaveRule(masterSlaveRuleConfig), configService.loadMasterSlaveConfigMap(),
+ new ShardingProperties(configService.loadMasterSlaveProperties()));
initOrchestrationFacade(dataSource);
}
From 1b302587b7b8e69510b57d688bafd24dcd49a8cd Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 16:26:34 +0800
Subject: [PATCH 062/100] delete getAvailableDataSourceMap()
---
.../datasource/AbstractOrchestrationDataSource.java | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/datasource/AbstractOrchestrationDataSource.java b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/datasource/AbstractOrchestrationDataSource.java
index 955f03ffcb891..35111e566655d 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/datasource/AbstractOrchestrationDataSource.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/datasource/AbstractOrchestrationDataSource.java
@@ -27,8 +27,6 @@
import javax.sql.DataSource;
import java.sql.SQLException;
-import java.util.Collection;
-import java.util.LinkedHashMap;
import java.util.Map;
/**
@@ -59,14 +57,6 @@ public AbstractOrchestrationDataSource(final OrchestrationFacade orchestrationFa
ShardingEventBusInstance.getInstance().register(this);
}
- protected final Map getAvailableDataSourceMap(final Collection disabledDataSourceNames) {
- Map result = new LinkedHashMap<>(dataSourceMap);
- for (String each : disabledDataSourceNames) {
- result.remove(each);
- }
- return result;
- }
-
/**
/**
* Renew circuit breaker dataSource names.
From b63afda1268185342773667af5427c40e5976106 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 16:26:54 +0800
Subject: [PATCH 063/100] delete renew
---
.../OrchestrationMasterSlaveDataSource.java | 16 ----------------
1 file changed, 16 deletions(-)
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 3e9f85156af5e..a33d4312697d0 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
@@ -28,16 +28,12 @@
import io.shardingsphere.orchestration.internal.OrchestrationFacade;
import io.shardingsphere.orchestration.internal.config.ConfigurationService;
import io.shardingsphere.orchestration.internal.event.config.MasterSlaveConfigurationEventBusEvent;
-import io.shardingsphere.orchestration.internal.event.state.DisabledStateEventBusEvent;
import io.shardingsphere.shardingjdbc.jdbc.core.datasource.MasterSlaveDataSource;
import io.shardingsphere.shardingjdbc.orchestration.internal.circuit.datasource.CircuitBreakerDataSource;
import io.shardingsphere.shardingjdbc.orchestration.internal.rule.OrchestrationMasterSlaveRule;
-import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
-import java.util.LinkedHashMap;
-import java.util.Map;
/**
* Orchestration master-slave datasource.
@@ -99,16 +95,4 @@ public void renew(final MasterSlaveConfigurationEventBusEvent masterSlaveEvent)
dataSource = new MasterSlaveDataSource(
masterSlaveEvent.getDataSourceMap(), masterSlaveEvent.getMasterSlaveRuleConfig(), ConfigMapContext.getInstance().getMasterSlaveConfig(), masterSlaveEvent.getProps());
}
-
- /**
- * Renew disable dataSource names.
- *
- * @param disabledStateEventBusEvent jdbc disabled event bus event
- * @throws SQLException sql exception
- */
- @Subscribe
- public void renew(final DisabledStateEventBusEvent disabledStateEventBusEvent) throws SQLException {
- Map newDataSourceMap = getAvailableDataSourceMap(disabledStateEventBusEvent.getDisabledDataSourceNames());
- dataSource = new MasterSlaveDataSource(newDataSourceMap, dataSource.getMasterSlaveRule(), new LinkedHashMap(), dataSource.getShardingProperties());
- }
}
From dc6e87d1059615bc9abc238140a247b6f56589f1 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 16:27:00 +0800
Subject: [PATCH 064/100] delete renew
---
.../OrchestrationShardingDataSource.java | 16 ----------------
1 file changed, 16 deletions(-)
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 96de45a64e0a4..f7406860e2b4e 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
@@ -25,16 +25,13 @@
import io.shardingsphere.orchestration.internal.OrchestrationFacade;
import io.shardingsphere.orchestration.internal.config.ConfigurationService;
import io.shardingsphere.orchestration.internal.event.config.ShardingConfigurationEventBusEvent;
-import io.shardingsphere.orchestration.internal.event.state.DisabledStateEventBusEvent;
import io.shardingsphere.shardingjdbc.jdbc.core.datasource.ShardingDataSource;
import io.shardingsphere.shardingjdbc.orchestration.internal.circuit.datasource.CircuitBreakerDataSource;
import io.shardingsphere.shardingjdbc.orchestration.internal.rule.OrchestrationShardingRule;
-import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.LinkedHashMap;
-import java.util.Map;
/**
* Orchestration sharding datasource.
@@ -91,17 +88,4 @@ public final void close() {
public void renew(final ShardingConfigurationEventBusEvent shardingEvent) throws SQLException {
dataSource = new ShardingDataSource(shardingEvent.getDataSourceMap(), shardingEvent.getShardingRule(), new LinkedHashMap(), shardingEvent.getProps());
}
-
- /**
- * Renew disable dataSource names.
- *
- * @param disabledStateEventBusEvent jdbc disabled event bus event
- * @throws SQLException SQL exception
- */
- @Subscribe
- public void renew(final DisabledStateEventBusEvent disabledStateEventBusEvent) throws SQLException {
- Map newDataSourceMap = getAvailableDataSourceMap(disabledStateEventBusEvent.getDisabledDataSourceNames());
- dataSource = new ShardingDataSource(newDataSourceMap, dataSource.getShardingContext(), dataSource.getShardingProperties());
- }
}
-
From b86b8d6c599481cb004e84715a96bee1e84b4ee9 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 16:52:35 +0800
Subject: [PATCH 065/100] from super class is false
---
.../shardingjdbc/spring/GenerateKeyJUnitTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sharding-jdbc/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/spring/GenerateKeyJUnitTest.java b/sharding-jdbc/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/spring/GenerateKeyJUnitTest.java
index e898c4e5b5464..69331106d95c8 100644
--- a/sharding-jdbc/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/spring/GenerateKeyJUnitTest.java
+++ b/sharding-jdbc/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/spring/GenerateKeyJUnitTest.java
@@ -62,7 +62,7 @@ public void assertGenerateKey() throws SQLException {
@SuppressWarnings("unchecked")
@Test
public void assertGenerateKeyColumn() {
- Object shardingContext = FieldValueUtil.getFieldValue(shardingDataSource, "shardingContext", true);
+ Object shardingContext = FieldValueUtil.getFieldValue(shardingDataSource, "shardingContext", false);
assertNotNull(shardingContext);
Object shardingRule = FieldValueUtil.getFieldValue(shardingContext, "shardingRule");
assertNotNull(shardingRule);
From 5ca88c25b7f912f0475d286d00065d250ac11f1c Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 16:52:50 +0800
Subject: [PATCH 066/100] modify new sharding datasource
---
.../internal/datasource/OrchestrationShardingDataSource.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 f7406860e2b4e..d42f00d78f5ea 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
@@ -45,7 +45,7 @@ public class OrchestrationShardingDataSource extends AbstractOrchestrationDataSo
public OrchestrationShardingDataSource(final ShardingDataSource shardingDataSource, final OrchestrationConfiguration orchestrationConfig) throws SQLException {
super(new OrchestrationFacade(orchestrationConfig), shardingDataSource.getDataSourceMap());
dataSource = new ShardingDataSource(shardingDataSource.getDataSourceMap(), new OrchestrationShardingRule(shardingDataSource.getShardingContext().getShardingRule().getShardingRuleConfig(),
- shardingDataSource.getDataSourceMap().keySet()));
+ shardingDataSource.getDataSourceMap().keySet()), ConfigMapContext.getInstance().getShardingConfig(), shardingDataSource.getShardingProperties().getProps());
initOrchestrationFacade(dataSource);
}
From b4dc267bac321a469939dd638a26a70d1d14d644 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 16:52:59 +0800
Subject: [PATCH 067/100] modify property
---
.../spring/OrchestrationShardingMasterSlaveNamespaceTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/orchestration/spring/OrchestrationShardingMasterSlaveNamespaceTest.java b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/orchestration/spring/OrchestrationShardingMasterSlaveNamespaceTest.java
index 19326526223d8..cd12573f42ae7 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/orchestration/spring/OrchestrationShardingMasterSlaveNamespaceTest.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/orchestration/spring/OrchestrationShardingMasterSlaveNamespaceTest.java
@@ -83,7 +83,7 @@ private Map getDataSourceMap(final String shardingDataSource
private ShardingRule getShardingRule(final String shardingDataSourceName) {
OrchestrationSpringShardingDataSource shardingDataSource = applicationContext.getBean(shardingDataSourceName, OrchestrationSpringShardingDataSource.class);
ShardingDataSource dataSource = (ShardingDataSource) FieldValueUtil.getFieldValue(shardingDataSource, "dataSource", true);
- Object shardingContext = FieldValueUtil.getFieldValue(dataSource, "shardingContext", true);
+ Object shardingContext = FieldValueUtil.getFieldValue(dataSource, "shardingContext", false);
return (ShardingRule) FieldValueUtil.getFieldValue(shardingContext, "shardingRule");
}
}
From b3e91195dbc5a9c62d36a65d92422d38084fae7e Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 16:53:05 +0800
Subject: [PATCH 068/100] modify OrchestrationShardingNamespaceTest.java
---
.../spring/OrchestrationShardingNamespaceTest.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/orchestration/spring/OrchestrationShardingNamespaceTest.java b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/orchestration/spring/OrchestrationShardingNamespaceTest.java
index a6920e9c5e472..50a0c1c08230b 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/orchestration/spring/OrchestrationShardingNamespaceTest.java
+++ b/sharding-jdbc/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/orchestration/spring/OrchestrationShardingNamespaceTest.java
@@ -140,9 +140,9 @@ public void assertPropsDataSource() {
Map configMap = new HashMap<>();
configMap.put("key1", "value1");
assertThat(ConfigMapContext.getInstance().getShardingConfig(), is(configMap));
- Object shardingContext = FieldValueUtil.getFieldValue(dataSource, "shardingContext", true);
+ Object shardingContext = FieldValueUtil.getFieldValue(dataSource, "shardingContext", false);
assertTrue((boolean) FieldValueUtil.getFieldValue(shardingContext, "showSQL"));
- ShardingProperties shardingProperties = (ShardingProperties) FieldValueUtil.getFieldValue(dataSource, "shardingProperties", true);
+ ShardingProperties shardingProperties = (ShardingProperties) FieldValueUtil.getFieldValue(dataSource, "shardingProperties", false);
boolean showSql = shardingProperties.getValue(ShardingPropertiesConstant.SQL_SHOW);
assertTrue(showSql);
int executorSize = shardingProperties.getValue(ShardingPropertiesConstant.EXECUTOR_SIZE);
@@ -159,7 +159,7 @@ public void assertShardingDataSourceType() {
public void assertDefaultActualDataNodes() {
OrchestrationSpringShardingDataSource multiTableRulesDataSource = applicationContext.getBean("multiTableRulesDataSourceOrchestration", OrchestrationSpringShardingDataSource.class);
ShardingDataSource dataSource = (ShardingDataSource) FieldValueUtil.getFieldValue(multiTableRulesDataSource, "dataSource", true);
- Object shardingContext = FieldValueUtil.getFieldValue(dataSource, "shardingContext", true);
+ Object shardingContext = FieldValueUtil.getFieldValue(dataSource, "shardingContext", false);
ShardingRule shardingRule = (ShardingRule) FieldValueUtil.getFieldValue(shardingContext, "shardingRule");
assertThat(shardingRule.getTableRules().size(), is(2));
Iterator tableRules = shardingRule.getTableRules().iterator();
@@ -183,7 +183,7 @@ private Map getDataSourceMap(final String shardingDataSource
private ShardingRule getShardingRule(final String shardingDataSourceName) {
OrchestrationSpringShardingDataSource shardingDataSource = applicationContext.getBean(shardingDataSourceName, OrchestrationSpringShardingDataSource.class);
ShardingDataSource dataSource = (ShardingDataSource) FieldValueUtil.getFieldValue(shardingDataSource, "dataSource", true);
- Object shardingContext = FieldValueUtil.getFieldValue(dataSource, "shardingContext", true);
+ Object shardingContext = FieldValueUtil.getFieldValue(dataSource, "shardingContext", false);
return (ShardingRule) FieldValueUtil.getFieldValue(shardingContext, "shardingRule");
}
}
From cf14ab091fb8d30c9cf6f3b52f3dd012e1d47d81 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 16:53:12 +0800
Subject: [PATCH 069/100] modify OrchestrationShardingNamespaceTest.java
---
.../shardingjdbc/spring/ShardingNamespaceTest.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sharding-jdbc/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/spring/ShardingNamespaceTest.java b/sharding-jdbc/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/spring/ShardingNamespaceTest.java
index d89fe74a03c83..786c7a4f4296b 100644
--- a/sharding-jdbc/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/spring/ShardingNamespaceTest.java
+++ b/sharding-jdbc/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/spring/ShardingNamespaceTest.java
@@ -211,7 +211,7 @@ public void assertPropsDataSource() {
Map configMap = new HashMap<>();
configMap.put("key1", "value1");
assertThat(ConfigMapContext.getInstance().getShardingConfig(), is(configMap));
- Object shardingContext = FieldValueUtil.getFieldValue(shardingDataSource, "shardingContext", true);
+ Object shardingContext = FieldValueUtil.getFieldValue(shardingDataSource, "shardingContext", false);
assertTrue((boolean) FieldValueUtil.getFieldValue(shardingContext, "showSQL"));
ShardingProperties shardingProperties = (ShardingProperties) FieldValueUtil.getFieldValue(shardingDataSource, "shardingProperties", true);
boolean showSql = shardingProperties.getValue(ShardingPropertiesConstant.SQL_SHOW);
@@ -229,7 +229,7 @@ public void assertShardingDataSourceType() {
@Test
public void assertDefaultActualDataNodes() {
ShardingDataSource multiTableRulesDataSource = this.applicationContext.getBean("multiTableRulesDataSource", ShardingDataSource.class);
- Object shardingContext = FieldValueUtil.getFieldValue(multiTableRulesDataSource, "shardingContext", true);
+ Object shardingContext = FieldValueUtil.getFieldValue(multiTableRulesDataSource, "shardingContext", false);
ShardingRule shardingRule = (ShardingRule) FieldValueUtil.getFieldValue(shardingContext, "shardingRule");
assertThat(shardingRule.getTableRules().size(), is(2));
Iterator tableRules = shardingRule.getTableRules().iterator();
@@ -251,7 +251,7 @@ private Map getDataSourceMap(final String shardingDataSource
private ShardingRule getShardingRule(final String shardingDataSourceName) {
ShardingDataSource shardingDataSource = this.applicationContext.getBean(shardingDataSourceName, ShardingDataSource.class);
- Object shardingContext = FieldValueUtil.getFieldValue(shardingDataSource, "shardingContext", true);
+ Object shardingContext = FieldValueUtil.getFieldValue(shardingDataSource, "shardingContext", false);
return (ShardingRule) FieldValueUtil.getFieldValue(shardingContext, "shardingRule");
}
}
From 438947eb7a64b5bdcbee4cee110f0b0037881499 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 17:23:06 +0800
Subject: [PATCH 070/100] use orchestration
---
.../shardingproxy/runtime/ShardingSchema.java | 21 +++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
index f3ae8dd8e2e3a..22312bc8f7a35 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
@@ -25,6 +25,8 @@
import io.shardingsphere.core.rule.MasterSlaveRule;
import io.shardingsphere.core.rule.ShardingRule;
import io.shardingsphere.core.yaml.YamlRuleConfiguration;
+import io.shardingsphere.orchestration.internal.rule.OrchestrationMasterSlaveRule;
+import io.shardingsphere.orchestration.internal.rule.OrchestrationShardingRule;
import io.shardingsphere.shardingproxy.backend.jdbc.datasource.JDBCBackendDataSource;
import io.shardingsphere.shardingproxy.runtime.metadata.ProxyTableMetaDataConnectionManager;
import lombok.Getter;
@@ -57,13 +59,28 @@ public final class ShardingSchema {
private ShardingMetaData metaData;
- public ShardingSchema(final String name, final Map dataSources, final YamlRuleConfiguration rule) {
+ public ShardingSchema(final String name, final Map dataSources, final YamlRuleConfiguration rule, final boolean isUsingOrchestration) {
this.name = name;
// TODO :jiaqi only use JDBC need connect db via JDBC, netty style should use SQL packet to get metadata
this.dataSources = dataSources;
+ if (isUsingOrchestration) {
+ initRuleWithOrchestration(dataSources, rule);
+ } else {
+ initRuleWithoutOrchestration(dataSources, rule);
+ }
+ backendDataSource = new JDBCBackendDataSource(dataSources);
+ }
+
+ private ShardingRule getShardingRule(final boolean isUsingOrchestration) {}
+
+ private void initRuleWithoutOrchestration(final Map dataSources, final YamlRuleConfiguration rule) {
shardingRule = new ShardingRule(null == rule.getShardingRule() ? new ShardingRuleConfiguration() : rule.getShardingRule().getShardingRuleConfiguration(), dataSources.keySet());
masterSlaveRule = null == rule.getMasterSlaveRule() ? null : new MasterSlaveRule(rule.getMasterSlaveRule().getMasterSlaveRuleConfiguration());
- backendDataSource = new JDBCBackendDataSource(dataSources);
+ }
+
+ private void initRuleWithOrchestration(final Map dataSources, final YamlRuleConfiguration rule) {
+ shardingRule = new OrchestrationShardingRule(null == rule.getShardingRule() ? new ShardingRuleConfiguration() : rule.getShardingRule().getShardingRuleConfiguration(), dataSources.keySet());
+ masterSlaveRule = null == rule.getMasterSlaveRule() ? null : new OrchestrationMasterSlaveRule(rule.getMasterSlaveRule().getMasterSlaveRuleConfiguration());
}
/**
From b39aa8daafd46f91e95b9215cf425951f76ee9bc Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 17:24:27 +0800
Subject: [PATCH 071/100] =?UTF-8?q?getShardingRule=EF=BC=88=EF=BC=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../shardingproxy/runtime/ShardingSchema.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
index 22312bc8f7a35..42007bab5cdb8 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
@@ -71,7 +71,12 @@ public ShardingSchema(final String name, final Map
backendDataSource = new JDBCBackendDataSource(dataSources);
}
- private ShardingRule getShardingRule(final boolean isUsingOrchestration) {}
+ private ShardingRule getShardingRule(final YamlRuleConfiguration rule, final boolean isUsingOrchestration) {
+ return isUsingOrchestration ? new OrchestrationShardingRule(null == rule.getShardingRule() ? new ShardingRuleConfiguration() : rule.getShardingRule().getShardingRuleConfiguration(), dataSources.keySet())
+ : new ShardingRule(null == rule.getShardingRule() ? new ShardingRuleConfiguration() : rule.getShardingRule().getShardingRuleConfiguration(), dataSources.keySet());
+ }
+
+
private void initRuleWithoutOrchestration(final Map dataSources, final YamlRuleConfiguration rule) {
shardingRule = new ShardingRule(null == rule.getShardingRule() ? new ShardingRuleConfiguration() : rule.getShardingRule().getShardingRuleConfiguration(), dataSources.keySet());
From e313c27bad679cad2c3590c77e977bc37b22ce7c Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 17:27:17 +0800
Subject: [PATCH 072/100] getMasterSlaveRule()
---
.../shardingproxy/runtime/ShardingSchema.java | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
index 42007bab5cdb8..7e0a6b2cda5d5 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
@@ -76,16 +76,11 @@ private ShardingRule getShardingRule(final YamlRuleConfiguration rule, final boo
: new ShardingRule(null == rule.getShardingRule() ? new ShardingRuleConfiguration() : rule.getShardingRule().getShardingRuleConfiguration(), dataSources.keySet());
}
-
-
- private void initRuleWithoutOrchestration(final Map dataSources, final YamlRuleConfiguration rule) {
- shardingRule = new ShardingRule(null == rule.getShardingRule() ? new ShardingRuleConfiguration() : rule.getShardingRule().getShardingRuleConfiguration(), dataSources.keySet());
- masterSlaveRule = null == rule.getMasterSlaveRule() ? null : new MasterSlaveRule(rule.getMasterSlaveRule().getMasterSlaveRuleConfiguration());
- }
-
- private void initRuleWithOrchestration(final Map dataSources, final YamlRuleConfiguration rule) {
- shardingRule = new OrchestrationShardingRule(null == rule.getShardingRule() ? new ShardingRuleConfiguration() : rule.getShardingRule().getShardingRuleConfiguration(), dataSources.keySet());
- masterSlaveRule = null == rule.getMasterSlaveRule() ? null : new OrchestrationMasterSlaveRule(rule.getMasterSlaveRule().getMasterSlaveRuleConfiguration());
+ private MasterSlaveRule getMasterSlaveRule(final YamlRuleConfiguration rule, final boolean isUsingOrchestration) {
+ if (null == rule.getMasterSlaveRule()) {
+ return null;
+ }
+ return isUsingOrchestration ? new OrchestrationMasterSlaveRule(rule.getMasterSlaveRule().getMasterSlaveRuleConfiguration()) : new MasterSlaveRule(rule.getMasterSlaveRule().getMasterSlaveRuleConfiguration());
}
/**
From bd6d629e2ecdc59f5bf9a5ec2e555edcf25cde51 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 17:29:34 +0800
Subject: [PATCH 073/100] modify construction function
---
.../shardingproxy/runtime/ShardingSchema.java | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
index 7e0a6b2cda5d5..b8bde43a81b9d 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
@@ -63,11 +63,8 @@ public ShardingSchema(final String name, final Map
this.name = name;
// TODO :jiaqi only use JDBC need connect db via JDBC, netty style should use SQL packet to get metadata
this.dataSources = dataSources;
- if (isUsingOrchestration) {
- initRuleWithOrchestration(dataSources, rule);
- } else {
- initRuleWithoutOrchestration(dataSources, rule);
- }
+ shardingRule = getShardingRule(rule, isUsingOrchestration);
+ masterSlaveRule = getMasterSlaveRule(rule, isUsingOrchestration);
backendDataSource = new JDBCBackendDataSource(dataSources);
}
From a626d8c5e7c6dcbe9e54e1219e4a9ad9a1c451cf Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 17:29:55 +0800
Subject: [PATCH 074/100] add init()
---
.../shardingproxy/runtime/GlobalRegistry.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
index aade829a5dc14..66ee145a2a36f 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
@@ -103,11 +103,15 @@ public void register() {
* @param schemaRules schema rule map
*/
public void init(final YamlServerConfiguration serverConfig, final Map> schemaDataSources, final Map schemaRules) {
+
+ }
+
+ public void init(final YamlServerConfiguration serverConfig, final Map> schemaDataSources, final Map schemaRules, final boolean isUsingOrchestration) {
initServerConfiguration(serverConfig);
for (Entry entry : schemaRules.entrySet()) {
String schemaName = entry.getKey();
schemaNames.add(schemaName);
- shardingSchemas.put(schemaName, new ShardingSchema(schemaName, schemaDataSources.get(schemaName), entry.getValue()));
+ shardingSchemas.put(schemaName, new ShardingSchema(schemaName, schemaDataSources.get(schemaName), entry.getValue(), isUsingOrchestration));
}
}
From 823aaddb867f7a682206b20666598a157bed5db0 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 17:31:47 +0800
Subject: [PATCH 075/100] modify renew()
---
.../shardingproxy/runtime/GlobalRegistry.java | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
index 66ee145a2a36f..d162567557d12 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
@@ -103,9 +103,17 @@ public void register() {
* @param schemaRules schema rule map
*/
public void init(final YamlServerConfiguration serverConfig, final Map> schemaDataSources, final Map schemaRules) {
-
+ init(serverConfig, schemaDataSources, schemaRules, false);
}
+ /**
+ * Initialize proxy context.
+ *
+ * @param serverConfig server configuration
+ * @param schemaDataSources data source map
+ * @param schemaRules schema rule map
+ * @param isUsingOrchestration is using orchestration or not
+ */
public void init(final YamlServerConfiguration serverConfig, final Map> schemaDataSources, final Map schemaRules, final boolean isUsingOrchestration) {
initServerConfiguration(serverConfig);
for (Entry entry : schemaRules.entrySet()) {
@@ -179,7 +187,7 @@ public void renew(final ProxyConfigurationEventBusEvent proxyConfigurationEventB
shardingSchemas.clear();
for (Entry> entry : proxyConfigurationEventBusEvent.getSchemaDataSourceMap().entrySet()) {
String schemaName = entry.getKey();
- shardingSchemas.put(schemaName, new ShardingSchema(schemaName, entry.getValue(), proxyConfigurationEventBusEvent.getSchemaRuleMap().get(schemaName)));
+ shardingSchemas.put(schemaName, new ShardingSchema(schemaName, entry.getValue(), proxyConfigurationEventBusEvent.getSchemaRuleMap().get(schemaName), true));
}
}
From 3dc426bd48c2ce17aefa8999f6c0010d9dda3b4a Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 17:32:45 +0800
Subject: [PATCH 076/100] modify startWithRegistryCenter()
---
.../main/java/io/shardingsphere/shardingproxy/Bootstrap.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 462d9bb61ec5a..935e5577efb46 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/Bootstrap.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/Bootstrap.java
@@ -92,7 +92,7 @@ private static void startWithRegistryCenter(
orchestrationFacade.init(getYamlServerConfiguration(serverConfig), getSchemaDataSourceMap(ruleConfigs), getRuleConfiguration(ruleConfigs));
}
GlobalRegistry.getInstance().init(orchestrationFacade.getConfigService().loadYamlServerConfiguration(),
- orchestrationFacade.getConfigService().loadProxyDataSources(), orchestrationFacade.getConfigService().loadProxyConfiguration());
+ orchestrationFacade.getConfigService().loadProxyDataSources(), orchestrationFacade.getConfigService().loadProxyConfiguration(), true);
initOpenTracing();
new ShardingProxy().start(port);
}
From a88e8cd6e122c9ff6763c55d9d15ee59bfa70116 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 17:33:25 +0800
Subject: [PATCH 077/100] move OrchestrationMasterSlaveRule.java
---
.../internal/rule/OrchestrationMasterSlaveRule.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
rename {sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc => sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere}/orchestration/internal/rule/OrchestrationMasterSlaveRule.java (96%)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
similarity index 96%
rename from sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
rename to sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
index fdccccd5b5406..52e5062b2e836 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
+++ b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
@@ -15,7 +15,7 @@
*
*/
-package io.shardingsphere.shardingjdbc.orchestration.internal.rule;
+package io.shardingsphere.orchestration.internal.rule;
import com.google.common.eventbus.Subscribe;
import io.shardingsphere.api.config.MasterSlaveRuleConfiguration;
From fd67f7cc7d1ecdea338b2d15935c89e44ca98b75 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 17:33:33 +0800
Subject: [PATCH 078/100] move OrchestrationShardingRule.java
---
.../orchestration/internal/rule/OrchestrationShardingRule.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
rename {sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc => sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere}/orchestration/internal/rule/OrchestrationShardingRule.java (96%)
diff --git a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationShardingRule.java b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/rule/OrchestrationShardingRule.java
similarity index 96%
rename from sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationShardingRule.java
rename to sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/rule/OrchestrationShardingRule.java
index 8cd752bfb0fe1..48e4fb3f98b0b 100644
--- a/sharding-jdbc/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/shardingjdbc/orchestration/internal/rule/OrchestrationShardingRule.java
+++ b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/rule/OrchestrationShardingRule.java
@@ -15,7 +15,7 @@
*
*/
-package io.shardingsphere.shardingjdbc.orchestration.internal.rule;
+package io.shardingsphere.orchestration.internal.rule;
import com.google.common.base.Function;
import com.google.common.collect.Collections2;
From b4656d853bac5ecbaedec2f99a667f14e08e6010 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 17:33:41 +0800
Subject: [PATCH 079/100] new import
---
.../internal/datasource/OrchestrationMasterSlaveDataSource.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 a33d4312697d0..7582b696e3fcb 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
@@ -30,7 +30,7 @@
import io.shardingsphere.orchestration.internal.event.config.MasterSlaveConfigurationEventBusEvent;
import io.shardingsphere.shardingjdbc.jdbc.core.datasource.MasterSlaveDataSource;
import io.shardingsphere.shardingjdbc.orchestration.internal.circuit.datasource.CircuitBreakerDataSource;
-import io.shardingsphere.shardingjdbc.orchestration.internal.rule.OrchestrationMasterSlaveRule;
+import io.shardingsphere.orchestration.internal.rule.OrchestrationMasterSlaveRule;
import java.sql.Connection;
import java.sql.SQLException;
From e74a2a75a08938044681f8c240cba7ca53351d04 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 17:33:48 +0800
Subject: [PATCH 080/100] change import
---
.../internal/datasource/OrchestrationShardingDataSource.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 d42f00d78f5ea..c20bf3aa2e2da 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
@@ -27,7 +27,7 @@
import io.shardingsphere.orchestration.internal.event.config.ShardingConfigurationEventBusEvent;
import io.shardingsphere.shardingjdbc.jdbc.core.datasource.ShardingDataSource;
import io.shardingsphere.shardingjdbc.orchestration.internal.circuit.datasource.CircuitBreakerDataSource;
-import io.shardingsphere.shardingjdbc.orchestration.internal.rule.OrchestrationShardingRule;
+import io.shardingsphere.orchestration.internal.rule.OrchestrationShardingRule;
import java.sql.Connection;
import java.sql.SQLException;
From 1d565e518292d8484e4a9097c65713ecf1750a93 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 17:35:05 +0800
Subject: [PATCH 081/100] rename to isUsingRegistry
---
.../shardingproxy/runtime/GlobalRegistry.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
index d162567557d12..7d2edd0d57272 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
@@ -112,14 +112,14 @@ public void init(final YamlServerConfiguration serverConfig, final Map> schemaDataSources, final Map schemaRules, final boolean isUsingOrchestration) {
+ public void init(final YamlServerConfiguration serverConfig, final Map> schemaDataSources, final Map schemaRules, final boolean isUsingRegistry) {
initServerConfiguration(serverConfig);
for (Entry entry : schemaRules.entrySet()) {
String schemaName = entry.getKey();
schemaNames.add(schemaName);
- shardingSchemas.put(schemaName, new ShardingSchema(schemaName, schemaDataSources.get(schemaName), entry.getValue(), isUsingOrchestration));
+ shardingSchemas.put(schemaName, new ShardingSchema(schemaName, schemaDataSources.get(schemaName), entry.getValue(), isUsingRegistry));
}
}
From 2ace845f8591f459994fd947cea77e51babe7525 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 17:35:12 +0800
Subject: [PATCH 082/100] rename to isUsingRegistry
---
.../shardingproxy/runtime/ShardingSchema.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
index b8bde43a81b9d..0ac8c1b6356fd 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
@@ -59,12 +59,12 @@ public final class ShardingSchema {
private ShardingMetaData metaData;
- public ShardingSchema(final String name, final Map dataSources, final YamlRuleConfiguration rule, final boolean isUsingOrchestration) {
+ public ShardingSchema(final String name, final Map dataSources, final YamlRuleConfiguration rule, final boolean isUsingRegistry) {
this.name = name;
// TODO :jiaqi only use JDBC need connect db via JDBC, netty style should use SQL packet to get metadata
this.dataSources = dataSources;
- shardingRule = getShardingRule(rule, isUsingOrchestration);
- masterSlaveRule = getMasterSlaveRule(rule, isUsingOrchestration);
+ shardingRule = getShardingRule(rule, isUsingRegistry);
+ masterSlaveRule = getMasterSlaveRule(rule, isUsingRegistry);
backendDataSource = new JDBCBackendDataSource(dataSources);
}
From ebe35ed28eb28c34ad3f9f17a7b55979b7f94dbc Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 17:36:15 +0800
Subject: [PATCH 083/100] isUsingRegistry
---
.../shardingproxy/runtime/ShardingSchema.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
index 0ac8c1b6356fd..cddc029eee782 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
@@ -68,16 +68,16 @@ public ShardingSchema(final String name, final Map
backendDataSource = new JDBCBackendDataSource(dataSources);
}
- private ShardingRule getShardingRule(final YamlRuleConfiguration rule, final boolean isUsingOrchestration) {
- return isUsingOrchestration ? new OrchestrationShardingRule(null == rule.getShardingRule() ? new ShardingRuleConfiguration() : rule.getShardingRule().getShardingRuleConfiguration(), dataSources.keySet())
+ private ShardingRule getShardingRule(final YamlRuleConfiguration rule, final boolean isUsingRegistry) {
+ return isUsingRegistry ? new OrchestrationShardingRule(null == rule.getShardingRule() ? new ShardingRuleConfiguration() : rule.getShardingRule().getShardingRuleConfiguration(), dataSources.keySet())
: new ShardingRule(null == rule.getShardingRule() ? new ShardingRuleConfiguration() : rule.getShardingRule().getShardingRuleConfiguration(), dataSources.keySet());
}
- private MasterSlaveRule getMasterSlaveRule(final YamlRuleConfiguration rule, final boolean isUsingOrchestration) {
+ private MasterSlaveRule getMasterSlaveRule(final YamlRuleConfiguration rule, final boolean isUsingRegistry) {
if (null == rule.getMasterSlaveRule()) {
return null;
}
- return isUsingOrchestration ? new OrchestrationMasterSlaveRule(rule.getMasterSlaveRule().getMasterSlaveRuleConfiguration()) : new MasterSlaveRule(rule.getMasterSlaveRule().getMasterSlaveRuleConfiguration());
+ return isUsingRegistry ? new OrchestrationMasterSlaveRule(rule.getMasterSlaveRule().getMasterSlaveRuleConfiguration()) : new MasterSlaveRule(rule.getMasterSlaveRule().getMasterSlaveRuleConfiguration());
}
/**
From 4ca2e0c501137f83f11e63d2b244b6d2ead51b58 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 17:36:47 +0800
Subject: [PATCH 084/100] modify java doc
---
.../io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
index 7d2edd0d57272..b64a7d08ac643 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
@@ -112,7 +112,7 @@ public void init(final YamlServerConfiguration serverConfig, final Map> schemaDataSources, final Map schemaRules, final boolean isUsingRegistry) {
initServerConfiguration(serverConfig);
From 60f053952837fdac184380b21cfc5851c834a151 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 18:05:17 +0800
Subject: [PATCH 085/100] add isToRenew()
---
.../rule/OrchestrationMasterSlaveRule.java | 20 +++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/rule/OrchestrationMasterSlaveRule.java b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
index 52e5062b2e836..7fe2fd3e4a33f 100644
--- a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
+++ b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
@@ -17,11 +17,14 @@
package io.shardingsphere.orchestration.internal.rule;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterators;
import com.google.common.eventbus.Subscribe;
import io.shardingsphere.api.config.MasterSlaveRuleConfiguration;
import io.shardingsphere.core.rule.MasterSlaveRule;
import io.shardingsphere.orchestration.internal.event.state.DisabledStateEventBusEvent;
+import javax.annotation.Nullable;
import java.util.Collection;
import java.util.LinkedList;
@@ -59,7 +62,20 @@ public Collection getSlaveDataSourceNames() {
*/
@Subscribe
public void renew(final DisabledStateEventBusEvent disabledStateEventBusEvent) {
- disabledDataSourceNames.clear();
- disabledDataSourceNames.addAll(disabledStateEventBusEvent.getDisabledDataSourceNames());
+ if (disabledStateEventBusEvent.getDisabledDataSourceNames().isEmpty()) {
+ disabledDataSourceNames.clear();
+ } else {
+ disabledDataSourceNames.addAll(disabledStateEventBusEvent.getDisabledDataSourceNames());
+ }
+ }
+
+ private boolean isToRenew(final Collection disabledDataSourceNames) {
+ return Iterators.contains(disabledDataSourceNames.iterator(), new Predicate() {
+
+ @Override
+ public boolean apply(@Nullable final String input) {
+ return OrchestrationMasterSlaveRule.super.getSlaveDataSourceNames().contains(input);
+ }
+ });
}
}
From 07dd8f696f2861f6582a0ae410ee2b46e00b6997 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 18:06:18 +0800
Subject: [PATCH 086/100] modify isToRenew()
---
.../internal/rule/OrchestrationMasterSlaveRule.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/rule/OrchestrationMasterSlaveRule.java b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
index 7fe2fd3e4a33f..c435e20bd98f6 100644
--- a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
+++ b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
@@ -24,7 +24,6 @@
import io.shardingsphere.core.rule.MasterSlaveRule;
import io.shardingsphere.orchestration.internal.event.state.DisabledStateEventBusEvent;
-import javax.annotation.Nullable;
import java.util.Collection;
import java.util.LinkedList;
@@ -73,7 +72,7 @@ private boolean isToRenew(final Collection disabledDataSourceNames) {
return Iterators.contains(disabledDataSourceNames.iterator(), new Predicate() {
@Override
- public boolean apply(@Nullable final String input) {
+ public boolean apply(final String input) {
return OrchestrationMasterSlaveRule.super.getSlaveDataSourceNames().contains(input);
}
});
From 18ebf50edfa5aefae8b8d2b23c781730a5e38ccf Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 18:12:57 +0800
Subject: [PATCH 087/100] reverse
---
.../rule/OrchestrationMasterSlaveRule.java | 19 ++-----------------
1 file changed, 2 insertions(+), 17 deletions(-)
diff --git a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/rule/OrchestrationMasterSlaveRule.java b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
index c435e20bd98f6..52e5062b2e836 100644
--- a/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
+++ b/sharding-orchestration/sharding-orchestration-core/src/main/java/io/shardingsphere/orchestration/internal/rule/OrchestrationMasterSlaveRule.java
@@ -17,8 +17,6 @@
package io.shardingsphere.orchestration.internal.rule;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterators;
import com.google.common.eventbus.Subscribe;
import io.shardingsphere.api.config.MasterSlaveRuleConfiguration;
import io.shardingsphere.core.rule.MasterSlaveRule;
@@ -61,20 +59,7 @@ public Collection getSlaveDataSourceNames() {
*/
@Subscribe
public void renew(final DisabledStateEventBusEvent disabledStateEventBusEvent) {
- if (disabledStateEventBusEvent.getDisabledDataSourceNames().isEmpty()) {
- disabledDataSourceNames.clear();
- } else {
- disabledDataSourceNames.addAll(disabledStateEventBusEvent.getDisabledDataSourceNames());
- }
- }
-
- private boolean isToRenew(final Collection disabledDataSourceNames) {
- return Iterators.contains(disabledDataSourceNames.iterator(), new Predicate() {
-
- @Override
- public boolean apply(final String input) {
- return OrchestrationMasterSlaveRule.super.getSlaveDataSourceNames().contains(input);
- }
- });
+ disabledDataSourceNames.clear();
+ disabledDataSourceNames.addAll(disabledStateEventBusEvent.getDisabledDataSourceNames());
}
}
From 3e36316952de2098e5e73428f4f031e4fd6bf7f3 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 19:44:47 +0800
Subject: [PATCH 088/100] getDisabledStateEventBusEvent
---
.../shardingproxy/runtime/GlobalRegistry.java | 26 ++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
index b64a7d08ac643..939ec4f35d6d9 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
@@ -26,11 +26,15 @@
import io.shardingsphere.core.executor.ShardingExecuteEngine;
import io.shardingsphere.core.rule.Authentication;
import io.shardingsphere.core.rule.DataSourceParameter;
+import io.shardingsphere.core.rule.MasterSlaveRule;
import io.shardingsphere.core.yaml.YamlRuleConfiguration;
import io.shardingsphere.core.yaml.other.YamlServerConfiguration;
import io.shardingsphere.orchestration.internal.event.config.ProxyConfigurationEventBusEvent;
import io.shardingsphere.orchestration.internal.event.state.CircuitStateEventBusEvent;
+import io.shardingsphere.orchestration.internal.event.state.DisabledStateEventBusEvent;
import io.shardingsphere.orchestration.internal.event.state.ProxyDisabledStateEventBusEvent;
+import io.shardingsphere.orchestration.internal.rule.OrchestrationMasterSlaveRule;
+import io.shardingsphere.orchestration.internal.rule.OrchestrationShardingRule;
import io.shardingsphere.shardingproxy.runtime.nio.BackendNIOConfiguration;
import lombok.AccessLevel;
import lombok.Getter;
@@ -208,11 +212,31 @@ public void renewCircuitBreakerDataSourceNames(final CircuitStateEventBusEvent c
*/
@Subscribe
public void renewDisabledDataSourceNames(final ProxyDisabledStateEventBusEvent disabledStateEventBusEvent) {
+
+
for (Entry entry : shardingSchemas.entrySet()) {
- entry.getValue().getBackendDataSource().setAvailableDataSources(getDisabledDataSourceNames(disabledStateEventBusEvent.getDisabledSchemaDataSourceMap(), entry.getKey()));
+ DisabledStateEventBusEvent disabledEvent = getDisabledStateEventBusEvent(disabledStateEventBusEvent, );
+ if (entry.getValue().isMasterSlaveOnly()) {
+ OrchestrationMasterSlaveRule orchestrationMasterSlaveRule = (OrchestrationMasterSlaveRule) entry.getValue().getMasterSlaveRule();
+ orchestrationMasterSlaveRule.renew(disabledEvent);
+ } else {
+ OrchestrationShardingRule orchestrationShardingRule = (OrchestrationShardingRule) entry.getValue().getShardingRule();
+ for (MasterSlaveRule each : orchestrationShardingRule.getMasterSlaveRules()) {
+ ((OrchestrationMasterSlaveRule) each).renew(disabledEvent);
+ }
+ }
}
}
+ private DisabledStateEventBusEvent getDisabledStateEventBusEvent(final ProxyDisabledStateEventBusEvent disabledStateEventBusEvent, final String shardingSchemaName) {
+ Collection disabledDataSourceNames = getDisabledDataSourceNames(disabledStateEventBusEvent.getDisabledSchemaDataSourceMap(), shardingSchemaName);
+ return new DisabledStateEventBusEvent(disabledDataSourceNames);
+ }
+
+ private void renewShardingSchema(final ShardingSchema shardingSchema, final Collection disabledSchemaDataSourceNames) {
+
+ }
+
private Collection getDisabledDataSourceNames(final Map> disabledSchemaDataSourceMap, final String shardingSchemaName) {
Collection result = new LinkedList<>();
if (disabledSchemaDataSourceMap.containsKey(shardingSchemaName)) {
From ebac2790d930ca6aee7d6762522dce9fbd41af45 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 19:48:09 +0800
Subject: [PATCH 089/100] renewShardingSchema
---
.../io/shardingsphere/shardingproxy/runtime/ShardingSchema.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
index cddc029eee782..c15a0f0895b9a 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
@@ -53,7 +53,7 @@ public final class ShardingSchema {
private final ShardingRule shardingRule;
- private final MasterSlaveRule masterSlaveRule;
+ private final MasterSlaveRule masterSlaveRule;fi
private final JDBCBackendDataSource backendDataSource;
From fcda767758429c60ae9ea5a2497c7290691d4c12 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 19:49:00 +0800
Subject: [PATCH 090/100] renewShardingSchemaWithMasterSlaveRule
---
.../shardingproxy/runtime/GlobalRegistry.java | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
index 939ec4f35d6d9..551a68e6fe9bf 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
@@ -215,10 +215,9 @@ public void renewDisabledDataSourceNames(final ProxyDisabledStateEventBusEvent d
for (Entry entry : shardingSchemas.entrySet()) {
- DisabledStateEventBusEvent disabledEvent = getDisabledStateEventBusEvent(disabledStateEventBusEvent, );
+ DisabledStateEventBusEvent disabledEvent = getDisabledStateEventBusEvent(disabledStateEventBusEvent.getDisabledSchemaDataSourceMap(), entry.getKey());
if (entry.getValue().isMasterSlaveOnly()) {
- OrchestrationMasterSlaveRule orchestrationMasterSlaveRule = (OrchestrationMasterSlaveRule) entry.getValue().getMasterSlaveRule();
- orchestrationMasterSlaveRule.renew(disabledEvent);
+ renewShardingSchemaWithMasterSlaveRule(entry.getValue(), disabledEvent);
} else {
OrchestrationShardingRule orchestrationShardingRule = (OrchestrationShardingRule) entry.getValue().getShardingRule();
for (MasterSlaveRule each : orchestrationShardingRule.getMasterSlaveRules()) {
@@ -228,12 +227,17 @@ public void renewDisabledDataSourceNames(final ProxyDisabledStateEventBusEvent d
}
}
- private DisabledStateEventBusEvent getDisabledStateEventBusEvent(final ProxyDisabledStateEventBusEvent disabledStateEventBusEvent, final String shardingSchemaName) {
- Collection disabledDataSourceNames = getDisabledDataSourceNames(disabledStateEventBusEvent.getDisabledSchemaDataSourceMap(), shardingSchemaName);
+ private void renewShardingSchemaWithMasterSlaveRule(final ShardingSchema shardingSchema, final DisabledStateEventBusEvent disabledEvent) {
+ OrchestrationMasterSlaveRule orchestrationMasterSlaveRule = (OrchestrationMasterSlaveRule) shardingSchema.getMasterSlaveRule();
+ orchestrationMasterSlaveRule.renew(disabledEvent);
+ }
+
+ private DisabledStateEventBusEvent getDisabledStateEventBusEvent(final Map> disabledSchemaDataSourceMap, final String shardingSchemaName) {
+ Collection disabledDataSourceNames = getDisabledDataSourceNames(disabledSchemaDataSourceMap, shardingSchemaName);
return new DisabledStateEventBusEvent(disabledDataSourceNames);
}
- private void renewShardingSchema(final ShardingSchema shardingSchema, final Collection disabledSchemaDataSourceNames) {
+ private void renewShardingSchemaWithMasterSlaveRule(final ShardingSchema shardingSchema, final Collection disabledSchemaDataSourceNames) {
}
From e7e0f7c5de00f4829365c83f1b97bb3a0e7441af Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 19:50:50 +0800
Subject: [PATCH 091/100] renewShardingSchemaWithShardingRule
---
.../shardingproxy/runtime/GlobalRegistry.java | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
index 551a68e6fe9bf..a73e597d553a3 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
@@ -219,28 +219,28 @@ public void renewDisabledDataSourceNames(final ProxyDisabledStateEventBusEvent d
if (entry.getValue().isMasterSlaveOnly()) {
renewShardingSchemaWithMasterSlaveRule(entry.getValue(), disabledEvent);
} else {
- OrchestrationShardingRule orchestrationShardingRule = (OrchestrationShardingRule) entry.getValue().getShardingRule();
- for (MasterSlaveRule each : orchestrationShardingRule.getMasterSlaveRules()) {
- ((OrchestrationMasterSlaveRule) each).renew(disabledEvent);
- }
+ renewShardingSchemaWithShardingRule(entry.getValue(), disabledEvent);
}
}
}
+ private void renewShardingSchemaWithShardingRule(final ShardingSchema shardingSchema, final DisabledStateEventBusEvent disabledEvent) {
+ OrchestrationShardingRule orchestrationShardingRule = (OrchestrationShardingRule) shardingSchema.getShardingRule();
+ for (MasterSlaveRule each : orchestrationShardingRule.getMasterSlaveRules()) {
+ ((OrchestrationMasterSlaveRule) each).renew(disabledEvent);
+ }
+ }
+
private void renewShardingSchemaWithMasterSlaveRule(final ShardingSchema shardingSchema, final DisabledStateEventBusEvent disabledEvent) {
OrchestrationMasterSlaveRule orchestrationMasterSlaveRule = (OrchestrationMasterSlaveRule) shardingSchema.getMasterSlaveRule();
orchestrationMasterSlaveRule.renew(disabledEvent);
}
- private DisabledStateEventBusEvent getDisabledStateEventBusEvent(final Map> disabledSchemaDataSourceMap, final String shardingSchemaName) {
+ private DisabledStateEventBusEvent getDisabledStateEventBusEvent(final String shardingSchemaName, final Map> disabledSchemaDataSourceMap) {
Collection disabledDataSourceNames = getDisabledDataSourceNames(disabledSchemaDataSourceMap, shardingSchemaName);
return new DisabledStateEventBusEvent(disabledDataSourceNames);
}
- private void renewShardingSchemaWithMasterSlaveRule(final ShardingSchema shardingSchema, final Collection disabledSchemaDataSourceNames) {
-
- }
-
private Collection getDisabledDataSourceNames(final Map> disabledSchemaDataSourceMap, final String shardingSchemaName) {
Collection result = new LinkedList<>();
if (disabledSchemaDataSourceMap.containsKey(shardingSchemaName)) {
From 95e5ff3a30e80cfdc8bb1a2e838691ea753856f4 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 19:51:15 +0800
Subject: [PATCH 092/100] modify getDisabledStateEventBusEvent()
---
.../io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
index a73e597d553a3..13edf8d921269 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
@@ -215,7 +215,7 @@ public void renewDisabledDataSourceNames(final ProxyDisabledStateEventBusEvent d
for (Entry entry : shardingSchemas.entrySet()) {
- DisabledStateEventBusEvent disabledEvent = getDisabledStateEventBusEvent(disabledStateEventBusEvent.getDisabledSchemaDataSourceMap(), entry.getKey());
+ DisabledStateEventBusEvent disabledEvent = getDisabledStateEventBusEvent(entry.getKey(), disabledStateEventBusEvent.getDisabledSchemaDataSourceMap());
if (entry.getValue().isMasterSlaveOnly()) {
renewShardingSchemaWithMasterSlaveRule(entry.getValue(), disabledEvent);
} else {
From 6d04b0da4feb5cffaa8c256223ba919b9fadee51 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 19:51:42 +0800
Subject: [PATCH 093/100] modify getDisabledDataSourceNames()
---
.../io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
index 13edf8d921269..a7f3cf47992d2 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
@@ -241,7 +241,7 @@ private DisabledStateEventBusEvent getDisabledStateEventBusEvent(final String sh
return new DisabledStateEventBusEvent(disabledDataSourceNames);
}
- private Collection getDisabledDataSourceNames(final Map> disabledSchemaDataSourceMap, final String shardingSchemaName) {
+ private Collection getDisabledDataSourceNames(final String shardingSchemaName, final Map> disabledSchemaDataSourceMap) {
Collection result = new LinkedList<>();
if (disabledSchemaDataSourceMap.containsKey(shardingSchemaName)) {
result.addAll(disabledSchemaDataSourceMap.get(shardingSchemaName));
From 6bf8a837248ff465cfe3b524dc6f324dac80b72c Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 19:54:05 +0800
Subject: [PATCH 094/100] adjust position
---
.../shardingproxy/runtime/GlobalRegistry.java | 28 +++++++++----------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
index a7f3cf47992d2..679285c47bc38 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
@@ -212,8 +212,6 @@ public void renewCircuitBreakerDataSourceNames(final CircuitStateEventBusEvent c
*/
@Subscribe
public void renewDisabledDataSourceNames(final ProxyDisabledStateEventBusEvent disabledStateEventBusEvent) {
-
-
for (Entry entry : shardingSchemas.entrySet()) {
DisabledStateEventBusEvent disabledEvent = getDisabledStateEventBusEvent(entry.getKey(), disabledStateEventBusEvent.getDisabledSchemaDataSourceMap());
if (entry.getValue().isMasterSlaveOnly()) {
@@ -224,20 +222,8 @@ public void renewDisabledDataSourceNames(final ProxyDisabledStateEventBusEvent d
}
}
- private void renewShardingSchemaWithShardingRule(final ShardingSchema shardingSchema, final DisabledStateEventBusEvent disabledEvent) {
- OrchestrationShardingRule orchestrationShardingRule = (OrchestrationShardingRule) shardingSchema.getShardingRule();
- for (MasterSlaveRule each : orchestrationShardingRule.getMasterSlaveRules()) {
- ((OrchestrationMasterSlaveRule) each).renew(disabledEvent);
- }
- }
-
- private void renewShardingSchemaWithMasterSlaveRule(final ShardingSchema shardingSchema, final DisabledStateEventBusEvent disabledEvent) {
- OrchestrationMasterSlaveRule orchestrationMasterSlaveRule = (OrchestrationMasterSlaveRule) shardingSchema.getMasterSlaveRule();
- orchestrationMasterSlaveRule.renew(disabledEvent);
- }
-
private DisabledStateEventBusEvent getDisabledStateEventBusEvent(final String shardingSchemaName, final Map> disabledSchemaDataSourceMap) {
- Collection disabledDataSourceNames = getDisabledDataSourceNames(disabledSchemaDataSourceMap, shardingSchemaName);
+ Collection disabledDataSourceNames = getDisabledDataSourceNames(shardingSchemaName, disabledSchemaDataSourceMap);
return new DisabledStateEventBusEvent(disabledDataSourceNames);
}
@@ -248,4 +234,16 @@ private Collection getDisabledDataSourceNames(final String shardingSchem
}
return result;
}
+
+ private void renewShardingSchemaWithShardingRule(final ShardingSchema shardingSchema, final DisabledStateEventBusEvent disabledEvent) {
+ OrchestrationShardingRule orchestrationShardingRule = (OrchestrationShardingRule) shardingSchema.getShardingRule();
+ for (MasterSlaveRule each : orchestrationShardingRule.getMasterSlaveRules()) {
+ ((OrchestrationMasterSlaveRule) each).renew(disabledEvent);
+ }
+ }
+
+ private void renewShardingSchemaWithMasterSlaveRule(final ShardingSchema shardingSchema, final DisabledStateEventBusEvent disabledEvent) {
+ OrchestrationMasterSlaveRule orchestrationMasterSlaveRule = (OrchestrationMasterSlaveRule) shardingSchema.getMasterSlaveRule();
+ orchestrationMasterSlaveRule.renew(disabledEvent);
+ }
}
From c54781fc010ec4ec8e27db646d14c39082df2673 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 19:55:23 +0800
Subject: [PATCH 095/100] delete getDisabledStateEventBusEvent()
---
.../shardingproxy/runtime/GlobalRegistry.java | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
index 679285c47bc38..60119a9a5ca84 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
@@ -213,7 +213,7 @@ public void renewCircuitBreakerDataSourceNames(final CircuitStateEventBusEvent c
@Subscribe
public void renewDisabledDataSourceNames(final ProxyDisabledStateEventBusEvent disabledStateEventBusEvent) {
for (Entry entry : shardingSchemas.entrySet()) {
- DisabledStateEventBusEvent disabledEvent = getDisabledStateEventBusEvent(entry.getKey(), disabledStateEventBusEvent.getDisabledSchemaDataSourceMap());
+ DisabledStateEventBusEvent disabledEvent = new DisabledStateEventBusEvent(getDisabledDataSourceNames(entry.getKey(), =disabledStateEventBusEvent.getDisabledSchemaDataSourceMap());
if (entry.getValue().isMasterSlaveOnly()) {
renewShardingSchemaWithMasterSlaveRule(entry.getValue(), disabledEvent);
} else {
@@ -222,11 +222,6 @@ public void renewDisabledDataSourceNames(final ProxyDisabledStateEventBusEvent d
}
}
- private DisabledStateEventBusEvent getDisabledStateEventBusEvent(final String shardingSchemaName, final Map> disabledSchemaDataSourceMap) {
- Collection disabledDataSourceNames = getDisabledDataSourceNames(shardingSchemaName, disabledSchemaDataSourceMap);
- return new DisabledStateEventBusEvent(disabledDataSourceNames);
- }
-
private Collection getDisabledDataSourceNames(final String shardingSchemaName, final Map> disabledSchemaDataSourceMap) {
Collection result = new LinkedList<>();
if (disabledSchemaDataSourceMap.containsKey(shardingSchemaName)) {
From 5661e61e02ab20ed9f9aa6b922ae25d48db399c6 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 19:55:54 +0800
Subject: [PATCH 096/100] modify renewDisabledDataSourceNames()
---
.../io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
index 60119a9a5ca84..675fb4734e756 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
@@ -213,7 +213,7 @@ public void renewCircuitBreakerDataSourceNames(final CircuitStateEventBusEvent c
@Subscribe
public void renewDisabledDataSourceNames(final ProxyDisabledStateEventBusEvent disabledStateEventBusEvent) {
for (Entry entry : shardingSchemas.entrySet()) {
- DisabledStateEventBusEvent disabledEvent = new DisabledStateEventBusEvent(getDisabledDataSourceNames(entry.getKey(), =disabledStateEventBusEvent.getDisabledSchemaDataSourceMap());
+ DisabledStateEventBusEvent disabledEvent = new DisabledStateEventBusEvent(getDisabledDataSourceNames(entry.getKey(), disabledStateEventBusEvent.getDisabledSchemaDataSourceMap()));
if (entry.getValue().isMasterSlaveOnly()) {
renewShardingSchemaWithMasterSlaveRule(entry.getValue(), disabledEvent);
} else {
From 968c0a053bbe3eae8a0d3b31c7a5d986d1adecb7 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 19:58:21 +0800
Subject: [PATCH 097/100] invalid chars
---
.../io/shardingsphere/shardingproxy/runtime/ShardingSchema.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
index c15a0f0895b9a..cddc029eee782 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/ShardingSchema.java
@@ -53,7 +53,7 @@ public final class ShardingSchema {
private final ShardingRule shardingRule;
- private final MasterSlaveRule masterSlaveRule;fi
+ private final MasterSlaveRule masterSlaveRule;
private final JDBCBackendDataSource backendDataSource;
From 9a18e2cbfabe7020f7b15a70c6e70e3c4b37997f Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 20:11:22 +0800
Subject: [PATCH 098/100] modify ShardingNamespaceTest.java
---
.../shardingjdbc/spring/ShardingNamespaceTest.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sharding-jdbc/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/spring/ShardingNamespaceTest.java b/sharding-jdbc/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/spring/ShardingNamespaceTest.java
index 786c7a4f4296b..d89fe74a03c83 100644
--- a/sharding-jdbc/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/spring/ShardingNamespaceTest.java
+++ b/sharding-jdbc/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/spring/ShardingNamespaceTest.java
@@ -211,7 +211,7 @@ public void assertPropsDataSource() {
Map configMap = new HashMap<>();
configMap.put("key1", "value1");
assertThat(ConfigMapContext.getInstance().getShardingConfig(), is(configMap));
- Object shardingContext = FieldValueUtil.getFieldValue(shardingDataSource, "shardingContext", false);
+ Object shardingContext = FieldValueUtil.getFieldValue(shardingDataSource, "shardingContext", true);
assertTrue((boolean) FieldValueUtil.getFieldValue(shardingContext, "showSQL"));
ShardingProperties shardingProperties = (ShardingProperties) FieldValueUtil.getFieldValue(shardingDataSource, "shardingProperties", true);
boolean showSql = shardingProperties.getValue(ShardingPropertiesConstant.SQL_SHOW);
@@ -229,7 +229,7 @@ public void assertShardingDataSourceType() {
@Test
public void assertDefaultActualDataNodes() {
ShardingDataSource multiTableRulesDataSource = this.applicationContext.getBean("multiTableRulesDataSource", ShardingDataSource.class);
- Object shardingContext = FieldValueUtil.getFieldValue(multiTableRulesDataSource, "shardingContext", false);
+ Object shardingContext = FieldValueUtil.getFieldValue(multiTableRulesDataSource, "shardingContext", true);
ShardingRule shardingRule = (ShardingRule) FieldValueUtil.getFieldValue(shardingContext, "shardingRule");
assertThat(shardingRule.getTableRules().size(), is(2));
Iterator tableRules = shardingRule.getTableRules().iterator();
@@ -251,7 +251,7 @@ private Map getDataSourceMap(final String shardingDataSource
private ShardingRule getShardingRule(final String shardingDataSourceName) {
ShardingDataSource shardingDataSource = this.applicationContext.getBean(shardingDataSourceName, ShardingDataSource.class);
- Object shardingContext = FieldValueUtil.getFieldValue(shardingDataSource, "shardingContext", false);
+ Object shardingContext = FieldValueUtil.getFieldValue(shardingDataSource, "shardingContext", true);
return (ShardingRule) FieldValueUtil.getFieldValue(shardingContext, "shardingRule");
}
}
From 2c301ef77127f81b89b221f9b441a07b576daae2 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 20:11:33 +0800
Subject: [PATCH 099/100] modify cases
---
.../shardingjdbc/spring/GenerateKeyJUnitTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sharding-jdbc/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/spring/GenerateKeyJUnitTest.java b/sharding-jdbc/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/spring/GenerateKeyJUnitTest.java
index 69331106d95c8..e898c4e5b5464 100644
--- a/sharding-jdbc/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/spring/GenerateKeyJUnitTest.java
+++ b/sharding-jdbc/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/shardingjdbc/spring/GenerateKeyJUnitTest.java
@@ -62,7 +62,7 @@ public void assertGenerateKey() throws SQLException {
@SuppressWarnings("unchecked")
@Test
public void assertGenerateKeyColumn() {
- Object shardingContext = FieldValueUtil.getFieldValue(shardingDataSource, "shardingContext", false);
+ Object shardingContext = FieldValueUtil.getFieldValue(shardingDataSource, "shardingContext", true);
assertNotNull(shardingContext);
Object shardingRule = FieldValueUtil.getFieldValue(shardingContext, "shardingRule");
assertNotNull(shardingRule);
From 25764e36e06579f981f4b22f10a4e26a7bc3cee4 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 20:19:26 +0800
Subject: [PATCH 100/100] modify renewShardingSchemaWithShardingRule()
---
.../shardingproxy/runtime/GlobalRegistry.java | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
index 675fb4734e756..a104c077b42d1 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
+++ b/sharding-proxy/src/main/java/io/shardingsphere/shardingproxy/runtime/GlobalRegistry.java
@@ -231,14 +231,12 @@ private Collection getDisabledDataSourceNames(final String shardingSchem
}
private void renewShardingSchemaWithShardingRule(final ShardingSchema shardingSchema, final DisabledStateEventBusEvent disabledEvent) {
- OrchestrationShardingRule orchestrationShardingRule = (OrchestrationShardingRule) shardingSchema.getShardingRule();
- for (MasterSlaveRule each : orchestrationShardingRule.getMasterSlaveRules()) {
+ for (MasterSlaveRule each : ((OrchestrationShardingRule) shardingSchema.getShardingRule()).getMasterSlaveRules()) {
((OrchestrationMasterSlaveRule) each).renew(disabledEvent);
}
}
private void renewShardingSchemaWithMasterSlaveRule(final ShardingSchema shardingSchema, final DisabledStateEventBusEvent disabledEvent) {
- OrchestrationMasterSlaveRule orchestrationMasterSlaveRule = (OrchestrationMasterSlaveRule) shardingSchema.getMasterSlaveRule();
- orchestrationMasterSlaveRule.renew(disabledEvent);
+ ((OrchestrationMasterSlaveRule) shardingSchema.getMasterSlaveRule()).renew(disabledEvent);
}
}