This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 5439c67e0a1 Remove DriverExecutorFacadeFactory (#34022)
5439c67e0a1 is described below
commit 5439c67e0a18f96fc81acc5583246b9ff25d072c
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Dec 12 14:38:50 2024 +0800
Remove DriverExecutorFacadeFactory (#34022)
---
.../engine/facade/DriverExecutorFacade.java | 86 ++++++++++++--
.../engine/facade/DriverExecutorFacadeFactory.java | 42 -------
.../standard/StandardDriverExecutorFacade.java | 129 ---------------------
.../StandardDriverExecutorFacadeFactory.java | 46 --------
.../core/connection/ShardingSphereConnection.java | 23 ++--
.../statement/ShardingSpherePreparedStatement.java | 27 ++---
.../core/statement/ShardingSphereStatement.java | 14 +--
.../driver/state/ok/OKDriverState.java | 2 +-
...cutor.engine.facade.DriverExecutorFacadeFactory | 18 ---
.../driver/jdbc/adapter/ConnectionAdapterTest.java | 2 +-
.../driver/jdbc/adapter/StatementAdapterTest.java | 4 +-
.../connection/ShardingSphereConnectionTest.java | 24 ++--
.../UnsupportedOperationConnectionTest.java | 2 +-
.../UnsupportedOperationStatementTest.java | 2 +-
.../scenario/migration/api/MigrationJobAPI.java | 14 +--
15 files changed, 130 insertions(+), 305 deletions(-)
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/DriverExecutorFacade.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/DriverExecutorFacade.java
index 1ace4cab0ec..8301aef3b9b 100644
---
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/DriverExecutorFacade.java
+++
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/DriverExecutorFacade.java
@@ -21,10 +21,26 @@ import
org.apache.shardingsphere.driver.executor.callback.add.StatementAddCallba
import
org.apache.shardingsphere.driver.executor.callback.execute.StatementExecuteCallback;
import
org.apache.shardingsphere.driver.executor.callback.execute.StatementExecuteUpdateCallback;
import
org.apache.shardingsphere.driver.executor.callback.replay.StatementReplayCallback;
+import org.apache.shardingsphere.driver.executor.engine.DriverExecuteExecutor;
+import
org.apache.shardingsphere.driver.executor.engine.DriverExecuteQueryExecutor;
+import
org.apache.shardingsphere.driver.executor.engine.DriverExecuteUpdateExecutor;
+import
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
+import org.apache.shardingsphere.driver.jdbc.core.statement.StatementManager;
import
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
+import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
+import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeRegistry;
+import org.apache.shardingsphere.infra.executor.audit.SQLAuditEngine;
+import
org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutionUnit;
+import
org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutor;
+import
org.apache.shardingsphere.infra.executor.sql.execute.engine.raw.RawExecutor;
+import
org.apache.shardingsphere.infra.executor.sql.prepare.driver.DriverExecutionPrepareEngine;
+import
org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.StatementOption;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.session.query.QueryContext;
+import org.apache.shardingsphere.sqlfederation.engine.SQLFederationEngine;
+import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
@@ -35,7 +51,39 @@ import java.util.Optional;
/**
* Driver executor facade.
*/
-public interface DriverExecutorFacade extends AutoCloseable {
+public final class DriverExecutorFacade implements AutoCloseable {
+
+ private final ShardingSphereConnection connection;
+
+ private final StatementOption statementOption;
+
+ private final StatementManager statementManager;
+
+ private final String jdbcDriverType;
+
+ private final SQLFederationEngine sqlFederationEngine;
+
+ private final DriverExecuteQueryExecutor queryExecutor;
+
+ private final DriverExecuteUpdateExecutor updateExecutor;
+
+ private final DriverExecuteExecutor executeExecutor;
+
+ public DriverExecutorFacade(final ShardingSphereConnection connection,
final StatementOption statementOption, final StatementManager statementManager,
final String jdbcDriverType) {
+ this.connection = connection;
+ this.statementOption = statementOption;
+ this.statementManager = statementManager;
+ this.jdbcDriverType = jdbcDriverType;
+ JDBCExecutor jdbcExecutor = new
JDBCExecutor(connection.getContextManager().getExecutorEngine(),
connection.getDatabaseConnectionManager().getConnectionContext());
+ ShardingSphereMetaData metaData =
connection.getContextManager().getMetaDataContexts().getMetaData();
+ String currentSchemaName = new
DatabaseTypeRegistry(metaData.getDatabase(connection.getCurrentDatabaseName()).getProtocolType()).getDefaultSchemaName(connection.getCurrentDatabaseName());
+ sqlFederationEngine =
+ new SQLFederationEngine(connection.getCurrentDatabaseName(),
currentSchemaName, metaData,
connection.getContextManager().getMetaDataContexts().getStatistics(),
jdbcExecutor);
+ RawExecutor rawExecutor = new
RawExecutor(connection.getContextManager().getExecutorEngine(),
connection.getDatabaseConnectionManager().getConnectionContext());
+ queryExecutor = new DriverExecuteQueryExecutor(connection, metaData,
jdbcExecutor, rawExecutor, sqlFederationEngine);
+ updateExecutor = new DriverExecuteUpdateExecutor(connection, metaData,
jdbcExecutor, rawExecutor);
+ executeExecutor = new DriverExecuteExecutor(connection, metaData,
jdbcExecutor, rawExecutor, sqlFederationEngine);
+ }
/**
* Execute query.
@@ -50,8 +98,11 @@ public interface DriverExecutorFacade extends AutoCloseable {
* @throws SQLException SQL exception
*/
@SuppressWarnings("rawtypes")
- ResultSet executeQuery(ShardingSphereDatabase database, QueryContext
queryContext,
- Statement statement, Map<String, Integer>
columnLabelAndIndexMap, StatementAddCallback addCallback,
StatementReplayCallback replayCallback) throws SQLException;
+ public ResultSet executeQuery(final ShardingSphereDatabase database, final
QueryContext queryContext, final Statement statement, final Map<String,
Integer> columnLabelAndIndexMap,
+ final StatementAddCallback addCallback,
final StatementReplayCallback replayCallback) throws SQLException {
+ SQLAuditEngine.audit(queryContext,
connection.getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData(),
database);
+ return queryExecutor.executeQuery(database, queryContext,
createDriverExecutionPrepareEngine(database, jdbcDriverType), statement,
columnLabelAndIndexMap, addCallback, replayCallback);
+ }
/**
* Execute update.
@@ -65,8 +116,11 @@ public interface DriverExecutorFacade extends AutoCloseable
{
* @throws SQLException SQL exception
*/
@SuppressWarnings("rawtypes")
- int executeUpdate(ShardingSphereDatabase database,
- QueryContext queryContext,
StatementExecuteUpdateCallback executeUpdateCallback, StatementAddCallback
addCallback, StatementReplayCallback replayCallback) throws SQLException;
+ public int executeUpdate(final ShardingSphereDatabase database, final
QueryContext queryContext,
+ final StatementExecuteUpdateCallback
executeUpdateCallback, final StatementAddCallback addCallback, final
StatementReplayCallback replayCallback) throws SQLException {
+ SQLAuditEngine.audit(queryContext,
connection.getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData(),
database);
+ return updateExecutor.executeUpdate(database, queryContext,
createDriverExecutionPrepareEngine(database, jdbcDriverType),
executeUpdateCallback, addCallback, replayCallback);
+ }
/**
* Execute.
@@ -80,8 +134,17 @@ public interface DriverExecutorFacade extends AutoCloseable
{
* @throws SQLException SQL exception
*/
@SuppressWarnings("rawtypes")
- boolean execute(ShardingSphereDatabase database,
- QueryContext queryContext, StatementExecuteCallback
executeCallback, StatementAddCallback addCallback, StatementReplayCallback
replayCallback) throws SQLException;
+ public boolean execute(final ShardingSphereDatabase database, final
QueryContext queryContext,
+ final StatementExecuteCallback executeCallback,
final StatementAddCallback addCallback, final StatementReplayCallback
replayCallback) throws SQLException {
+ SQLAuditEngine.audit(queryContext,
connection.getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData(),
database);
+ return executeExecutor.execute(database, queryContext,
createDriverExecutionPrepareEngine(database, jdbcDriverType), executeCallback,
addCallback, replayCallback);
+ }
+
+ private DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection>
createDriverExecutionPrepareEngine(final ShardingSphereDatabase database, final
String jdbcDriverType) {
+ int maxConnectionsSizePerQuery =
connection.getContextManager().getMetaDataContexts().getMetaData().getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
+ return new DriverExecutionPrepareEngine<>(jdbcDriverType,
maxConnectionsSizePerQuery, connection.getDatabaseConnectionManager(),
statementManager, statementOption,
+ database.getRuleMetaData().getRules(),
database.getResourceMetaData().getStorageUnits());
+ }
/**
* Get result set.
@@ -93,8 +156,13 @@ public interface DriverExecutorFacade extends AutoCloseable
{
* @return result set
* @throws SQLException SQL exception
*/
- Optional<ResultSet> getResultSet(ShardingSphereDatabase database,
SQLStatementContext sqlStatementContext, Statement statement, List<? extends
Statement> statements) throws SQLException;
+ public Optional<ResultSet> getResultSet(final ShardingSphereDatabase
database,
+ final SQLStatementContext
sqlStatementContext, final Statement statement, final List<? extends Statement>
statements) throws SQLException {
+ return executeExecutor.getResultSet(database, sqlStatementContext,
statement, statements);
+ }
@Override
- void close() throws SQLException;
+ public void close() throws SQLException {
+ sqlFederationEngine.close();
+ }
}
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/DriverExecutorFacadeFactory.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/DriverExecutorFacadeFactory.java
deleted file mode 100644
index 7c15bfd1ee0..00000000000
---
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/DriverExecutorFacadeFactory.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.driver.executor.engine.facade;
-
-import
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
-import org.apache.shardingsphere.driver.jdbc.core.statement.StatementManager;
-import
org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.StatementOption;
-import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
-
-/**
- * Driver executor facade factory.
- */
-@SingletonSPI
-public interface DriverExecutorFacadeFactory extends TypedSPI {
-
- /**
- * Create new instance of driver executor facade.
- *
- * @param connection connection
- * @param statementOption statement option
- * @param statementManager statement manager
- * @param jdbcDriverType JDBC driver type
- * @return created instance
- */
- DriverExecutorFacade newInstance(ShardingSphereConnection connection,
StatementOption statementOption, StatementManager statementManager, String
jdbcDriverType);
-}
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/standard/StandardDriverExecutorFacade.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/standard/StandardDriverExecutorFacade.java
deleted file mode 100644
index c361dd670a7..00000000000
---
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/standard/StandardDriverExecutorFacade.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.driver.executor.engine.facade.standard;
-
-import
org.apache.shardingsphere.driver.executor.callback.add.StatementAddCallback;
-import
org.apache.shardingsphere.driver.executor.callback.execute.StatementExecuteCallback;
-import
org.apache.shardingsphere.driver.executor.callback.execute.StatementExecuteUpdateCallback;
-import
org.apache.shardingsphere.driver.executor.callback.replay.StatementReplayCallback;
-import org.apache.shardingsphere.driver.executor.engine.DriverExecuteExecutor;
-import
org.apache.shardingsphere.driver.executor.engine.DriverExecuteQueryExecutor;
-import
org.apache.shardingsphere.driver.executor.engine.DriverExecuteUpdateExecutor;
-import
org.apache.shardingsphere.driver.executor.engine.facade.DriverExecutorFacade;
-import
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
-import org.apache.shardingsphere.driver.jdbc.core.statement.StatementManager;
-import
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
-import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeRegistry;
-import org.apache.shardingsphere.infra.executor.audit.SQLAuditEngine;
-import
org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutionUnit;
-import
org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutor;
-import
org.apache.shardingsphere.infra.executor.sql.execute.engine.raw.RawExecutor;
-import
org.apache.shardingsphere.infra.executor.sql.prepare.driver.DriverExecutionPrepareEngine;
-import
org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.StatementOption;
-import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.session.query.QueryContext;
-import org.apache.shardingsphere.sqlfederation.engine.SQLFederationEngine;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
-/**
- * Standard driver executor facade.
- */
-public final class StandardDriverExecutorFacade implements
DriverExecutorFacade {
-
- private final ShardingSphereConnection connection;
-
- private final StatementOption statementOption;
-
- private final StatementManager statementManager;
-
- private final String jdbcDriverType;
-
- private final SQLFederationEngine sqlFederationEngine;
-
- private final DriverExecuteQueryExecutor queryExecutor;
-
- private final DriverExecuteUpdateExecutor updateExecutor;
-
- private final DriverExecuteExecutor executeExecutor;
-
- public StandardDriverExecutorFacade(final ShardingSphereConnection
connection, final StatementOption statementOption, final StatementManager
statementManager, final String jdbcDriverType) {
- this.connection = connection;
- this.statementOption = statementOption;
- this.statementManager = statementManager;
- this.jdbcDriverType = jdbcDriverType;
- JDBCExecutor jdbcExecutor = new
JDBCExecutor(connection.getContextManager().getExecutorEngine(),
connection.getDatabaseConnectionManager().getConnectionContext());
- ShardingSphereMetaData metaData =
connection.getContextManager().getMetaDataContexts().getMetaData();
- String currentSchemaName = new
DatabaseTypeRegistry(metaData.getDatabase(connection.getCurrentDatabaseName()).getProtocolType()).getDefaultSchemaName(connection.getCurrentDatabaseName());
- sqlFederationEngine =
- new SQLFederationEngine(connection.getCurrentDatabaseName(),
currentSchemaName, metaData,
connection.getContextManager().getMetaDataContexts().getStatistics(),
jdbcExecutor);
- RawExecutor rawExecutor = new
RawExecutor(connection.getContextManager().getExecutorEngine(),
connection.getDatabaseConnectionManager().getConnectionContext());
- queryExecutor = new DriverExecuteQueryExecutor(connection, metaData,
jdbcExecutor, rawExecutor, sqlFederationEngine);
- updateExecutor = new DriverExecuteUpdateExecutor(connection, metaData,
jdbcExecutor, rawExecutor);
- executeExecutor = new DriverExecuteExecutor(connection, metaData,
jdbcExecutor, rawExecutor, sqlFederationEngine);
- }
-
- @Override
- @SuppressWarnings("rawtypes")
- public ResultSet executeQuery(final ShardingSphereDatabase database, final
QueryContext queryContext, final Statement statement, final Map<String,
Integer> columnLabelAndIndexMap,
- final StatementAddCallback addCallback,
final StatementReplayCallback replayCallback) throws SQLException {
- SQLAuditEngine.audit(queryContext,
connection.getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData(),
database);
- return queryExecutor.executeQuery(database, queryContext,
createDriverExecutionPrepareEngine(database, jdbcDriverType), statement,
columnLabelAndIndexMap, addCallback, replayCallback);
- }
-
- @Override
- @SuppressWarnings("rawtypes")
- public int executeUpdate(final ShardingSphereDatabase database, final
QueryContext queryContext,
- final StatementExecuteUpdateCallback
executeUpdateCallback, final StatementAddCallback addCallback, final
StatementReplayCallback replayCallback) throws SQLException {
- SQLAuditEngine.audit(queryContext,
connection.getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData(),
database);
- return updateExecutor.executeUpdate(database, queryContext,
createDriverExecutionPrepareEngine(database, jdbcDriverType),
executeUpdateCallback, addCallback, replayCallback);
- }
-
- @Override
- @SuppressWarnings("rawtypes")
- public boolean execute(final ShardingSphereDatabase database, final
QueryContext queryContext,
- final StatementExecuteCallback executeCallback,
final StatementAddCallback addCallback, final StatementReplayCallback
replayCallback) throws SQLException {
- SQLAuditEngine.audit(queryContext,
connection.getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData(),
database);
- return executeExecutor.execute(database, queryContext,
createDriverExecutionPrepareEngine(database, jdbcDriverType), executeCallback,
addCallback, replayCallback);
- }
-
- private DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection>
createDriverExecutionPrepareEngine(final ShardingSphereDatabase database, final
String jdbcDriverType) {
- int maxConnectionsSizePerQuery =
connection.getContextManager().getMetaDataContexts().getMetaData().getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
- return new DriverExecutionPrepareEngine<>(jdbcDriverType,
maxConnectionsSizePerQuery, connection.getDatabaseConnectionManager(),
statementManager, statementOption,
- database.getRuleMetaData().getRules(),
database.getResourceMetaData().getStorageUnits());
- }
-
- @Override
- public Optional<ResultSet> getResultSet(final ShardingSphereDatabase
database,
- final SQLStatementContext
sqlStatementContext, final Statement statement, final List<? extends Statement>
statements) throws SQLException {
- return executeExecutor.getResultSet(database, sqlStatementContext,
statement, statements);
- }
-
- @Override
- public void close() throws SQLException {
- sqlFederationEngine.close();
- }
-}
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/standard/StandardDriverExecutorFacadeFactory.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/standard/StandardDriverExecutorFacadeFactory.java
deleted file mode 100644
index f3799660900..00000000000
---
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/standard/StandardDriverExecutorFacadeFactory.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.driver.executor.engine.facade.standard;
-
-import
org.apache.shardingsphere.driver.executor.engine.facade.DriverExecutorFacade;
-import
org.apache.shardingsphere.driver.executor.engine.facade.DriverExecutorFacadeFactory;
-import
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
-import org.apache.shardingsphere.driver.jdbc.core.statement.StatementManager;
-import
org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.StatementOption;
-
-/**
- * Standard driver executor facade factory.
- */
-public final class StandardDriverExecutorFacadeFactory implements
DriverExecutorFacadeFactory {
-
- @Override
- public DriverExecutorFacade newInstance(final ShardingSphereConnection
connection,
- final StatementOption
statementOption, final StatementManager statementManager, final String
jdbcDriverType) {
- return new StandardDriverExecutorFacade(connection, statementOption,
statementManager, jdbcDriverType);
- }
-
- @Override
- public Object getType() {
- return "Standard";
- }
-
- @Override
- public boolean isDefault() {
- return true;
- }
-}
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
index 6e41678f3bc..eff5feae349 100644
---
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
+++
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
@@ -71,8 +71,6 @@ public final class ShardingSphereConnection extends
AbstractConnectionAdapter {
@Getter
private final String processId;
- private final String executorType;
-
private boolean autoCommit = true;
private int transactionIsolation = TRANSACTION_READ_UNCOMMITTED;
@@ -81,12 +79,11 @@ public final class ShardingSphereConnection extends
AbstractConnectionAdapter {
private volatile boolean closed;
- public ShardingSphereConnection(final String currentDatabaseName, final
ContextManager contextManager, final String executorType) {
+ public ShardingSphereConnection(final String currentDatabaseName, final
ContextManager contextManager) {
this.currentDatabaseName = currentDatabaseName;
this.contextManager = contextManager;
databaseConnectionManager = new
DriverDatabaseConnectionManager(currentDatabaseName, contextManager);
processId = processEngine.connect(currentDatabaseName);
- this.executorType = executorType;
}
/**
@@ -108,47 +105,47 @@ public final class ShardingSphereConnection extends
AbstractConnectionAdapter {
@Override
public PreparedStatement prepareStatement(final String sql) throws
SQLException {
- return new ShardingSpherePreparedStatement(this, sql, executorType);
+ return new ShardingSpherePreparedStatement(this, sql);
}
@Override
public PreparedStatement prepareStatement(final String sql, final int
resultSetType, final int resultSetConcurrency) throws SQLException {
- return new ShardingSpherePreparedStatement(this, sql, resultSetType,
resultSetConcurrency, executorType);
+ return new ShardingSpherePreparedStatement(this, sql, resultSetType,
resultSetConcurrency);
}
@Override
public PreparedStatement prepareStatement(final String sql, final int
resultSetType, final int resultSetConcurrency, final int resultSetHoldability)
throws SQLException {
- return new ShardingSpherePreparedStatement(this, sql, resultSetType,
resultSetConcurrency, resultSetHoldability, executorType);
+ return new ShardingSpherePreparedStatement(this, sql, resultSetType,
resultSetConcurrency, resultSetHoldability);
}
@Override
public PreparedStatement prepareStatement(final String sql, final int
autoGeneratedKeys) throws SQLException {
- return new ShardingSpherePreparedStatement(this, sql,
autoGeneratedKeys, executorType);
+ return new ShardingSpherePreparedStatement(this, sql,
autoGeneratedKeys);
}
@Override
public PreparedStatement prepareStatement(final String sql, final int[]
columnIndexes) throws SQLException {
- return new ShardingSpherePreparedStatement(this, sql,
Statement.RETURN_GENERATED_KEYS, executorType);
+ return new ShardingSpherePreparedStatement(this, sql,
Statement.RETURN_GENERATED_KEYS);
}
@Override
public PreparedStatement prepareStatement(final String sql, final String[]
columnNames) throws SQLException {
- return new ShardingSpherePreparedStatement(this, sql, columnNames,
executorType);
+ return new ShardingSpherePreparedStatement(this, sql, columnNames);
}
@Override
public Statement createStatement() {
- return new ShardingSphereStatement(this, executorType);
+ return new ShardingSphereStatement(this);
}
@Override
public Statement createStatement(final int resultSetType, final int
resultSetConcurrency) {
- return new ShardingSphereStatement(this, resultSetType,
resultSetConcurrency, executorType);
+ return new ShardingSphereStatement(this, resultSetType,
resultSetConcurrency);
}
@Override
public Statement createStatement(final int resultSetType, final int
resultSetConcurrency, final int resultSetHoldability) {
- return new ShardingSphereStatement(this, resultSetType,
resultSetConcurrency, resultSetHoldability, executorType);
+ return new ShardingSphereStatement(this, resultSetType,
resultSetConcurrency, resultSetHoldability);
}
@Override
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
index 3304a614ea4..1a667159a82 100644
---
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
+++
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
@@ -22,7 +22,6 @@ import lombok.Getter;
import
org.apache.shardingsphere.driver.executor.callback.add.StatementAddCallback;
import
org.apache.shardingsphere.driver.executor.engine.batch.preparedstatement.DriverExecuteBatchExecutor;
import
org.apache.shardingsphere.driver.executor.engine.facade.DriverExecutorFacade;
-import
org.apache.shardingsphere.driver.executor.engine.facade.DriverExecutorFacadeFactory;
import
org.apache.shardingsphere.driver.jdbc.adapter.AbstractPreparedStatementAdapter;
import
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
import
org.apache.shardingsphere.driver.jdbc.core.resultset.GeneratedKeysResultSet;
@@ -50,7 +49,6 @@ import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.rule.attribute.datanode.DataNodeRuleAttribute;
import
org.apache.shardingsphere.infra.rule.attribute.resoure.StorageConnectorReusableRuleAttribute;
import org.apache.shardingsphere.infra.session.query.QueryContext;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
import org.apache.shardingsphere.transaction.util.AutoCommitUtils;
@@ -113,30 +111,29 @@ public final class ShardingSpherePreparedStatement
extends AbstractPreparedState
private ResultSet currentBatchGeneratedKeysResultSet;
- public ShardingSpherePreparedStatement(final ShardingSphereConnection
connection, final String sql, final String executorType) throws SQLException {
- this(connection, sql, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT, false, null,
executorType);
+ public ShardingSpherePreparedStatement(final ShardingSphereConnection
connection, final String sql) throws SQLException {
+ this(connection, sql, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT, false, null);
}
- public ShardingSpherePreparedStatement(final ShardingSphereConnection
connection, final String sql, final int resultSetType, final int
resultSetConcurrency,
- final String executorType) throws
SQLException {
- this(connection, sql, resultSetType, resultSetConcurrency,
ResultSet.HOLD_CURSORS_OVER_COMMIT, false, null, executorType);
+ public ShardingSpherePreparedStatement(final ShardingSphereConnection
connection, final String sql, final int resultSetType, final int
resultSetConcurrency) throws SQLException {
+ this(connection, sql, resultSetType, resultSetConcurrency,
ResultSet.HOLD_CURSORS_OVER_COMMIT, false, null);
}
- public ShardingSpherePreparedStatement(final ShardingSphereConnection
connection, final String sql, final int autoGeneratedKeys, final String
executorType) throws SQLException {
- this(connection, sql, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT,
RETURN_GENERATED_KEYS == autoGeneratedKeys, null, executorType);
+ public ShardingSpherePreparedStatement(final ShardingSphereConnection
connection, final String sql, final int autoGeneratedKeys) throws SQLException {
+ this(connection, sql, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT,
RETURN_GENERATED_KEYS == autoGeneratedKeys, null);
}
- public ShardingSpherePreparedStatement(final ShardingSphereConnection
connection, final String sql, final String[] columns, final String
executorType) throws SQLException {
- this(connection, sql, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT, true, columns,
executorType);
+ public ShardingSpherePreparedStatement(final ShardingSphereConnection
connection, final String sql, final String[] columns) throws SQLException {
+ this(connection, sql, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT, true, columns);
}
public ShardingSpherePreparedStatement(final ShardingSphereConnection
connection, final String sql, final int resultSetType, final int
resultSetConcurrency,
- final int resultSetHoldability,
final String executorType) throws SQLException {
- this(connection, sql, resultSetType, resultSetConcurrency,
resultSetHoldability, false, null, executorType);
+ final int resultSetHoldability)
throws SQLException {
+ this(connection, sql, resultSetType, resultSetConcurrency,
resultSetHoldability, false, null);
}
private ShardingSpherePreparedStatement(final ShardingSphereConnection
connection, final String sql, final int resultSetType, final int
resultSetConcurrency,
- final int resultSetHoldability,
final boolean returnGeneratedKeys, final String[] columns, final String
executorType) throws SQLException {
+ final int resultSetHoldability,
final boolean returnGeneratedKeys, final String[] columns) throws SQLException {
ShardingSpherePreconditions.checkNotEmpty(sql, () -> new
EmptySQLException().toSQLException());
this.connection = connection;
metaData =
connection.getContextManager().getMetaDataContexts().getMetaData();
@@ -153,7 +150,7 @@ public final class ShardingSpherePreparedStatement extends
AbstractPreparedState
statementManager = new StatementManager();
connection.getStatementManagers().add(statementManager);
parameterMetaData = new ShardingSphereParameterMetaData(sqlStatement);
- driverExecutorFacade =
TypedSPILoader.getService(DriverExecutorFacadeFactory.class,
executorType).newInstance(connection, statementOption, statementManager,
JDBCDriverType.PREPARED_STATEMENT);
+ driverExecutorFacade = new DriverExecutorFacade(connection,
statementOption, statementManager, JDBCDriverType.PREPARED_STATEMENT);
executeBatchExecutor = new DriverExecuteBatchExecutor(connection,
metaData, statementOption, statementManager, usedDatabase);
statementsCacheable = isStatementsCacheable();
}
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
index cb6b10cf525..2125b8fc4e9 100644
---
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
+++
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
@@ -24,7 +24,6 @@ import
org.apache.shardingsphere.driver.executor.callback.execute.StatementExecu
import
org.apache.shardingsphere.driver.executor.callback.execute.StatementExecuteUpdateCallback;
import
org.apache.shardingsphere.driver.executor.engine.batch.statement.BatchStatementExecutor;
import
org.apache.shardingsphere.driver.executor.engine.facade.DriverExecutorFacade;
-import
org.apache.shardingsphere.driver.executor.engine.facade.DriverExecutorFacadeFactory;
import org.apache.shardingsphere.driver.jdbc.adapter.AbstractStatementAdapter;
import
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
import
org.apache.shardingsphere.driver.jdbc.core.resultset.GeneratedKeysResultSet;
@@ -47,7 +46,6 @@ import
org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.rule.attribute.datanode.DataNodeRuleAttribute;
import org.apache.shardingsphere.infra.session.query.QueryContext;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
import org.apache.shardingsphere.transaction.util.AutoCommitUtils;
@@ -91,21 +89,21 @@ public final class ShardingSphereStatement extends
AbstractStatementAdapter {
private ResultSet currentResultSet;
- public ShardingSphereStatement(final ShardingSphereConnection connection,
final String executorType) {
- this(connection, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT, executorType);
+ public ShardingSphereStatement(final ShardingSphereConnection connection) {
+ this(connection, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
}
- public ShardingSphereStatement(final ShardingSphereConnection connection,
final int resultSetType, final int resultSetConcurrency, final String
executorType) {
- this(connection, resultSetType, resultSetConcurrency,
ResultSet.HOLD_CURSORS_OVER_COMMIT, executorType);
+ public ShardingSphereStatement(final ShardingSphereConnection connection,
final int resultSetType, final int resultSetConcurrency) {
+ this(connection, resultSetType, resultSetConcurrency,
ResultSet.HOLD_CURSORS_OVER_COMMIT);
}
- public ShardingSphereStatement(final ShardingSphereConnection connection,
final int resultSetType, final int resultSetConcurrency, final int
resultSetHoldability, final String executorType) {
+ public ShardingSphereStatement(final ShardingSphereConnection connection,
final int resultSetType, final int resultSetConcurrency, final int
resultSetHoldability) {
this.connection = connection;
metaData =
connection.getContextManager().getMetaDataContexts().getMetaData();
statementOption = new StatementOption(resultSetType,
resultSetConcurrency, resultSetHoldability);
statementManager = new StatementManager();
connection.getStatementManagers().add(statementManager);
- driverExecutorFacade =
TypedSPILoader.getService(DriverExecutorFacadeFactory.class,
executorType).newInstance(connection, statementOption, statementManager,
JDBCDriverType.STATEMENT);
+ driverExecutorFacade = new DriverExecutorFacade(connection,
statementOption, statementManager, JDBCDriverType.STATEMENT);
batchStatementExecutor = new BatchStatementExecutor(this);
statements = new LinkedList<>();
usedDatabaseName = connection.getCurrentDatabaseName();
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/state/ok/OKDriverState.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/state/ok/OKDriverState.java
index 78f43c6abe3..75e3a07a70a 100644
---
a/jdbc/src/main/java/org/apache/shardingsphere/driver/state/ok/OKDriverState.java
+++
b/jdbc/src/main/java/org/apache/shardingsphere/driver/state/ok/OKDriverState.java
@@ -30,6 +30,6 @@ public final class OKDriverState implements DriverState {
@Override
public Connection getConnection(final String databaseName, final
ContextManager contextManager) {
- return new ShardingSphereConnection(databaseName, contextManager,
null);
+ return new ShardingSphereConnection(databaseName, contextManager);
}
}
diff --git
a/jdbc/src/main/resources/META-INF/services/org.apache.shardingsphere.driver.executor.engine.facade.DriverExecutorFacadeFactory
b/jdbc/src/main/resources/META-INF/services/org.apache.shardingsphere.driver.executor.engine.facade.DriverExecutorFacadeFactory
deleted file mode 100644
index 0dadb7fcb12..00000000000
---
a/jdbc/src/main/resources/META-INF/services/org.apache.shardingsphere.driver.executor.engine.facade.DriverExecutorFacadeFactory
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.shardingsphere.driver.executor.engine.facade.standard.StandardDriverExecutorFacadeFactory
diff --git
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/ConnectionAdapterTest.java
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/ConnectionAdapterTest.java
index d87d671b01d..3814fc9110d 100644
---
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/ConnectionAdapterTest.java
+++
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/ConnectionAdapterTest.java
@@ -96,6 +96,6 @@ class ConnectionAdapterTest {
private Connection createConnectionAdaptor() {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(new
RuleMetaData(Collections.singleton(mock(TransactionRule.class,
RETURNS_DEEP_STUBS))));
- return new ShardingSphereConnection("foo_db", contextManager, null);
+ return new ShardingSphereConnection("foo_db", contextManager);
}
}
diff --git
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/StatementAdapterTest.java
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/StatementAdapterTest.java
index 1e2d6ee6978..8b04db87af2 100644
---
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/StatementAdapterTest.java
+++
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/StatementAdapterTest.java
@@ -241,7 +241,7 @@ class StatementAdapterTest {
when(connection.getCurrentDatabaseName()).thenReturn("db");
DatabaseType databaseType =
TypedSPILoader.getService(DatabaseType.class, "FIXTURE");
when(connection.getContextManager().getMetaDataContexts().getMetaData().getDatabase("db").getProtocolType()).thenReturn(databaseType);
- ShardingSphereStatement result = new
ShardingSphereStatement(connection, null);
+ ShardingSphereStatement result = new
ShardingSphereStatement(connection);
result.getRoutedStatements().addAll(Arrays.asList(statements));
return result;
}
@@ -259,7 +259,7 @@ class StatementAdapterTest {
new SQLFederationRule(new
DefaultSQLFederationRuleConfigurationBuilder().build(),
Collections.emptyList()),
new SQLParserRule(new
DefaultSQLParserRuleConfigurationBuilder().build()))));
when(connection.getContextManager().getMetaDataContexts().getMetaData().getProps()).thenReturn(new
ConfigurationProperties(new Properties()));
- ShardingSphereStatement result = new
ShardingSphereStatement(connection, null);
+ ShardingSphereStatement result = new
ShardingSphereStatement(connection);
result.getRoutedStatements().addAll(Arrays.asList(statements));
setExecutionContext(result);
return result;
diff --git
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnectionTest.java
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnectionTest.java
index 0e1e716cbe7..f43be4e2d8e 100644
---
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnectionTest.java
+++
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnectionTest.java
@@ -53,7 +53,7 @@ class ShardingSphereConnectionTest {
@Test
void assertSetAutoCommitWithLocalTransaction() throws SQLException {
Connection physicalConnection = mock(Connection.class);
- try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager(physicalConnection),
null)) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager(physicalConnection))) {
connection.getDatabaseConnectionManager().getConnections("foo_db",
"ds", 0, 1, ConnectionMode.MEMORY_STRICTLY);
connection.setAutoCommit(true);
assertTrue(connection.getAutoCommit());
@@ -66,7 +66,7 @@ class ShardingSphereConnectionTest {
ConnectionTransaction connectionTransaction =
mock(ConnectionTransaction.class);
when(connectionTransaction.getDistributedTransactionOperationType(true)).thenReturn(Optional.of(DistributedTransactionOperationType.COMMIT));
when(connectionTransaction.getTransactionType()).thenReturn(TransactionType.XA);
- try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager(), null)) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager())) {
DriverDatabaseConnectionManager connectionManager =
mockConnectionManager(connection, connectionTransaction);
connection.setAutoCommit(true);
assertTrue(connection.getAutoCommit());
@@ -77,7 +77,7 @@ class ShardingSphereConnectionTest {
@Test
void assertCommitWithLocalTransaction() throws SQLException {
Connection physicalConnection = mock(Connection.class);
- try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager(physicalConnection),
null)) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager(physicalConnection))) {
connection.getDatabaseConnectionManager().getConnections("foo_db",
"ds", 0, 1, ConnectionMode.MEMORY_STRICTLY);
connection.setAutoCommit(false);
assertFalse(connection.getAutoCommit());
@@ -94,7 +94,7 @@ class ShardingSphereConnectionTest {
ConnectionTransaction connectionTransaction =
mock(ConnectionTransaction.class);
when(connectionTransaction.getDistributedTransactionOperationType(false)).thenReturn(Optional.of(DistributedTransactionOperationType.BEGIN));
when(connectionTransaction.getTransactionType()).thenReturn(TransactionType.XA);
- try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager(), null)) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager())) {
DriverDatabaseConnectionManager databaseConnectionManager =
mockConnectionManager(connection, connectionTransaction);
connection.setAutoCommit(false);
assertFalse(connection.getAutoCommit());
@@ -107,7 +107,7 @@ class ShardingSphereConnectionTest {
@Test
void assertRollbackWithLocalTransaction() throws SQLException {
Connection physicalConnection = mock(Connection.class);
- try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager(physicalConnection),
null)) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager(physicalConnection))) {
connection.getDatabaseConnectionManager().getConnections("foo_db",
"ds", 0, 1, ConnectionMode.MEMORY_STRICTLY);
connection.setAutoCommit(false);
assertFalse(connection.getAutoCommit());
@@ -121,7 +121,7 @@ class ShardingSphereConnectionTest {
ConnectionTransaction connectionTransaction =
mock(ConnectionTransaction.class);
when(connectionTransaction.getDistributedTransactionOperationType(false)).thenReturn(Optional.of(DistributedTransactionOperationType.BEGIN));
when(connectionTransaction.getTransactionType()).thenReturn(TransactionType.XA);
- try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager(), null)) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager())) {
final DriverDatabaseConnectionManager databaseConnectionManager =
mockConnectionManager(connection, connectionTransaction);
connection.setAutoCommit(false);
assertFalse(connection.getAutoCommit());
@@ -142,14 +142,14 @@ class ShardingSphereConnectionTest {
@Test
void assertIsValidWhenEmptyConnection() throws SQLException {
- try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager(), null)) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager())) {
assertTrue(connection.isValid(0));
}
}
@Test
void assertIsInvalid() throws SQLException {
- try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager(), null)) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager())) {
connection.getDatabaseConnectionManager().getConnections("foo_db",
"ds", 0, 1, ConnectionMode.MEMORY_STRICTLY);
assertFalse(connection.isValid(0));
}
@@ -157,7 +157,7 @@ class ShardingSphereConnectionTest {
@Test
void assertSetReadOnly() throws SQLException {
- try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager(), null)) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager())) {
assertFalse(connection.isReadOnly());
Connection physicalConnection =
connection.getDatabaseConnectionManager().getConnections("foo_db", "ds", 0, 1,
ConnectionMode.MEMORY_STRICTLY).get(0);
connection.setReadOnly(true);
@@ -168,7 +168,7 @@ class ShardingSphereConnectionTest {
@Test
void assertGetTransactionIsolationWithoutCachedConnections() throws
SQLException {
- try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager(), null)) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager())) {
assertThat(connection.getTransactionIsolation(),
is(Connection.TRANSACTION_READ_UNCOMMITTED));
}
@@ -176,7 +176,7 @@ class ShardingSphereConnectionTest {
@Test
void assertSetTransactionIsolation() throws SQLException {
- try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager(), null)) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager())) {
Connection physicalConnection =
connection.getDatabaseConnectionManager().getConnections("foo_db", "ds", 0, 1,
ConnectionMode.MEMORY_STRICTLY).get(0);
connection.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
verify(physicalConnection).setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
@@ -185,7 +185,7 @@ class ShardingSphereConnectionTest {
@Test
void assertClose() throws SQLException {
- try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager(), null)) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection("foo_db", mockContextManager())) {
connection.close();
assertTrue(connection.isClosed());
}
diff --git
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationConnectionTest.java
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationConnectionTest.java
index 5c09e254674..2ae289e4ccd 100644
---
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationConnectionTest.java
+++
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationConnectionTest.java
@@ -44,7 +44,7 @@ class UnsupportedOperationConnectionTest {
void setUp() {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(new
RuleMetaData(Collections.singleton(mock(TransactionRule.class,
RETURNS_DEEP_STUBS))));
- shardingSphereConnection = new ShardingSphereConnection("foo_db",
contextManager, null);
+ shardingSphereConnection = new ShardingSphereConnection("foo_db",
contextManager);
}
@SuppressWarnings("JDBCResourceOpenedButNotSafelyClosed")
diff --git
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationStatementTest.java
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationStatementTest.java
index ed6da52a7ce..cffd4b62731 100644
---
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationStatementTest.java
+++
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationStatementTest.java
@@ -55,7 +55,7 @@ class UnsupportedOperationStatementTest {
new SQLFederationRule(new
DefaultSQLFederationRuleConfigurationBuilder().build(),
Collections.emptyList()),
new SQLParserRule(new
DefaultSQLParserRuleConfigurationBuilder().build()))));
when(connection.getContextManager().getMetaDataContexts().getMetaData().getProps()).thenReturn(new
ConfigurationProperties(new Properties()));
- shardingSphereStatement = new ShardingSphereStatement(connection,
null);
+ shardingSphereStatement = new ShardingSphereStatement(connection);
}
@Test
diff --git
a/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/api/MigrationJobAPI.java
b/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/api/MigrationJobAPI.java
index 04f69fd3eb5..3043aefc834 100644
---
a/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/api/MigrationJobAPI.java
+++
b/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/api/MigrationJobAPI.java
@@ -196,16 +196,16 @@ public final class MigrationJobAPI implements
TransmissionJobAPI {
}
private Collection<YamlRuleConfiguration> getYamlRuleConfigurations(final
Collection<RuleConfiguration> rules) {
- Collection<YamlRuleConfiguration> ruleConfigurations = new
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfigurations(rules);
- Optional<YamlSingleRuleConfiguration> originalSingleRuleConfig =
-
ruleConfigurations.stream().filter(YamlSingleRuleConfiguration.class::isInstance).map(YamlSingleRuleConfiguration.class::cast).findFirst();
-
ruleConfigurations.removeIf(YamlSingleRuleConfiguration.class::isInstance);
+ Collection<YamlRuleConfiguration> result = new
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfigurations(rules);
+ Optional<YamlSingleRuleConfiguration> originalSingleRuleConfig =
result.stream()
+
.filter(YamlSingleRuleConfiguration.class::isInstance).map(YamlSingleRuleConfiguration.class::cast).findFirst();
+ result.removeIf(YamlSingleRuleConfiguration.class::isInstance);
YamlSingleRuleConfiguration singleRuleConfig = new
YamlSingleRuleConfiguration();
- // todo Provide only the necessary tables.
+ // TODO Provide only the necessary tables.
singleRuleConfig.setTables(Collections.singletonList(SingleTableConstants.ALL_TABLES));
originalSingleRuleConfig.ifPresent(optional ->
singleRuleConfig.setDefaultDataSource(optional.getDefaultDataSource()));
- ruleConfigurations.add(singleRuleConfig);
- return ruleConfigurations;
+ result.add(singleRuleConfig);
+ return result;
}
private Map<String, String> buildTargetTableSchemaMap(final Map<String,
List<DataNode>> sourceDataNodes) {