From 07e0904e832b1b08e38d7f33b32ecebbd8f884d4 Mon Sep 17 00:00:00 2001
From: tristaZero
Date: Mon, 15 Oct 2018 15:01:42 +0800
Subject: [PATCH 01/57] 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 02/57] 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 03/57] 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 04/57] 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 05/57] 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 06/57] 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 07/57] 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 08/57] 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 09/57] 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 10/57] 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 11/57] 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 12/57] 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 13/57] 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 14/57] 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 15/57] 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 16/57] 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 17/57] 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 18/57] 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 19/57] 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 20/57] 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 21/57] 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 22/57] 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 23/57] 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 24/57] 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 25/57] 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 26/57] 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 27/57] 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 28/57] =?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 29/57] 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 30/57] 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 31/57] 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 32/57] 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 33/57] 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 34/57] 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 35/57] 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 36/57] 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 37/57] 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 38/57] 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 39/57] 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 40/57] 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 41/57] 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 42/57] 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 43/57] 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 44/57] 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 45/57] 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 46/57] 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 47/57] 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 48/57] 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 49/57] 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 50/57] 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 51/57] 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 52/57] 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 53/57] 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 54/57] 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 55/57] 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 56/57] 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 57/57] 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);
}
}