You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by me...@apache.org on 2021/12/03 06:21:23 UTC
[shardingsphere] branch master updated: Change discovery api (#13885)
This is an automated email from the ASF dual-hosted git repository.
menghaoran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 13e1a28 Change discovery api (#13885)
13e1a28 is described below
commit 13e1a28cd7dc59a7934f56b926bf002da5604ac5
Author: zhaojinchao <33...@users.noreply.github.com>
AuthorDate: Fri Dec 3 14:20:30 2021 +0800
Change discovery api (#13885)
* change discovery api
* update
* update
* update
* update
---
.../config/DatabaseDiscoveryRuleConfiguration.java | 3 +++
...tabaseDiscoveryDataSourceRuleConfiguration.java | 2 ++
...> DatabaseDiscoveryHeartBeatConfiguration.java} | 12 ++++------
...ProvidedDatabaseDiscoveryRuleConfiguration.java | 3 +++
.../YamlDatabaseDiscoveryRuleConfiguration.java | 3 +++
...tabaseDiscoveryDataSourceRuleConfiguration.java | 5 ++---
...mlDatabaseDiscoveryHeartBeatConfiguration.java} | 10 ++-------
...eAlgorithmProviderConfigurationYamlSwapper.java | 3 ++-
...abaseDiscoveryRuleConfigurationYamlSwapper.java | 26 ++++++++++++++++++++--
.../route/DatabaseDiscoverySQLRouterTest.java | 5 +++--
.../rule/DatabaseDiscoveryDataSourceRuleTest.java | 8 +++----
.../rule/DatabaseDiscoveryRuleTest.java | 6 ++---
...hmProvidedDatabaseDiscoveryRuleBuilderTest.java | 2 +-
.../builder/DatabaseDiscoveryRuleBuilderTest.java | 5 +++--
...orithmProviderConfigurationYamlSwapperTest.java | 5 +++--
...eDiscoveryRuleConfigurationYamlSwapperTest.java | 9 ++++----
.../DatabaseDiscoveryRuleStatementConverter.java | 7 ++++--
.../DatabaseDiscoveryRuleQueryResultSetTest.java | 5 +++--
...rDatabaseDiscoveryRuleStatementUpdaterTest.java | 6 ++---
...eDatabaseDiscoveryRuleStatementUpdaterTest.java | 4 ++--
...pDatabaseDiscoveryRuleStatementUpdaterTest.java | 10 ++++-----
21 files changed, 85 insertions(+), 54 deletions(-)
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/api/config/DatabaseDiscoveryRuleConfiguration.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/api/config/DatabaseDiscoveryRuleConfiguration.java
index 887c175..45eabe7 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/api/config/DatabaseDiscoveryRuleConfiguration.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/api/config/DatabaseDiscoveryRuleConfiguration.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.dbdiscovery.api.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryHeartBeatConfiguration;
import org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryDataSourceRuleConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.config.function.DistributedRuleConfiguration;
@@ -36,5 +37,7 @@ public final class DatabaseDiscoveryRuleConfiguration implements SchemaRuleConfi
private final Collection<DatabaseDiscoveryDataSourceRuleConfiguration> dataSources;
+ private final Map<String, DatabaseDiscoveryHeartBeatConfiguration> discoveryHeartbeats;
+
private final Map<String, ShardingSphereAlgorithmConfiguration> discoveryTypes;
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/api/config/rule/DatabaseDiscoveryDataSourceRuleConfiguration.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/api/config/rule/DatabaseDiscoveryDataSourceRuleConfiguration.java
index 8a1fcb7..544ff11 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/api/config/rule/DatabaseDiscoveryDataSourceRuleConfiguration.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/api/config/rule/DatabaseDiscoveryDataSourceRuleConfiguration.java
@@ -33,5 +33,7 @@ public final class DatabaseDiscoveryDataSourceRuleConfiguration {
private final List<String> dataSourceNames;
+ private final String discoveryHeartbeatName;
+
private final String discoveryTypeName;
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/api/config/rule/DatabaseDiscoveryDataSourceRuleConfiguration.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/api/config/rule/DatabaseDiscoveryHeartBeatConfiguration.java
similarity index 77%
copy from shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/api/config/rule/DatabaseDiscoveryDataSourceRuleConfiguration.java
copy to shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/api/config/rule/DatabaseDiscoveryHeartBeatConfiguration.java
index 8a1fcb7..420c34a 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/api/config/rule/DatabaseDiscoveryDataSourceRuleConfiguration.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/api/config/rule/DatabaseDiscoveryHeartBeatConfiguration.java
@@ -20,18 +20,14 @@ package org.apache.shardingsphere.dbdiscovery.api.config.rule;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import java.util.List;
+import java.util.Properties;
/**
- * Database discovery data source rule configuration.
+ * Database discovery heartbeat configuration.
*/
@RequiredArgsConstructor
@Getter
-public final class DatabaseDiscoveryDataSourceRuleConfiguration {
+public final class DatabaseDiscoveryHeartBeatConfiguration {
- private final String name;
-
- private final List<String> dataSourceNames;
-
- private final String discoveryTypeName;
+ private final Properties props;
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/config/AlgorithmProvidedDatabaseDiscoveryRuleConfiguration.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/config/AlgorithmProvidedDatabaseDiscoveryRuleConfiguration.java
index 2aacf43..2c299db 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/config/AlgorithmProvidedDatabaseDiscoveryRuleConfiguration.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/algorithm/config/AlgorithmProvidedDatabaseDiscoveryRuleConfiguration.java
@@ -21,6 +21,7 @@ import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
+import org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryHeartBeatConfiguration;
import org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryDataSourceRuleConfiguration;
import org.apache.shardingsphere.dbdiscovery.spi.DatabaseDiscoveryType;
import org.apache.shardingsphere.infra.config.function.DistributedRuleConfiguration;
@@ -42,5 +43,7 @@ public final class AlgorithmProvidedDatabaseDiscoveryRuleConfiguration implement
private Collection<DatabaseDiscoveryDataSourceRuleConfiguration> dataSources = new LinkedList<>();
+ private Collection<DatabaseDiscoveryHeartBeatConfiguration> discoveryHeartbeats = new LinkedList<>();
+
private Map<String, DatabaseDiscoveryType> discoveryTypes = new LinkedHashMap<>();
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/yaml/config/YamlDatabaseDiscoveryRuleConfiguration.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/yaml/config/YamlDatabaseDiscoveryRuleConfiguration.java
index d1aefb4..3634faf 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/yaml/config/YamlDatabaseDiscoveryRuleConfiguration.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/yaml/config/YamlDatabaseDiscoveryRuleConfiguration.java
@@ -21,6 +21,7 @@ import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.dbdiscovery.api.config.DatabaseDiscoveryRuleConfiguration;
import org.apache.shardingsphere.dbdiscovery.yaml.config.rule.YamlDatabaseDiscoveryDataSourceRuleConfiguration;
+import org.apache.shardingsphere.dbdiscovery.yaml.config.rule.YamlDatabaseDiscoveryHeartBeatConfiguration;
import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRuleConfiguration;
import org.apache.shardingsphere.infra.yaml.config.pojo.algorithm.YamlShardingSphereAlgorithmConfiguration;
@@ -36,6 +37,8 @@ public final class YamlDatabaseDiscoveryRuleConfiguration implements YamlRuleCon
private Map<String, YamlDatabaseDiscoveryDataSourceRuleConfiguration> dataSources = new LinkedHashMap<>();
+ private Map<String, YamlDatabaseDiscoveryHeartBeatConfiguration> discoveryHeartbeats = new LinkedHashMap<>();
+
private Map<String, YamlShardingSphereAlgorithmConfiguration> discoveryTypes = new LinkedHashMap<>();
@Override
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/yaml/config/rule/YamlDatabaseDiscoveryDataSourceRuleConfiguration.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/yaml/config/rule/YamlDatabaseDiscoveryDataSourceRuleConfiguration.java
index f7782f3..03e0819 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/yaml/config/rule/YamlDatabaseDiscoveryDataSourceRuleConfiguration.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/yaml/config/rule/YamlDatabaseDiscoveryDataSourceRuleConfiguration.java
@@ -23,7 +23,6 @@ import org.apache.shardingsphere.infra.yaml.config.pojo.YamlConfiguration;
import java.util.ArrayList;
import java.util.List;
-import java.util.Properties;
/**
* Database discovery data source rule configuration for YAML.
@@ -34,7 +33,7 @@ public final class YamlDatabaseDiscoveryDataSourceRuleConfiguration implements Y
private List<String> dataSourceNames = new ArrayList<>();
- private String discoveryTypeName;
+ private String discoveryHeartbeatName;
- private Properties props = new Properties();
+ private String discoveryTypeName;
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/yaml/config/rule/YamlDatabaseDiscoveryDataSourceRuleConfiguration.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/yaml/config/rule/YamlDatabaseDiscoveryHeartBeatConfiguration.java
similarity index 77%
copy from shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/yaml/config/rule/YamlDatabaseDiscoveryDataSourceRuleConfiguration.java
copy to shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/yaml/config/rule/YamlDatabaseDiscoveryHeartBeatConfiguration.java
index f7782f3..a33c364 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/yaml/config/rule/YamlDatabaseDiscoveryDataSourceRuleConfiguration.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/yaml/config/rule/YamlDatabaseDiscoveryHeartBeatConfiguration.java
@@ -21,20 +21,14 @@ import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.infra.yaml.config.pojo.YamlConfiguration;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Properties;
/**
- * Database discovery data source rule configuration for YAML.
+ * Database discovery heart beat configuration for YAML.
*/
@Getter
@Setter
-public final class YamlDatabaseDiscoveryDataSourceRuleConfiguration implements YamlConfiguration {
-
- private List<String> dataSourceNames = new ArrayList<>();
-
- private String discoveryTypeName;
+public final class YamlDatabaseDiscoveryHeartBeatConfiguration implements YamlConfiguration {
private Properties props = new Properties();
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwapper.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwapper.java
index e40767e..bdc9a92 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwapper.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwapper.java
@@ -62,7 +62,8 @@ public final class DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwappe
}
private DatabaseDiscoveryDataSourceRuleConfiguration swapToObject(final String name, final YamlDatabaseDiscoveryDataSourceRuleConfiguration yamlDataSourceRuleConfig) {
- return new DatabaseDiscoveryDataSourceRuleConfiguration(name, yamlDataSourceRuleConfig.getDataSourceNames(), yamlDataSourceRuleConfig.getDiscoveryTypeName());
+ return new DatabaseDiscoveryDataSourceRuleConfiguration(name, yamlDataSourceRuleConfig.getDataSourceNames(), yamlDataSourceRuleConfig.getDiscoveryHeartbeatName(),
+ yamlDataSourceRuleConfig.getDiscoveryTypeName());
}
@Override
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/DatabaseDiscoveryRuleConfigurationYamlSwapper.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/DatabaseDiscoveryRuleConfigurationYamlSwapper.java
index 32c3adb..a3cd23d 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/DatabaseDiscoveryRuleConfigurationYamlSwapper.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/DatabaseDiscoveryRuleConfigurationYamlSwapper.java
@@ -17,10 +17,12 @@
package org.apache.shardingsphere.dbdiscovery.yaml.swapper;
+import org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryHeartBeatConfiguration;
import org.apache.shardingsphere.dbdiscovery.constant.DatabaseDiscoveryOrder;
import org.apache.shardingsphere.dbdiscovery.yaml.config.rule.YamlDatabaseDiscoveryDataSourceRuleConfiguration;
import org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryDataSourceRuleConfiguration;
import org.apache.shardingsphere.dbdiscovery.yaml.config.YamlDatabaseDiscoveryRuleConfiguration;
+import org.apache.shardingsphere.dbdiscovery.yaml.config.rule.YamlDatabaseDiscoveryHeartBeatConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.yaml.config.swapper.YamlRuleConfigurationSwapper;
import org.apache.shardingsphere.infra.yaml.config.swapper.algorithm.ShardingSphereAlgorithmConfigurationYamlSwapper;
@@ -30,6 +32,7 @@ import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;
+
import java.util.Map.Entry;
import java.util.stream.Collectors;
@@ -46,6 +49,9 @@ public final class DatabaseDiscoveryRuleConfigurationYamlSwapper
YamlDatabaseDiscoveryRuleConfiguration result = new YamlDatabaseDiscoveryRuleConfiguration();
result.setDataSources(data.getDataSources().stream().collect(
Collectors.toMap(DatabaseDiscoveryDataSourceRuleConfiguration::getName, this::swapToYamlConfiguration, (oldValue, currentValue) -> oldValue, LinkedHashMap::new)));
+ if (null != data.getDiscoveryHeartbeats()) {
+ data.getDiscoveryHeartbeats().forEach((key, value) -> result.getDiscoveryHeartbeats().put(key, swapToYamlConfiguration(value)));
+ }
if (null != data.getDiscoveryTypes()) {
data.getDiscoveryTypes().forEach((key, value) -> result.getDiscoveryTypes().put(key, algorithmSwapper.swapToYamlConfiguration(value)));
}
@@ -55,25 +61,41 @@ public final class DatabaseDiscoveryRuleConfigurationYamlSwapper
private YamlDatabaseDiscoveryDataSourceRuleConfiguration swapToYamlConfiguration(final DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfig) {
YamlDatabaseDiscoveryDataSourceRuleConfiguration result = new YamlDatabaseDiscoveryDataSourceRuleConfiguration();
result.setDataSourceNames(dataSourceRuleConfig.getDataSourceNames());
+ result.setDiscoveryHeartbeatName(dataSourceRuleConfig.getDiscoveryHeartbeatName());
result.setDiscoveryTypeName(dataSourceRuleConfig.getDiscoveryTypeName());
return result;
}
+ private YamlDatabaseDiscoveryHeartBeatConfiguration swapToYamlConfiguration(final DatabaseDiscoveryHeartBeatConfiguration heartBeatRuleConfig) {
+ YamlDatabaseDiscoveryHeartBeatConfiguration result = new YamlDatabaseDiscoveryHeartBeatConfiguration();
+ result.setProps(heartBeatRuleConfig.getProps());
+ return result;
+ }
+
@Override
public DatabaseDiscoveryRuleConfiguration swapToObject(final YamlDatabaseDiscoveryRuleConfiguration yamlConfig) {
Collection<DatabaseDiscoveryDataSourceRuleConfiguration> dataSources = new LinkedList<>();
for (Entry<String, YamlDatabaseDiscoveryDataSourceRuleConfiguration> entry : yamlConfig.getDataSources().entrySet()) {
dataSources.add(swapToObject(entry.getKey(), entry.getValue()));
}
+ Map<String, DatabaseDiscoveryHeartBeatConfiguration> heartBeats = new LinkedHashMap<>(yamlConfig.getDiscoveryHeartbeats().entrySet().size(), 1);
+ if (null != yamlConfig.getDiscoveryHeartbeats()) {
+ yamlConfig.getDiscoveryHeartbeats().forEach((key, value) -> heartBeats.put(key, swapToObject(value)));
+ }
Map<String, ShardingSphereAlgorithmConfiguration> haTypes = new LinkedHashMap<>(yamlConfig.getDiscoveryTypes().entrySet().size(), 1);
if (null != yamlConfig.getDiscoveryTypes()) {
yamlConfig.getDiscoveryTypes().forEach((key, value) -> haTypes.put(key, algorithmSwapper.swapToObject(value)));
}
- return new DatabaseDiscoveryRuleConfiguration(dataSources, haTypes);
+ return new DatabaseDiscoveryRuleConfiguration(dataSources, heartBeats, haTypes);
}
private DatabaseDiscoveryDataSourceRuleConfiguration swapToObject(final String name, final YamlDatabaseDiscoveryDataSourceRuleConfiguration yamlDataSourceRuleConfig) {
- return new DatabaseDiscoveryDataSourceRuleConfiguration(name, yamlDataSourceRuleConfig.getDataSourceNames(), yamlDataSourceRuleConfig.getDiscoveryTypeName());
+ return new DatabaseDiscoveryDataSourceRuleConfiguration(name, yamlDataSourceRuleConfig.getDataSourceNames(), yamlDataSourceRuleConfig.getDiscoveryHeartbeatName(),
+ yamlDataSourceRuleConfig.getDiscoveryTypeName());
+ }
+
+ private DatabaseDiscoveryHeartBeatConfiguration swapToObject(final YamlDatabaseDiscoveryHeartBeatConfiguration yamlHeartbeatRuleConfig) {
+ return new DatabaseDiscoveryHeartBeatConfiguration(yamlHeartbeatRuleConfig.getProps());
}
@Override
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/route/DatabaseDiscoverySQLRouterTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/route/DatabaseDiscoverySQLRouterTest.java
index 249fe24..c46ba1c 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/route/DatabaseDiscoverySQLRouterTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/route/DatabaseDiscoverySQLRouterTest.java
@@ -74,9 +74,10 @@ public final class DatabaseDiscoverySQLRouterTest {
@Before
public void setUp() {
DatabaseDiscoveryDataSourceRuleConfiguration dataSourceConfig
- = new DatabaseDiscoveryDataSourceRuleConfiguration(DATA_SOURCE_NAME, Collections.singletonList(PRIMARY_DATA_SOURCE), "TEST");
+ = new DatabaseDiscoveryDataSourceRuleConfiguration(DATA_SOURCE_NAME, Collections.singletonList(PRIMARY_DATA_SOURCE), "ha_heartbeat", "TEST");
ShardingSphereAlgorithmConfiguration algorithmConfig = new ShardingSphereAlgorithmConfiguration("TEST", new Properties());
- DatabaseDiscoveryRuleConfiguration config = new DatabaseDiscoveryRuleConfiguration(Collections.singleton(dataSourceConfig), Collections.singletonMap("TEST", algorithmConfig));
+ DatabaseDiscoveryRuleConfiguration config = new DatabaseDiscoveryRuleConfiguration(Collections.singleton(dataSourceConfig), Collections.emptyMap(),
+ Collections.singletonMap("TEST", algorithmConfig));
rule = new DatabaseDiscoveryRule(config, "TEST", Collections.singletonMap("ds", mock(DataSource.class)));
sqlRouter = (DatabaseDiscoverySQLRouter) OrderedSPIRegistry.getRegisteredServices(SQLRouter.class, Collections.singleton(rule)).get(rule);
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryDataSourceRuleTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryDataSourceRuleTest.java
index fbe8832..5407a76 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryDataSourceRuleTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryDataSourceRuleTest.java
@@ -33,21 +33,21 @@ import static org.junit.Assert.assertThat;
public final class DatabaseDiscoveryDataSourceRuleTest {
private final DatabaseDiscoveryDataSourceRule databaseDiscoveryDataSourceRule = new DatabaseDiscoveryDataSourceRule(
- new DatabaseDiscoveryDataSourceRuleConfiguration("test_pr", Arrays.asList("ds_0", "ds_1"), "discoveryTypeName"), new MGRDatabaseDiscoveryType());
+ new DatabaseDiscoveryDataSourceRuleConfiguration("test_pr", Arrays.asList("ds_0", "ds_1"), "ha_heartbeat", "discoveryTypeName"), new MGRDatabaseDiscoveryType());
@Test(expected = IllegalArgumentException.class)
public void assertNewHADataSourceRuleWithoutName() {
- new DatabaseDiscoveryDataSourceRule(new DatabaseDiscoveryDataSourceRuleConfiguration("", Arrays.asList("ds_0", "ds_1"), "discoveryTypeName"), new MGRDatabaseDiscoveryType());
+ new DatabaseDiscoveryDataSourceRule(new DatabaseDiscoveryDataSourceRuleConfiguration("", Arrays.asList("ds_0", "ds_1"), "ha_heartbeat", "discoveryTypeName"), new MGRDatabaseDiscoveryType());
}
@Test(expected = IllegalArgumentException.class)
public void assertNewHADataSourceRuleWithNullDataSourceName() {
- new DatabaseDiscoveryDataSourceRule(new DatabaseDiscoveryDataSourceRuleConfiguration("ds", null, "discoveryTypeName"), new MGRDatabaseDiscoveryType());
+ new DatabaseDiscoveryDataSourceRule(new DatabaseDiscoveryDataSourceRuleConfiguration("ds", null, "ha_heartbeat", "discoveryTypeName"), new MGRDatabaseDiscoveryType());
}
@Test(expected = IllegalArgumentException.class)
public void assertNewHADataSourceRuleWithEmptyDataSourceName() {
- new DatabaseDiscoveryDataSourceRule(new DatabaseDiscoveryDataSourceRuleConfiguration("ds", Collections.emptyList(), "discoveryTypeName"), new MGRDatabaseDiscoveryType());
+ new DatabaseDiscoveryDataSourceRule(new DatabaseDiscoveryDataSourceRuleConfiguration("ds", Collections.emptyList(), "ha_heartbeat", "discoveryTypeName"), new MGRDatabaseDiscoveryType());
}
@Test
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRuleTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRuleTest.java
index 00ea6d0..1688fbf 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRuleTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRuleTest.java
@@ -43,7 +43,7 @@ public final class DatabaseDiscoveryRuleTest {
@Test(expected = IllegalArgumentException.class)
public void assertNewWithEmptyDataSourceRule() {
- new DatabaseDiscoveryRule(new DatabaseDiscoveryRuleConfiguration(Collections.emptyList(), Collections.emptyMap()), "ha_db", dataSourceMap);
+ new DatabaseDiscoveryRule(new DatabaseDiscoveryRuleConfiguration(Collections.emptyList(), Collections.emptyMap(), Collections.emptyMap()), "ha_db", dataSourceMap);
}
@Test
@@ -101,8 +101,8 @@ public final class DatabaseDiscoveryRuleTest {
}
private DatabaseDiscoveryRule createRule() {
- DatabaseDiscoveryDataSourceRuleConfiguration config = new DatabaseDiscoveryDataSourceRuleConfiguration("test_pr", Arrays.asList("ds_0", "ds_1"), "TEST");
+ DatabaseDiscoveryDataSourceRuleConfiguration config = new DatabaseDiscoveryDataSourceRuleConfiguration("test_pr", Arrays.asList("ds_0", "ds_1"), "ha_heartbeat", "TEST");
return new DatabaseDiscoveryRule(new DatabaseDiscoveryRuleConfiguration(
- Collections.singleton(config), ImmutableMap.of("TEST", new ShardingSphereAlgorithmConfiguration("TEST", new Properties()))), "ha_db", dataSourceMap);
+ Collections.singleton(config), Collections.emptyMap(), ImmutableMap.of("TEST", new ShardingSphereAlgorithmConfiguration("TEST", new Properties()))), "ha_db", dataSourceMap);
}
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/builder/AlgorithmProvidedDatabaseDiscoveryRuleBuilderTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/builder/AlgorithmProvidedDatabaseDiscoveryRuleBuilderTest.java
index c36c79c..2ca699b 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/builder/AlgorithmProvidedDatabaseDiscoveryRuleBuilderTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/builder/AlgorithmProvidedDatabaseDiscoveryRuleBuilderTest.java
@@ -46,7 +46,7 @@ public final class AlgorithmProvidedDatabaseDiscoveryRuleBuilderTest {
@Test(expected = IllegalArgumentException.class)
public void assertBuild() {
AlgorithmProvidedDatabaseDiscoveryRuleConfiguration algorithmProvidedRuleConfig = mock(AlgorithmProvidedDatabaseDiscoveryRuleConfiguration.class);
- DatabaseDiscoveryDataSourceRuleConfiguration ruleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("name", Collections.singletonList("name"), "discoveryTypeName");
+ DatabaseDiscoveryDataSourceRuleConfiguration ruleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("name", Collections.singletonList("name"), "ha_heartbeat", "discoveryTypeName");
when(algorithmProvidedRuleConfig.getDataSources()).thenReturn(Collections.singletonList(ruleConfig));
SchemaRuleBuilder builder = OrderedSPIRegistry.getRegisteredServices(
SchemaRuleBuilder.class, Collections.singletonList(algorithmProvidedRuleConfig)).get(algorithmProvidedRuleConfig);
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/builder/DatabaseDiscoveryRuleBuilderTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/builder/DatabaseDiscoveryRuleBuilderTest.java
index c7ca391..cd0960c 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/builder/DatabaseDiscoveryRuleBuilderTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/builder/DatabaseDiscoveryRuleBuilderTest.java
@@ -48,9 +48,10 @@ public final class DatabaseDiscoveryRuleBuilderTest {
@SuppressWarnings({"rawtypes", "unchecked"})
@Test
public void assertBuild() {
- DatabaseDiscoveryDataSourceRuleConfiguration dataSourceConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("name", Collections.singletonList("name"), "TEST");
+ DatabaseDiscoveryDataSourceRuleConfiguration dataSourceConfig =
+ new DatabaseDiscoveryDataSourceRuleConfiguration("name", Collections.singletonList("name"), "ha_heartbeat", "TEST");
DatabaseDiscoveryRuleConfiguration config = new DatabaseDiscoveryRuleConfiguration(
- Collections.singleton(dataSourceConfig), Collections.singletonMap("TEST", new ShardingSphereAlgorithmConfiguration("TEST", new Properties())));
+ Collections.singleton(dataSourceConfig), Collections.emptyMap(), Collections.singletonMap("TEST", new ShardingSphereAlgorithmConfiguration("TEST", new Properties())));
SchemaRuleBuilder builder = OrderedSPIRegistry.getRegisteredServices(SchemaRuleBuilder.class, Collections.singletonList(config)).get(config);
Map<String, DataSource> dataSourceMap = new HashMap<>(1, 1);
dataSourceMap.put("primaryDataSourceName", mock(DataSource.class));
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwapperTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwapperTest.java
index 64bcd5b..ff89cb4 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwapperTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwapperTest.java
@@ -73,8 +73,9 @@ public final class DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwappe
private YamlDatabaseDiscoveryRuleConfiguration createYamlHARuleConfiguration() {
DatabaseDiscoveryDataSourceRuleConfiguration ruleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("name",
- Collections.singletonList("dataSourceNames"), "discoveryTypeName");
+ Collections.singletonList("dataSourceNames"), "ha_heartbeat", "discoveryTypeName");
return swapper.swapToYamlConfiguration(
- new AlgorithmProvidedDatabaseDiscoveryRuleConfiguration(Collections.singletonList(ruleConfig), ImmutableMap.of("mgr", new MGRDatabaseDiscoveryType())));
+ new AlgorithmProvidedDatabaseDiscoveryRuleConfiguration(Collections.singletonList(ruleConfig), Collections.emptyList(),
+ ImmutableMap.of("mgr", new MGRDatabaseDiscoveryType())));
}
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/DatabaseDiscoveryRuleConfigurationYamlSwapperTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/DatabaseDiscoveryRuleConfigurationYamlSwapperTest.java
index cbd4d57..6dae120 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/DatabaseDiscoveryRuleConfigurationYamlSwapperTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/DatabaseDiscoveryRuleConfigurationYamlSwapperTest.java
@@ -48,18 +48,19 @@ public final class DatabaseDiscoveryRuleConfigurationYamlSwapperTest {
@Test
public void assertSwapToYamlWithLoadBalanceAlgorithm() {
DatabaseDiscoveryDataSourceRuleConfiguration dataSourceConfig =
- new DatabaseDiscoveryDataSourceRuleConfiguration("ds", Collections.singletonList("dataSourceName"), "discoveryTypeName");
+ new DatabaseDiscoveryDataSourceRuleConfiguration("ds", Collections.singletonList("dataSourceName"), "ha_heartbeat", "discoveryTypeName");
YamlDatabaseDiscoveryRuleConfiguration actual = getHARuleConfigurationYamlSwapper().swapToYamlConfiguration(new DatabaseDiscoveryRuleConfiguration(Collections.singleton(dataSourceConfig),
- ImmutableMap.of("mgr", new ShardingSphereAlgorithmConfiguration("MGR", new Properties()))));
+ Collections.emptyMap(), ImmutableMap.of("mgr", new ShardingSphereAlgorithmConfiguration("MGR", new Properties()))));
assertThat(actual.getDataSources().keySet(), is(Collections.singleton("ds")));
assertThat(actual.getDataSources().get("ds").getDataSourceNames(), is(Collections.singletonList("dataSourceName")));
}
@Test
public void assertSwapToYamlWithoutLoadBalanceAlgorithm() {
- DatabaseDiscoveryDataSourceRuleConfiguration dataSourceConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("ds", Collections.singletonList("dataSourceName"), "discoveryTypeName");
+ DatabaseDiscoveryDataSourceRuleConfiguration dataSourceConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("ds", Collections.singletonList("dataSourceName"),
+ "ha_heartbeat", "discoveryTypeName");
YamlDatabaseDiscoveryRuleConfiguration actual = getHARuleConfigurationYamlSwapper().swapToYamlConfiguration(
- new DatabaseDiscoveryRuleConfiguration(Collections.singleton(dataSourceConfig), Collections.emptyMap()));
+ new DatabaseDiscoveryRuleConfiguration(Collections.singleton(dataSourceConfig), Collections.emptyMap(), Collections.emptyMap()));
assertThat(actual.getDataSources().keySet(), is(Collections.singleton("ds")));
assertThat(actual.getDataSources().get("ds").getDataSourceNames(), is(Collections.singletonList("dataSourceName")));
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/converter/DatabaseDiscoveryRuleStatementConverter.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/converter/DatabaseDisco [...]
index 3bcdceb..b25ffcc 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/converter/DatabaseDiscoveryRuleStatementConverter.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/converter/DatabaseDiscoveryRuleStatementConverter.java
@@ -25,10 +25,12 @@ import org.apache.shardingsphere.dbdiscovery.distsql.parser.segment.DatabaseDisc
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
+
/**
* Database discovery rule statement converter.
*/
@@ -46,10 +48,11 @@ public final class DatabaseDiscoveryRuleStatementConverter {
Map<String, ShardingSphereAlgorithmConfiguration> discoveryTypes = new HashMap<>(ruleSegments.size(), 1);
for (DatabaseDiscoveryRuleSegment each : ruleSegments) {
String type = getDatabaseDiscoveryType(each.getName(), each.getDiscoveryTypeName());
- dataSources.add(new DatabaseDiscoveryDataSourceRuleConfiguration(each.getName(), new LinkedList<>(each.getDataSources()), type));
+ //TODO get real discoveryHeartbeatName
+ dataSources.add(new DatabaseDiscoveryDataSourceRuleConfiguration(each.getName(), new LinkedList<>(each.getDataSources()), "", type));
discoveryTypes.put(type, new ShardingSphereAlgorithmConfiguration(each.getDiscoveryTypeName(), each.getProps()));
}
- return new DatabaseDiscoveryRuleConfiguration(dataSources, discoveryTypes);
+ return new DatabaseDiscoveryRuleConfiguration(dataSources, Collections.emptyMap(), discoveryTypes);
}
private static String getDatabaseDiscoveryType(final String ruleName, final String type) {
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryRuleQueryResultSetTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryRule [...]
index 8a6644a..4e3737e 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryRuleQueryResultSetTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/DatabaseDiscoveryRuleQueryResultSetTest.java
@@ -63,10 +63,11 @@ public final class DatabaseDiscoveryRuleQueryResultSetTest {
}
private RuleConfiguration createRuleConfiguration() {
- DatabaseDiscoveryDataSourceRuleConfiguration databaseDiscoveryDataSourceRuleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("ms_group", Arrays.asList("ds_0", "ds_1"), "test");
+ DatabaseDiscoveryDataSourceRuleConfiguration databaseDiscoveryDataSourceRuleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("ms_group", Arrays.asList("ds_0", "ds_1"),
+ "ms-heartbeat", "test");
ShardingSphereAlgorithmConfiguration shardingSphereAlgorithmConfig = new ShardingSphereAlgorithmConfiguration("MGR", new Properties());
Map<String, ShardingSphereAlgorithmConfiguration> discoverTypes = new HashMap<>(1, 1);
discoverTypes.put("test", shardingSphereAlgorithmConfig);
- return new DatabaseDiscoveryRuleConfiguration(Collections.singleton(databaseDiscoveryDataSourceRuleConfig), discoverTypes);
+ return new DatabaseDiscoveryRuleConfiguration(Collections.singleton(databaseDiscoveryDataSourceRuleConfig), Collections.emptyMap(), discoverTypes);
}
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabas [...]
index 2607b62..d062d64 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryRuleStatementUpdaterTest.java
@@ -64,7 +64,7 @@ public final class AlterDatabaseDiscoveryRuleStatementUpdaterTest {
@Test(expected = RequiredRuleMissedException.class)
public void assertCheckSQLStatementWithoutToBeAlteredDatabaseDiscoveryRule() throws DistSQLException {
- updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement("TEST"), new DatabaseDiscoveryRuleConfiguration(Collections.emptyList(), Collections.emptyMap()));
+ updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement("TEST"), new DatabaseDiscoveryRuleConfiguration(Collections.emptyList(), Collections.emptyMap(), Collections.emptyMap()));
}
@Test(expected = RequiredResourceMissedException.class)
@@ -84,7 +84,7 @@ public final class AlterDatabaseDiscoveryRuleStatementUpdaterTest {
}
private DatabaseDiscoveryRuleConfiguration createCurrentRuleConfiguration() {
- DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("ha_group", Collections.emptyList(), "TEST");
- return new DatabaseDiscoveryRuleConfiguration(new LinkedList<>(Collections.singleton(dataSourceRuleConfig)), Collections.emptyMap());
+ DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("ha_group", Collections.emptyList(), "ha-heartbeat", "TEST");
+ return new DatabaseDiscoveryRuleConfiguration(new LinkedList<>(Collections.singleton(dataSourceRuleConfig)), Collections.emptyMap(), Collections.emptyMap());
}
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatab [...]
index 85d63a1..fb4cc33 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/CreateDatabaseDiscoveryRuleStatementUpdaterTest.java
@@ -58,9 +58,9 @@ public final class CreateDatabaseDiscoveryRuleStatementUpdaterTest {
@Test(expected = DuplicateRuleException.class)
public void assertCheckSQLStatementWithDuplicateRuleNames() throws DistSQLException {
- DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("pr_ds", Collections.emptyList(), "test");
+ DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("pr_ds", Collections.emptyList(), "ha-heartbeat", "test");
updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement("TEST"),
- new DatabaseDiscoveryRuleConfiguration(Collections.singleton(dataSourceRuleConfig), Collections.emptyMap()));
+ new DatabaseDiscoveryRuleConfiguration(Collections.singleton(dataSourceRuleConfig), Collections.emptyMap(), Collections.emptyMap()));
}
@Test(expected = RequiredResourceMissedException.class)
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseDiscoveryRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseD [...]
index 9370767..d237fdd 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseDiscoveryRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/DropDatabaseDiscoveryRuleStatementUpdaterTest.java
@@ -56,7 +56,7 @@ public final class DropDatabaseDiscoveryRuleStatementUpdaterTest {
@Test(expected = RequiredRuleMissedException.class)
public void assertCheckSQLStatementWithoutToBeDroppedRules() throws RuleDefinitionViolationException {
- updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(), new DatabaseDiscoveryRuleConfiguration(Collections.emptyList(), Collections.emptyMap()));
+ updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(), new DatabaseDiscoveryRuleConfiguration(Collections.emptyList(), Collections.emptyMap(), Collections.emptyMap()));
}
@Test
@@ -78,17 +78,17 @@ public final class DropDatabaseDiscoveryRuleStatementUpdaterTest {
}
private DatabaseDiscoveryRuleConfiguration createCurrentRuleConfiguration() {
- DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("ha_group", Collections.emptyList(), "pr_ds_MGR");
+ DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("ha_group", Collections.emptyList(), "ha_heartbeat", "pr_ds_MGR");
Map<String, ShardingSphereAlgorithmConfiguration> discoveryTypes = new HashMap<>(1, 1);
discoveryTypes.put("pr_ds_MGR", new ShardingSphereAlgorithmConfiguration("pr_ds_MGR", new Properties()));
- return new DatabaseDiscoveryRuleConfiguration(new LinkedList<>(Collections.singleton(dataSourceRuleConfig)), discoveryTypes);
+ return new DatabaseDiscoveryRuleConfiguration(new LinkedList<>(Collections.singleton(dataSourceRuleConfig)), Collections.emptyMap(), discoveryTypes);
}
private DatabaseDiscoveryRuleConfiguration createMultipleCurrentRuleConfigurations() {
- DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("ha_group", Collections.emptyList(), "pr_ds_MGR");
+ DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("ha_group", Collections.emptyList(), "ha_heartbeat", "pr_ds_MGR");
Map<String, ShardingSphereAlgorithmConfiguration> discoveryTypes = new HashMap<>(1, 1);
discoveryTypes.put("pr_ds_MGR", new ShardingSphereAlgorithmConfiguration("pr_ds_MGR", new Properties()));
return new DatabaseDiscoveryRuleConfiguration(new LinkedList<>(Arrays.asList(dataSourceRuleConfig,
- new DatabaseDiscoveryDataSourceRuleConfiguration("ha_group_another", Collections.emptyList(), "pr_ds_MGR"))), discoveryTypes);
+ new DatabaseDiscoveryDataSourceRuleConfiguration("ha_group_another", Collections.emptyList(), "ha_heartbeat", "pr_ds_MGR"))), Collections.emptyMap(), discoveryTypes);
}
}