You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2022/09/08 04:56:00 UTC
[shardingsphere] branch master updated: Move get SQLFederationExecutor login to SQLFederationRule (#20865)
This is an automated email from the ASF dual-hosted git repository.
panjuan 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 aa892f1afa0 Move get SQLFederationExecutor login to SQLFederationRule (#20865)
aa892f1afa0 is described below
commit aa892f1afa0062c14e2b98d1320f5a1a016783dd
Author: Zhengqiang Duan <du...@apache.org>
AuthorDate: Thu Sep 8 12:55:50 2022 +0800
Move get SQLFederationExecutor login to SQLFederationRule (#20865)
---
.../shardingsphere-proxy/yaml-config/props.cn.md | 2 +-
.../shardingsphere-proxy/yaml-config/props.en.md | 2 +-
.../rule/builder/global/GlobalRuleBuilder.java | 4 +++-
.../rule/builder/global/GlobalRulesBuilder.java | 8 ++++---
.../builder/fixture/FixtureGlobalRuleBuilder.java | 4 +++-
.../builder/global/GlobalRulesBuilderTest.java | 7 ++++--
.../driver/executor/DriverExecutor.java | 5 ++--
.../statement/ShardingSpherePreparedStatement.java | 4 ++--
.../core/statement/ShardingSphereStatement.java | 4 ++--
.../jdbc/adapter/PreparedStatementAdapterTest.java | 5 ++++
.../driver/jdbc/adapter/StatementAdapterTest.java | 5 ++++
.../UnsupportedOperationPreparedStatementTest.java | 5 ++++
.../UnsupportedOperationStatementTest.java | 4 ++++
.../rule/builder/AuthorityRuleBuilder.java | 4 +++-
.../parser/rule/builder/SQLParserRuleBuilder.java | 4 +++-
.../api/config/SQLFederationRuleConfiguration.java | 10 +++++---
.../factory/SQLFederationExecutorFactory.java | 22 ------------------
.../sqlfederation/spi/SQLFederationExecutor.java | 2 +-
...text.java => SQLFederationExecutorContext.java} | 4 ++--
.../table/CommonTableScanExecutorContext.java | 4 ++--
.../sqlfederation/rule/SQLFederationRule.java | 27 ++++++++++++++++++++--
.../rule/builder/SQLFederationRuleBuilder.java | 6 ++++-
.../advanced/AdvancedFederationExecutor.java | 6 ++---
.../table/TranslatableTableScanExecutor.java | 4 ++--
.../original/OriginalFederationExecutor.java | 15 ++++++------
.../table/FilterableTableScanExecutor.java | 4 ++--
.../rule/builder/SQLTranslatorRuleBuilder.java | 4 +++-
.../traffic/rule/builder/TrafficRuleBuilder.java | 4 +++-
.../rule/builder/TransactionRuleBuilder.java | 4 +++-
.../mode/manager/ContextManager.java | 7 +++---
.../mode/metadata/MetaDataContextsFactory.java | 2 +-
.../jdbc/JDBCDatabaseCommunicationEngine.java | 9 ++++----
.../handler/distsql/rul/sql/PreviewHandler.java | 11 +++++----
.../jdbc/JDBCDatabaseCommunicationEngineTest.java | 19 ++++++++-------
.../frontend/mysql/MySQLFrontendEngineTest.java | 2 +-
.../MySQLAuthenticationHandlerTest.java | 4 ++--
.../OpenGaussAuthenticationEngineTest.java | 2 +-
.../OpenGaussAuthenticationHandlerTest.java | 2 +-
.../PostgreSQLAuthenticationEngineTest.java | 2 +-
.../PostgreSQLAuthenticationHandlerTest.java | 2 +-
.../PipelineDataSourceCreatorFactoryTest.java | 3 +--
.../sqlbuilder/PipelineSQLBuilderFactoryTest.java | 3 +--
.../position/PositionInitializerFactoryTest.java | 3 +--
43 files changed, 153 insertions(+), 101 deletions(-)
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/yaml-config/props.cn.md b/docs/document/content/user-manual/shardingsphere-proxy/yaml-config/props.cn.md
index fe3154af73b..331d8364963 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/yaml-config/props.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/yaml-config/props.cn.md
@@ -25,7 +25,7 @@ Apache ShardingSphere 提供属性配置的方式配置系统级配置。本节
| proxy-frontend-executor-size (?) | int | Proxy 前端 Netty 线程池线程数量,默认值 0 代表使用 Netty 默认值。 | 0 | 否 |
| proxy-backend-executor-suitable (?) | String | 可选选项:OLAP、OLTP。OLTP 选项可能会减少向客户端写入数据包的时间开销,但如果客户端连接数超过 `proxy-frontend-executor-size`,尤其是执行慢 SQL 时,它可能会增加 SQL 执行的延迟甚至阻塞其他客户端的连接。 | OLAP | 是 |
| proxy-frontend-max-connections (?) | int | 允许连接 Proxy 的最大客户端数量,默认值 0 代表不限制。 | 0 | 是 |
-| sql-federation-type (?) | String | 联邦查询执行器类型,包括:NONE,ORIGINAL,ADVANCED。 | NONE | 是 |
+| sql-federation-type (?) | String | 联邦查询执行器类型,包括:NONE,ORIGINAL,ADVANCED。 | NONE | 否 |
| proxy-mysql-default-version (?) | String | Proxy 通过配置文件指定 MySQL 的版本号,默认版本:5.7.22。 | 5.7.22 | 否 |
| proxy-default-port (?) | String | Proxy 通过配置文件指定默认端口。 | 3307 | 否 |
| proxy-netty-backlog (?) | int | Proxy 通过配置文件指定默认netty back_log参数。 | 1024 | 否 |
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/yaml-config/props.en.md b/docs/document/content/user-manual/shardingsphere-proxy/yaml-config/props.en.md
index 2287f979d92..1915d432e63 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/yaml-config/props.en.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/yaml-config/props.en.md
@@ -25,7 +25,7 @@ Apache ShardingSphere can configure system-level configuration through property
| proxy-frontend-executor-size (?) | int | The number of threads in the Netty thread pool of front-end Proxy. | 0 | False |
| proxy-backend-executor-suitable (?) | String | Options: OLAP and OLTP. The OLTP option may reduce the time overhead when writing packets to the client,but if the number of client connections exceeds `proxy-frontend-executor-size`,especially with slow SQL, it can cause a longer delay to SQL execution and even block connections to other clients. | OLAP | True |
| proxy-frontend-max-connections (?) | int | The maximum number of clients that can be connected to Proxy. The default value of 0 indicates that there's no limit. | 0 | True |
-| sql-federation-type (?) | String | SQL federation executor type, including: NONE, ORIGINAL, ADVANCED. | NONE | True |
+| sql-federation-type (?) | String | SQL federation executor type, including: NONE, ORIGINAL, ADVANCED. | NONE | False |
| proxy-mysql-default-version (?) | String | Proxy specifies the MySQL version through configuration files, and the default verison is 5.7.22. | 5.7.22 | False |
| proxy-default-port (?) | String | Proxy specifies the default window through configuration files. | 3307 | False |
| proxy-netty-backlog (?) | int | Proxy specifies the default netty back_log parameter through configuration files. | 1024 | False |
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/global/GlobalRuleBuilder.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/global/GlobalRuleBuilder.java
index 9a43caf4e72..475eaff103e 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/global/GlobalRuleBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/global/GlobalRuleBuilder.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.infra.rule.builder.global;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -40,7 +41,8 @@ public interface GlobalRuleBuilder<T extends RuleConfiguration> extends RuleBuil
* @param ruleConfig rule configuration
* @param databases databases
* @param instanceContext instance context
+ * @param props props
* @return global rule
*/
- GlobalRule build(T ruleConfig, Map<String, ShardingSphereDatabase> databases, InstanceContext instanceContext);
+ GlobalRule build(T ruleConfig, Map<String, ShardingSphereDatabase> databases, InstanceContext instanceContext, ConfigurationProperties props);
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/global/GlobalRulesBuilder.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/global/GlobalRulesBuilder.java
index 9bf912428c9..09f1d996e1a 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/global/GlobalRulesBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/global/GlobalRulesBuilder.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.infra.rule.builder.global;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -43,14 +44,15 @@ public final class GlobalRulesBuilder {
* @param globalRuleConfigs global rule configurations
* @param databases databases
* @param instanceContext instance context
+ * @param props props
* @return built rules
*/
@SuppressWarnings({"unchecked", "rawtypes"})
- public static Collection<ShardingSphereRule> buildRules(final Collection<RuleConfiguration> globalRuleConfigs,
- final Map<String, ShardingSphereDatabase> databases, final InstanceContext instanceContext) {
+ public static Collection<ShardingSphereRule> buildRules(final Collection<RuleConfiguration> globalRuleConfigs, final Map<String, ShardingSphereDatabase> databases,
+ final InstanceContext instanceContext, final ConfigurationProperties props) {
Collection<ShardingSphereRule> result = new LinkedList<>();
for (Entry<RuleConfiguration, GlobalRuleBuilder> entry : getRuleBuilderMap(globalRuleConfigs).entrySet()) {
- result.add(entry.getValue().build(entry.getKey(), databases, instanceContext));
+ result.add(entry.getValue().build(entry.getKey(), databases, instanceContext, props));
}
return result;
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/builder/fixture/FixtureGlobalRuleBuilder.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/builder/fixture/FixtureGlobalRuleBuilder.java
index 552252b8508..888cc9f458d 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/builder/fixture/FixtureGlobalRuleBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/builder/fixture/FixtureGlobalRuleBuilder.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.infra.rule.builder.fixture;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.builder.global.GlobalRuleBuilder;
@@ -26,7 +27,8 @@ import java.util.Map;
public final class FixtureGlobalRuleBuilder implements GlobalRuleBuilder<FixtureGlobalRuleConfiguration> {
@Override
- public FixtureGlobalRule build(final FixtureGlobalRuleConfiguration ruleConfig, final Map<String, ShardingSphereDatabase> databases, final InstanceContext instanceContext) {
+ public FixtureGlobalRule build(final FixtureGlobalRuleConfiguration ruleConfig, final Map<String, ShardingSphereDatabase> databases, final InstanceContext instanceContext,
+ final ConfigurationProperties props) {
return new FixtureGlobalRule();
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/builder/global/GlobalRulesBuilderTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/builder/global/GlobalRulesBuilderTest.java
index 0283ba64c30..a9660d855ea 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/builder/global/GlobalRulesBuilderTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/builder/global/GlobalRulesBuilderTest.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.infra.rule.builder.global;
import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.schedule.ScheduleContext;
import org.apache.shardingsphere.infra.util.eventbus.EventBusContext;
@@ -49,14 +50,16 @@ public final class GlobalRulesBuilderTest {
@Test
public void assertBuildRules() {
Collection<ShardingSphereRule> shardingSphereRules = GlobalRulesBuilder
- .buildRules(Collections.singletonList(new FixtureGlobalRuleConfiguration()), Collections.singletonMap("logic_db", buildShardingSphereDatabase()), buildInstanceContext());
+ .buildRules(Collections.singletonList(new FixtureGlobalRuleConfiguration()), Collections.singletonMap("logic_db", buildShardingSphereDatabase()), buildInstanceContext(),
+ mock(ConfigurationProperties.class));
assertThat(shardingSphereRules.size(), is(1));
}
@Test
public void assertBuildRulesClassType() {
Collection<ShardingSphereRule> shardingSphereRules = GlobalRulesBuilder
- .buildRules(Collections.singletonList(new FixtureGlobalRuleConfiguration()), Collections.singletonMap("logic_db", buildShardingSphereDatabase()), buildInstanceContext());
+ .buildRules(Collections.singletonList(new FixtureGlobalRuleConfiguration()), Collections.singletonMap("logic_db", buildShardingSphereDatabase()), buildInstanceContext(),
+ mock(ConfigurationProperties.class));
assertTrue(shardingSphereRules.toArray()[0] instanceof FixtureGlobalRule);
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/DriverExecutor.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/DriverExecutor.java
index f97e0a7bf9f..a0266395368 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/DriverExecutor.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/DriverExecutor.java
@@ -26,7 +26,7 @@ import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.J
import org.apache.shardingsphere.infra.executor.sql.execute.engine.raw.RawExecutor;
import org.apache.shardingsphere.infra.util.eventbus.EventBusContext;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.sqlfederation.factory.SQLFederationExecutorFactory;
+import org.apache.shardingsphere.sqlfederation.rule.SQLFederationRule;
import org.apache.shardingsphere.sqlfederation.spi.SQLFederationExecutor;
import org.apache.shardingsphere.traffic.executor.TrafficExecutor;
@@ -55,7 +55,8 @@ public final class DriverExecutor implements AutoCloseable {
rawExecutor = new RawExecutor(executorEngine, connection.isHoldTransaction(), metaDataContexts.getMetaData().getProps(), eventBusContext);
DatabaseType databaseType = metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType();
String schemaName = DatabaseTypeEngine.getDefaultSchemaName(databaseType, connection.getDatabaseName());
- federationExecutor = SQLFederationExecutorFactory.newInstance(connection.getDatabaseName(), schemaName, metaDataContexts.getMetaData(), jdbcExecutor, eventBusContext);
+ SQLFederationRule sqlFederationRule = metaDataContexts.getMetaData().getGlobalRuleMetaData().getSingleRule(SQLFederationRule.class);
+ federationExecutor = sqlFederationRule.getSQLFederationExecutor(connection.getDatabaseName(), schemaName, metaDataContexts.getMetaData(), jdbcExecutor, eventBusContext);
trafficExecutor = new TrafficExecutor();
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
index 862af818e04..b3dd3d0a4e3 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
@@ -83,7 +83,7 @@ import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dal.DALStatement;
-import org.apache.shardingsphere.sqlfederation.spi.SQLFederationContext;
+import org.apache.shardingsphere.sqlfederation.spi.SQLFederationExecutorContext;
import org.apache.shardingsphere.traffic.engine.TrafficEngine;
import org.apache.shardingsphere.traffic.exception.EmptyTrafficExecutionUnitException;
import org.apache.shardingsphere.traffic.rule.TrafficRule;
@@ -302,7 +302,7 @@ public final class ShardingSpherePreparedStatement extends AbstractPreparedState
PreparedStatementExecuteQueryCallback callback = new PreparedStatementExecuteQueryCallback(
metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType(), sqlStatement, SQLExecutorExceptionHandler.isExceptionThrown(),
eventBusContext);
- SQLFederationContext context = new SQLFederationContext(false, queryContext, metaDataContexts.getMetaData().getDatabases());
+ SQLFederationExecutorContext context = new SQLFederationExecutorContext(false, queryContext, metaDataContexts.getMetaData().getDatabases());
return executor.getFederationExecutor().executeQuery(createDriverExecutionPrepareEngine(), callback, context);
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
index aac95c6f669..c1592d7bb57 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
@@ -77,7 +77,7 @@ import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dal.DALStatement;
-import org.apache.shardingsphere.sqlfederation.spi.SQLFederationContext;
+import org.apache.shardingsphere.sqlfederation.spi.SQLFederationExecutorContext;
import org.apache.shardingsphere.traffic.engine.TrafficEngine;
import org.apache.shardingsphere.traffic.exception.EmptyTrafficExecutionUnitException;
import org.apache.shardingsphere.traffic.rule.TrafficRule;
@@ -222,7 +222,7 @@ public final class ShardingSphereStatement extends AbstractStatementAdapter {
private ResultSet executeFederationQuery(final QueryContext queryContext) throws SQLException {
StatementExecuteQueryCallback callback = new StatementExecuteQueryCallback(metaDataContexts.getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType(),
queryContext.getSqlStatementContext().getSqlStatement(), SQLExecutorExceptionHandler.isExceptionThrown(), eventBusContext);
- SQLFederationContext context = new SQLFederationContext(false, queryContext, metaDataContexts.getMetaData().getDatabases());
+ SQLFederationExecutorContext context = new SQLFederationExecutorContext(false, queryContext, metaDataContexts.getMetaData().getDatabases());
return executor.getFederationExecutor().executeQuery(createDriverExecutionPrepareEngine(), callback, context);
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/PreparedStatementAdapterTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/PreparedStatementAdapterTest.java
index 2d521edeb54..b914a0a589c 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/PreparedStatementAdapterTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/PreparedStatementAdapterTest.java
@@ -24,6 +24,8 @@ import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
import org.apache.shardingsphere.parser.rule.builder.DefaultSQLParserRuleConfigurationBuilder;
+import org.apache.shardingsphere.sqlfederation.rule.SQLFederationRule;
+import org.apache.shardingsphere.sqlfederation.rule.builder.DefaultSQLFederationRuleConfigurationBuilder;
import org.apache.shardingsphere.traffic.rule.TrafficRule;
import org.apache.shardingsphere.traffic.rule.builder.DefaultTrafficRuleConfigurationBuilder;
import org.junit.Before;
@@ -60,6 +62,8 @@ public final class PreparedStatementAdapterTest {
private final TrafficRule trafficRule = new TrafficRule(new DefaultTrafficRuleConfigurationBuilder().build());
+ private final SQLFederationRule sqlFederationRule = new SQLFederationRule(new DefaultSQLFederationRuleConfigurationBuilder().build());
+
@Before
public void setUp() throws SQLException {
ShardingSphereConnection connection = mock(ShardingSphereConnection.class, RETURNS_DEEP_STUBS);
@@ -70,6 +74,7 @@ public final class PreparedStatementAdapterTest {
when(connection.getContextManager().getMetaDataContexts().getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType()).thenReturn(new MySQLDatabaseType());
when(connection.getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getSingleRule(SQLParserRule.class)).thenReturn(sqlParserRule);
when(connection.getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getSingleRule(TrafficRule.class)).thenReturn(trafficRule);
+ when(connection.getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getSingleRule(SQLFederationRule.class)).thenReturn(sqlFederationRule);
shardingSpherePreparedStatement = new ShardingSpherePreparedStatement(connection, "SELECT 1");
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/StatementAdapterTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/StatementAdapterTest.java
index b560a34593e..214617813f1 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/StatementAdapterTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/StatementAdapterTest.java
@@ -24,6 +24,8 @@ import org.apache.shardingsphere.infra.database.DefaultDatabase;
import org.apache.shardingsphere.infra.executor.sql.context.ExecutionContext;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.rule.identifier.type.DataNodeContainedRule;
+import org.apache.shardingsphere.sqlfederation.rule.SQLFederationRule;
+import org.apache.shardingsphere.sqlfederation.rule.builder.DefaultSQLFederationRuleConfigurationBuilder;
import org.apache.shardingsphere.traffic.rule.TrafficRule;
import org.apache.shardingsphere.traffic.rule.builder.DefaultTrafficRuleConfigurationBuilder;
import org.junit.Test;
@@ -227,6 +229,7 @@ public final class StatementAdapterTest {
when(connection.getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(globalRuleMetaData);
when(connection.getDatabaseName()).thenReturn("db");
when(globalRuleMetaData.getSingleRule(TrafficRule.class)).thenReturn(new TrafficRule(new DefaultTrafficRuleConfigurationBuilder().build()));
+ when(globalRuleMetaData.getSingleRule(SQLFederationRule.class)).thenReturn(new SQLFederationRule(new DefaultSQLFederationRuleConfigurationBuilder().build()));
ShardingSphereStatement result = new ShardingSphereStatement(connection);
result.getRoutedStatements().addAll(Arrays.asList(statements));
return result;
@@ -239,10 +242,12 @@ public final class StatementAdapterTest {
when(connection.getContextManager()
.getMetaDataContexts().getMetaData().getDatabase(DefaultDatabase.LOGIC_NAME).getRuleMetaData().getRules()).thenReturn(Collections.singletonList(rule));
TrafficRule trafficRule = new TrafficRule(new DefaultTrafficRuleConfigurationBuilder().build());
+ SQLFederationRule sqlFederationRule = new SQLFederationRule(new DefaultSQLFederationRuleConfigurationBuilder().build());
ShardingSphereRuleMetaData globalRuleMetaData = mock(ShardingSphereRuleMetaData.class);
when(connection.getDatabaseName()).thenReturn("db");
when(connection.getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(globalRuleMetaData);
when(globalRuleMetaData.getSingleRule(TrafficRule.class)).thenReturn(trafficRule);
+ when(globalRuleMetaData.getSingleRule(SQLFederationRule.class)).thenReturn(sqlFederationRule);
ShardingSphereStatement result = new ShardingSphereStatement(connection);
result.getRoutedStatements().addAll(Arrays.asList(statements));
ExecutionContext executionContext = mock(ExecutionContext.class, RETURNS_DEEP_STUBS);
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationPreparedStatementTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationPreparedStatementTest.java
index 1509338c077..217149af14a 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationPreparedStatementTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationPreparedStatementTest.java
@@ -24,6 +24,8 @@ import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
import org.apache.shardingsphere.parser.rule.builder.DefaultSQLParserRuleConfigurationBuilder;
+import org.apache.shardingsphere.sqlfederation.rule.SQLFederationRule;
+import org.apache.shardingsphere.sqlfederation.rule.builder.DefaultSQLFederationRuleConfigurationBuilder;
import org.apache.shardingsphere.traffic.rule.TrafficRule;
import org.apache.shardingsphere.traffic.rule.builder.DefaultTrafficRuleConfigurationBuilder;
import org.junit.Before;
@@ -46,6 +48,8 @@ public final class UnsupportedOperationPreparedStatementTest {
private final TrafficRule trafficRule = new TrafficRule(new DefaultTrafficRuleConfigurationBuilder().build());
+ private final SQLFederationRule sqlFederationRule = new SQLFederationRule(new DefaultSQLFederationRuleConfigurationBuilder().build());
+
@Before
public void setUp() throws SQLException {
ShardingSphereConnection connection = mock(ShardingSphereConnection.class, RETURNS_DEEP_STUBS);
@@ -55,6 +59,7 @@ public final class UnsupportedOperationPreparedStatementTest {
when(connection.getContextManager().getMetaDataContexts().getMetaData().getDatabase(connection.getDatabaseName()).getResource().getDatabaseType()).thenReturn(new MySQLDatabaseType());
when(globalRuleMetaData.getSingleRule(SQLParserRule.class)).thenReturn(sqlParserRule);
when(globalRuleMetaData.getSingleRule(TrafficRule.class)).thenReturn(trafficRule);
+ when(globalRuleMetaData.getSingleRule(SQLFederationRule.class)).thenReturn(sqlFederationRule);
shardingSpherePreparedStatement = new ShardingSpherePreparedStatement(connection, "SELECT 1");
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationStatementTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationStatementTest.java
index eba32edf4b4..61e4c620a4a 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationStatementTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationStatementTest.java
@@ -20,6 +20,8 @@ package org.apache.shardingsphere.driver.jdbc.unsupported;
import org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
import org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.sqlfederation.rule.SQLFederationRule;
+import org.apache.shardingsphere.sqlfederation.rule.builder.DefaultSQLFederationRuleConfigurationBuilder;
import org.apache.shardingsphere.traffic.rule.TrafficRule;
import org.apache.shardingsphere.traffic.rule.builder.DefaultTrafficRuleConfigurationBuilder;
import org.junit.Before;
@@ -41,9 +43,11 @@ public final class UnsupportedOperationStatementTest {
ShardingSphereConnection connection = mock(ShardingSphereConnection.class, RETURNS_DEEP_STUBS);
ShardingSphereRuleMetaData globalRuleMetaData = mock(ShardingSphereRuleMetaData.class);
TrafficRule trafficRule = new TrafficRule(new DefaultTrafficRuleConfigurationBuilder().build());
+ SQLFederationRule sqlFederationRule = new SQLFederationRule(new DefaultSQLFederationRuleConfigurationBuilder().build());
when(connection.getDatabaseName()).thenReturn("db");
when(connection.getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(globalRuleMetaData);
when(globalRuleMetaData.getSingleRule(TrafficRule.class)).thenReturn(trafficRule);
+ when(globalRuleMetaData.getSingleRule(SQLFederationRule.class)).thenReturn(sqlFederationRule);
shardingSphereStatement = new ShardingSphereStatement(connection);
}
diff --git a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/rule/builder/AuthorityRuleBuilder.java b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/rule/builder/AuthorityRuleBuilder.java
index 629622599e8..646776ef885 100644
--- a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/rule/builder/AuthorityRuleBuilder.java
+++ b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/rule/builder/AuthorityRuleBuilder.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.authority.rule.builder;
import org.apache.shardingsphere.authority.config.AuthorityRuleConfiguration;
import org.apache.shardingsphere.authority.constant.AuthorityOrder;
import org.apache.shardingsphere.authority.rule.AuthorityRule;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.builder.global.GlobalRuleBuilder;
@@ -32,7 +33,8 @@ import java.util.Map;
public final class AuthorityRuleBuilder implements GlobalRuleBuilder<AuthorityRuleConfiguration> {
@Override
- public AuthorityRule build(final AuthorityRuleConfiguration ruleConfig, final Map<String, ShardingSphereDatabase> databases, final InstanceContext instanceContext) {
+ public AuthorityRule build(final AuthorityRuleConfiguration ruleConfig, final Map<String, ShardingSphereDatabase> databases, final InstanceContext instanceContext,
+ final ConfigurationProperties props) {
return new AuthorityRule(ruleConfig, databases);
}
diff --git a/shardingsphere-kernel/shardingsphere-parser/shardingsphere-parser-core/src/main/java/org/apache/shardingsphere/parser/rule/builder/SQLParserRuleBuilder.java b/shardingsphere-kernel/shardingsphere-parser/shardingsphere-parser-core/src/main/java/org/apache/shardingsphere/parser/rule/builder/SQLParserRuleBuilder.java
index 429376a6130..d86b40f5de3 100644
--- a/shardingsphere-kernel/shardingsphere-parser/shardingsphere-parser-core/src/main/java/org/apache/shardingsphere/parser/rule/builder/SQLParserRuleBuilder.java
+++ b/shardingsphere-kernel/shardingsphere-parser/shardingsphere-parser-core/src/main/java/org/apache/shardingsphere/parser/rule/builder/SQLParserRuleBuilder.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.parser.rule.builder;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.builder.global.GlobalRuleBuilder;
@@ -32,7 +33,8 @@ import java.util.Map;
public final class SQLParserRuleBuilder implements GlobalRuleBuilder<SQLParserRuleConfiguration> {
@Override
- public SQLParserRule build(final SQLParserRuleConfiguration ruleConfig, final Map<String, ShardingSphereDatabase> databases, final InstanceContext instanceContext) {
+ public SQLParserRule build(final SQLParserRuleConfiguration ruleConfig, final Map<String, ShardingSphereDatabase> databases, final InstanceContext instanceContext,
+ final ConfigurationProperties props) {
return new SQLParserRule(ruleConfig);
}
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
index 77f9a8ae0df..c4e3eeab45f 100644
--- 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
@@ -18,15 +18,19 @@
package org.apache.shardingsphere.sqlfederation.api.config;
import lombok.Getter;
-import lombok.RequiredArgsConstructor;
+import lombok.Setter;
import org.apache.shardingsphere.infra.config.rule.scope.GlobalRuleConfiguration;
/**
* SQL federation rule configuration.
*/
-@RequiredArgsConstructor
@Getter
+@Setter
public final class SQLFederationRuleConfiguration implements GlobalRuleConfiguration {
- private final String sqlFederationType;
+ private String sqlFederationType;
+
+ public SQLFederationRuleConfiguration(final String sqlFederationType) {
+ this.sqlFederationType = sqlFederationType;
+ }
}
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-api/src/main/java/org/apache/shardingsphere/sqlfederation/factory/SQLFederationExecutorFactory.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-api/src/main/java/org/apache/shardingsphere/sqlfederation/factory/SQLFederationExecutorFactory.java
index 49de10dac90..b377f398157 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-api/src/main/java/org/apache/shardingsphere/sqlfederation/factory/SQLFederationExecutorFactory.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-api/src/main/java/org/apache/shardingsphere/sqlfederation/factory/SQLFederationExecutorFactory.java
@@ -19,10 +19,6 @@ package org.apache.shardingsphere.sqlfederation.factory;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutor;
-import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.infra.util.eventbus.EventBusContext;
import org.apache.shardingsphere.infra.util.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.util.spi.type.required.RequiredSPIRegistry;
import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPIRegistry;
@@ -47,22 +43,4 @@ public final class SQLFederationExecutorFactory {
public static SQLFederationExecutor getInstance(final String type) {
return TypedSPIRegistry.findRegisteredService(SQLFederationExecutor.class, type).orElse(RequiredSPIRegistry.getRegisteredService(SQLFederationExecutor.class));
}
-
- /**
- * Create new instance of federation executor factory.
- *
- * @param databaseName database name
- * @param schemaName schema name
- * @param metaData ShardingSphere meta data
- * @param jdbcExecutor jdbc executor
- * @param eventBusContext event bus context
- * @return created instance
- */
- public static SQLFederationExecutor newInstance(final String databaseName, final String schemaName, final ShardingSphereMetaData metaData, final JDBCExecutor jdbcExecutor,
- final EventBusContext eventBusContext) {
- String sqlFederationType = metaData.getProps().getValue(ConfigurationPropertyKey.SQL_FEDERATION_TYPE);
- SQLFederationExecutor result = getInstance(sqlFederationType);
- result.init(databaseName, schemaName, metaData, jdbcExecutor, eventBusContext);
- return result;
- }
}
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-api/src/main/java/org/apache/shardingsphere/sqlfederation/spi/SQLFederationExecutor.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-api/src/main/java/org/apache/shardingsphere/sqlfederation/spi/SQLFederationExecutor.java
index 9bef5eb5389..58e0f6c6e9c 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-api/src/main/java/org/apache/shardingsphere/sqlfederation/spi/SQLFederationExecutor.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-api/src/main/java/org/apache/shardingsphere/sqlfederation/spi/SQLFederationExecutor.java
@@ -57,7 +57,7 @@ public interface SQLFederationExecutor extends TypedSPI, RequiredSPI, AutoClosea
* @throws SQLException SQL exception
*/
ResultSet executeQuery(DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine,
- JDBCExecutorCallback<? extends ExecuteResult> callback, SQLFederationContext federationContext) throws SQLException;
+ JDBCExecutorCallback<? extends ExecuteResult> callback, SQLFederationExecutorContext federationContext) throws SQLException;
/**
* Get result set.
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-api/src/main/java/org/apache/shardingsphere/sqlfederation/spi/SQLFederationContext.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-api/src/main/java/org/apache/shardingsphere/sqlfederation/spi/SQLFederationExecutorContext.java
similarity index 94%
rename from shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-api/src/main/java/org/apache/shardingsphere/sqlfederation/spi/SQLFederationContext.java
rename to shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-api/src/main/java/org/apache/shardingsphere/sqlfederation/spi/SQLFederationExecutorContext.java
index 599bbd04328..4a7abda48c7 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-api/src/main/java/org/apache/shardingsphere/sqlfederation/spi/SQLFederationContext.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-api/src/main/java/org/apache/shardingsphere/sqlfederation/spi/SQLFederationExecutorContext.java
@@ -28,11 +28,11 @@ import java.util.LinkedList;
import java.util.Map;
/**
- * SQL federation context.
+ * SQL federation executor context.
*/
@RequiredArgsConstructor
@Getter
-public final class SQLFederationContext {
+public final class SQLFederationExecutorContext {
private final Collection<ExecutionUnit> executionUnits = new LinkedList<>();
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/src/main/java/org/apache/shardingsphere/sqlfederation/common/table/CommonTableScanExecutorContext.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/src/main/java/org/apache/shardingsphere/sqlfederation/common/table/CommonTableScanExecutorContext.java
index fa89253839f..ae0979c3337 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/src/main/java/org/apache/shardingsphere/sqlfederation/common/table/CommonTableScanExecutorContext.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-core/src/main/java/org/apache/shardingsphere/sqlfederation/common/table/CommonTableScanExecutorContext.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.sqlfederation.common.table;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
-import org.apache.shardingsphere.sqlfederation.spi.SQLFederationContext;
+import org.apache.shardingsphere.sqlfederation.spi.SQLFederationExecutorContext;
/**
* Translatable table scan executor context.
@@ -35,5 +35,5 @@ public final class CommonTableScanExecutorContext {
private final ConfigurationProperties props;
- private final SQLFederationContext federationContext;
+ private final SQLFederationExecutorContext federationContext;
}
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
index 93b8f9535e1..17652691ccd 100644
--- 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
@@ -18,20 +18,43 @@
package org.apache.shardingsphere.sqlfederation.rule;
import lombok.Getter;
+import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutor;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.rule.identifier.scope.GlobalRule;
+import org.apache.shardingsphere.infra.util.eventbus.EventBusContext;
import org.apache.shardingsphere.sqlfederation.api.config.SQLFederationRuleConfiguration;
+import org.apache.shardingsphere.sqlfederation.factory.SQLFederationExecutorFactory;
+import org.apache.shardingsphere.sqlfederation.spi.SQLFederationExecutor;
/**
* SQL federation rule.
*/
-@Getter
public final class SQLFederationRule implements GlobalRule {
+ @Getter
private final SQLFederationRuleConfiguration configuration;
+ private final SQLFederationExecutor sqlFederationExecutor;
+
public SQLFederationRule(final SQLFederationRuleConfiguration ruleConfig) {
configuration = ruleConfig;
- // TODO lode SQLFederationExecutor by sqlFederationType
+ sqlFederationExecutor = SQLFederationExecutorFactory.getInstance(ruleConfig.getSqlFederationType());
+ }
+
+ /**
+ * Get SQL federation executor.
+ *
+ * @param databaseName database name
+ * @param schemaName schema name
+ * @param metaData ShardingSphere meta data
+ * @param jdbcExecutor jdbc executor
+ * @param eventBusContext event bus context
+ * @return created instance
+ */
+ public SQLFederationExecutor getSQLFederationExecutor(final String databaseName, final String schemaName, final ShardingSphereMetaData metaData,
+ final JDBCExecutor jdbcExecutor, final EventBusContext eventBusContext) {
+ sqlFederationExecutor.init(databaseName, schemaName, metaData, jdbcExecutor, eventBusContext);
+ return sqlFederationExecutor;
}
@Override
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
index fd268164968..38d4ea70e09 100644
--- 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
@@ -17,6 +17,8 @@
package org.apache.shardingsphere.sqlfederation.rule.builder;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.builder.global.GlobalRuleBuilder;
@@ -33,7 +35,9 @@ import java.util.Map;
public final class SQLFederationRuleBuilder implements GlobalRuleBuilder<SQLFederationRuleConfiguration> {
@Override
- public GlobalRule build(final SQLFederationRuleConfiguration ruleConfig, final Map<String, ShardingSphereDatabase> databases, final InstanceContext instanceContext) {
+ public GlobalRule build(final SQLFederationRuleConfiguration ruleConfig, final Map<String, ShardingSphereDatabase> databases, final InstanceContext instanceContext,
+ final ConfigurationProperties props) {
+ ruleConfig.setSqlFederationType(props.getValue(ConfigurationPropertyKey.SQL_FEDERATION_TYPE));
return new SQLFederationRule(ruleConfig);
}
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-executor/shardingsphere-sql-federation-advanced-executor/src/main/java/org/apache/shardingsphere/sqlfederation/advanced/AdvancedFederationExecutor.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-executor/shardingsphere-sql-federation-advanced-executor/src/main/java/org/apache/shardingsphere/sqlfederation/advanced/AdvancedFederationExecutor.java
index fbe3bde0fcb..ecba0811f26 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-executor/shardingsphere-sql-federation-advanced-executor/src/main/java/org/apache/shardingsphere/sqlfederation/advanced/AdvancedFederationExecutor.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-executor/shardingsphere-sql-federation-advanced-executor/src/main/java/org/apache/shardingsphere/sqlfederation/advanced/AdvancedFederationExecutor.java
@@ -54,7 +54,7 @@ import org.apache.shardingsphere.sqlfederation.optimizer.context.OptimizerContex
import org.apache.shardingsphere.sqlfederation.optimizer.context.planner.OptimizerPlannerContextFactory;
import org.apache.shardingsphere.sqlfederation.optimizer.metadata.translatable.TranslatableSchema;
import org.apache.shardingsphere.sqlfederation.optimizer.planner.QueryOptimizePlannerFactory;
-import org.apache.shardingsphere.sqlfederation.spi.SQLFederationContext;
+import org.apache.shardingsphere.sqlfederation.spi.SQLFederationExecutorContext;
import org.apache.shardingsphere.sqlfederation.spi.SQLFederationExecutor;
import java.sql.Connection;
@@ -99,7 +99,7 @@ public final class AdvancedFederationExecutor implements SQLFederationExecutor {
@Override
public ResultSet executeQuery(final DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine,
- final JDBCExecutorCallback<? extends ExecuteResult> callback, final SQLFederationContext federationContext) throws SQLException {
+ final JDBCExecutorCallback<? extends ExecuteResult> callback, final SQLFederationExecutorContext federationContext) throws SQLException {
SQLStatementContext<?> sqlStatementContext = federationContext.getQueryContext().getSqlStatementContext();
Preconditions.checkArgument(sqlStatementContext instanceof SelectStatementContext, "SQL statement context must be select statement context.");
ShardingSphereSchema schema = federationContext.getDatabases().get(databaseName.toLowerCase()).getSchema(schemaName);
@@ -120,7 +120,7 @@ public final class AdvancedFederationExecutor implements SQLFederationExecutor {
}
private TranslatableSchema createTranslatableSchema(final DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine, final ShardingSphereSchema schema,
- final JDBCExecutorCallback<? extends ExecuteResult> callback, final SQLFederationContext federationContext) {
+ final JDBCExecutorCallback<? extends ExecuteResult> callback, final SQLFederationExecutorContext federationContext) {
CommonTableScanExecutorContext executorContext = new CommonTableScanExecutorContext(databaseName, schemaName, props, federationContext);
TranslatableTableScanExecutor executor = new TranslatableTableScanExecutor(prepareEngine, jdbcExecutor, callback, optimizerContext, globalRuleMetaData, executorContext, eventBusContext);
return new TranslatableSchema(schemaName, schema, executor);
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-executor/shardingsphere-sql-federation-advanced-executor/src/main/java/org/apache/shardingsphere/sqlfederation/advanced/table/TranslatableTableScanExecutor.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-executor/shardingsphere-sql-federation-advanced-executor/src/main/java/org/apache/shardingsphere/sqlfederation/advanced/table/TranslatableTableScanExecutor.java
index f50488dcde1..e58da3a2343 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-executor/shardingsphere-sql-federation-advanced-executor/src/main/java/org/apache/shardingsphere/sqlfederation/advanced/table/TranslatableTableScanExecutor.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-executor/shardingsphere-sql-federation-advanced-executor/src/main/java/org/apache/shardingsphere/sqlfederation/advanced/table/TranslatableTableScanExecutor.java
@@ -82,7 +82,7 @@ import org.apache.shardingsphere.infra.parser.sql.SQLStatementParserEngine;
import org.apache.shardingsphere.infra.util.eventbus.EventBusContext;
import org.apache.shardingsphere.infra.util.exception.external.sql.SQLWrapperException;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
-import org.apache.shardingsphere.sqlfederation.spi.SQLFederationContext;
+import org.apache.shardingsphere.sqlfederation.spi.SQLFederationExecutorContext;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -123,7 +123,7 @@ public final class TranslatableTableScanExecutor implements TableScanExecutor {
DatabaseType databaseType = DatabaseTypeEngine.getTrunkDatabaseType(optimizerContext.getParserContexts().get(databaseName).getDatabaseType().getType());
SqlString sqlString = createSQLString(table, (TranslatableScanNodeExecutorContext) scanContext, SQLDialectFactory.getSQLDialect(databaseType));
// TODO replace sql parse with sql convert
- SQLFederationContext federationContext = executorContext.getFederationContext();
+ SQLFederationExecutorContext federationContext = executorContext.getFederationContext();
QueryContext queryContext = createQueryContext(federationContext.getDatabases(), sqlString, databaseType);
ShardingSphereDatabase database = federationContext.getDatabases().get(databaseName.toLowerCase());
ExecutionContext context = new KernelProcessor().generateExecutionContext(queryContext, database, globalRuleMetaData, executorContext.getProps(), new ConnectionContext());
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-executor/shardingsphere-sql-federation-original-executor/src/main/java/org/apache/shardingsphere/sqlfederation/original/OriginalFederationExecutor.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-executor/shardingsphere-sql-federation-original-executor/src/main/java/org/apache/shardingsphere/sqlfederation/original/OriginalFederationExecutor.java
index 059c049d821..e05957dc9d5 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-executor/shardingsphere-sql-federation-original-executor/src/main/java/org/apache/shardingsphere/sqlfederation/original/OriginalFederationExecutor.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-executor/shardingsphere-sql-federation-original-executor/src/main/java/org/apache/shardingsphere/sqlfederation/original/OriginalFederationExecutor.java
@@ -34,8 +34,8 @@ import org.apache.shardingsphere.sqlfederation.optimizer.context.OptimizerContex
import org.apache.shardingsphere.sqlfederation.optimizer.context.OptimizerContextFactory;
import org.apache.shardingsphere.sqlfederation.optimizer.metadata.filter.FilterableDatabase;
import org.apache.shardingsphere.sqlfederation.original.table.FilterableTableScanExecutor;
-import org.apache.shardingsphere.sqlfederation.spi.SQLFederationContext;
import org.apache.shardingsphere.sqlfederation.spi.SQLFederationExecutor;
+import org.apache.shardingsphere.sqlfederation.spi.SQLFederationExecutorContext;
import java.sql.Connection;
import java.sql.DriverManager;
@@ -69,6 +69,8 @@ public final class OriginalFederationExecutor implements SQLFederationExecutor {
private EventBusContext eventBusContext;
+ private Connection connection;
+
private Statement statement;
static {
@@ -92,23 +94,23 @@ public final class OriginalFederationExecutor implements SQLFederationExecutor {
@Override
public ResultSet executeQuery(final DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine,
- final JDBCExecutorCallback<? extends ExecuteResult> callback, final SQLFederationContext federationContext) throws SQLException {
- Connection connection = createConnection(prepareEngine, callback, federationContext);
+ final JDBCExecutorCallback<? extends ExecuteResult> callback, final SQLFederationExecutorContext federationContext) throws SQLException {
+ connection = createConnection(prepareEngine, callback, federationContext);
PreparedStatement preparedStatement = connection.prepareStatement(SQLUtil.trimSemicolon(federationContext.getQueryContext().getSql()));
setParameters(preparedStatement, federationContext.getQueryContext().getParameters());
- this.statement = preparedStatement;
+ statement = preparedStatement;
return preparedStatement.executeQuery();
}
private Connection createConnection(final DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine,
- final JDBCExecutorCallback<? extends ExecuteResult> callback, final SQLFederationContext federationContext) throws SQLException {
+ final JDBCExecutorCallback<? extends ExecuteResult> callback, final SQLFederationExecutorContext federationContext) throws SQLException {
Connection result = DriverManager.getConnection(CONNECTION_URL, optimizerContext.getParserContexts().get(databaseName).getDialectProps());
addSchema(result.unwrap(CalciteConnection.class), prepareEngine, callback, federationContext);
return result;
}
private void addSchema(final CalciteConnection connection, final DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine,
- final JDBCExecutorCallback<? extends ExecuteResult> callback, final SQLFederationContext federationContext) throws SQLException {
+ final JDBCExecutorCallback<? extends ExecuteResult> callback, final SQLFederationExecutorContext federationContext) throws SQLException {
CommonTableScanExecutorContext executorContext = new CommonTableScanExecutorContext(databaseName, schemaName, props, federationContext);
FilterableTableScanExecutor executor = new FilterableTableScanExecutor(prepareEngine, jdbcExecutor, callback, optimizerContext, globalRuleMetaData, executorContext, eventBusContext);
FilterableDatabase database = new FilterableDatabase(federationContext.getDatabases().get(databaseName.toLowerCase()), executor);
@@ -133,7 +135,6 @@ public final class OriginalFederationExecutor implements SQLFederationExecutor {
@Override
public void close() throws SQLException {
if (null != statement && !statement.isClosed()) {
- Connection connection = statement.getConnection();
statement.close();
connection.close();
}
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-executor/shardingsphere-sql-federation-original-executor/src/main/java/org/apache/shardingsphere/sqlfederation/original/table/FilterableTableScanExecutor.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-executor/shardingsphere-sql-federation-original-executor/src/main/java/org/apache/shardingsphere/sqlfederation/original/table/FilterableTableScanExecutor.java
index 5fe3520497d..8292f99dc7a 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-executor/shardingsphere-sql-federation-original-executor/src/main/java/org/apache/shardingsphere/sqlfederation/original/table/FilterableTableScanExecutor.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-executor/shardingsphere-sql-federation-original-executor/src/main/java/org/apache/shardingsphere/sqlfederation/original/table/FilterableTableScanExecutor.java
@@ -76,7 +76,7 @@ import org.apache.shardingsphere.sqlfederation.optimizer.executor.TableScanExecu
import org.apache.shardingsphere.sqlfederation.optimizer.metadata.filter.FilterableSchema;
import org.apache.shardingsphere.sqlfederation.optimizer.planner.QueryOptimizePlannerFactory;
import org.apache.shardingsphere.sqlfederation.common.SQLDialectFactory;
-import org.apache.shardingsphere.sqlfederation.spi.SQLFederationContext;
+import org.apache.shardingsphere.sqlfederation.spi.SQLFederationExecutorContext;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -116,7 +116,7 @@ public final class FilterableTableScanExecutor implements TableScanExecutor {
String schemaName = executorContext.getSchemaName();
DatabaseType databaseType = DatabaseTypeEngine.getTrunkDatabaseType(optimizerContext.getParserContexts().get(databaseName).getDatabaseType().getType());
SqlString sqlString = createSQLString(table, (FilterableScanNodeExecutorContext) scanContext, SQLDialectFactory.getSQLDialect(databaseType));
- SQLFederationContext federationContext = executorContext.getFederationContext();
+ SQLFederationExecutorContext federationContext = executorContext.getFederationContext();
QueryContext queryContext = createQueryContext(federationContext.getDatabases(), sqlString, databaseType);
ShardingSphereDatabase database = federationContext.getDatabases().get(databaseName.toLowerCase());
// TODO need to get session context
diff --git a/shardingsphere-kernel/shardingsphere-sql-translator/shardingsphere-sql-translator-core/src/main/java/org/apache/shardingsphere/sqltranslator/rule/builder/SQLTranslatorRuleBuilder.java b/shardingsphere-kernel/shardingsphere-sql-translator/shardingsphere-sql-translator-core/src/main/java/org/apache/shardingsphere/sqltranslator/rule/builder/SQLTranslatorRuleBuilder.java
index 0fc1899fffc..b3537a060ef 100644
--- a/shardingsphere-kernel/shardingsphere-sql-translator/shardingsphere-sql-translator-core/src/main/java/org/apache/shardingsphere/sqltranslator/rule/builder/SQLTranslatorRuleBuilder.java
+++ b/shardingsphere-kernel/shardingsphere-sql-translator/shardingsphere-sql-translator-core/src/main/java/org/apache/shardingsphere/sqltranslator/rule/builder/SQLTranslatorRuleBuilder.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.sqltranslator.rule.builder;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.builder.global.GlobalRuleBuilder;
@@ -32,7 +33,8 @@ import java.util.Map;
public final class SQLTranslatorRuleBuilder implements GlobalRuleBuilder<SQLTranslatorRuleConfiguration> {
@Override
- public SQLTranslatorRule build(final SQLTranslatorRuleConfiguration ruleConfig, final Map<String, ShardingSphereDatabase> databases, final InstanceContext instanceContext) {
+ public SQLTranslatorRule build(final SQLTranslatorRuleConfiguration ruleConfig, final Map<String, ShardingSphereDatabase> databases, final InstanceContext instanceContext,
+ final ConfigurationProperties props) {
return new SQLTranslatorRule(ruleConfig);
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/rule/builder/TrafficRuleBuilder.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/rule/builder/TrafficRuleBuilder.java
index c9ec1b591ec..4125f61be09 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/rule/builder/TrafficRuleBuilder.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/rule/builder/TrafficRuleBuilder.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.traffic.rule.builder;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.builder.global.GlobalRuleBuilder;
@@ -33,7 +34,8 @@ import java.util.Map;
public final class TrafficRuleBuilder implements GlobalRuleBuilder<TrafficRuleConfiguration> {
@Override
- public GlobalRule build(final TrafficRuleConfiguration ruleConfig, final Map<String, ShardingSphereDatabase> databases, final InstanceContext instanceContext) {
+ public GlobalRule build(final TrafficRuleConfiguration ruleConfig, final Map<String, ShardingSphereDatabase> databases, final InstanceContext instanceContext,
+ final ConfigurationProperties props) {
return new TrafficRule(ruleConfig);
}
diff --git a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/rule/builder/TransactionRuleBuilder.java b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/rule/builder/TransactionRuleBuilder.java
index 09e95cf751f..3962cd86858 100644
--- a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/rule/builder/TransactionRuleBuilder.java
+++ b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/rule/builder/TransactionRuleBuilder.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.transaction.rule.builder;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.builder.global.GlobalRuleBuilder;
@@ -32,7 +33,8 @@ import java.util.Map;
public final class TransactionRuleBuilder implements GlobalRuleBuilder<TransactionRuleConfiguration> {
@Override
- public TransactionRule build(final TransactionRuleConfiguration ruleConfig, final Map<String, ShardingSphereDatabase> databases, final InstanceContext instanceContext) {
+ public TransactionRule build(final TransactionRuleConfiguration ruleConfig, final Map<String, ShardingSphereDatabase> databases, final InstanceContext instanceContext,
+ final ConfigurationProperties props) {
return new TransactionRule(ruleConfig, databases, instanceContext);
}
diff --git a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
index d6eb16dc0fc..b0b1f7f3536 100644
--- a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
+++ b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
@@ -360,9 +360,10 @@ public final class ContextManager implements AutoCloseable {
private MetaDataContexts createMetaDataContexts(final String databaseName, final SwitchingResource switchingResource, final Collection<RuleConfiguration> ruleConfigs) throws SQLException {
Map<String, ShardingSphereDatabase> changedDatabases = createChangedDatabases(databaseName, switchingResource, ruleConfigs);
+ ConfigurationProperties props = metaDataContexts.getMetaData().getProps();
ShardingSphereRuleMetaData changedGlobalMetaData = new ShardingSphereRuleMetaData(
- GlobalRulesBuilder.buildRules(metaDataContexts.getMetaData().getGlobalRuleMetaData().getConfigurations(), changedDatabases, instanceContext));
- return newMetaDataContexts(new ShardingSphereMetaData(changedDatabases, changedGlobalMetaData, metaDataContexts.getMetaData().getProps()));
+ GlobalRulesBuilder.buildRules(metaDataContexts.getMetaData().getGlobalRuleMetaData().getConfigurations(), changedDatabases, instanceContext, props));
+ return newMetaDataContexts(new ShardingSphereMetaData(changedDatabases, changedGlobalMetaData, props));
}
private Map<String, ShardingSphereDatabase> createChangedDatabases(final String databaseName,
@@ -406,7 +407,7 @@ public final class ContextManager implements AutoCloseable {
Collection<ResourceHeldRule> staleResourceHeldRules = metaDataContexts.getMetaData().getGlobalRuleMetaData().findRules(ResourceHeldRule.class);
staleResourceHeldRules.forEach(ResourceHeldRule::closeStaleResource);
ShardingSphereRuleMetaData toBeChangedGlobalRuleMetaData = new ShardingSphereRuleMetaData(
- GlobalRulesBuilder.buildRules(ruleConfigs, metaDataContexts.getMetaData().getDatabases(), instanceContext));
+ GlobalRulesBuilder.buildRules(ruleConfigs, metaDataContexts.getMetaData().getDatabases(), instanceContext, metaDataContexts.getMetaData().getProps()));
ShardingSphereMetaData toBeChangedMetaData = new ShardingSphereMetaData(
metaDataContexts.getMetaData().getDatabases(), toBeChangedGlobalRuleMetaData, metaDataContexts.getMetaData().getProps());
metaDataContexts = newMetaDataContexts(toBeChangedMetaData);
diff --git a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsFactory.java b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsFactory.java
index 015007e6342..f09b7686345 100644
--- a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsFactory.java
+++ b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsFactory.java
@@ -67,7 +67,7 @@ public final class MetaDataContextsFactory {
ConfigurationProperties props = new ConfigurationProperties(persistService.getPropsService().load());
Map<String, ShardingSphereDatabase> databases = ShardingSphereDatabasesFactory.create(effectiveDatabaseConfigs, props, instanceContext);
databases.putAll(reloadDatabases(databases, persistService));
- ShardingSphereRuleMetaData globalMetaData = new ShardingSphereRuleMetaData(GlobalRulesBuilder.buildRules(globalRuleConfigs, databases, instanceContext));
+ ShardingSphereRuleMetaData globalMetaData = new ShardingSphereRuleMetaData(GlobalRulesBuilder.buildRules(globalRuleConfigs, databases, instanceContext, props));
return new MetaDataContexts(persistService, new ShardingSphereMetaData(databases, globalMetaData, props));
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java
index 636bc98f994..db0cbf6351d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java
@@ -49,9 +49,9 @@ import org.apache.shardingsphere.proxy.backend.response.header.query.QueryRespon
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
import org.apache.shardingsphere.sharding.merge.common.IteratorStreamMergedResult;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLInsertStatement;
-import org.apache.shardingsphere.sqlfederation.factory.SQLFederationExecutorFactory;
-import org.apache.shardingsphere.sqlfederation.spi.SQLFederationContext;
+import org.apache.shardingsphere.sqlfederation.rule.SQLFederationRule;
import org.apache.shardingsphere.sqlfederation.spi.SQLFederationExecutor;
+import org.apache.shardingsphere.sqlfederation.spi.SQLFederationExecutorContext;
import java.sql.Connection;
import java.sql.ResultSet;
@@ -145,7 +145,8 @@ public final class JDBCDatabaseCommunicationEngine extends DatabaseCommunication
String databaseName = backendConnection.getConnectionSession().getDatabaseName();
DatabaseType databaseType = getQueryContext().getSqlStatementContext().getDatabaseType();
String schemaName = getQueryContext().getSqlStatementContext().getTablesContext().getSchemaName().orElseGet(() -> DatabaseTypeEngine.getDefaultSchemaName(databaseType, databaseName));
- federationExecutor = SQLFederationExecutorFactory.newInstance(databaseName, schemaName, metaDataContexts.getMetaData(),
+ SQLFederationRule sqlFederationRule = metaDataContexts.getMetaData().getGlobalRuleMetaData().getSingleRule(SQLFederationRule.class);
+ federationExecutor = sqlFederationRule.getSQLFederationExecutor(databaseName, schemaName, metaDataContexts.getMetaData(),
new JDBCExecutor(BackendExecutorContext.getInstance().getExecutorEngine(), backendConnection.isSerialExecute()),
ProxyContext.getInstance().getContextManager().getInstanceContext().getEventBusContext());
}
@@ -158,7 +159,7 @@ public final class JDBCDatabaseCommunicationEngine extends DatabaseCommunication
ProxyJDBCExecutorCallback callback = ProxyJDBCExecutorCallbackFactory.newInstance(getDriverType(), protocolType, databaseType,
queryContext.getSqlStatementContext().getSqlStatement(), this, isReturnGeneratedKeys, SQLExecutorExceptionHandler.isExceptionThrown(), true);
DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine = createDriverExecutionPrepareEngine(isReturnGeneratedKeys, metaDataContexts);
- SQLFederationContext context = new SQLFederationContext(false, queryContext, metaDataContexts.getMetaData().getDatabases());
+ SQLFederationExecutorContext context = new SQLFederationExecutorContext(false, queryContext, metaDataContexts.getMetaData().getDatabases());
return federationExecutor.executeQuery(prepareEngine, callback, context);
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/sql/PreviewHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/sql/PreviewHandler.java
index c70a426af3a..97c7911d670 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/sql/PreviewHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/sql/PreviewHandler.java
@@ -61,9 +61,9 @@ import org.apache.shardingsphere.proxy.backend.exception.RuleNotExistedException
import org.apache.shardingsphere.proxy.backend.handler.distsql.rul.SQLRULBackendHandler;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLInsertStatement;
-import org.apache.shardingsphere.sqlfederation.factory.SQLFederationExecutorFactory;
-import org.apache.shardingsphere.sqlfederation.spi.SQLFederationContext;
+import org.apache.shardingsphere.sqlfederation.rule.SQLFederationRule;
import org.apache.shardingsphere.sqlfederation.spi.SQLFederationExecutor;
+import org.apache.shardingsphere.sqlfederation.spi.SQLFederationExecutorContext;
import java.sql.Connection;
import java.sql.SQLException;
@@ -138,13 +138,14 @@ public final class PreviewHandler extends SQLRULBackendHandler<PreviewStatement>
SQLStatement sqlStatement = queryContext.getSqlStatementContext().getSqlStatement();
boolean isReturnGeneratedKeys = sqlStatement instanceof MySQLInsertStatement;
DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine = createDriverExecutionPrepareEngine(isReturnGeneratedKeys, metaDataContexts);
- SQLFederationContext context = new SQLFederationContext(true, queryContext, metaDataContexts.getMetaData().getDatabases());
+ SQLFederationExecutorContext context = new SQLFederationExecutorContext(true, queryContext, metaDataContexts.getMetaData().getDatabases());
DatabaseType databaseType = metaDataContexts.getMetaData().getDatabase(getDatabaseName()).getResource().getDatabaseType();
String schemaName = queryContext.getSqlStatementContext().getTablesContext().getSchemaName().orElseGet(() -> DatabaseTypeEngine.getDefaultSchemaName(databaseType, databaseName));
EventBusContext eventBusContext = ProxyContext.getInstance().getContextManager().getInstanceContext().getEventBusContext();
- SQLFederationExecutor executor = SQLFederationExecutorFactory.newInstance(databaseName, schemaName,
+ SQLFederationRule sqlFederationRule = metaDataContexts.getMetaData().getGlobalRuleMetaData().getSingleRule(SQLFederationRule.class);
+ SQLFederationExecutor sqlFederationExecutor = sqlFederationRule.getSQLFederationExecutor(databaseName, schemaName,
metaDataContexts.getMetaData(), new JDBCExecutor(BackendExecutorContext.getInstance().getExecutorEngine(), false), eventBusContext);
- executor.executeQuery(prepareEngine, createPreviewFederationCallback(sqlStatement, databaseType, eventBusContext), context);
+ sqlFederationExecutor.executeQuery(prepareEngine, createPreviewFederationCallback(sqlStatement, databaseType, eventBusContext), context);
return context.getExecutionUnits();
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngineTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngineTest.java
index e445748a680..3c951d8d69c 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngineTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngineTest.java
@@ -27,7 +27,6 @@ import org.apache.shardingsphere.infra.database.DefaultDatabase;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutor;
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryResult;
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryResultMetaData;
import org.apache.shardingsphere.infra.executor.sql.prepare.driver.DriverExecutionPrepareEngine;
@@ -42,7 +41,6 @@ import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereTable;
import org.apache.shardingsphere.infra.metadata.database.schema.util.SystemSchemaUtil;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-import org.apache.shardingsphere.infra.util.eventbus.EventBusContext;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
@@ -56,9 +54,11 @@ import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
import org.apache.shardingsphere.proxy.backend.response.header.query.QueryHeaderBuilderEngine;
import org.apache.shardingsphere.proxy.backend.util.ProxyContextRestorer;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
+import org.apache.shardingsphere.sqlfederation.api.config.SQLFederationRuleConfiguration;
import org.apache.shardingsphere.sqlfederation.factory.SQLFederationExecutorFactory;
-import org.apache.shardingsphere.sqlfederation.spi.SQLFederationContext;
+import org.apache.shardingsphere.sqlfederation.rule.SQLFederationRule;
import org.apache.shardingsphere.sqlfederation.spi.SQLFederationExecutor;
+import org.apache.shardingsphere.sqlfederation.spi.SQLFederationExecutorContext;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -89,7 +89,6 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
@@ -109,11 +108,14 @@ public final class JDBCDatabaseCommunicationEngineTest extends ProxyContextResto
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private ResultSet resultSet;
+ @Mock
+ private ShardingSphereRuleMetaData globalRuleMetaData;
+
@Before
public void setUp() {
when(backendConnection.getConnectionSession().getDatabaseName()).thenReturn("db");
MetaDataContexts metaDataContexts = new MetaDataContexts(mock(MetaDataPersistService.class),
- new ShardingSphereMetaData(mockDatabases(), mock(ShardingSphereRuleMetaData.class), new ConfigurationProperties(new Properties())));
+ new ShardingSphereMetaData(mockDatabases(), globalRuleMetaData, new ConfigurationProperties(new Properties())));
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
ProxyContext.init(contextManager);
@@ -146,14 +148,15 @@ public final class JDBCDatabaseCommunicationEngineTest extends ProxyContextResto
try (
MockedStatic<SQLFederationExecutorFactory> federationExecutorFactory = mockStatic(SQLFederationExecutorFactory.class);
MockedStatic<SystemSchemaUtil> systemSchemaUtil = mockStatic(SystemSchemaUtil.class)) {
- when(federationExecutor.executeQuery(any(DriverExecutionPrepareEngine.class), any(ProxyJDBCExecutorCallback.class), any(SQLFederationContext.class))).thenReturn(resultSet);
+ when(federationExecutor.executeQuery(any(DriverExecutionPrepareEngine.class), any(ProxyJDBCExecutorCallback.class), any(SQLFederationExecutorContext.class))).thenReturn(resultSet);
when(resultSet.getMetaData().getColumnCount()).thenReturn(1);
when(resultSet.getMetaData().getColumnType(1)).thenReturn(Types.INTEGER);
when(resultSet.next()).thenReturn(true, false);
when(resultSet.getObject(1)).thenReturn(Integer.MAX_VALUE);
- federationExecutorFactory.when(() -> SQLFederationExecutorFactory.newInstance(anyString(), nullable(String.class),
- any(ShardingSphereMetaData.class), any(JDBCExecutor.class), any(EventBusContext.class))).thenReturn(federationExecutor);
+ federationExecutorFactory.when(() -> SQLFederationExecutorFactory.getInstance(anyString())).thenReturn(federationExecutor);
systemSchemaUtil.when(() -> SystemSchemaUtil.containsSystemSchema(any(DatabaseType.class), any(), any(ShardingSphereDatabase.class))).thenReturn(true);
+ SQLFederationRule sqlFederationRule = new SQLFederationRule(new SQLFederationRuleConfiguration("ORIGINAL"));
+ when(globalRuleMetaData.getSingleRule(SQLFederationRule.class)).thenReturn(sqlFederationRule);
engine.execute();
}
assertTrue(engine.next());
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java
index 139c51e6762..dc782babec7 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java
@@ -189,7 +189,7 @@ public final class MySQLFrontendEngineTest extends ProxyContextRestorer {
private ShardingSphereRuleMetaData buildGlobalRuleMetaData(final ShardingSphereUser user) {
AuthorityRuleConfiguration ruleConfig = new AuthorityRuleConfiguration(Collections.singletonList(user), new AlgorithmConfiguration("ALL_PERMITTED", new Properties()));
- AuthorityRule rule = new AuthorityRuleBuilder().build(ruleConfig, Collections.emptyMap(), mock(InstanceContext.class));
+ AuthorityRule rule = new AuthorityRuleBuilder().build(ruleConfig, Collections.emptyMap(), mock(InstanceContext.class), mock(ConfigurationProperties.class));
return new ShardingSphereRuleMetaData(Collections.singletonList(rule));
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationHandlerTest.java
index f7d74e887c4..c464b719d7d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationHandlerTest.java
@@ -24,8 +24,8 @@ import org.apache.shardingsphere.authority.model.AuthorityRegistry;
import org.apache.shardingsphere.authority.rule.AuthorityRule;
import org.apache.shardingsphere.authority.rule.builder.AuthorityRuleBuilder;
import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLAuthenticationMethod;
-import org.apache.shardingsphere.dialect.mysql.vendor.MySQLVendorError;
import org.apache.shardingsphere.db.protocol.mysql.packet.handshake.MySQLAuthPluginData;
+import org.apache.shardingsphere.dialect.mysql.vendor.MySQLVendorError;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.instance.InstanceContext;
@@ -153,7 +153,7 @@ public final class MySQLAuthenticationHandlerTest extends ProxyContextRestorer {
private ShardingSphereRuleMetaData buildGlobalRuleMetaData(final ShardingSphereUser user, final boolean isNeedSuper) throws NoSuchFieldException, IllegalAccessException {
AuthorityRuleConfiguration ruleConfig = new AuthorityRuleConfiguration(Collections.singletonList(user), new AlgorithmConfiguration("ALL_PERMITTED", new Properties()));
- AuthorityRule rule = new AuthorityRuleBuilder().build(ruleConfig, Collections.emptyMap(), mock(InstanceContext.class));
+ AuthorityRule rule = new AuthorityRuleBuilder().build(ruleConfig, Collections.emptyMap(), mock(InstanceContext.class), mock(ConfigurationProperties.class));
if (!isNeedSuper) {
Field authorityRegistryField = AuthorityRule.class.getDeclaredField("authorityRegistry");
AuthorityRegistry authorityRegistry = mock(AuthorityRegistry.class);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationEngineTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationEngineTest.java
index b16c3fdaf38..b80b9a54f09 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationEngineTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationEngineTest.java
@@ -174,7 +174,7 @@ public final class OpenGaussAuthenticationEngineTest extends ProxyContextRestore
private ShardingSphereRuleMetaData buildGlobalRuleMetaData(final ShardingSphereUser user) {
AuthorityRuleConfiguration ruleConfig = new AuthorityRuleConfiguration(Collections.singletonList(user), new AlgorithmConfiguration("ALL_PERMITTED", new Properties()));
- AuthorityRule rule = new AuthorityRuleBuilder().build(ruleConfig, Collections.emptyMap(), mock(InstanceContext.class));
+ AuthorityRule rule = new AuthorityRuleBuilder().build(ruleConfig, Collections.emptyMap(), mock(InstanceContext.class), mock(ConfigurationProperties.class));
return new ShardingSphereRuleMetaData(Collections.singletonList(rule));
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandlerTest.java
index a0efebf7bac..38f57d95b8b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandlerTest.java
@@ -142,7 +142,7 @@ public final class OpenGaussAuthenticationHandlerTest extends ProxyContextRestor
private ShardingSphereRuleMetaData buildGlobalRuleMetaData(final ShardingSphereUser user) {
AuthorityRuleConfiguration ruleConfig = new AuthorityRuleConfiguration(Collections.singletonList(user), new AlgorithmConfiguration("ALL_PERMITTED", new Properties()));
- AuthorityRule rule = new AuthorityRuleBuilder().build(ruleConfig, Collections.emptyMap(), mock(InstanceContext.class));
+ AuthorityRule rule = new AuthorityRuleBuilder().build(ruleConfig, Collections.emptyMap(), mock(InstanceContext.class), mock(ConfigurationProperties.class));
return new ShardingSphereRuleMetaData(Collections.singleton(rule));
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngineTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngineTest.java
index d11e71ead4c..73f95cf67a6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngineTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngineTest.java
@@ -184,7 +184,7 @@ public final class PostgreSQLAuthenticationEngineTest extends ProxyContextRestor
private ShardingSphereRuleMetaData buildGlobalRuleMetaData(final ShardingSphereUser user) {
AuthorityRuleConfiguration ruleConfig = new AuthorityRuleConfiguration(Collections.singletonList(user), new AlgorithmConfiguration("ALL_PERMITTED", new Properties()));
- AuthorityRule rule = new AuthorityRuleBuilder().build(ruleConfig, Collections.emptyMap(), mock(InstanceContext.class));
+ AuthorityRule rule = new AuthorityRuleBuilder().build(ruleConfig, Collections.emptyMap(), mock(InstanceContext.class), mock(ConfigurationProperties.class));
return new ShardingSphereRuleMetaData(Collections.singletonList(rule));
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandlerTest.java
index 92924d091ee..d6d7328e183 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandlerTest.java
@@ -149,7 +149,7 @@ public final class PostgreSQLAuthenticationHandlerTest extends ProxyContextResto
private ShardingSphereRuleMetaData buildGlobalRuleMetaData(final ShardingSphereUser user) {
AuthorityRuleConfiguration ruleConfig = new AuthorityRuleConfiguration(Collections.singletonList(user), new AlgorithmConfiguration("ALL_PERMITTED", new Properties()));
- AuthorityRule rule = new AuthorityRuleBuilder().build(ruleConfig, Collections.emptyMap(), mock(InstanceContext.class));
+ AuthorityRule rule = new AuthorityRuleBuilder().build(ruleConfig, Collections.emptyMap(), mock(InstanceContext.class), mock(ConfigurationProperties.class));
return new ShardingSphereRuleMetaData(Collections.singleton(rule));
}
diff --git a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/PipelineDataSourceCreatorFactoryTest.java b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/PipelineDataSourceCreatorFactoryTest.java
index 312a665e1ef..6cf3c5d6c1a 100644
--- a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/PipelineDataSourceCreatorFactoryTest.java
+++ b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/PipelineDataSourceCreatorFactoryTest.java
@@ -36,8 +36,7 @@ public final class PipelineDataSourceCreatorFactoryTest {
public void assertGetInstance() {
Collection<Pair<String, Class<? extends PipelineDataSourceCreator>>> paramResult = Arrays.asList(
Pair.of(StandardPipelineDataSourceConfiguration.TYPE, StandardPipelineDataSourceCreator.class),
- Pair.of(ShardingSpherePipelineDataSourceConfiguration.TYPE, ShardingSpherePipelineDataSourceCreator.class)
- );
+ Pair.of(ShardingSpherePipelineDataSourceConfiguration.TYPE, ShardingSpherePipelineDataSourceCreator.class));
for (Pair<String, Class<? extends PipelineDataSourceCreator>> each : paramResult) {
PipelineDataSourceCreator actual = PipelineDataSourceCreatorFactory.getInstance(each.getKey());
assertThat(actual, instanceOf(each.getValue()));
diff --git a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/PipelineSQLBuilderFactoryTest.java b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/PipelineSQLBuilderFactoryTest.java
index c17297f9c47..a330d66130a 100644
--- a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/PipelineSQLBuilderFactoryTest.java
+++ b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/PipelineSQLBuilderFactoryTest.java
@@ -37,8 +37,7 @@ public final class PipelineSQLBuilderFactoryTest {
Collection<Pair<String, Class<? extends PipelineSQLBuilder>>> paramResult = Arrays.asList(
Pair.of("MySQL", MySQLPipelineSQLBuilder.class), Pair.of("PostgreSQL", PostgreSQLPipelineSQLBuilder.class),
Pair.of("openGauss", OpenGaussPipelineSQLBuilder.class), Pair.of("Oracle", OraclePipelineSQLBuilder.class),
- Pair.of("DB2", DefaultPipelineSQLBuilder.class)
- );
+ Pair.of("DB2", DefaultPipelineSQLBuilder.class));
for (Pair<String, Class<? extends PipelineSQLBuilder>> each : paramResult) {
PipelineSQLBuilder actual = PipelineSQLBuilderFactory.getInstance(each.getKey());
assertThat(actual, instanceOf(each.getValue()));
diff --git a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/spi/ingest/position/PositionInitializerFactoryTest.java b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/spi/ingest/position/PositionInitializerFactoryTest.java
index fa76fd61d62..fc8a6258e5d 100644
--- a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/spi/ingest/position/PositionInitializerFactoryTest.java
+++ b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/spi/ingest/position/PositionInitializerFactoryTest.java
@@ -36,8 +36,7 @@ public final class PositionInitializerFactoryTest {
public void assertGetInstance() {
Collection<Pair<String, Class<? extends PositionInitializer>>> paramResult = Arrays.asList(
Pair.of("MySQL", MySQLPositionInitializer.class), Pair.of("PostgreSQL", PostgreSQLPositionInitializer.class),
- Pair.of("openGauss", OpenGaussPositionInitializer.class), Pair.of("Oracle", DefaultPositionInitializer.class)
- );
+ Pair.of("openGauss", OpenGaussPositionInitializer.class), Pair.of("Oracle", DefaultPositionInitializer.class));
for (Pair<String, Class<? extends PositionInitializer>> each : paramResult) {
PositionInitializer actual = PositionInitializerFactory.getInstance(each.getKey());
assertThat(actual, instanceOf(each.getValue()));