This is an automated email from the ASF dual-hosted git repository.
zhaojinchao 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 b3f78f9db7e Add shardingsphere-sql-federation moudle and
SQLFederationRuleConfiguration related class (#20723)
b3f78f9db7e is described below
commit b3f78f9db7ef685e7273e42c29a98b20fdb50dd6
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Fri Sep 2 10:42:13 2022 +0800
Add shardingsphere-sql-federation moudle and SQLFederationRuleConfiguration
related class (#20723)
* Add shardingsphere-sql-federation moudle and
SQLFederationRuleConfiguration related class
* optimize checkstyle
---
.../dialect/SQLServerSchemaMetaDataLoader.java | 4 +-
.../dialect/SQLServerSchemaMetaDataLoaderTest.java | 4 +-
shardingsphere-kernel/pom.xml | 1 +
.../{ => shardingsphere-sql-federation}/pom.xml | 15 +++----
.../shardingsphere-sql-federation-api}/pom.xml | 22 ++++------
.../api/config/SQLFederationRuleConfiguration.java | 32 ++++++++++++++
.../shardingsphere-sql-federation-core}/pom.xml | 22 ++++------
.../sqlfederation/constant/SQLFederationOrder.java | 33 +++++++++++++++
.../sqlfederation/rule/SQLFederationRule.java | 41 ++++++++++++++++++
...faultSQLFederationRuleConfigurationBuilder.java | 43 +++++++++++++++++++
.../rule/builder/SQLFederationRuleBuilder.java | 49 ++++++++++++++++++++++
...er.global.DefaultGlobalRuleConfigurationBuilder | 18 ++++++++
...ere.infra.rule.builder.global.GlobalRuleBuilder | 18 ++++++++
.../pom.xml | 14 ++-----
.../pom.xml | 22 ++++------
.../pom.xml | 22 ++++------
.../common/constant/DistSQLScriptConstants.java | 16 +++----
.../queryable/ConvertYamlConfigurationHandler.java | 14 +++----
.../ConvertYamlConfigurationHandlerTest.java | 10 ++---
19 files changed, 304 insertions(+), 96 deletions(-)
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/loader/dialect/SQLServerSchemaMetaDataLoader.java
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/loader/dialect/SQLServerSchemaMetaDataLoader.java
index 272da05e9cb..38245394d3e 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/loader/dialect/SQLServerSchemaMetaDataLoader.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/loader/dialect/SQLServerSchemaMetaDataLoader.java
@@ -54,7 +54,7 @@ public final class SQLServerSchemaMetaDataLoader implements
DialectSchemaMetaDat
private static final String ORDER_BY_COLUMN_ID = " ORDER BY col.column_id";
private static final String TABLE_META_DATA_SQL =
TABLE_META_DATA_SQL_NO_ORDER + ORDER_BY_COLUMN_ID;
-
+
private static final String VIEW_META_DATA_SQL = "SELECT TABLE_NAME,
VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_CATALOG = ?";
private static final String TABLE_META_DATA_SQL_IN_TABLES =
TABLE_META_DATA_SQL_NO_ORDER + " WHERE obj.name IN (%s)" + ORDER_BY_COLUMN_ID;
@@ -77,7 +77,7 @@ public final class SQLServerSchemaMetaDataLoader implements
DialectSchemaMetaDat
}
return Collections.singletonList(new SchemaMetaData(defaultSchemaName,
tableMetaDataList, loadViewMetaData(dataSource, tables)));
}
-
+
private Collection<ViewMetaData> loadViewMetaData(final DataSource
dataSource, final Collection<String> tables) throws SQLException {
Collection<ViewMetaData> result = new LinkedList<>();
try (
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/loader/dialect/SQLServerSchemaMetaDataLoaderTest.java
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/loader/dialect/SQLServerSchemaMetaDataLoaderTest.java
index 6cb73f1bf7d..2959a21a2d9 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/loader/dialect/SQLServerSchemaMetaDataLoaderTest.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/loader/dialect/SQLServerSchemaMetaDataLoaderTest.java
@@ -72,7 +72,7 @@ public final class SQLServerSchemaMetaDataLoaderTest {
private static final String LOAD_INDEX_META_DATA = "SELECT a.name AS
INDEX_NAME, c.name AS TABLE_NAME FROM sys.indexes a"
+ " JOIN sys.objects c ON a.object_id = c.object_id WHERE
a.index_id NOT IN (0, 255) AND c.name IN ('tbl')";
-
+
private static final String LOAD_VIEW_META_DATA = "SELECT TABLE_NAME,
VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_CATALOG = ?";
@Test
@@ -144,7 +144,7 @@ public final class SQLServerSchemaMetaDataLoaderTest {
assertThat(columnsIterator.next(), is(new ColumnMetaData("id", 4,
false, true, true, true)));
assertThat(columnsIterator.next(), is(new ColumnMetaData("name", 12,
false, false, false, true)));
}
-
+
@Test
public void assertLoadViewMetaData() throws SQLException {
DataSource dataSource = mockDataSource();
diff --git a/shardingsphere-kernel/pom.xml b/shardingsphere-kernel/pom.xml
index 5a07fefc62f..adb7e919bcc 100644
--- a/shardingsphere-kernel/pom.xml
+++ b/shardingsphere-kernel/pom.xml
@@ -35,6 +35,7 @@
<module>shardingsphere-transaction</module>
<module>shardingsphere-schedule</module>
<module>shardingsphere-data-pipeline</module>
+ <module>shardingsphere-sql-federation</module>
<module>shardingsphere-sql-translator</module>
<module>shardingsphere-traffic</module>
</modules>
diff --git a/shardingsphere-kernel/pom.xml
b/shardingsphere-kernel/shardingsphere-sql-federation/pom.xml
similarity index 72%
copy from shardingsphere-kernel/pom.xml
copy to shardingsphere-kernel/shardingsphere-sql-federation/pom.xml
index 5a07fefc62f..30340779454 100644
--- a/shardingsphere-kernel/pom.xml
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/pom.xml
@@ -21,21 +21,16 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere</artifactId>
+ <artifactId>shardingsphere-kernel</artifactId>
<version>5.1.3-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-kernel</artifactId>
+ <artifactId>shardingsphere-sql-federation</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<modules>
- <module>shardingsphere-parser</module>
- <module>shardingsphere-single-table</module>
- <module>shardingsphere-authority</module>
- <module>shardingsphere-transaction</module>
- <module>shardingsphere-schedule</module>
- <module>shardingsphere-data-pipeline</module>
- <module>shardingsphere-sql-translator</module>
- <module>shardingsphere-traffic</module>
+ <module>shardingsphere-sql-federation-api</module>
+ <module>shardingsphere-sql-federation-core</module>
+ <module>shardingsphere-sql-federation-provider</module>
</modules>
</project>
diff --git a/shardingsphere-kernel/pom.xml
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-api/pom.xml
similarity index 69%
copy from shardingsphere-kernel/pom.xml
copy to
shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-api/pom.xml
index 5a07fefc62f..35c901a3b75 100644
--- a/shardingsphere-kernel/pom.xml
+++
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-api/pom.xml
@@ -21,21 +21,17 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere</artifactId>
+ <artifactId>shardingsphere-sql-federation</artifactId>
<version>5.1.3-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-kernel</artifactId>
- <packaging>pom</packaging>
+ <artifactId>shardingsphere-sql-federation-api</artifactId>
<name>${project.artifactId}</name>
- <modules>
- <module>shardingsphere-parser</module>
- <module>shardingsphere-single-table</module>
- <module>shardingsphere-authority</module>
- <module>shardingsphere-transaction</module>
- <module>shardingsphere-schedule</module>
- <module>shardingsphere-data-pipeline</module>
- <module>shardingsphere-sql-translator</module>
- <module>shardingsphere-traffic</module>
- </modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-infra-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</project>
diff --git
a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-api/src/main/java/org/apache/shardingsphere/sqlfederation/api/config/SQLFederationRuleConfiguration.java
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-api/src/main/java/org/apache/shardingsphere/sqlfederation/api/config/SQLFederationRuleConfiguration.java
new file mode 100644
index 00000000000..77f9a8ae0df
--- /dev/null
+++
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-api/src/main/java/org/apache/shardingsphere/sqlfederation/api/config/SQLFederationRuleConfiguration.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.shardingsphere.sqlfederation.api.config;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import
org.apache.shardingsphere.infra.config.rule.scope.GlobalRuleConfiguration;
+
+/**
+ * SQL federation rule configuration.
+ */
+@RequiredArgsConstructor
+@Getter
+public final class SQLFederationRuleConfiguration implements
GlobalRuleConfiguration {
+
+ private final String sqlFederationType;
+}
diff --git a/shardingsphere-kernel/pom.xml
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/pom.xml
similarity index 69%
copy from shardingsphere-kernel/pom.xml
copy to
shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/pom.xml
index 5a07fefc62f..aae7afdad57 100644
--- a/shardingsphere-kernel/pom.xml
+++
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/pom.xml
@@ -21,21 +21,17 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere</artifactId>
+ <artifactId>shardingsphere-sql-federation</artifactId>
<version>5.1.3-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-kernel</artifactId>
- <packaging>pom</packaging>
+ <artifactId>shardingsphere-sql-federation-core</artifactId>
<name>${project.artifactId}</name>
- <modules>
- <module>shardingsphere-parser</module>
- <module>shardingsphere-single-table</module>
- <module>shardingsphere-authority</module>
- <module>shardingsphere-transaction</module>
- <module>shardingsphere-schedule</module>
- <module>shardingsphere-data-pipeline</module>
- <module>shardingsphere-sql-translator</module>
- <module>shardingsphere-traffic</module>
- </modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-sql-federation-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</project>
diff --git
a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/src/main/java/org/apache/shardingsphere/sqlfederation/constant/SQLFederationOrder.java
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/src/main/java/org/apache/shardingsphere/sqlfederation/constant/SQLFederationOrder.java
new file mode 100644
index 00000000000..84e00b2dc18
--- /dev/null
+++
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/src/main/java/org/apache/shardingsphere/sqlfederation/constant/SQLFederationOrder.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.shardingsphere.sqlfederation.constant;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+/**
+ * SQL federation order.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class SQLFederationOrder {
+
+ /**
+ * SQL federation order.
+ */
+ public static final int ORDER = 1000;
+}
diff --git
a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/src/main/java/org/apache/shardingsphere/sqlfederation/rule/SQLFederationRule.java
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/src/main/java/org/apache/shardingsphere/sqlfederation/rule/SQLFederationRule.java
new file mode 100644
index 00000000000..93b8f9535e1
--- /dev/null
+++
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/src/main/java/org/apache/shardingsphere/sqlfederation/rule/SQLFederationRule.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.shardingsphere.sqlfederation.rule;
+
+import lombok.Getter;
+import org.apache.shardingsphere.infra.rule.identifier.scope.GlobalRule;
+import
org.apache.shardingsphere.sqlfederation.api.config.SQLFederationRuleConfiguration;
+
+/**
+ * SQL federation rule.
+ */
+@Getter
+public final class SQLFederationRule implements GlobalRule {
+
+ private final SQLFederationRuleConfiguration configuration;
+
+ public SQLFederationRule(final SQLFederationRuleConfiguration ruleConfig) {
+ configuration = ruleConfig;
+ // TODO lode SQLFederationExecutor by sqlFederationType
+ }
+
+ @Override
+ public String getType() {
+ return SQLFederationRule.class.getSimpleName();
+ }
+}
diff --git
a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/src/main/java/org/apache/shardingsphere/sqlfederation/rule/builder/DefaultSQLFederationRuleConfigurationBuilder.java
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/src/main/java/org/apache/shardingsphere/sqlfederation/rule/builder/DefaultSQLFederationRuleConfigurationBuilder.java
new file mode 100644
index 00000000000..37b22d5dcfa
--- /dev/null
+++
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/src/main/java/org/apache/shardingsphere/sqlfederation/rule/builder/DefaultSQLFederationRuleConfigurationBuilder.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.shardingsphere.sqlfederation.rule.builder;
+
+import
org.apache.shardingsphere.infra.rule.builder.global.DefaultGlobalRuleConfigurationBuilder;
+import
org.apache.shardingsphere.sqlfederation.api.config.SQLFederationRuleConfiguration;
+import org.apache.shardingsphere.sqlfederation.constant.SQLFederationOrder;
+
+/**
+ * Default sql federation rule configuration builder.
+ */
+public final class DefaultSQLFederationRuleConfigurationBuilder implements
DefaultGlobalRuleConfigurationBuilder<SQLFederationRuleConfiguration,
SQLFederationRuleBuilder> {
+
+ @Override
+ public SQLFederationRuleConfiguration build() {
+ return new SQLFederationRuleConfiguration("NONE");
+ }
+
+ @Override
+ public int getOrder() {
+ return SQLFederationOrder.ORDER;
+ }
+
+ @Override
+ public Class<SQLFederationRuleBuilder> getTypeClass() {
+ return SQLFederationRuleBuilder.class;
+ }
+}
diff --git
a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/src/main/java/org/apache/shardingsphere/sqlfederation/rule/builder/SQLFederationRuleBuilder.java
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/src/main/java/org/apache/shardingsphere/sqlfederation/rule/builder/SQLFederationRuleBuilder.java
new file mode 100644
index 00000000000..fd268164968
--- /dev/null
+++
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/src/main/java/org/apache/shardingsphere/sqlfederation/rule/builder/SQLFederationRuleBuilder.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.shardingsphere.sqlfederation.rule.builder;
+
+import org.apache.shardingsphere.infra.instance.InstanceContext;
+import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.rule.builder.global.GlobalRuleBuilder;
+import org.apache.shardingsphere.infra.rule.identifier.scope.GlobalRule;
+import
org.apache.shardingsphere.sqlfederation.api.config.SQLFederationRuleConfiguration;
+import org.apache.shardingsphere.sqlfederation.constant.SQLFederationOrder;
+import org.apache.shardingsphere.sqlfederation.rule.SQLFederationRule;
+
+import java.util.Map;
+
+/**
+ * SQL federation rule builder.
+ */
+public final class SQLFederationRuleBuilder implements
GlobalRuleBuilder<SQLFederationRuleConfiguration> {
+
+ @Override
+ public GlobalRule build(final SQLFederationRuleConfiguration ruleConfig,
final Map<String, ShardingSphereDatabase> databases, final InstanceContext
instanceContext) {
+ return new SQLFederationRule(ruleConfig);
+ }
+
+ @Override
+ public int getOrder() {
+ return SQLFederationOrder.ORDER;
+ }
+
+ @Override
+ public Class<SQLFederationRuleConfiguration> getTypeClass() {
+ return SQLFederationRuleConfiguration.class;
+ }
+}
diff --git
a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.global.DefaultGlobalRuleConfigurationBuilder
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.global.DefaultGlobalRuleConfigurationBuilder
new file mode 100644
index 00000000000..14b11c0eeaf
--- /dev/null
+++
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.global.DefaultGlobalRuleConfigurationBuilder
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+
+org.apache.shardingsphere.sqlfederation.rule.builder.DefaultSQLFederationRuleConfigurationBuilder
diff --git
a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.global.GlobalRuleBuilder
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.global.GlobalRuleBuilder
new file mode 100644
index 00000000000..2646f2a599e
--- /dev/null
+++
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.global.GlobalRuleBuilder
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+
+org.apache.shardingsphere.sqlfederation.rule.builder.SQLFederationRuleBuilder
diff --git a/shardingsphere-kernel/pom.xml
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-provider/pom.xml
similarity index 72%
copy from shardingsphere-kernel/pom.xml
copy to
shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-provider/pom.xml
index 5a07fefc62f..b3dc224a8f1 100644
--- a/shardingsphere-kernel/pom.xml
+++
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-provider/pom.xml
@@ -21,21 +21,15 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere</artifactId>
+ <artifactId>shardingsphere-sql-federation</artifactId>
<version>5.1.3-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-kernel</artifactId>
+ <artifactId>shardingsphere-sql-federation-provider</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<modules>
- <module>shardingsphere-parser</module>
- <module>shardingsphere-single-table</module>
- <module>shardingsphere-authority</module>
- <module>shardingsphere-transaction</module>
- <module>shardingsphere-schedule</module>
- <module>shardingsphere-data-pipeline</module>
- <module>shardingsphere-sql-translator</module>
- <module>shardingsphere-traffic</module>
+ <module>shardingsphere-sql-federation-advanced-provider</module>
+ <module>shardingsphere-sql-federation-original-provider</module>
</modules>
</project>
diff --git a/shardingsphere-kernel/pom.xml
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-provider/shardingsphere-sql-federation-advanced-provider/pom.xml
similarity index 69%
copy from shardingsphere-kernel/pom.xml
copy to
shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-provider/shardingsphere-sql-federation-advanced-provider/pom.xml
index 5a07fefc62f..951475438ef 100644
--- a/shardingsphere-kernel/pom.xml
+++
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-provider/shardingsphere-sql-federation-advanced-provider/pom.xml
@@ -21,21 +21,17 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere</artifactId>
+ <artifactId>shardingsphere-sql-federation-provider</artifactId>
<version>5.1.3-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-kernel</artifactId>
- <packaging>pom</packaging>
+ <artifactId>shardingsphere-sql-federation-advanced-provider</artifactId>
<name>${project.artifactId}</name>
- <modules>
- <module>shardingsphere-parser</module>
- <module>shardingsphere-single-table</module>
- <module>shardingsphere-authority</module>
- <module>shardingsphere-transaction</module>
- <module>shardingsphere-schedule</module>
- <module>shardingsphere-data-pipeline</module>
- <module>shardingsphere-sql-translator</module>
- <module>shardingsphere-traffic</module>
- </modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-sql-federation-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</project>
diff --git a/shardingsphere-kernel/pom.xml
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-provider/shardingsphere-sql-federation-original-provider/pom.xml
similarity index 69%
copy from shardingsphere-kernel/pom.xml
copy to
shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-provider/shardingsphere-sql-federation-original-provider/pom.xml
index 5a07fefc62f..18e2aa0f5b7 100644
--- a/shardingsphere-kernel/pom.xml
+++
b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-provider/shardingsphere-sql-federation-original-provider/pom.xml
@@ -21,21 +21,17 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere</artifactId>
+ <artifactId>shardingsphere-sql-federation-provider</artifactId>
<version>5.1.3-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-kernel</artifactId>
- <packaging>pom</packaging>
+ <artifactId>shardingsphere-sql-federation-original-provider</artifactId>
<name>${project.artifactId}</name>
- <modules>
- <module>shardingsphere-parser</module>
- <module>shardingsphere-single-table</module>
- <module>shardingsphere-authority</module>
- <module>shardingsphere-transaction</module>
- <module>shardingsphere-schedule</module>
- <module>shardingsphere-data-pipeline</module>
- <module>shardingsphere-sql-translator</module>
- <module>shardingsphere-traffic</module>
- </modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-sql-federation-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</project>
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/constant/DistSQLScriptConstants.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/constant/DistSQLScriptConstants.java
index 164936e5896..60a20e9a572 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/constant/DistSQLScriptConstants.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/constant/DistSQLScriptConstants.java
@@ -25,15 +25,15 @@ import lombok.NoArgsConstructor;
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class DistSQLScriptConstants {
-
+
public static final String RESOURCE_DB = "resource_db";
public static final String SHARDING_DB = "sharding_db";
public static final String READWRITE_SPLITTING_DB =
"readwrite_splitting_db";
-
+
public static final String DATABASE_DISCOVERY_DB = "database_discovery_db";
-
+
public static final String STANDARD = "standard";
public static final String COMPLEX = "complex";
@@ -136,15 +136,15 @@ public final class DistSQLScriptConstants {
+ "%s"
+ System.lineSeparator()
+ ")";
-
+
public static final String READWRITE_SPLITTING_TYPE = "TYPE(NAME=\"%s\")";
public static final String READWRITE_SPLITTING_TYPE_PROPERTIES =
"TYPE(NAME=\"%s\", PROPERTIES(%s))";
public static final String READ_RESOURCE = "%s";
-
+
public static final String CREATE_DB_DISCOVERY = "CREATE DB_DISCOVERY
RULE";
-
+
public static final String DB_DISCOVERY = " %s ("
+ System.lineSeparator()
+ "RESOURCES(%s),"
@@ -154,8 +154,8 @@ public final class DistSQLScriptConstants {
+ "HEARTBEAT(PROPERTIES(%s))"
+ System.lineSeparator()
+ ")";
-
+
public static final String DB_DISCOVERY_TYPE = "TYPE(NAME=\'%s\',
PROPERTIES(%s))";
-
+
public static final String DB_DISCOVERY_PROPERTY = "\'%s\'=\'%s\'";
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java
index 66938ab49b4..5ca9d78e3a2 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java
@@ -125,7 +125,7 @@ public final class ConvertYamlConfigurationHandler extends
QueryableRALBackendHa
appendResources(yamlConfig.getDataSources(), result);
appendReadWriteSplittingRules(yamlConfig.getRules(), result);
}
-
+
private void addDatabaseDiscoveryDistSQL(final
YamlProxyDatabaseConfiguration yamlConfig, final StringBuilder result) {
appendDatabase(yamlConfig.getDatabaseName(), result);
appendResources(yamlConfig.getDataSources(), result);
@@ -396,13 +396,13 @@ public final class ConvertYamlConfigurationHandler
extends QueryableRALBackendHa
}
return result.toString();
}
-
+
private void appendDatabaseDiscoveryRules(final
Collection<YamlRuleConfiguration> ruleConfigs, final StringBuilder result) {
if (ruleConfigs.isEmpty()) {
return;
}
result.append(DistSQLScriptConstants.CREATE_DB_DISCOVERY);
- for (YamlRuleConfiguration ruleConfig: ruleConfigs) {
+ for (YamlRuleConfiguration ruleConfig : ruleConfigs) {
Iterator<Entry<String,
YamlDatabaseDiscoveryDataSourceRuleConfiguration>> dataSourcesIter =
((YamlDatabaseDiscoveryRuleConfiguration)
ruleConfig).getDataSources().entrySet().iterator();
while (dataSourcesIter.hasNext()) {
Entry<String,
YamlDatabaseDiscoveryDataSourceRuleConfiguration> entry =
dataSourcesIter.next();
@@ -418,7 +418,7 @@ public final class ConvertYamlConfigurationHandler extends
QueryableRALBackendHa
result.append(DistSQLScriptConstants.SEMI).append(System.lineSeparator());
}
}
-
+
private String getDatabaseDiscoveryResources(final Collection<String>
databaseDiscoveryNames) {
StringBuilder result = new StringBuilder();
Iterator<String> iterator = databaseDiscoveryNames.iterator();
@@ -431,7 +431,7 @@ public final class ConvertYamlConfigurationHandler extends
QueryableRALBackendHa
}
return result.toString();
}
-
+
private String getDatabaseDiscoveryHeartbeat(final String
discoveryHeartbeatName, final YamlRuleConfiguration ruleConfig) {
StringBuilder result = new StringBuilder();
Iterator<Entry<String, YamlDatabaseDiscoveryHeartBeatConfiguration>>
discoveryHeartbeatsIter =
@@ -444,7 +444,7 @@ public final class ConvertYamlConfigurationHandler extends
QueryableRALBackendHa
}
return result.toString();
}
-
+
private String getDatabaseDiscoveryType(final String discoveryTypeName,
final YamlRuleConfiguration ruleConfig) {
StringBuilder result = new StringBuilder();
StringBuilder properties = new StringBuilder();
@@ -460,7 +460,7 @@ public final class ConvertYamlConfigurationHandler extends
QueryableRALBackendHa
}
return result.toString();
}
-
+
private void getDatabaseDiscoveryProperties(final Properties
heartbeatProperties, final StringBuilder result) {
Iterator<Entry<Object, Object>> iterator =
heartbeatProperties.entrySet().iterator();
while (iterator.hasNext()) {
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandlerTest.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandlerTest.java
index bb0074b81fe..50b111cc673 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandlerTest.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandlerTest.java
@@ -51,7 +51,7 @@ public final class ConvertYamlConfigurationHandlerTest
extends ProxyContextResto
private final String shardingFilePath =
"/conf/convert/config-sharding.yaml";
private final String readWriteSplittingFilePath =
"/conf/convert/config-readwrite-splitting.yaml";
-
+
private final String databaseDiscoveryFilePath =
"/conf/convert/config-database-discovery.yaml";
private final String resourceExpectedFilePath =
"/expected/convert-add-resource.yaml";
@@ -59,7 +59,7 @@ public final class ConvertYamlConfigurationHandlerTest
extends ProxyContextResto
private final String shardingExpectedFilePath =
"/expected/convert-create-sharding.yaml";
private final String readWriteSplittingExpectedFilePath =
"/expected/convert-readwrite-splitting.yaml";
-
+
private final String databaseDiscoveryExpectedFilePath =
"/expected/convert-database-discovery.yaml";
private final String resource = "resource";
@@ -67,7 +67,7 @@ public final class ConvertYamlConfigurationHandlerTest
extends ProxyContextResto
private final String sharding = "sharding";
private final String readWriteSplitting = "readWriteSplitting";
-
+
private final String databaseDiscovery = "databaseDiscovery";
private final Map<String, String> featureMap = new HashMap<>(4, 1);
@@ -100,12 +100,12 @@ public final class ConvertYamlConfigurationHandlerTest
extends ProxyContextResto
public void assertExecuteWithReadWriteSplitting() throws SQLException {
assertExecute(readWriteSplitting, readWriteSplittingExpectedFilePath);
}
-
+
@Test
public void assertExecuteWithDatabaseDiscovery() throws SQLException {
assertExecute(databaseDiscovery, databaseDiscoveryExpectedFilePath);
}
-
+
public void assertExecute(final String type, final String
expectedFilePath) throws SQLException {
ConvertYamlConfigurationHandler handler = new
ConvertYamlConfigurationHandler();
handler.init(new
ConvertYamlConfigurationStatement(Objects.requireNonNull(ConvertYamlConfigurationHandlerTest.class.getResource(featureMap.get(type))).getPath()),