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/12/20 06:27:59 UTC
[shardingsphere] branch master updated: Remove Vert.x from ShardingSphere-Proxy (#22982)
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 497b46fd5d8 Remove Vert.x from ShardingSphere-Proxy (#22982)
497b46fd5d8 is described below
commit 497b46fd5d83ae2e8884752896ad2e30b74a04fd
Author: 吴伟杰 <wu...@apache.org>
AuthorDate: Tue Dec 20 14:27:36 2022 +0800
Remove Vert.x from ShardingSphere-Proxy (#22982)
* Remove Vert.x from ShardingSphere-Proxy
* Update related documents and configurations
* Inline DatabaseCommunicationEngine and BackendConnection
* Update server.yaml in E2E tests
* Inline Portal
* Remove type parameter from ConnectionPostProcessor
* Update RAL documents and tests
* Remove unused Netty dependencies
* Revise javadoc
---
.../jaeger/advice/CommandExecutorTaskAdvice.java | 4 +-
.../zipkin/advice/CommandExecutorTaskAdvice.java | 4 +-
.../proxy-native/src/main/release-docs/LICENSE | 5 -
.../proxy-native/src/main/release-docs/NOTICE | 45 --
.../release-docs/licenses/LICENSE-vertx-core.txt | 491 ---------------------
distribution/proxy/src/main/release-docs/LICENSE | 5 -
distribution/proxy/src/main/release-docs/NOTICE | 45 --
.../release-docs/licenses/LICENSE-vertx-core.txt | 491 ---------------------
.../distsql/syntax/ral/show-dist-variable.cn.md | 5 +-
.../distsql/syntax/ral/show-dist-variable.en.md | 3 +-
.../optional-plugins/_index.cn.md | 1 -
.../optional-plugins/_index.en.md | 1 -
.../config/props/ConfigurationPropertyKey.java | 5 -
.../config/props/ConfigurationPropertiesTest.java | 3 -
infra/executor/pom.xml | 5 -
.../engine/driver/vertx/VertxExecutionUnit.java | 42 --
.../execute/engine/driver/vertx/VertxExecutor.java | 49 --
.../engine/driver/vertx/VertxExecutorCallback.java | 66 ---
.../vertx/VertxMySQLQueryResultMetaData.java | 89 ----
.../query/impl/driver/vertx/VertxQueryResult.java | 79 ----
.../vertx/ExecutorVertxConnectionManager.java | 28 --
.../vertx/ExecutorVertxStatementManager.java | 31 --
.../driver/vertx/VertxExecutionContext.java | 26 --
.../builder/PreparedQueryExecutionUnitBuilder.java | 44 --
.../vertx/builder/VertxExecutionUnitBuilder.java | 31 --
...utor.sql.prepare.driver.SQLExecutionUnitBuilder | 1 -
.../driver/vertx/VertxExecutorCallbackTest.java | 86 ----
pom.xml | 16 -
.../backend/communication/BackendConnection.java | 309 ++++++++++++-
.../communication/DatabaseCommunicationEngine.java | 233 ++++++++--
.../DatabaseCommunicationEngineFactory.java | 22 +-
.../backend/communication/ProxySQLExecutor.java | 10 +-
.../communication/ReactiveProxySQLExecutor.java | 163 -------
.../backend/communication/TransactionManager.java | 22 +-
.../jdbc/JDBCDatabaseCommunicationEngine.java | 243 ----------
.../jdbc/connection/ConnectionPostProcessor.java | 8 +-
.../jdbc/connection/JDBCBackendConnection.java | 336 --------------
.../jdbc/executor/ProxyJDBCExecutor.java | 4 +-
.../callback/ProxyJDBCExecutorCallback.java | 6 +-
.../callback/ProxyJDBCExecutorCallbackFactory.java | 4 +-
.../ProxyPreparedStatementExecutorCallback.java | 4 +-
.../impl/ProxyStatementExecutorCallback.java | 4 +-
...Manager.java => BackendTransactionManager.java} | 32 +-
.../jdbc/transaction/LocalTransactionManager.java | 51 +--
.../vertx/VertxBackendConnection.java | 177 --------
.../vertx/VertxBackendDataSource.java | 156 -------
.../communication/vertx/VertxBackendStatement.java | 47 --
.../vertx/VertxDatabaseCommunicationEngine.java | 99 -----
.../vertx/executor/ProxyReactiveExecutor.java | 63 ---
.../transaction/VertxLocalTransactionManager.java | 77 ----
.../proxy/backend/handler/ProxyBackendHandler.java | 14 -
.../admin/mysql/MySQLAdminExecutorCreator.java | 6 +-
.../executor/UnicastResourceShowExecutor.java | 4 +-
.../data/DatabaseBackendHandlerFactory.java | 6 -
.../data/impl/UnicastDatabaseBackendHandler.java | 16 +-
.../ral/queryable/ShowDistVariableHandler.java | 10 +-
.../ral/queryable/ShowDistVariablesHandler.java | 5 +-
.../handler/distsql/rul/sql/PreviewHandler.java | 3 +-
.../transaction/TransactionBackendHandler.java | 50 +--
.../handler/transaction/TransactionXAHandler.java | 4 +-
.../reactive/context/ReactiveProxyContext.java | 44 --
.../proxy/backend/session/ConnectionSession.java | 23 +-
.../DatabaseCommunicationEngineFactoryTest.java | 5 +-
.../communication/ProxySQLExecutorTest.java | 28 +-
...t.java => DatabaseCommunicationEngineTest.java} | 29 +-
...nectionTest.java => BackendConnectionTest.java} | 44 +-
.../jdbc/connection/MockConnectionUtil.java | 3 +-
...est.java => BackendTransactionManagerTest.java} | 12 +-
.../transaction/LocalTransactionManagerTest.java | 4 +-
.../handler/ProxyBackendHandlerFactoryTest.java | 4 +-
.../mysql/MySQLSetVariableAdminExecutorTest.java | 8 +-
.../data/DatabaseBackendHandlerFactoryTest.java | 7 +-
.../impl/UnicastDatabaseBackendHandlerTest.java | 4 +-
.../ShowDistVariableBackendHandlerTest.java | 2 +-
.../queryable/ShowDistVariablesHandlerTest.java | 2 +-
.../updatable/RefreshTableMetaDataHandlerTest.java | 2 +-
.../SetDistVariableBackendHandlerTest.java | 2 +-
.../TransactionBackendHandlerFactoryTest.java | 15 +-
.../transaction/TransactionBackendHandlerTest.java | 4 +-
.../backend/session/ConnectionSessionTest.java | 10 +-
proxy/bootstrap/pom.xml | 5 -
.../bootstrap/src/main/resources/conf/server.yaml | 2 -
.../proxy/frontend/ShardingSphereProxy.java | 6 -
.../frontend/command/CommandExecutorTask.java | 1 -
.../netty/FrontendChannelInboundHandler.java | 3 +-
.../proxy/frontend/state/ProxyStateContext.java | 11 +-
.../frontend/state/impl/JDBCOKProxyState.java | 73 ---
.../proxy/frontend/state/impl/OKProxyState.java | 48 +-
.../frontend/state/impl/OKProxyStateFactory.java | 44 --
...ngsphere.proxy.frontend.state.impl.OKProxyState | 18 -
.../frontend/command/CommandExecutorTaskTest.java | 4 +-
.../frontend/fixture/FixtureOKProxyState.java | 36 --
.../state/impl/OKProxyStateFactoryTest.java | 33 --
...OKProxyStateTest.java => OKProxyStateTest.java} | 14 +-
...ngsphere.proxy.frontend.state.impl.OKProxyState | 18 -
.../mysql/command/MySQLCommandExecuteEngine.java | 3 +-
.../admin/MySQLComResetConnectionExecutor.java | 7 +-
.../fieldlist/MySQLComFieldListPacketExecutor.java | 8 +-
.../text/query/MySQLMultiStatementsHandler.java | 3 +-
.../command/MySQLCommandExecutorFactoryTest.java | 4 +-
.../admin/MySQLComResetConnectionExecutorTest.java | 8 +-
.../execute/MySQLComStmtExecuteExecutorTest.java | 4 +-
.../query/MySQLMultiStatementsHandlerTest.java | 4 +-
.../query/simple/OpenGaussComQueryExecutor.java | 2 +-
.../bind/OpenGaussComBatchBindExecutorTest.java | 4 +-
proxy/frontend/pom.xml | 3 -
.../frontend/postgresql/command/PortalContext.java | 26 +-
.../command/PostgreSQLCommandExecuteEngine.java | 7 +-
.../command/query/extended/JDBCPortal.java | 207 ---------
.../postgresql/command/query/extended/Portal.java | 190 +++++++-
.../PostgreSQLBatchedStatementsExecutor.java | 3 +-
.../extended/bind/PostgreSQLComBindExecutor.java | 8 +-
.../extended/close/PostgreSQLComCloseExecutor.java | 3 +-
.../describe/PostgreSQLComDescribeExecutor.java | 7 +-
.../execute/PostgreSQLComExecuteExecutor.java | 7 +-
.../query/simple/PostgreSQLComQueryExecutor.java | 2 +-
.../postgresql/command/PortalContextTest.java | 25 +-
.../PostgreSQLCommandExecuteEngineTest.java | 10 +-
.../{JDBCPortalTest.java => PortalTest.java} | 22 +-
...egatedBatchedStatementsCommandExecutorTest.java | 4 +-
.../PostgreSQLBatchedStatementsExecutorTest.java | 4 +-
.../bind/PostgreSQLComBindExecutorTest.java | 8 +-
.../close/PostgreSQLComCloseExecutorTest.java | 5 +-
.../PostgreSQLComDescribeExecutorTest.java | 6 +-
.../execute/PostgreSQLComExecuteExecutorTest.java | 13 +-
proxy/frontend/reactive-core/pom.xml | 41 --
.../command/ReactiveCommandExecuteTask.java | 133 ------
...ctiveDatabaseProtocolFrontendEngineFactory.java | 47 --
.../reactive/state/impl/ReactiveOKProxyState.java | 56 ---
.../wrap/WrappedReactiveCommandExecutor.java | 57 ---
...ngsphere.proxy.frontend.state.impl.OKProxyState | 18 -
.../command/ReactiveCommandExecuteTaskTest.java | 139 ------
...eDatabaseProtocolFrontendEngineFactoryTest.java | 38 --
...ummyReactiveDatabaseProtocolFrontendEngine.java | 67 ---
.../state/impl/ReactiveOKProxyStateTest.java | 56 ---
.../wrap/WrappedReactiveCommandExecutorTest.java | 79 ----
...tive.spi.ReactiveDatabaseProtocolFrontendEngine | 18 -
.../src/test/resources/logback-test.xml | 30 --
proxy/frontend/reactive-mysql/pom.xml | 41 --
.../ReactiveMySQLCommandExecutorFactory.java | 68 ---
.../mysql/command/ReactiveMySQLFrontendEngine.java | 78 ----
.../ReactiveMySQLComStmtExecuteExecutor.java | 182 --------
.../ReactiveMySQLComFieldListPacketExecutor.java | 100 -----
.../query/ReactiveMySQLComQueryPacketExecutor.java | 103 -----
...tive.spi.ReactiveDatabaseProtocolFrontendEngine | 18 -
proxy/frontend/reactive-spi/pom.xml | 36 --
.../command/ReactiveCommandExecuteEngine.java | 39 --
.../command/executor/ReactiveCommandExecutor.java | 45 --
.../ReactiveDatabaseProtocolFrontendEngine.java | 34 --
.../src/test/resources/env/opengauss/server.yaml | 1 -
.../src/test/resources/env/postgresql/server.yaml | 2 -
.../empty_rules/cluster/show_dist_variables.xml | 1 -
.../empty_rules/standalone/show_dist_variables.xml | 1 -
.../src/test/resources/env/opengauss/server.yaml | 1 -
.../src/test/resources/env/postgresql/server.yaml | 2 -
155 files changed, 1005 insertions(+), 5590 deletions(-)
diff --git a/agent/plugins/tracing/type/jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/CommandExecutorTaskAdvice.java b/agent/plugins/tracing/type/jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/CommandExecutorTaskAdvice.java
index cd160a31714..658146683ba 100644
--- a/agent/plugins/tracing/type/jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/CommandExecutorTaskAdvice.java
+++ b/agent/plugins/tracing/type/jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/CommandExecutorTaskAdvice.java
@@ -27,7 +27,7 @@ import org.apache.shardingsphere.agent.advice.MethodInvocationResult;
import org.apache.shardingsphere.agent.plugin.tracing.jaeger.constant.JaegerConstants;
import org.apache.shardingsphere.agent.plugin.tracing.jaeger.span.JaegerErrorSpan;
import org.apache.shardingsphere.infra.executor.kernel.model.ExecutorDataMap;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask;
@@ -55,7 +55,7 @@ public final class CommandExecutorTaskAdvice implements InstanceMethodAdvice {
ExecutorDataMap.getValue().remove(JaegerConstants.ROOT_SPAN);
Field field = CommandExecutorTask.class.getDeclaredField("connectionSession");
field.setAccessible(true);
- JDBCBackendConnection connection = (JDBCBackendConnection) ((ConnectionSession) field.get(target)).getBackendConnection();
+ BackendConnection connection = ((ConnectionSession) field.get(target)).getBackendConnection();
Scope scope = GlobalTracer.get().scopeManager().active();
scope.span().setTag(JaegerConstants.ShardingSphereTags.CONNECTION_COUNT.getKey(), connection.getConnectionSize());
scope.close();
diff --git a/agent/plugins/tracing/type/zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/CommandExecutorTaskAdvice.java b/agent/plugins/tracing/type/zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/CommandExecutorTaskAdvice.java
index bb188a2c847..f9d78e71d07 100644
--- a/agent/plugins/tracing/type/zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/CommandExecutorTaskAdvice.java
+++ b/agent/plugins/tracing/type/zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/CommandExecutorTaskAdvice.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.agent.advice.TargetAdviceObject;
import org.apache.shardingsphere.agent.advice.MethodInvocationResult;
import org.apache.shardingsphere.agent.plugin.tracing.zipkin.constant.ZipkinConstants;
import org.apache.shardingsphere.infra.executor.kernel.model.ExecutorDataMap;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask;
@@ -52,7 +52,7 @@ public final class CommandExecutorTaskAdvice implements InstanceMethodAdvice {
public void afterMethod(final TargetAdviceObject target, final Method method, final Object[] args, final MethodInvocationResult invocationResult) {
Field field = CommandExecutorTask.class.getDeclaredField("connectionSession");
field.setAccessible(true);
- JDBCBackendConnection connection = (JDBCBackendConnection) ((ConnectionSession) field.get(target)).getBackendConnection();
+ BackendConnection connection = ((ConnectionSession) field.get(target)).getBackendConnection();
Span span = (Span) ExecutorDataMap.getValue().remove(ZipkinConstants.ROOT_SPAN);
span.tag(ZipkinConstants.Tags.CONNECTION_COUNT, String.valueOf(connection.getConnectionSize()));
span.finish();
diff --git a/distribution/proxy-native/src/main/release-docs/LICENSE b/distribution/proxy-native/src/main/release-docs/LICENSE
index 1f01a1be21a..48c8c9ec9c6 100644
--- a/distribution/proxy-native/src/main/release-docs/LICENSE
+++ b/distribution/proxy-native/src/main/release-docs/LICENSE
@@ -270,7 +270,6 @@ The text of each license is the standard Apache 2.0 license.
memory 0.9.0, Apache 2.0
netty-buffer 4.1.85.Final: https://github.com/netty, Apache 2.0
netty-codec 4.1.85.Final: https://github.com/netty, Apache 2.0
- netty-codec-dns 4.1.85.Final: https://github.com/netty, Apache 2.0
netty-codec-http 4.1.85.Final: https://github.com/netty, Apache 2.0
netty-codec-http2 4.1.85.Final: https://github.com/netty, Apache 2.0
netty-codec-socks 4.1.85.Final: https://github.com/netty, Apache 2.0
@@ -278,7 +277,6 @@ The text of each license is the standard Apache 2.0 license.
netty-handler 4.1.85.Final: https://github.com/netty, Apache 2.0
netty-handler-proxy 4.1.85.Final: https://github.com/netty, Apache 2.0
netty-resolver 4.1.85.Final: https://github.com/netty, Apache 2.0
- netty-resolver-dns 4.1.85.Final: https://github.com/netty, Apache 2.0
netty-transport 4.1.85.Final: https://github.com/netty, Apache 2.0
netty-transport-classes-epoll 4.1.85.Final: https://github.com/netty, Apache 2.0
netty-transport-native-epoll 4.1.85.Final-linux-aarch_64: https://github.com/netty, Apache 2.0
@@ -291,8 +289,6 @@ The text of each license is the standard Apache 2.0 license.
sketches-core 0.9.0, Apache 2.0
snakeyaml 1.33: https://bitbucket.org/snakeyaml/snakeyaml, Apache 2.0
uzaygezen-core 0.2: https://code.google.com/p/uzaygezen, Apache 2.0
- vertx-mysql-client 4.3.3: https://github.com/eclipse-vertx/vertx-sql-client, Apache 2.0
- vertx-sql-client 4.3.3: https://github.com/eclipse-vertx/vertx-sql-client, Apache 2.0
zookeeper 3.8.0: https://github.com/apache/zookeeper, Apache 2.0
zookeeper-jute 3.8.0: https://github.com/apache/zookeeper, Apache 2.0
@@ -308,7 +304,6 @@ The text of each license is also included at licenses/LICENSE-[project].txt.
transactions-api 5.0.9: https://www.atomikos.com, Apache 2.0
transactions-jdbc 5.0.9: https://www.atomikos.com, Apache 2.0
transactions-jta 5.0.9: https://www.atomikos.com, Apache 2.0
- vertx-core 4.3.3: https://github.com/eclipse-vertx/vert.x, Apache 2.0
========================================================================
BSD licenses
diff --git a/distribution/proxy-native/src/main/release-docs/NOTICE b/distribution/proxy-native/src/main/release-docs/NOTICE
index a9c6ef5108d..c673ee4b9da 100644
--- a/distribution/proxy-native/src/main/release-docs/NOTICE
+++ b/distribution/proxy-native/src/main/release-docs/NOTICE
@@ -387,48 +387,3 @@ SoundCloud Ltd. (http://soundcloud.com/).
This product includes software developed as part of the
Ocelli project by Netflix Inc. (https://github.com/Netflix/ocelli/).
-
-========================================================================
-
-Vert.x NOTICE
-
-========================================================================
-
-This content is produced and maintained by the Eclipse Vert.x project.
-
-* Project home: https://projects.eclipse.org/projects/rt.vertx
-
-Eclipse Vert.x, and Vert.x are trademarks of the Eclipse Foundation. Eclipse,
-and the Eclipse Logo are registered trademarks of the Eclipse Foundation.
-
-## Declared Project Licenses
-
-This program and the accompanying materials are made available under the
-terms of the Eclipse Public License 2.0 which is available at
-http://www.eclipse.org/legal/epl-2.0, or the Apache Software License
-2.0 which is available at https://www.apache.org/licenses/LICENSE-2.0.
-
-SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
-
-## Source Code
-
-The project maintains the following source code repositories:
-
-* https://github.com/eclipse-vertx/vert.x
-
-## Copyright Holders
-
-> See the header in each individual file and https://github.com/eclipse/vert.x/graphs/contributors.
-
-## Third-party Content
-
-> See the declared runtime dependencies in `pom.xml`.
-
-## Cryptography
-
-Content may contain encryption software. The country in which you are currently
-may have restrictions on the import, possession, and use, and/or re-export to
-another country, of encryption software. BEFORE using any encryption software,
-please check the country's laws, regulations and policies concerning the import,
-possession, or use, and re-export of encryption software, to see if this is
-permitted.
diff --git a/distribution/proxy-native/src/main/release-docs/licenses/LICENSE-vertx-core.txt b/distribution/proxy-native/src/main/release-docs/licenses/LICENSE-vertx-core.txt
deleted file mode 100644
index d6023804894..00000000000
--- a/distribution/proxy-native/src/main/release-docs/licenses/LICENSE-vertx-core.txt
+++ /dev/null
@@ -1,491 +0,0 @@
-vertx-core License
----------------
-
-This program and the accompanying materials are made available under the
-terms of the Eclipse Public License 2.0 which is available at
-http://www.eclipse.org/legal/epl-2.0, or the Apache Software License
-2.0 which is available at https://www.apache.org/licenses/LICENSE-2.0.
-
-## Eclipse Public License - Version 2.0
-
- Eclipse Public License - v 2.0
-
- THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
- PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION
- OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
-
- 1. DEFINITIONS
-
- "Contribution" means:
-
- a) in the case of the initial Contributor, the initial content
- Distributed under this Agreement, and
-
- b) in the case of each subsequent Contributor:
- i) changes to the Program, and
- ii) additions to the Program;
- where such changes and/or additions to the Program originate from
- and are Distributed by that particular Contributor. A Contribution
- "originates" from a Contributor if it was added to the Program by
- such Contributor itself or anyone acting on such Contributor's behalf.
- Contributions do not include changes or additions to the Program that
- are not Modified Works.
-
- "Contributor" means any person or entity that Distributes the Program.
-
- "Licensed Patents" mean patent claims licensable by a Contributor which
- are necessarily infringed by the use or sale of its Contribution alone
- or when combined with the Program.
-
- "Program" means the Contributions Distributed in accordance with this
- Agreement.
-
- "Recipient" means anyone who receives the Program under this Agreement
- or any Secondary License (as applicable), including Contributors.
-
- "Derivative Works" shall mean any work, whether in Source Code or other
- form, that is based on (or derived from) the Program and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship.
-
- "Modified Works" shall mean any work in Source Code or other form that
- results from an addition to, deletion from, or modification of the
- contents of the Program, including, for purposes of clarity any new file
- in Source Code form that contains any contents of the Program. Modified
- Works shall not include works that contain only declarations,
- interfaces, types, classes, structures, or files of the Program solely
- in each case in order to link to, bind by name, or subclass the Program
- or Modified Works thereof.
-
- "Distribute" means the acts of a) distributing or b) making available
- in any manner that enables the transfer of a copy.
-
- "Source Code" means the form of a Program preferred for making
- modifications, including but not limited to software source code,
- documentation source, and configuration files.
-
- "Secondary License" means either the GNU General Public License,
- Version 2.0, or any later versions of that license, including any
- exceptions or additional permissions as identified by the initial
- Contributor.
-
- 2. GRANT OF RIGHTS
-
- a) Subject to the terms of this Agreement, each Contributor hereby
- grants Recipient a non-exclusive, worldwide, royalty-free copyright
- license to reproduce, prepare Derivative Works of, publicly display,
- publicly perform, Distribute and sublicense the Contribution of such
- Contributor, if any, and such Derivative Works.
-
- b) Subject to the terms of this Agreement, each Contributor hereby
- grants Recipient a non-exclusive, worldwide, royalty-free patent
- license under Licensed Patents to make, use, sell, offer to sell,
- import and otherwise transfer the Contribution of such Contributor,
- if any, in Source Code or other form. This patent license shall
- apply to the combination of the Contribution and the Program if, at
- the time the Contribution is added by the Contributor, such addition
- of the Contribution causes such combination to be covered by the
- Licensed Patents. The patent license shall not apply to any other
- combinations which include the Contribution. No hardware per se is
- licensed hereunder.
-
- c) Recipient understands that although each Contributor grants the
- licenses to its Contributions set forth herein, no assurances are
- provided by any Contributor that the Program does not infringe the
- patent or other intellectual property rights of any other entity.
- Each Contributor disclaims any liability to Recipient for claims
- brought by any other entity based on infringement of intellectual
- property rights or otherwise. As a condition to exercising the
- rights and licenses granted hereunder, each Recipient hereby
- assumes sole responsibility to secure any other intellectual
- property rights needed, if any. For example, if a third party
- patent license is required to allow Recipient to Distribute the
- Program, it is Recipient's responsibility to acquire that license
- before distributing the Program.
-
- d) Each Contributor represents that to its knowledge it has
- sufficient copyright rights in its Contribution, if any, to grant
- the copyright license set forth in this Agreement.
-
- e) Notwithstanding the terms of any Secondary License, no
- Contributor makes additional grants to any Recipient (other than
- those set forth in this Agreement) as a result of such Recipient's
- receipt of the Program under the terms of a Secondary License
- (if permitted under the terms of Section 3).
-
- 3. REQUIREMENTS
-
- 3.1 If a Contributor Distributes the Program in any form, then:
-
- a) the Program must also be made available as Source Code, in
- accordance with section 3.2, and the Contributor must accompany
- the Program with a statement that the Source Code for the Program
- is available under this Agreement, and informs Recipients how to
- obtain it in a reasonable manner on or through a medium customarily
- used for software exchange; and
-
- b) the Contributor may Distribute the Program under a license
- different than this Agreement, provided that such license:
- i) effectively disclaims on behalf of all other Contributors all
- warranties and conditions, express and implied, including
- warranties or conditions of title and non-infringement, and
- implied warranties or conditions of merchantability and fitness
- for a particular purpose;
-
- ii) effectively excludes on behalf of all other Contributors all
- liability for damages, including direct, indirect, special,
- incidental and consequential damages, such as lost profits;
-
- iii) does not attempt to limit or alter the recipients' rights
- in the Source Code under section 3.2; and
-
- iv) requires any subsequent distribution of the Program by any
- party to be under a license that satisfies the requirements
- of this section 3.
-
- 3.2 When the Program is Distributed as Source Code:
-
- a) it must be made available under this Agreement, or if the
- Program (i) is combined with other material in a separate file or
- files made available under a Secondary License, and (ii) the initial
- Contributor attached to the Source Code the notice described in
- Exhibit A of this Agreement, then the Program may be made available
- under the terms of such Secondary Licenses, and
-
- b) a copy of this Agreement must be included with each copy of
- the Program.
-
- 3.3 Contributors may not remove or alter any copyright, patent,
- trademark, attribution notices, disclaimers of warranty, or limitations
- of liability ("notices") contained within the Program from any copy of
- the Program which they Distribute, provided that Contributors may add
- their own appropriate notices.
-
- 4. COMMERCIAL DISTRIBUTION
-
- Commercial distributors of software may accept certain responsibilities
- with respect to end users, business partners and the like. While this
- license is intended to facilitate the commercial use of the Program,
- the Contributor who includes the Program in a commercial product
- offering should do so in a manner which does not create potential
- liability for other Contributors. Therefore, if a Contributor includes
- the Program in a commercial product offering, such Contributor
- ("Commercial Contributor") hereby agrees to defend and indemnify every
- other Contributor ("Indemnified Contributor") against any losses,
- damages and costs (collectively "Losses") arising from claims, lawsuits
- and other legal actions brought by a third party against the Indemnified
- Contributor to the extent caused by the acts or omissions of such
- Commercial Contributor in connection with its distribution of the Program
- in a commercial product offering. The obligations in this section do not
- apply to any claims or Losses relating to any actual or alleged
- intellectual property infringement. In order to qualify, an Indemnified
- Contributor must: a) promptly notify the Commercial Contributor in
- writing of such claim, and b) allow the Commercial Contributor to control,
- and cooperate with the Commercial Contributor in, the defense and any
- related settlement negotiations. The Indemnified Contributor may
- participate in any such claim at its own expense.
-
- For example, a Contributor might include the Program in a commercial
- product offering, Product X. That Contributor is then a Commercial
- Contributor. If that Commercial Contributor then makes performance
- claims, or offers warranties related to Product X, those performance
- claims and warranties are such Commercial Contributor's responsibility
- alone. Under this section, the Commercial Contributor would have to
- defend claims against the other Contributors related to those performance
- claims and warranties, and if a court requires any other Contributor to
- pay any damages as a result, the Commercial Contributor must pay
- those damages.
-
- 5. NO WARRANTY
-
- EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
- PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS"
- BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
- IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF
- TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
- PURPOSE. Each Recipient is solely responsible for determining the
- appropriateness of using and distributing the Program and assumes all
- risks associated with its exercise of rights under this Agreement,
- including but not limited to the risks and costs of program errors,
- compliance with applicable laws, damage to or loss of data, programs
- or equipment, and unavailability or interruption of operations.
-
- 6. DISCLAIMER OF LIABILITY
-
- EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
- PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS
- SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
- PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
- EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGES.
-
- 7. GENERAL
-
- If any provision of this Agreement is invalid or unenforceable under
- applicable law, it shall not affect the validity or enforceability of
- the remainder of the terms of this Agreement, and without further
- action by the parties hereto, such provision shall be reformed to the
- minimum extent necessary to make such provision valid and enforceable.
-
- If Recipient institutes patent litigation against any entity
- (including a cross-claim or counterclaim in a lawsuit) alleging that the
- Program itself (excluding combinations of the Program with other software
- or hardware) infringes such Recipient's patent(s), then such Recipient's
- rights granted under Section 2(b) shall terminate as of the date such
- litigation is filed.
-
- All Recipient's rights under this Agreement shall terminate if it
- fails to comply with any of the material terms or conditions of this
- Agreement and does not cure such failure in a reasonable period of
- time after becoming aware of such noncompliance. If all Recipient's
- rights under this Agreement terminate, Recipient agrees to cease use
- and distribution of the Program as soon as reasonably practicable.
- However, Recipient's obligations under this Agreement and any licenses
- granted by Recipient relating to the Program shall continue and survive.
-
- Everyone is permitted to copy and distribute copies of this Agreement,
- but in order to avoid inconsistency the Agreement is copyrighted and
- may only be modified in the following manner. The Agreement Steward
- reserves the right to publish new versions (including revisions) of
- this Agreement from time to time. No one other than the Agreement
- Steward has the right to modify this Agreement. The Eclipse Foundation
- is the initial Agreement Steward. The Eclipse Foundation may assign the
- responsibility to serve as the Agreement Steward to a suitable separate
- entity. Each new version of the Agreement will be given a distinguishing
- version number. The Program (including Contributions) may always be
- Distributed subject to the version of the Agreement under which it was
- received. In addition, after a new version of the Agreement is published,
- Contributor may elect to Distribute the Program (including its
- Contributions) under the new version.
-
- Except as expressly stated in Sections 2(a) and 2(b) above, Recipient
- receives no rights or licenses to the intellectual property of any
- Contributor under this Agreement, whether expressly, by implication,
- estoppel or otherwise. All rights in the Program not expressly granted
- under this Agreement are reserved. Nothing in this Agreement is intended
- to be enforceable by any entity that is not a Contributor or Recipient.
- No third-party beneficiary rights are created under this Agreement.
-
- Exhibit A - Form of Secondary Licenses Notice
-
- "This Source Code may also be made available under the following
- Secondary Licenses when the conditions for such availability set forth
- in the Eclipse Public License, v. 2.0 are satisfied: {name license(s),
- version(s), and exceptions or additional permissions here}."
-
- Simply including a copy of this Agreement, including this Exhibit A
- is not sufficient to license the Source Code under Secondary Licenses.
-
- If it is not possible or desirable to put the notice in a particular
- file, then You may include the notice in a location (such as a LICENSE
- file in a relevant directory) where a recipient would be likely to
- look for such a notice.
-
- You may add additional accurate notices of copyright ownership.
-
-## Apache License - Version 2.0
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/distribution/proxy/src/main/release-docs/LICENSE b/distribution/proxy/src/main/release-docs/LICENSE
index a8ca6f08cf3..a631bde2cc7 100644
--- a/distribution/proxy/src/main/release-docs/LICENSE
+++ b/distribution/proxy/src/main/release-docs/LICENSE
@@ -270,7 +270,6 @@ The text of each license is the standard Apache 2.0 license.
memory 0.9.0, Apache 2.0
netty-buffer 4.1.85.Final: https://github.com/netty, Apache 2.0
netty-codec 4.1.85.Final: https://github.com/netty, Apache 2.0
- netty-codec-dns 4.1.85.Final: https://github.com/netty, Apache 2.0
netty-codec-http 4.1.85.Final: https://github.com/netty, Apache 2.0
netty-codec-http2 4.1.85.Final: https://github.com/netty, Apache 2.0
netty-codec-socks 4.1.85.Final: https://github.com/netty, Apache 2.0
@@ -278,7 +277,6 @@ The text of each license is the standard Apache 2.0 license.
netty-handler 4.1.85.Final: https://github.com/netty, Apache 2.0
netty-handler-proxy 4.1.85.Final: https://github.com/netty, Apache 2.0
netty-resolver 4.1.85.Final: https://github.com/netty, Apache 2.0
- netty-resolver-dns 4.1.85.Final: https://github.com/netty, Apache 2.0
netty-tcnative 2.0.48.Final: https://github.com/netty/netty-tcnative, Apache 2.0
netty-tcnative-classes 2.0.48.Final: https://github.com/netty/netty-tcnative, Apache 2.0
netty-transport 4.1.85.Final: https://github.com/netty, Apache 2.0
@@ -293,8 +291,6 @@ The text of each license is the standard Apache 2.0 license.
sketches-core 0.9.0, Apache 2.0
snakeyaml 1.33: https://bitbucket.org/snakeyaml/snakeyaml, Apache 2.0
uzaygezen-core 0.2: https://code.google.com/p/uzaygezen, Apache 2.0
- vertx-mysql-client 4.3.3: https://github.com/eclipse-vertx/vertx-sql-client, Apache 2.0
- vertx-sql-client 4.3.3: https://github.com/eclipse-vertx/vertx-sql-client, Apache 2.0
zookeeper 3.8.0: https://github.com/apache/zookeeper, Apache 2.0
zookeeper-jute 3.8.0: https://github.com/apache/zookeeper, Apache 2.0
@@ -310,7 +306,6 @@ The text of each license is also included at licenses/LICENSE-[project].txt.
transactions-api 5.0.9: https://www.atomikos.com, Apache 2.0
transactions-jdbc 5.0.9: https://www.atomikos.com, Apache 2.0
transactions-jta 5.0.9: https://www.atomikos.com, Apache 2.0
- vertx-core 4.3.3: https://github.com/eclipse-vertx/vert.x, Apache 2.0
========================================================================
BSD licenses
diff --git a/distribution/proxy/src/main/release-docs/NOTICE b/distribution/proxy/src/main/release-docs/NOTICE
index a9c6ef5108d..c673ee4b9da 100644
--- a/distribution/proxy/src/main/release-docs/NOTICE
+++ b/distribution/proxy/src/main/release-docs/NOTICE
@@ -387,48 +387,3 @@ SoundCloud Ltd. (http://soundcloud.com/).
This product includes software developed as part of the
Ocelli project by Netflix Inc. (https://github.com/Netflix/ocelli/).
-
-========================================================================
-
-Vert.x NOTICE
-
-========================================================================
-
-This content is produced and maintained by the Eclipse Vert.x project.
-
-* Project home: https://projects.eclipse.org/projects/rt.vertx
-
-Eclipse Vert.x, and Vert.x are trademarks of the Eclipse Foundation. Eclipse,
-and the Eclipse Logo are registered trademarks of the Eclipse Foundation.
-
-## Declared Project Licenses
-
-This program and the accompanying materials are made available under the
-terms of the Eclipse Public License 2.0 which is available at
-http://www.eclipse.org/legal/epl-2.0, or the Apache Software License
-2.0 which is available at https://www.apache.org/licenses/LICENSE-2.0.
-
-SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
-
-## Source Code
-
-The project maintains the following source code repositories:
-
-* https://github.com/eclipse-vertx/vert.x
-
-## Copyright Holders
-
-> See the header in each individual file and https://github.com/eclipse/vert.x/graphs/contributors.
-
-## Third-party Content
-
-> See the declared runtime dependencies in `pom.xml`.
-
-## Cryptography
-
-Content may contain encryption software. The country in which you are currently
-may have restrictions on the import, possession, and use, and/or re-export to
-another country, of encryption software. BEFORE using any encryption software,
-please check the country's laws, regulations and policies concerning the import,
-possession, or use, and re-export of encryption software, to see if this is
-permitted.
diff --git a/distribution/proxy/src/main/release-docs/licenses/LICENSE-vertx-core.txt b/distribution/proxy/src/main/release-docs/licenses/LICENSE-vertx-core.txt
deleted file mode 100644
index d6023804894..00000000000
--- a/distribution/proxy/src/main/release-docs/licenses/LICENSE-vertx-core.txt
+++ /dev/null
@@ -1,491 +0,0 @@
-vertx-core License
----------------
-
-This program and the accompanying materials are made available under the
-terms of the Eclipse Public License 2.0 which is available at
-http://www.eclipse.org/legal/epl-2.0, or the Apache Software License
-2.0 which is available at https://www.apache.org/licenses/LICENSE-2.0.
-
-## Eclipse Public License - Version 2.0
-
- Eclipse Public License - v 2.0
-
- THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
- PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION
- OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
-
- 1. DEFINITIONS
-
- "Contribution" means:
-
- a) in the case of the initial Contributor, the initial content
- Distributed under this Agreement, and
-
- b) in the case of each subsequent Contributor:
- i) changes to the Program, and
- ii) additions to the Program;
- where such changes and/or additions to the Program originate from
- and are Distributed by that particular Contributor. A Contribution
- "originates" from a Contributor if it was added to the Program by
- such Contributor itself or anyone acting on such Contributor's behalf.
- Contributions do not include changes or additions to the Program that
- are not Modified Works.
-
- "Contributor" means any person or entity that Distributes the Program.
-
- "Licensed Patents" mean patent claims licensable by a Contributor which
- are necessarily infringed by the use or sale of its Contribution alone
- or when combined with the Program.
-
- "Program" means the Contributions Distributed in accordance with this
- Agreement.
-
- "Recipient" means anyone who receives the Program under this Agreement
- or any Secondary License (as applicable), including Contributors.
-
- "Derivative Works" shall mean any work, whether in Source Code or other
- form, that is based on (or derived from) the Program and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship.
-
- "Modified Works" shall mean any work in Source Code or other form that
- results from an addition to, deletion from, or modification of the
- contents of the Program, including, for purposes of clarity any new file
- in Source Code form that contains any contents of the Program. Modified
- Works shall not include works that contain only declarations,
- interfaces, types, classes, structures, or files of the Program solely
- in each case in order to link to, bind by name, or subclass the Program
- or Modified Works thereof.
-
- "Distribute" means the acts of a) distributing or b) making available
- in any manner that enables the transfer of a copy.
-
- "Source Code" means the form of a Program preferred for making
- modifications, including but not limited to software source code,
- documentation source, and configuration files.
-
- "Secondary License" means either the GNU General Public License,
- Version 2.0, or any later versions of that license, including any
- exceptions or additional permissions as identified by the initial
- Contributor.
-
- 2. GRANT OF RIGHTS
-
- a) Subject to the terms of this Agreement, each Contributor hereby
- grants Recipient a non-exclusive, worldwide, royalty-free copyright
- license to reproduce, prepare Derivative Works of, publicly display,
- publicly perform, Distribute and sublicense the Contribution of such
- Contributor, if any, and such Derivative Works.
-
- b) Subject to the terms of this Agreement, each Contributor hereby
- grants Recipient a non-exclusive, worldwide, royalty-free patent
- license under Licensed Patents to make, use, sell, offer to sell,
- import and otherwise transfer the Contribution of such Contributor,
- if any, in Source Code or other form. This patent license shall
- apply to the combination of the Contribution and the Program if, at
- the time the Contribution is added by the Contributor, such addition
- of the Contribution causes such combination to be covered by the
- Licensed Patents. The patent license shall not apply to any other
- combinations which include the Contribution. No hardware per se is
- licensed hereunder.
-
- c) Recipient understands that although each Contributor grants the
- licenses to its Contributions set forth herein, no assurances are
- provided by any Contributor that the Program does not infringe the
- patent or other intellectual property rights of any other entity.
- Each Contributor disclaims any liability to Recipient for claims
- brought by any other entity based on infringement of intellectual
- property rights or otherwise. As a condition to exercising the
- rights and licenses granted hereunder, each Recipient hereby
- assumes sole responsibility to secure any other intellectual
- property rights needed, if any. For example, if a third party
- patent license is required to allow Recipient to Distribute the
- Program, it is Recipient's responsibility to acquire that license
- before distributing the Program.
-
- d) Each Contributor represents that to its knowledge it has
- sufficient copyright rights in its Contribution, if any, to grant
- the copyright license set forth in this Agreement.
-
- e) Notwithstanding the terms of any Secondary License, no
- Contributor makes additional grants to any Recipient (other than
- those set forth in this Agreement) as a result of such Recipient's
- receipt of the Program under the terms of a Secondary License
- (if permitted under the terms of Section 3).
-
- 3. REQUIREMENTS
-
- 3.1 If a Contributor Distributes the Program in any form, then:
-
- a) the Program must also be made available as Source Code, in
- accordance with section 3.2, and the Contributor must accompany
- the Program with a statement that the Source Code for the Program
- is available under this Agreement, and informs Recipients how to
- obtain it in a reasonable manner on or through a medium customarily
- used for software exchange; and
-
- b) the Contributor may Distribute the Program under a license
- different than this Agreement, provided that such license:
- i) effectively disclaims on behalf of all other Contributors all
- warranties and conditions, express and implied, including
- warranties or conditions of title and non-infringement, and
- implied warranties or conditions of merchantability and fitness
- for a particular purpose;
-
- ii) effectively excludes on behalf of all other Contributors all
- liability for damages, including direct, indirect, special,
- incidental and consequential damages, such as lost profits;
-
- iii) does not attempt to limit or alter the recipients' rights
- in the Source Code under section 3.2; and
-
- iv) requires any subsequent distribution of the Program by any
- party to be under a license that satisfies the requirements
- of this section 3.
-
- 3.2 When the Program is Distributed as Source Code:
-
- a) it must be made available under this Agreement, or if the
- Program (i) is combined with other material in a separate file or
- files made available under a Secondary License, and (ii) the initial
- Contributor attached to the Source Code the notice described in
- Exhibit A of this Agreement, then the Program may be made available
- under the terms of such Secondary Licenses, and
-
- b) a copy of this Agreement must be included with each copy of
- the Program.
-
- 3.3 Contributors may not remove or alter any copyright, patent,
- trademark, attribution notices, disclaimers of warranty, or limitations
- of liability ("notices") contained within the Program from any copy of
- the Program which they Distribute, provided that Contributors may add
- their own appropriate notices.
-
- 4. COMMERCIAL DISTRIBUTION
-
- Commercial distributors of software may accept certain responsibilities
- with respect to end users, business partners and the like. While this
- license is intended to facilitate the commercial use of the Program,
- the Contributor who includes the Program in a commercial product
- offering should do so in a manner which does not create potential
- liability for other Contributors. Therefore, if a Contributor includes
- the Program in a commercial product offering, such Contributor
- ("Commercial Contributor") hereby agrees to defend and indemnify every
- other Contributor ("Indemnified Contributor") against any losses,
- damages and costs (collectively "Losses") arising from claims, lawsuits
- and other legal actions brought by a third party against the Indemnified
- Contributor to the extent caused by the acts or omissions of such
- Commercial Contributor in connection with its distribution of the Program
- in a commercial product offering. The obligations in this section do not
- apply to any claims or Losses relating to any actual or alleged
- intellectual property infringement. In order to qualify, an Indemnified
- Contributor must: a) promptly notify the Commercial Contributor in
- writing of such claim, and b) allow the Commercial Contributor to control,
- and cooperate with the Commercial Contributor in, the defense and any
- related settlement negotiations. The Indemnified Contributor may
- participate in any such claim at its own expense.
-
- For example, a Contributor might include the Program in a commercial
- product offering, Product X. That Contributor is then a Commercial
- Contributor. If that Commercial Contributor then makes performance
- claims, or offers warranties related to Product X, those performance
- claims and warranties are such Commercial Contributor's responsibility
- alone. Under this section, the Commercial Contributor would have to
- defend claims against the other Contributors related to those performance
- claims and warranties, and if a court requires any other Contributor to
- pay any damages as a result, the Commercial Contributor must pay
- those damages.
-
- 5. NO WARRANTY
-
- EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
- PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS"
- BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
- IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF
- TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
- PURPOSE. Each Recipient is solely responsible for determining the
- appropriateness of using and distributing the Program and assumes all
- risks associated with its exercise of rights under this Agreement,
- including but not limited to the risks and costs of program errors,
- compliance with applicable laws, damage to or loss of data, programs
- or equipment, and unavailability or interruption of operations.
-
- 6. DISCLAIMER OF LIABILITY
-
- EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
- PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS
- SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
- PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
- EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGES.
-
- 7. GENERAL
-
- If any provision of this Agreement is invalid or unenforceable under
- applicable law, it shall not affect the validity or enforceability of
- the remainder of the terms of this Agreement, and without further
- action by the parties hereto, such provision shall be reformed to the
- minimum extent necessary to make such provision valid and enforceable.
-
- If Recipient institutes patent litigation against any entity
- (including a cross-claim or counterclaim in a lawsuit) alleging that the
- Program itself (excluding combinations of the Program with other software
- or hardware) infringes such Recipient's patent(s), then such Recipient's
- rights granted under Section 2(b) shall terminate as of the date such
- litigation is filed.
-
- All Recipient's rights under this Agreement shall terminate if it
- fails to comply with any of the material terms or conditions of this
- Agreement and does not cure such failure in a reasonable period of
- time after becoming aware of such noncompliance. If all Recipient's
- rights under this Agreement terminate, Recipient agrees to cease use
- and distribution of the Program as soon as reasonably practicable.
- However, Recipient's obligations under this Agreement and any licenses
- granted by Recipient relating to the Program shall continue and survive.
-
- Everyone is permitted to copy and distribute copies of this Agreement,
- but in order to avoid inconsistency the Agreement is copyrighted and
- may only be modified in the following manner. The Agreement Steward
- reserves the right to publish new versions (including revisions) of
- this Agreement from time to time. No one other than the Agreement
- Steward has the right to modify this Agreement. The Eclipse Foundation
- is the initial Agreement Steward. The Eclipse Foundation may assign the
- responsibility to serve as the Agreement Steward to a suitable separate
- entity. Each new version of the Agreement will be given a distinguishing
- version number. The Program (including Contributions) may always be
- Distributed subject to the version of the Agreement under which it was
- received. In addition, after a new version of the Agreement is published,
- Contributor may elect to Distribute the Program (including its
- Contributions) under the new version.
-
- Except as expressly stated in Sections 2(a) and 2(b) above, Recipient
- receives no rights or licenses to the intellectual property of any
- Contributor under this Agreement, whether expressly, by implication,
- estoppel or otherwise. All rights in the Program not expressly granted
- under this Agreement are reserved. Nothing in this Agreement is intended
- to be enforceable by any entity that is not a Contributor or Recipient.
- No third-party beneficiary rights are created under this Agreement.
-
- Exhibit A - Form of Secondary Licenses Notice
-
- "This Source Code may also be made available under the following
- Secondary Licenses when the conditions for such availability set forth
- in the Eclipse Public License, v. 2.0 are satisfied: {name license(s),
- version(s), and exceptions or additional permissions here}."
-
- Simply including a copy of this Agreement, including this Exhibit A
- is not sufficient to license the Source Code under Secondary Licenses.
-
- If it is not possible or desirable to put the notice in a particular
- file, then You may include the notice in a location (such as a LICENSE
- file in a relevant directory) where a recipient would be likely to
- look for such a notice.
-
- You may add additional accurate notices of copyright ownership.
-
-## Apache License - Version 2.0
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/docs/document/content/reference/distsql/syntax/ral/show-dist-variable.cn.md b/docs/document/content/reference/distsql/syntax/ral/show-dist-variable.cn.md
index 4b2b18b8444..809b2e599f5 100644
--- a/docs/document/content/reference/distsql/syntax/ral/show-dist-variable.cn.md
+++ b/docs/document/content/reference/distsql/syntax/ral/show-dist-variable.cn.md
@@ -54,7 +54,6 @@ mysql> SHOW DIST VARIABLES;
| proxy_frontend_executor_size | 0 |
| proxy_backend_executor_suitable | OLAP |
| proxy_frontend_max_connections | 0 |
-| proxy_backend_driver_type | JDBC |
| proxy_mysql_default_version | 5.7.22 |
| proxy_default_port | 3307 |
| proxy_netty_backlog | 1024 |
@@ -64,7 +63,7 @@ mysql> SHOW DIST VARIABLES;
| cached_connections | 0 |
| transaction_type | LOCAL |
+---------------------------------------+----------------+
-22 rows in set (0.01 sec)
+21 rows in set (0.01 sec)
```
- 查询指定 `PROXY` 系统变量配置
@@ -89,4 +88,4 @@ mysql> SHOW DIST VARIABLE WHERE NAME = sql_show;
### 相关链接
-- [保留字](/cn/reference/distsql/syntax/reserved-word/)
\ No newline at end of file
+- [保留字](/cn/reference/distsql/syntax/reserved-word/)
diff --git a/docs/document/content/reference/distsql/syntax/ral/show-dist-variable.en.md b/docs/document/content/reference/distsql/syntax/ral/show-dist-variable.en.md
index 86334804a99..79145f8d0e0 100644
--- a/docs/document/content/reference/distsql/syntax/ral/show-dist-variable.en.md
+++ b/docs/document/content/reference/distsql/syntax/ral/show-dist-variable.en.md
@@ -54,7 +54,6 @@ mysql> SHOW DIST VARIABLES;
| proxy_frontend_executor_size | 0 |
| proxy_backend_executor_suitable | OLAP |
| proxy_frontend_max_connections | 0 |
-| proxy_backend_driver_type | JDBC |
| proxy_mysql_default_version | 5.7.22 |
| proxy_default_port | 3307 |
| proxy_netty_backlog | 1024 |
@@ -64,7 +63,7 @@ mysql> SHOW DIST VARIABLES;
| cached_connections | 0 |
| transaction_type | LOCAL |
+---------------------------------------+----------------+
-22 rows in set (0.01 sec)
+21 rows in set (0.01 sec)
```
- Query specified system variable configuration of `PROXY`
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/optional-plugins/_index.cn.md b/docs/document/content/user-manual/shardingsphere-proxy/optional-plugins/_index.cn.md
index 020fb49a42b..c9f7a126787 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/optional-plugins/_index.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/optional-plugins/_index.cn.md
@@ -16,7 +16,6 @@ ShardingSphere 默认情况下仅包含核心 SPI 的实现,在 Git Source 存
- `org.apache.shardingsphere:shardingsphere-opengauss-protocol`,数据库协议的 OpenGauss 实现
- `org.apache.shardingsphere:shardingsphere-proxy-frontend-core`,用于 ShardingSphere-Proxy 解析与适配访问数据库的协议
- `org.apache.shardingsphere:shardingsphere-proxy-frontend-mysql`,用于 ShardingSphere-Proxy 解析与适配访问数据库的协议的 MySQL 实现
-- `org.apache.shardingsphere:shardingsphere-proxy-frontend-reactive-mysql`,用于 ShardingSphere-Proxy 解析与适配访问数据库的协议的 MySQL 的 `vertx-sql-client` 实现
- `org.apache.shardingsphere:shardingsphere-proxy-frontend-postgresql`,用于 ShardingSphere-Proxy 解析与适配访问数据库的协议的 PostgresSQL 实现
- `org.apache.shardingsphere:shardingsphere-proxy-frontend-opengauss`,用于 ShardingSphere-Proxy 解析与适配访问数据库的协议的 openGauss 实现
- `org.apache.shardingsphere:shardingsphere-proxy-backend`,ShardingSphere Proxy 的后端
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/optional-plugins/_index.en.md b/docs/document/content/user-manual/shardingsphere-proxy/optional-plugins/_index.en.md
index 023ae8f347a..6e1c04946a6 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/optional-plugins/_index.en.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/optional-plugins/_index.en.md
@@ -18,7 +18,6 @@ All built-in plugins are listed below in the form of `groupId:artifactId`.
- `org.apache.shardingsphere:shardingsphere-opengauss-protocol`, the OpenGauss implementation of the database protocol
- `org.apache.shardingsphere:shardingsphere-proxy-frontend-core`, used by ShardingSphere-Proxy to parse and adapt the protocol for accessing the database
- `org.apache.shardingsphere:shardingsphere-proxy-frontend-mysql`, a MySQL implementation for ShardingSphere-Proxy to parse and adapt the protocol for accessing the database
-- `org.apache.shardingsphere:shardingsphere-proxy-frontend-reactive-mysql`, the `vertx-sql-client` implementation of MySQL for ShardingSphere-Proxy to parse and adapt the protocol for accessing the database
- `org.apache.shardingsphere:shardingsphere-proxy-frontend-postgresql`, a PostgresSQL implementation for ShardingSphere-Proxy to parse and adapt the protocol for accessing the database
- `org.apache.shardingsphere:shardingsphere-proxy-frontend-opengauss`, an openGauss implementation for ShardingSphere-Proxy to parse and adapt the protocol for accessing the database
- `org.apache.shardingsphere:shardingsphere-proxy-backend`, the backend for ShardingSphere Proxy
diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertyKey.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertyKey.java
index 0f9ba44f021..a4568dfa096 100644
--- a/infra/common/src/main/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertyKey.java
+++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertyKey.java
@@ -99,11 +99,6 @@ public enum ConfigurationPropertyKey implements TypedPropertyKey {
*/
PROXY_FRONTEND_MAX_CONNECTIONS("proxy-frontend-max-connections", "0", int.class, false),
- /**
- * Proxy backend driver type.
- */
- PROXY_BACKEND_DRIVER_TYPE("proxy-backend-driver-type", "JDBC", String.class, true),
-
/**
* Proxy MySQL default version.
*/
diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertiesTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertiesTest.java
index a9c4eb14c4e..f6751156f23 100644
--- a/infra/common/src/test/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertiesTest.java
+++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertiesTest.java
@@ -44,7 +44,6 @@ public final class ConfigurationPropertiesTest {
assertThat(actual.getValue(ConfigurationPropertyKey.PROXY_FRONTEND_EXECUTOR_SIZE), is(20));
assertThat(actual.getValue(ConfigurationPropertyKey.PROXY_BACKEND_EXECUTOR_SUITABLE), is(BackendExecutorType.OLTP));
assertThat(actual.getValue(ConfigurationPropertyKey.PROXY_FRONTEND_MAX_CONNECTIONS), is(20));
- assertThat(actual.getValue(ConfigurationPropertyKey.PROXY_BACKEND_DRIVER_TYPE), is("JDBC"));
assertThat(actual.getValue(ConfigurationPropertyKey.PROXY_MYSQL_DEFAULT_VERSION), is("5.7.22"));
assertThat(actual.getValue(ConfigurationPropertyKey.PROXY_DEFAULT_PORT), is(3308));
assertThat(actual.getValue(ConfigurationPropertyKey.PROXY_NETTY_BACKLOG), is(1024));
@@ -65,7 +64,6 @@ public final class ConfigurationPropertiesTest {
result.setProperty(ConfigurationPropertyKey.PROXY_FRONTEND_EXECUTOR_SIZE.getKey(), "20");
result.setProperty(ConfigurationPropertyKey.PROXY_BACKEND_EXECUTOR_SUITABLE.getKey(), BackendExecutorType.OLTP.name());
result.setProperty(ConfigurationPropertyKey.PROXY_FRONTEND_MAX_CONNECTIONS.getKey(), "20");
- result.setProperty(ConfigurationPropertyKey.PROXY_BACKEND_DRIVER_TYPE.getKey(), "JDBC");
result.setProperty(ConfigurationPropertyKey.PROXY_MYSQL_DEFAULT_VERSION.getKey(), "5.7.22");
result.setProperty(ConfigurationPropertyKey.PROXY_DEFAULT_PORT.getKey(), "3308");
result.setProperty(ConfigurationPropertyKey.PROXY_NETTY_BACKLOG.getKey(), "1024");
@@ -88,7 +86,6 @@ public final class ConfigurationPropertiesTest {
assertThat(actual.getValue(ConfigurationPropertyKey.PROXY_FRONTEND_EXECUTOR_SIZE), is(0));
assertThat(actual.getValue(ConfigurationPropertyKey.PROXY_BACKEND_EXECUTOR_SUITABLE), is(BackendExecutorType.OLAP));
assertThat(actual.getValue(ConfigurationPropertyKey.PROXY_FRONTEND_MAX_CONNECTIONS), is(0));
- assertThat(actual.getValue(ConfigurationPropertyKey.PROXY_BACKEND_DRIVER_TYPE), is("JDBC"));
assertThat(actual.getValue(ConfigurationPropertyKey.PROXY_MYSQL_DEFAULT_VERSION), is("5.7.22"));
assertThat(actual.getValue(ConfigurationPropertyKey.PROXY_DEFAULT_PORT), is(3307));
assertThat(actual.getValue(ConfigurationPropertyKey.PROXY_NETTY_BACKLOG), is(1024));
diff --git a/infra/executor/pom.xml b/infra/executor/pom.xml
index 4841ebb97f5..d8188c172a2 100644
--- a/infra/executor/pom.xml
+++ b/infra/executor/pom.xml
@@ -45,10 +45,5 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>io.vertx</groupId>
- <artifactId>vertx-mysql-client</artifactId>
- </dependency>
</dependencies>
</project>
diff --git a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/driver/vertx/VertxExecutionUnit.java b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/driver/vertx/VertxExecutionUnit.java
deleted file mode 100644
index 773e5a43cab..00000000000
--- a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/driver/vertx/VertxExecutionUnit.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.infra.executor.sql.execute.engine.driver.vertx;
-
-import io.vertx.core.Future;
-import io.vertx.sqlclient.PreparedQuery;
-import io.vertx.sqlclient.Row;
-import io.vertx.sqlclient.RowSet;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.DriverExecutionUnit;
-
-/**
- * Vert.x execution unit.
- */
-@RequiredArgsConstructor
-@Getter
-public final class VertxExecutionUnit implements DriverExecutionUnit<Future<PreparedQuery<RowSet<Row>>>> {
-
- private final ExecutionUnit executionUnit;
-
- private final ConnectionMode connectionMode;
-
- private final Future<PreparedQuery<RowSet<Row>>> storageResource;
-}
diff --git a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/driver/vertx/VertxExecutor.java b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/driver/vertx/VertxExecutor.java
deleted file mode 100644
index c381e96c39e..00000000000
--- a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/driver/vertx/VertxExecutor.java
+++ /dev/null
@@ -1,49 +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.infra.executor.sql.execute.engine.driver.vertx;
-
-import io.vertx.core.Future;
-import lombok.RequiredArgsConstructor;
-import lombok.SneakyThrows;
-import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
-import org.apache.shardingsphere.infra.executor.kernel.model.ExecutionGroupContext;
-import org.apache.shardingsphere.infra.executor.sql.execute.result.ExecuteResult;
-
-import java.sql.SQLException;
-import java.util.List;
-
-/**
- * Vert.x executor.
- */
-@RequiredArgsConstructor
-public final class VertxExecutor {
-
- private final ExecutorEngine executorEngine;
-
- /**
- * Execute group context and return futures.
- *
- * @param executionGroupContext Vert.x execution group context
- * @param callback callback
- * @return futures of execute results
- */
- @SneakyThrows(SQLException.class)
- public List<Future<ExecuteResult>> execute(final ExecutionGroupContext<VertxExecutionUnit> executionGroupContext, final VertxExecutorCallback callback) {
- return executorEngine.execute(executionGroupContext, null, callback, true);
- }
-}
diff --git a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/driver/vertx/VertxExecutorCallback.java b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/driver/vertx/VertxExecutorCallback.java
deleted file mode 100644
index d9f374966d3..00000000000
--- a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/driver/vertx/VertxExecutorCallback.java
+++ /dev/null
@@ -1,66 +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.infra.executor.sql.execute.engine.driver.vertx;
-
-import io.vertx.core.Future;
-import io.vertx.mysqlclient.MySQLClient;
-import io.vertx.mysqlclient.impl.protocol.ColumnDefinition;
-import io.vertx.sqlclient.Row;
-import io.vertx.sqlclient.RowSet;
-import io.vertx.sqlclient.Tuple;
-import org.apache.shardingsphere.infra.executor.kernel.model.ExecutorCallback;
-import org.apache.shardingsphere.infra.executor.sql.execute.result.ExecuteResult;
-import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.driver.vertx.VertxMySQLQueryResultMetaData;
-import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.driver.vertx.VertxQueryResult;
-import org.apache.shardingsphere.infra.executor.sql.execute.result.update.UpdateResult;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Vert.x executor callback.
- */
-public final class VertxExecutorCallback implements ExecutorCallback<VertxExecutionUnit, Future<ExecuteResult>> {
-
- @Override
- public Collection<Future<ExecuteResult>> execute(final Collection<VertxExecutionUnit> inputs, final boolean isTrunkThread, final Map<String, Object> dataMap) {
- List<Future<ExecuteResult>> result = new ArrayList<>(inputs.size());
- for (VertxExecutionUnit each : inputs) {
- Future<RowSet<Row>> future = each.getStorageResource().compose(preparedQuery -> preparedQuery.execute(Tuple.from(each.getExecutionUnit().getSqlUnit().getParameters())));
- result.add(future.compose(this::handleResult));
- }
- return result;
- }
-
- private Future<ExecuteResult> handleResult(final RowSet<Row> rowSet) {
- if (null == rowSet.columnDescriptors()) {
- return Future.succeededFuture(new UpdateResult(rowSet.rowCount(), getGeneratedKey(rowSet)));
- }
- // TODO Decoupling MySQL implementations
- List<ColumnDefinition> columnDefinitions = new ArrayList<>(rowSet.columnDescriptors().size());
- rowSet.columnDescriptors().forEach(each -> columnDefinitions.add((ColumnDefinition) each));
- return Future.succeededFuture(new VertxQueryResult(new VertxMySQLQueryResultMetaData(columnDefinitions), rowSet.iterator()));
- }
-
- private long getGeneratedKey(final RowSet<Row> rowSet) {
- Long result = rowSet.property(MySQLClient.LAST_INSERTED_ID);
- return null == result ? 0L : result;
- }
-}
diff --git a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/result/query/impl/driver/vertx/VertxMySQLQueryResultMetaData.java b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/result/query/impl/driver/vertx/VertxMySQLQueryResultMetaData.java
deleted file mode 100644
index 7a2924d74eb..00000000000
--- a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/result/query/impl/driver/vertx/VertxMySQLQueryResultMetaData.java
+++ /dev/null
@@ -1,89 +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.infra.executor.sql.execute.result.query.impl.driver.vertx;
-
-import io.vertx.mysqlclient.impl.protocol.ColumnDefinition;
-import io.vertx.mysqlclient.impl.protocol.ColumnDefinition.ColumnDefinitionFlags;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryResultMetaData;
-
-import java.util.List;
-
-/**
- * Vert.x query result meta data for MySQL.
- */
-@RequiredArgsConstructor
-public final class VertxMySQLQueryResultMetaData implements QueryResultMetaData {
-
- private final List<ColumnDefinition> columnDefinitions;
-
- @Override
- public int getColumnCount() {
- return columnDefinitions.size();
- }
-
- @Override
- public String getTableName(final int columnIndex) {
- return columnDefinitions.get(columnIndex - 1).table();
- }
-
- @Override
- public String getColumnName(final int columnIndex) {
- return columnDefinitions.get(columnIndex - 1).orgName();
- }
-
- @Override
- public String getColumnLabel(final int columnIndex) {
- return columnDefinitions.get(columnIndex - 1).name();
- }
-
- @Override
- public int getColumnType(final int columnIndex) {
- return columnDefinitions.get(columnIndex - 1).jdbcType().getVendorTypeNumber();
- }
-
- @Override
- public String getColumnTypeName(final int columnIndex) {
- return columnDefinitions.get(columnIndex - 1).jdbcType().getName();
- }
-
- @Override
- public int getColumnLength(final int columnIndex) {
- return (int) columnDefinitions.get(columnIndex - 1).columnLength();
- }
-
- @Override
- public int getDecimals(final int columnIndex) {
- return columnDefinitions.get(columnIndex - 1).decimals();
- }
-
- @Override
- public boolean isSigned(final int columnIndex) {
- return false;
- }
-
- @Override
- public boolean isNotNull(final int columnIndex) {
- return (columnDefinitions.get(columnIndex - 1).flags() & ColumnDefinitionFlags.NOT_NULL_FLAG) == ColumnDefinitionFlags.NOT_NULL_FLAG;
- }
-
- @Override
- public boolean isAutoIncrement(final int columnIndex) {
- return (columnDefinitions.get(columnIndex - 1).flags() & ColumnDefinitionFlags.AUTO_INCREMENT_FLAG) == ColumnDefinitionFlags.AUTO_INCREMENT_FLAG;
- }
-}
diff --git a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/result/query/impl/driver/vertx/VertxQueryResult.java b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/result/query/impl/driver/vertx/VertxQueryResult.java
deleted file mode 100644
index aa214d1f82a..00000000000
--- a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/result/query/impl/driver/vertx/VertxQueryResult.java
+++ /dev/null
@@ -1,79 +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.infra.executor.sql.execute.result.query.impl.driver.vertx;
-
-import io.vertx.sqlclient.Row;
-import lombok.RequiredArgsConstructor;
-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.util.exception.external.sql.type.generic.UnsupportedSQLOperationException;
-
-import java.io.InputStream;
-import java.util.Calendar;
-import java.util.Iterator;
-
-/**
- * Vert.x query result.
- */
-@RequiredArgsConstructor
-public final class VertxQueryResult implements QueryResult {
-
- private final QueryResultMetaData queryResultMetaData;
-
- private final Iterator<Row> rowIterator;
-
- private Row current;
-
- @Override
- public boolean next() {
- boolean hasNext = rowIterator.hasNext();
- if (hasNext) {
- current = rowIterator.next();
- }
- return hasNext;
- }
-
- @Override
- public Object getValue(final int columnIndex, final Class<?> type) {
- return Object.class == type ? current.getValue(columnIndex - 1) : current.get(type, columnIndex - 1);
- }
-
- @Override
- public Object getCalendarValue(final int columnIndex, final Class<?> type, final Calendar calendar) {
- throw new UnsupportedSQLOperationException("");
- }
-
- @Override
- public InputStream getInputStream(final int columnIndex, final String type) {
- throw new UnsupportedSQLOperationException("getInputStream");
- }
-
- @Override
- public boolean wasNull() {
- return false;
- }
-
- @Override
- public QueryResultMetaData getMetaData() {
- return queryResultMetaData;
- }
-
- @Override
- public void close() {
- }
-}
diff --git a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/vertx/ExecutorVertxConnectionManager.java b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/vertx/ExecutorVertxConnectionManager.java
deleted file mode 100644
index b917d84c6a7..00000000000
--- a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/vertx/ExecutorVertxConnectionManager.java
+++ /dev/null
@@ -1,28 +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.infra.executor.sql.prepare.driver.vertx;
-
-import io.vertx.core.Future;
-import io.vertx.sqlclient.SqlClient;
-import org.apache.shardingsphere.infra.executor.sql.prepare.driver.ExecutorConnectionManager;
-
-/**
- * Executor connection manager for Vert.x.
- */
-public interface ExecutorVertxConnectionManager extends ExecutorConnectionManager<Future<? extends SqlClient>> {
-}
diff --git a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/vertx/ExecutorVertxStatementManager.java b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/vertx/ExecutorVertxStatementManager.java
deleted file mode 100644
index 16fbc80401d..00000000000
--- a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/vertx/ExecutorVertxStatementManager.java
+++ /dev/null
@@ -1,31 +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.infra.executor.sql.prepare.driver.vertx;
-
-import io.vertx.core.Future;
-import io.vertx.sqlclient.Query;
-import io.vertx.sqlclient.Row;
-import io.vertx.sqlclient.RowSet;
-import io.vertx.sqlclient.SqlClient;
-import org.apache.shardingsphere.infra.executor.sql.prepare.driver.ExecutorStatementManager;
-
-/**
- * Executor statement manager for Vert.x.
- */
-public interface ExecutorVertxStatementManager extends ExecutorStatementManager<Future<? extends SqlClient>, Future<Query<RowSet<Row>>>, VertxExecutionContext> {
-}
diff --git a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/vertx/VertxExecutionContext.java b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/vertx/VertxExecutionContext.java
deleted file mode 100644
index a1158c7291d..00000000000
--- a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/vertx/VertxExecutionContext.java
+++ /dev/null
@@ -1,26 +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.infra.executor.sql.prepare.driver.vertx;
-
-import org.apache.shardingsphere.infra.executor.sql.prepare.driver.StorageResourceOption;
-
-/**
- * Vert.x execution context.
- */
-public final class VertxExecutionContext implements StorageResourceOption {
-}
diff --git a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/vertx/builder/PreparedQueryExecutionUnitBuilder.java b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/vertx/builder/PreparedQueryExecutionUnitBuilder.java
deleted file mode 100644
index 359240bd2f2..00000000000
--- a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/vertx/builder/PreparedQueryExecutionUnitBuilder.java
+++ /dev/null
@@ -1,44 +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.infra.executor.sql.prepare.driver.vertx.builder;
-
-import io.vertx.core.Future;
-import io.vertx.sqlclient.SqlClient;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.vertx.VertxExecutionUnit;
-import org.apache.shardingsphere.infra.executor.sql.prepare.driver.vertx.ExecutorVertxStatementManager;
-import org.apache.shardingsphere.infra.executor.sql.prepare.driver.vertx.VertxExecutionContext;
-
-/**
- * Execution unit builder using Vert.x prepared query.
- */
-public final class PreparedQueryExecutionUnitBuilder implements VertxExecutionUnitBuilder {
-
- @Override
- public VertxExecutionUnit build(final ExecutionUnit executionUnit, final ExecutorVertxStatementManager statementManager,
- final Future<? extends SqlClient> connection, final ConnectionMode connectionMode, final VertxExecutionContext option, final DatabaseType databaseType) {
- return new VertxExecutionUnit(executionUnit, connectionMode, connection.compose(sqlClient -> Future.succeededFuture(sqlClient.preparedQuery(executionUnit.getSqlUnit().getSql()))));
- }
-
- @Override
- public String getType() {
- return "Vert.x";
- }
-}
diff --git a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/vertx/builder/VertxExecutionUnitBuilder.java b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/vertx/builder/VertxExecutionUnitBuilder.java
deleted file mode 100644
index 80944d7f5dc..00000000000
--- a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/vertx/builder/VertxExecutionUnitBuilder.java
+++ /dev/null
@@ -1,31 +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.infra.executor.sql.prepare.driver.vertx.builder;
-
-import io.vertx.core.Future;
-import io.vertx.sqlclient.SqlClient;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.vertx.VertxExecutionUnit;
-import org.apache.shardingsphere.infra.executor.sql.prepare.driver.SQLExecutionUnitBuilder;
-import org.apache.shardingsphere.infra.executor.sql.prepare.driver.vertx.ExecutorVertxStatementManager;
-import org.apache.shardingsphere.infra.executor.sql.prepare.driver.vertx.VertxExecutionContext;
-
-/**
- * Execution unit builder for Vert.x.
- */
-public interface VertxExecutionUnitBuilder extends SQLExecutionUnitBuilder<VertxExecutionUnit, ExecutorVertxStatementManager, Future<? extends SqlClient>, VertxExecutionContext> {
-}
diff --git a/infra/executor/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.executor.sql.prepare.driver.SQLExecutionUnitBuilder b/infra/executor/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.executor.sql.prepare.driver.SQLExecutionUnitBuilder
index d9fc6119e7a..6af382a4c5a 100644
--- a/infra/executor/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.executor.sql.prepare.driver.SQLExecutionUnitBuilder
+++ b/infra/executor/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.executor.sql.prepare.driver.SQLExecutionUnitBuilder
@@ -17,4 +17,3 @@
org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.builder.StatementExecutionUnitBuilder
org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.builder.PreparedStatementExecutionUnitBuilder
-org.apache.shardingsphere.infra.executor.sql.prepare.driver.vertx.builder.PreparedQueryExecutionUnitBuilder
diff --git a/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/driver/vertx/VertxExecutorCallbackTest.java b/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/driver/vertx/VertxExecutorCallbackTest.java
deleted file mode 100644
index 6fd0c6d2d4e..00000000000
--- a/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/driver/vertx/VertxExecutorCallbackTest.java
+++ /dev/null
@@ -1,86 +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.infra.executor.sql.execute.engine.driver.vertx;
-
-import io.vertx.core.Future;
-import io.vertx.mysqlclient.MySQLClient;
-import io.vertx.sqlclient.PreparedQuery;
-import io.vertx.sqlclient.Row;
-import io.vertx.sqlclient.RowSet;
-import io.vertx.sqlclient.Tuple;
-import org.apache.shardingsphere.infra.executor.sql.execute.result.ExecuteResult;
-import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.driver.vertx.VertxQueryResult;
-import org.apache.shardingsphere.infra.executor.sql.execute.result.update.UpdateResult;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-
-import java.util.Collection;
-import java.util.Collections;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public final class VertxExecutorCallbackTest {
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private VertxExecutionUnit vertxExecutionUnit;
-
- @Mock
- private PreparedQuery<RowSet<Row>> preparedQuery;
-
- @Mock
- private RowSet<Row> rowSet;
-
- private final VertxExecutorCallback callback = new VertxExecutorCallback();
-
- @Before
- public void setup() {
- when(vertxExecutionUnit.getExecutionUnit().getSqlUnit().getParameters()).thenReturn(Collections.emptyList());
- when(vertxExecutionUnit.getStorageResource()).thenReturn(Future.succeededFuture(preparedQuery));
- when(preparedQuery.execute(any(Tuple.class))).thenReturn(Future.succeededFuture(rowSet));
- }
-
- @Test
- public void assertExecuteQuery() {
- Collection<Future<ExecuteResult>> actual = callback.execute(Collections.singletonList(vertxExecutionUnit), true, Collections.emptyMap());
- assertThat(actual.size(), is(1));
- assertThat(actual.iterator().next().result(), instanceOf(VertxQueryResult.class));
- }
-
- @Test
- public void assertExecuteUpdate() {
- when(rowSet.columnDescriptors()).thenReturn(null);
- when(rowSet.rowCount()).thenReturn(10);
- when(rowSet.property(MySQLClient.LAST_INSERTED_ID)).thenReturn(-1L);
- Collection<Future<ExecuteResult>> actual = callback.execute(Collections.singletonList(vertxExecutionUnit), true, Collections.emptyMap());
- assertThat(actual.size(), is(1));
- ExecuteResult actualResult = actual.iterator().next().result();
- assertThat(actualResult, instanceOf(UpdateResult.class));
- UpdateResult actualUpdateResult = (UpdateResult) actualResult;
- assertThat(actualUpdateResult.getUpdateCount(), is(10));
- assertThat(actualUpdateResult.getLastInsertId(), is(-1L));
- }
-}
diff --git a/pom.xml b/pom.xml
index 55fdc70acff..11b52ee097a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -77,7 +77,6 @@
<activation-api.version>1.2.0</activation-api.version>
<calcite.version>1.32.0</calcite.version>
- <vertx.version>4.3.3</vertx.version>
<netty.version>4.1.86.Final</netty.version>
<javax.transaction.version>1.1</javax.transaction.version>
@@ -252,11 +251,6 @@
<artifactId>calcite-core</artifactId>
<version>${calcite.version}</version>
</dependency>
- <dependency>
- <groupId>io.vertx</groupId>
- <artifactId>vertx-mysql-client</artifactId>
- <version>${vertx.version}</version>
- </dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
@@ -267,11 +261,6 @@
<artifactId>netty-codec</artifactId>
<version>${netty.version}</version>
</dependency>
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-codec-dns</artifactId>
- <version>${netty.version}</version>
- </dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http</artifactId>
@@ -307,11 +296,6 @@
<artifactId>netty-resolver</artifactId>
<version>${netty.version}</version>
</dependency>
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-resolver-dns</artifactId>
- <version>${netty.version}</version>
- </dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/BackendConnection.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/BackendConnection.java
index c01afa6ad23..d223802c343 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/BackendConnection.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/BackendConnection.java
@@ -17,49 +17,322 @@
package org.apache.shardingsphere.proxy.backend.communication;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.LinkedHashMultimap;
+import com.google.common.collect.Multimap;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode;
+import org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.ExecutorJDBCConnectionManager;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.ConnectionPostProcessor;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.ResourceLock;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.BackendTransactionManager;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.exception.BackendConnectionException;
+import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandler;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.proxy.backend.util.TransactionUtil;
+import org.apache.shardingsphere.transaction.api.TransactionType;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
/**
- * Backend connection for Proxy.
- *
- * @param <T> return type of methods
+ * Backend connection.
*/
-public interface BackendConnection<T> {
+@RequiredArgsConstructor
+@Getter
+public final class BackendConnection implements ExecutorJDBCConnectionManager {
+
+ private final ConnectionSession connectionSession;
+
+ private final Multimap<String, Connection> cachedConnections = LinkedHashMultimap.create();
+
+ private final Collection<ProxyBackendHandler> backendHandlers = Collections.newSetFromMap(new ConcurrentHashMap<>(64));
+
+ private final Collection<ProxyBackendHandler> inUseBackendHandlers = Collections.newSetFromMap(new ConcurrentHashMap<>(64));
+
+ private final Collection<ConnectionPostProcessor> connectionPostProcessors = new LinkedList<>();
+
+ private final ResourceLock resourceLock = new ResourceLock();
+
+ private final AtomicBoolean closed = new AtomicBoolean(false);
+
+ @Override
+ public List<Connection> getConnections(final String dataSourceName, final int connectionSize, final ConnectionMode connectionMode) throws SQLException {
+ Preconditions.checkNotNull(connectionSession.getDatabaseName(), "Current database name is null.");
+ Collection<Connection> connections;
+ synchronized (cachedConnections) {
+ connections = cachedConnections.get(connectionSession.getDatabaseName().toLowerCase() + "." + dataSourceName);
+ }
+ List<Connection> result;
+ if (connections.size() >= connectionSize) {
+ result = new ArrayList<>(connections).subList(0, connectionSize);
+ } else if (!connections.isEmpty()) {
+ result = new ArrayList<>(connectionSize);
+ result.addAll(connections);
+ List<Connection> newConnections = createNewConnections(dataSourceName, connectionSize - connections.size(), connectionMode);
+ result.addAll(newConnections);
+ synchronized (cachedConnections) {
+ cachedConnections.putAll(connectionSession.getDatabaseName().toLowerCase() + "." + dataSourceName, newConnections);
+ }
+ } else {
+ result = createNewConnections(dataSourceName, connectionSize, connectionMode);
+ synchronized (cachedConnections) {
+ cachedConnections.putAll(connectionSession.getDatabaseName().toLowerCase() + "." + dataSourceName, result);
+ }
+ }
+ return result;
+ }
+
+ private List<Connection> createNewConnections(final String dataSourceName, final int connectionSize, final ConnectionMode connectionMode) throws SQLException {
+ List<Connection> result = ProxyContext.getInstance().getBackendDataSource().getConnections(connectionSession.getDatabaseName().toLowerCase(), dataSourceName, connectionSize, connectionMode);
+ setSessionVariablesIfNecessary(result);
+ for (Connection each : result) {
+ replayTransactionOption(each);
+ }
+ if (connectionSession.getTransactionStatus().isInTransaction()) {
+ for (Connection each : result) {
+ replayMethodsInvocation(each);
+ }
+ }
+ return result;
+ }
+
+ private void setSessionVariablesIfNecessary(final List<Connection> connections) throws SQLException {
+ if (connectionSession.getRequiredSessionVariableRecorder().isEmpty() || connections.isEmpty()) {
+ return;
+ }
+ String databaseType = connections.iterator().next().getMetaData().getDatabaseProductName();
+ List<String> setSQLs = connectionSession.getRequiredSessionVariableRecorder().toSetSQLs(databaseType);
+ SQLException sqlException = null;
+ for (Connection each : connections) {
+ try (Statement statement = each.createStatement()) {
+ for (String eachSetSQL : setSQLs) {
+ statement.execute(eachSetSQL);
+ }
+ } catch (final SQLException ex) {
+ sqlException = ex;
+ break;
+ }
+ }
+ if (null == sqlException) {
+ return;
+ }
+ for (Connection each : connections) {
+ try {
+ each.close();
+ } catch (final SQLException ex) {
+ sqlException.setNextException(ex);
+ }
+ }
+ throw sqlException;
+ }
+
+ private void replayMethodsInvocation(final Connection target) {
+ for (ConnectionPostProcessor each : connectionPostProcessors) {
+ each.process(target);
+ }
+ }
+
+ private void replayTransactionOption(final Connection connection) throws SQLException {
+ if (null == connection) {
+ return;
+ }
+ if (connectionSession.isReadOnly()) {
+ connection.setReadOnly(true);
+ }
+ if (null != connectionSession.getIsolationLevel()) {
+ connection.setTransactionIsolation(TransactionUtil.getTransactionIsolationLevel(connectionSession.getIsolationLevel()));
+ }
+ }
+
+ @Override
+ public Collection<String> getDataSourceNamesOfCachedConnections() {
+ Collection<String> result = new ArrayList<>(cachedConnections.size());
+ String databaseName = connectionSession.getDatabaseName().toLowerCase();
+ for (String each : cachedConnections.keySet()) {
+ String[] split = each.split("\\.", 2);
+ String cachedDatabaseName = split[0];
+ String cachedDataSourceName = split[1];
+ if (databaseName.equals(cachedDatabaseName)) {
+ result.add(cachedDataSourceName);
+ }
+ }
+ return result;
+ }
/**
- * Get connection session of backend connection.
- *
- * @return connection session
+ * Whether execute SQL serial or not.
+ *
+ * @return true or false
*/
- ConnectionSession getConnectionSession();
+ public boolean isSerialExecute() {
+ return connectionSession.getTransactionStatus().isInTransaction()
+ && (TransactionType.LOCAL == connectionSession.getTransactionStatus().getTransactionType() || TransactionType.XA == connectionSession.getTransactionStatus().getTransactionType());
+ }
/**
- * Prepare for task execution.
+ * Get connection size.
*
- * @return can be Void or Future
+ * @return connection size
*/
- T prepareForTaskExecution();
+ public int getConnectionSize() {
+ return cachedConnections.values().size();
+ }
/**
- * Handle auto commit.
+ * Add handler.
+ *
+ * @param handler handler to be added
+ */
+ public void add(final ProxyBackendHandler handler) {
+ backendHandlers.add(handler);
+ }
+
+ /**
+ * Mark a handler as in use.
+ *
+ * @param handler handler to be marked
+ */
+ public void markResourceInUse(final ProxyBackendHandler handler) {
+ inUseBackendHandlers.add(handler);
+ }
+
+ /**
+ * Unmark a in use proxy backend handler.
*
- * @return can be Void or Future
+ * @param handler proxy backend handler to be added
*/
- T handleAutoCommit();
+ public void unmarkResourceInUse(final ProxyBackendHandler handler) {
+ inUseBackendHandlers.remove(handler);
+ }
+
+ /**
+ * Handle auto commit.
+ */
+ public void handleAutoCommit() {
+ if (!connectionSession.isAutoCommit() && !connectionSession.getTransactionStatus().isInTransaction()) {
+ BackendTransactionManager transactionManager = new BackendTransactionManager(this);
+ transactionManager.begin();
+ }
+ }
/**
* Close resources used in execution.
*
- * @return can be Void or Future
* @throws BackendConnectionException backend connection exception
*/
- T closeExecutionResources() throws BackendConnectionException;
+ public void closeExecutionResources() throws BackendConnectionException {
+ synchronized (this) {
+ Collection<Exception> result = new LinkedList<>(closeHandlers(false));
+ if (!connectionSession.getTransactionStatus().isInConnectionHeldTransaction()) {
+ result.addAll(closeHandlers(true));
+ result.addAll(closeConnections(false));
+ } else if (closed.get()) {
+ result.addAll(closeHandlers(true));
+ result.addAll(closeConnections(true));
+ }
+ if (result.isEmpty()) {
+ return;
+ }
+ throw new BackendConnectionException(result);
+ }
+ }
/**
* Close all resources.
+ */
+ public void closeAllResources() {
+ synchronized (this) {
+ closed.set(true);
+ closeHandlers(true);
+ closeConnections(true);
+ }
+ }
+
+ /**
+ * Close handlers.
*
- * @return can be Void or Future
+ * @param includeInUse include handlers in use
+ * @return SQL exception when handler close
*/
- T closeAllResources();
+ public Collection<SQLException> closeHandlers(final boolean includeInUse) {
+ Collection<SQLException> result = new LinkedList<>();
+ for (ProxyBackendHandler each : backendHandlers) {
+ if (!includeInUse && inUseBackendHandlers.contains(each)) {
+ continue;
+ }
+ try {
+ each.close();
+ } catch (final SQLException ex) {
+ result.add(ex);
+ }
+ }
+ if (includeInUse) {
+ inUseBackendHandlers.clear();
+ }
+ backendHandlers.retainAll(inUseBackendHandlers);
+ return result;
+ }
+
+ /**
+ * Close connections.
+ *
+ * @param forceRollback is force rollback
+ * @return SQL exception when connections close
+ */
+ public Collection<SQLException> closeConnections(final boolean forceRollback) {
+ Collection<SQLException> result = new LinkedList<>();
+ synchronized (cachedConnections) {
+ resetSessionVariablesIfNecessary(cachedConnections.values(), result);
+ for (Connection each : cachedConnections.values()) {
+ try {
+ if (forceRollback && connectionSession.getTransactionStatus().isInTransaction()) {
+ each.rollback();
+ }
+ each.close();
+ } catch (final SQLException ex) {
+ result.add(ex);
+ }
+ }
+ cachedConnections.clear();
+ }
+ if (!forceRollback) {
+ connectionPostProcessors.clear();
+ }
+ return result;
+ }
+
+ private void resetSessionVariablesIfNecessary(final Collection<Connection> values, final Collection<SQLException> exceptions) {
+ if (connectionSession.getRequiredSessionVariableRecorder().isEmpty() || values.isEmpty()) {
+ return;
+ }
+ String databaseType;
+ try {
+ databaseType = values.iterator().next().getMetaData().getDatabaseProductName();
+ } catch (final SQLException ex) {
+ exceptions.add(ex);
+ return;
+ }
+ List<String> resetSQLs = connectionSession.getRequiredSessionVariableRecorder().toResetSQLs(databaseType);
+ for (Connection each : values) {
+ try (Statement statement = each.createStatement()) {
+ for (String eachResetSQL : resetSQLs) {
+ statement.execute(eachResetSQL);
+ }
+ } catch (final SQLException ex) {
+ exceptions.add(ex);
+ }
+ }
+ connectionSession.getRequiredSessionVariableRecorder().removeVariablesWithDefaultValue();
+ }
}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngine.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngine.java
index 763a30769e4..1b443278e62 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngine.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngine.java
@@ -18,21 +18,31 @@
package org.apache.shardingsphere.proxy.backend.communication;
import com.google.common.base.Preconditions;
-import lombok.AccessLevel;
-import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.infra.binder.QueryContext;
import org.apache.shardingsphere.infra.binder.aware.CursorDefinitionAware;
+import org.apache.shardingsphere.infra.binder.decider.context.SQLFederationDeciderContext;
+import org.apache.shardingsphere.infra.binder.decider.engine.SQLFederationDeciderEngine;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.binder.statement.ddl.CloseStatementContext;
import org.apache.shardingsphere.infra.binder.statement.ddl.CursorStatementContext;
import org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext;
import org.apache.shardingsphere.infra.binder.type.CursorAvailable;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.context.kernel.KernelProcessor;
import org.apache.shardingsphere.infra.context.refresher.MetaDataRefreshEngine;
+import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import org.apache.shardingsphere.infra.database.type.DatabaseTypeEngine;
import org.apache.shardingsphere.infra.executor.sql.context.ExecutionContext;
+import org.apache.shardingsphere.infra.executor.sql.execute.engine.SQLExecutorExceptionHandler;
+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.result.query.QueryResult;
+import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.driver.jdbc.metadata.JDBCQueryResultMetaData;
+import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.driver.jdbc.type.stream.JDBCStreamQueryResult;
import org.apache.shardingsphere.infra.executor.sql.execute.result.update.UpdateResult;
+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.merge.MergeEngine;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -41,30 +51,52 @@ import org.apache.shardingsphere.infra.metadata.database.schema.util.SystemSchem
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.rule.identifier.type.DataNodeContainedRule;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
+import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.ProxyJDBCExecutorCallback;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.ProxyJDBCExecutorCallbackFactory;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.JDBCBackendStatement;
+import org.apache.shardingsphere.proxy.backend.context.BackendExecutorContext;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.exception.RuleNotExistedException;
import org.apache.shardingsphere.proxy.backend.exception.StorageUnitNotExistedException;
import org.apache.shardingsphere.proxy.backend.handler.data.DatabaseBackendHandler;
import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseCell;
import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.query.QueryHeader;
import org.apache.shardingsphere.proxy.backend.response.header.query.QueryHeaderBuilderEngine;
import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+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.rule.SQLFederationRule;
+import org.apache.shardingsphere.sqlfederation.spi.SQLFederationExecutor;
+import org.apache.shardingsphere.sqlfederation.spi.SQLFederationExecutorContext;
+import java.sql.Connection;
+import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
+import java.util.concurrent.CopyOnWriteArrayList;
/**
* Database communication engine.
*/
-@Getter(AccessLevel.PROTECTED)
-@Setter(AccessLevel.PROTECTED)
-public abstract class DatabaseCommunicationEngine implements DatabaseBackendHandler {
+public final class DatabaseCommunicationEngine implements DatabaseBackendHandler {
+
+ private final ProxySQLExecutor proxySQLExecutor;
+
+ private final Collection<Statement> cachedStatements = new CopyOnWriteArrayList<>();
+
+ private final Collection<ResultSet> cachedResultSets = new CopyOnWriteArrayList<>();
private final String driverType;
@@ -72,27 +104,25 @@ public abstract class DatabaseCommunicationEngine implements DatabaseBackendHand
private final QueryContext queryContext;
- private final KernelProcessor kernelProcessor = new KernelProcessor();
+ private final BackendConnection backendConnection;
- private final MetaDataRefreshEngine metaDataRefreshEngine;
+ private volatile SQLFederationExecutor federationExecutor;
private List<QueryHeader> queryHeaders;
private MergedResult mergedResult;
- private final BackendConnection<?> backendConnection;
-
- public DatabaseCommunicationEngine(final String driverType, final ShardingSphereDatabase database, final QueryContext queryContext, final BackendConnection<?> backendConnection) {
+ public DatabaseCommunicationEngine(final String driverType, final ShardingSphereDatabase database, final QueryContext queryContext, final BackendConnection backendConnection) {
SQLStatementContext<?> sqlStatementContext = queryContext.getSqlStatementContext();
failedIfBackendNotReady(backendConnection.getConnectionSession(), sqlStatementContext);
this.driverType = driverType;
this.database = database;
this.queryContext = queryContext;
this.backendConnection = backendConnection;
- metaDataRefreshEngine = new MetaDataRefreshEngine(database, ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps());
if (sqlStatementContext instanceof CursorAvailable) {
- prepareCursorStatementContext((CursorAvailable) sqlStatementContext, backendConnection.getConnectionSession());
+ DatabaseCommunicationEngine.this.prepareCursorStatementContext((CursorAvailable) sqlStatementContext, backendConnection.getConnectionSession());
}
+ proxySQLExecutor = new ProxySQLExecutor(driverType, backendConnection, this);
}
private void failedIfBackendNotReady(final ConnectionSession connectionSession, final SQLStatementContext<?> sqlStatementContext) {
@@ -104,6 +134,101 @@ public abstract class DatabaseCommunicationEngine implements DatabaseBackendHand
}
}
+ /**
+ * Add statement.
+ *
+ * @param statement statement to be added
+ */
+ public void add(final Statement statement) {
+ cachedStatements.add(statement);
+ }
+
+ /**
+ * Add result set.
+ *
+ * @param resultSet result set to be added
+ */
+ public void add(final ResultSet resultSet) {
+ cachedResultSets.add(resultSet);
+ }
+
+ /**
+ * Execute to database.
+ *
+ * @return backend response
+ */
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ @Override
+ public ResponseHeader execute() throws SQLException {
+ MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
+ SQLFederationDeciderContext deciderContext = decide(queryContext, metaDataContexts.getMetaData().getProps(), database);
+ if (deciderContext.isUseSQLFederation()) {
+ prepareFederationExecutor();
+ ResultSet resultSet = doExecuteFederation(queryContext, metaDataContexts);
+ return processExecuteFederation(resultSet, metaDataContexts);
+ }
+ ExecutionContext executionContext = new KernelProcessor().generateExecutionContext(queryContext, database, metaDataContexts.getMetaData().getGlobalRuleMetaData(),
+ metaDataContexts.getMetaData().getProps(), backendConnection.getConnectionSession().getConnectionContext());
+ if (executionContext.getExecutionUnits().isEmpty()) {
+ return new UpdateResponseHeader(executionContext.getSqlStatementContext().getSqlStatement());
+ }
+ proxySQLExecutor.checkExecutePrerequisites(executionContext);
+ List result = proxySQLExecutor.execute(executionContext);
+ refreshMetaData(executionContext);
+ Object executeResultSample = result.iterator().next();
+ return executeResultSample instanceof QueryResult
+ ? processExecuteQuery(executionContext, result, (QueryResult) executeResultSample)
+ : processExecuteUpdate(executionContext, result);
+ }
+
+ private static SQLFederationDeciderContext decide(final QueryContext queryContext, final ConfigurationProperties props, final ShardingSphereDatabase database) {
+ SQLFederationDeciderEngine deciderEngine = new SQLFederationDeciderEngine(database.getRuleMetaData().getRules(), props);
+ return deciderEngine.decide(queryContext, database);
+ }
+
+ private void prepareFederationExecutor() {
+ MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
+ String databaseName = backendConnection.getConnectionSession().getDatabaseName();
+ DatabaseType databaseType = queryContext.getSqlStatementContext().getDatabaseType();
+ String schemaName = queryContext.getSqlStatementContext().getTablesContext().getSchemaName().orElseGet(() -> DatabaseTypeEngine.getDefaultSchemaName(databaseType, databaseName));
+ SQLFederationRule sqlFederationRule = metaDataContexts.getMetaData().getGlobalRuleMetaData().getSingleRule(SQLFederationRule.class);
+ federationExecutor = sqlFederationRule.getSQLFederationExecutor(databaseName, schemaName, metaDataContexts.getMetaData(), metaDataContexts.getShardingSphereData(),
+ new JDBCExecutor(BackendExecutorContext.getInstance().getExecutorEngine(), backendConnection.getConnectionSession().getConnectionContext()),
+ ProxyContext.getInstance().getContextManager().getInstanceContext().getEventBusContext());
+ }
+
+ private ResultSet doExecuteFederation(final QueryContext queryContext, final MetaDataContexts metaDataContexts) throws SQLException {
+ boolean isReturnGeneratedKeys = queryContext.getSqlStatementContext().getSqlStatement() instanceof MySQLInsertStatement;
+ ShardingSphereDatabase database = metaDataContexts.getMetaData().getDatabase(backendConnection.getConnectionSession().getDatabaseName());
+ DatabaseType protocolType = database.getProtocolType();
+ Map<String, DatabaseType> storageTypes = database.getResourceMetaData().getStorageTypes();
+ ProxyJDBCExecutorCallback callback = ProxyJDBCExecutorCallbackFactory.newInstance(driverType, protocolType, storageTypes,
+ queryContext.getSqlStatementContext().getSqlStatement(), this, isReturnGeneratedKeys, SQLExecutorExceptionHandler.isExceptionThrown(), true);
+ DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine = createDriverExecutionPrepareEngine(isReturnGeneratedKeys, metaDataContexts);
+ SQLFederationExecutorContext context = new SQLFederationExecutorContext(false, queryContext, metaDataContexts.getMetaData());
+ return federationExecutor.executeQuery(prepareEngine, callback, context);
+ }
+
+ private DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> createDriverExecutionPrepareEngine(final boolean isReturnGeneratedKeys, final MetaDataContexts metaData) {
+ int maxConnectionsSizePerQuery = metaData.getMetaData().getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
+ JDBCBackendStatement statementManager = (JDBCBackendStatement) backendConnection.getConnectionSession().getStatementManager();
+ return new DriverExecutionPrepareEngine<>(driverType, maxConnectionsSizePerQuery, backendConnection, statementManager,
+ new StatementOption(isReturnGeneratedKeys), metaData.getMetaData().getDatabase(backendConnection.getConnectionSession().getDatabaseName()).getRuleMetaData().getRules(),
+ metaData.getMetaData().getDatabase(backendConnection.getConnectionSession().getDatabaseName()).getResourceMetaData().getStorageTypes());
+ }
+
+ private ResponseHeader processExecuteFederation(final ResultSet resultSet, final MetaDataContexts metaDataContexts) throws SQLException {
+ int columnCount = resultSet.getMetaData().getColumnCount();
+ queryHeaders = new ArrayList<>(columnCount);
+ ShardingSphereDatabase database = metaDataContexts.getMetaData().getDatabase(backendConnection.getConnectionSession().getDatabaseName());
+ QueryHeaderBuilderEngine queryHeaderBuilderEngine = new QueryHeaderBuilderEngine(null == database ? null : database.getProtocolType());
+ for (int columnIndex = 1; columnIndex <= columnCount; columnIndex++) {
+ queryHeaders.add(queryHeaderBuilderEngine.build(new JDBCQueryResultMetaData(resultSet.getMetaData()), database, columnIndex));
+ }
+ mergedResult = new IteratorStreamMergedResult(Collections.singletonList(new JDBCStreamQueryResult(resultSet)));
+ return new QueryResponseHeader(queryHeaders);
+ }
+
private void prepareCursorStatementContext(final CursorAvailable statementContext, final ConnectionSession connectionSession) {
if (statementContext.getCursorName().isPresent()) {
String cursorName = statementContext.getCursorName().get().getIdentifier().getValue().toLowerCase();
@@ -128,20 +253,21 @@ public abstract class DatabaseCommunicationEngine implements DatabaseBackendHand
}
}
- protected void refreshMetaData(final ExecutionContext executionContext) throws SQLException {
+ private void refreshMetaData(final ExecutionContext executionContext) throws SQLException {
+ MetaDataRefreshEngine metaDataRefreshEngine = new MetaDataRefreshEngine(database, ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps());
Optional<MetaDataRefreshedEvent> event = metaDataRefreshEngine.refresh(executionContext.getSqlStatementContext(), executionContext.getRouteContext().getRouteUnits());
if (ProxyContext.getInstance().getContextManager().getInstanceContext().isCluster() && event.isPresent()) {
ProxyContext.getInstance().getContextManager().getInstanceContext().getEventBusContext().post(event.get());
}
}
- protected QueryResponseHeader processExecuteQuery(final ExecutionContext executionContext, final List<QueryResult> queryResults, final QueryResult queryResultSample) throws SQLException {
+ private QueryResponseHeader processExecuteQuery(final ExecutionContext executionContext, final List<QueryResult> queryResults, final QueryResult queryResultSample) throws SQLException {
queryHeaders = createQueryHeaders(executionContext, queryResultSample);
mergedResult = mergeQuery(executionContext.getSqlStatementContext(), queryResults);
return new QueryResponseHeader(queryHeaders);
}
- protected List<QueryHeader> createQueryHeaders(final ExecutionContext executionContext, final QueryResult queryResultSample) throws SQLException {
+ private List<QueryHeader> createQueryHeaders(final ExecutionContext executionContext, final QueryResult queryResultSample) throws SQLException {
int columnCount = getColumnCount(executionContext, queryResultSample);
List<QueryHeader> result = new ArrayList<>(columnCount);
QueryHeaderBuilderEngine queryHeaderBuilderEngine = new QueryHeaderBuilderEngine(database.getProtocolType());
@@ -151,42 +277,42 @@ public abstract class DatabaseCommunicationEngine implements DatabaseBackendHand
return result;
}
- protected QueryHeader createQueryHeader(final QueryHeaderBuilderEngine queryHeaderBuilderEngine, final ExecutionContext executionContext,
- final QueryResult queryResultSample, final ShardingSphereDatabase database, final int columnIndex) throws SQLException {
+ private QueryHeader createQueryHeader(final QueryHeaderBuilderEngine queryHeaderBuilderEngine, final ExecutionContext executionContext,
+ final QueryResult queryResultSample, final ShardingSphereDatabase database, final int columnIndex) throws SQLException {
return hasSelectExpandProjections(executionContext.getSqlStatementContext()) ? queryHeaderBuilderEngine.build(
((SelectStatementContext) executionContext.getSqlStatementContext()).getProjectionsContext(), queryResultSample.getMetaData(), database, columnIndex)
: queryHeaderBuilderEngine.build(queryResultSample.getMetaData(), database, columnIndex);
}
- protected int getColumnCount(final ExecutionContext executionContext, final QueryResult queryResultSample) throws SQLException {
+ private int getColumnCount(final ExecutionContext executionContext, final QueryResult queryResultSample) throws SQLException {
return hasSelectExpandProjections(executionContext.getSqlStatementContext())
? ((SelectStatementContext) executionContext.getSqlStatementContext()).getProjectionsContext().getExpandProjections().size()
: queryResultSample.getMetaData().getColumnCount();
}
- protected boolean hasSelectExpandProjections(final SQLStatementContext<?> sqlStatementContext) {
+ private boolean hasSelectExpandProjections(final SQLStatementContext<?> sqlStatementContext) {
return sqlStatementContext instanceof SelectStatementContext && !((SelectStatementContext) sqlStatementContext).getProjectionsContext().getExpandProjections().isEmpty();
}
- protected MergedResult mergeQuery(final SQLStatementContext<?> sqlStatementContext, final List<QueryResult> queryResults) throws SQLException {
+ private MergedResult mergeQuery(final SQLStatementContext<?> sqlStatementContext, final List<QueryResult> queryResults) throws SQLException {
MergeEngine mergeEngine = new MergeEngine(database, ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps(),
- getBackendConnection().getConnectionSession().getConnectionContext());
+ backendConnection.getConnectionSession().getConnectionContext());
return mergeEngine.merge(queryResults, sqlStatementContext);
}
- protected UpdateResponseHeader processExecuteUpdate(final ExecutionContext executionContext, final Collection<UpdateResult> updateResults) {
+ private UpdateResponseHeader processExecuteUpdate(final ExecutionContext executionContext, final Collection<UpdateResult> updateResults) {
UpdateResponseHeader result = new UpdateResponseHeader(executionContext.getSqlStatementContext().getSqlStatement(), updateResults);
mergeUpdateCount(executionContext.getSqlStatementContext(), result);
return result;
}
- protected void mergeUpdateCount(final SQLStatementContext<?> sqlStatementContext, final UpdateResponseHeader response) {
+ private void mergeUpdateCount(final SQLStatementContext<?> sqlStatementContext, final UpdateResponseHeader response) {
if (isNeedAccumulate(sqlStatementContext)) {
response.mergeUpdateCount();
}
}
- protected boolean isNeedAccumulate(final SQLStatementContext<?> sqlStatementContext) {
+ private boolean isNeedAccumulate(final SQLStatementContext<?> sqlStatementContext) {
Optional<DataNodeContainedRule> dataNodeContainedRule = findDataNodeContainedRule();
return dataNodeContainedRule.isPresent() && dataNodeContainedRule.get().isNeedAccumulate(sqlStatementContext.getTablesContext().getTableNames());
}
@@ -226,4 +352,61 @@ public abstract class DatabaseCommunicationEngine implements DatabaseBackendHand
}
return new QueryResponseRow(cells);
}
+
+ /**
+ * Close database communication engine.
+ *
+ * @throws SQLException SQL exception
+ */
+ @Override
+ public void close() throws SQLException {
+ Collection<SQLException> result = new LinkedList<>();
+ result.addAll(closeResultSets());
+ result.addAll(closeStatements());
+ closeFederationExecutor().ifPresent(result::add);
+ if (result.isEmpty()) {
+ return;
+ }
+ SQLException ex = new SQLException();
+ result.forEach(ex::setNextException);
+ throw ex;
+ }
+
+ private Collection<SQLException> closeResultSets() {
+ Collection<SQLException> result = new LinkedList<>();
+ for (ResultSet each : cachedResultSets) {
+ try {
+ each.close();
+ } catch (final SQLException ex) {
+ result.add(ex);
+ }
+ }
+ cachedResultSets.clear();
+ return result;
+ }
+
+ private Collection<SQLException> closeStatements() {
+ Collection<SQLException> result = new LinkedList<>();
+ for (Statement each : cachedStatements) {
+ try {
+ each.cancel();
+ each.close();
+ } catch (final SQLException ex) {
+ result.add(ex);
+ }
+ }
+ cachedStatements.clear();
+ return result;
+ }
+
+ private Optional<SQLException> closeFederationExecutor() {
+ if (null != federationExecutor) {
+ try {
+ federationExecutor.close();
+ } catch (final SQLException ex) {
+ return Optional.of(ex);
+ }
+ }
+ return Optional.empty();
+ }
}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactory.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactory.java
index 930000a886c..9c62285fb3c 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactory.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactory.java
@@ -22,16 +22,11 @@ import lombok.NoArgsConstructor;
import org.apache.shardingsphere.infra.binder.QueryContext;
import org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.JDBCDriverType;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
-import org.apache.shardingsphere.proxy.backend.communication.vertx.VertxBackendConnection;
-import org.apache.shardingsphere.proxy.backend.communication.vertx.VertxDatabaseCommunicationEngine;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
/**
* Database communication engine factory.
*/
-@SuppressWarnings("unchecked")
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class DatabaseCommunicationEngineFactory {
@@ -49,25 +44,16 @@ public final class DatabaseCommunicationEngineFactory {
/**
* Create new instance of {@link DatabaseCommunicationEngine}.
*
- * @param <T> type of DatabaseCommunicationEngine
* @param queryContext query context
* @param backendConnection backend connection
* @param preferPreparedStatement use prepared statement as possible
* @return created instance
*/
- public <T extends DatabaseCommunicationEngine> T newDatabaseCommunicationEngine(final QueryContext queryContext, final BackendConnection<?> backendConnection,
- final boolean preferPreparedStatement) {
+ public DatabaseCommunicationEngine newDatabaseCommunicationEngine(final QueryContext queryContext, final BackendConnection backendConnection, final boolean preferPreparedStatement) {
ShardingSphereDatabase database = ProxyContext.getInstance().getDatabase(backendConnection.getConnectionSession().getDatabaseName());
- T result;
- if (backendConnection instanceof JDBCBackendConnection) {
- JDBCBackendConnection jdbcBackendConnection = (JDBCBackendConnection) backendConnection;
- String driverType = preferPreparedStatement || !queryContext.getParameters().isEmpty() ? JDBCDriverType.PREPARED_STATEMENT : JDBCDriverType.STATEMENT;
- result = (T) new JDBCDatabaseCommunicationEngine(driverType, database, queryContext, jdbcBackendConnection);
- jdbcBackendConnection.add(result);
- } else {
- VertxBackendConnection vertxBackendConnection = (VertxBackendConnection) backendConnection;
- result = (T) new VertxDatabaseCommunicationEngine(database, queryContext, vertxBackendConnection);
- }
+ String driverType = preferPreparedStatement || !queryContext.getParameters().isEmpty() ? JDBCDriverType.PREPARED_STATEMENT : JDBCDriverType.STATEMENT;
+ DatabaseCommunicationEngine result = new DatabaseCommunicationEngine(driverType, database, queryContext, backendConnection);
+ backendConnection.add(result);
return result;
}
}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/ProxySQLExecutor.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/ProxySQLExecutor.java
index 4992eb2170d..c4a719e154f 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/ProxySQLExecutor.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/ProxySQLExecutor.java
@@ -40,11 +40,9 @@ import org.apache.shardingsphere.infra.executor.sql.prepare.raw.RawExecutionPrep
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.rule.identifier.type.RawExecutionRule;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.ProxyJDBCExecutor;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.JDBCBackendStatement;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.JDBCBackendTransactionManager;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.BackendTransactionManager;
import org.apache.shardingsphere.proxy.backend.context.BackendExecutorContext;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.transaction.TransactionStatus;
@@ -76,13 +74,13 @@ public final class ProxySQLExecutor {
private final String type;
- private final JDBCBackendConnection backendConnection;
+ private final BackendConnection backendConnection;
private final ProxyJDBCExecutor jdbcExecutor;
private final RawExecutor rawExecutor;
- public ProxySQLExecutor(final String type, final JDBCBackendConnection backendConnection, final JDBCDatabaseCommunicationEngine databaseCommunicationEngine) {
+ public ProxySQLExecutor(final String type, final BackendConnection backendConnection, final DatabaseCommunicationEngine databaseCommunicationEngine) {
this.type = type;
this.backendConnection = backendConnection;
ExecutorEngine executorEngine = BackendExecutorContext.getInstance().getExecutorEngine();
@@ -160,7 +158,7 @@ public final class ProxySQLExecutor {
private List<ExecuteResult> doExecuteWithImplicitCommitTransaction(final ExecutionContext executionContext) throws SQLException {
List<ExecuteResult> result;
- JDBCBackendTransactionManager transactionManager = new JDBCBackendTransactionManager(backendConnection);
+ BackendTransactionManager transactionManager = new BackendTransactionManager(backendConnection);
try {
transactionManager.begin();
result = doExecute(executionContext);
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/ReactiveProxySQLExecutor.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/ReactiveProxySQLExecutor.java
deleted file mode 100644
index f5d2650f2ed..00000000000
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/ReactiveProxySQLExecutor.java
+++ /dev/null
@@ -1,163 +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.proxy.backend.communication;
-
-import io.vertx.core.Future;
-import io.vertx.sqlclient.SqlClient;
-import org.apache.shardingsphere.dialect.exception.transaction.TableModifyInTransactionException;
-import org.apache.shardingsphere.infra.binder.type.TableAvailable;
-import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.executor.kernel.model.ExecutionGroupContext;
-import org.apache.shardingsphere.infra.executor.sql.context.ExecutionContext;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.sane.SaneQueryResultEngineFactory;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.vertx.VertxExecutionUnit;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.vertx.VertxExecutor;
-import org.apache.shardingsphere.infra.executor.sql.execute.result.ExecuteResult;
-import org.apache.shardingsphere.infra.executor.sql.prepare.driver.DriverExecutionPrepareEngine;
-import org.apache.shardingsphere.infra.executor.sql.prepare.driver.vertx.VertxExecutionContext;
-import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-import org.apache.shardingsphere.proxy.backend.communication.vertx.VertxBackendConnection;
-import org.apache.shardingsphere.proxy.backend.communication.vertx.VertxBackendStatement;
-import org.apache.shardingsphere.proxy.backend.communication.vertx.executor.ProxyReactiveExecutor;
-import org.apache.shardingsphere.proxy.backend.context.BackendExecutorContext;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.session.transaction.TransactionStatus;
-import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
-import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CloseStatement;
-import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DDLStatement;
-import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.FetchStatement;
-import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.MoveStatement;
-import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.TruncateStatement;
-import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.OpenGaussStatement;
-import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCursorStatement;
-import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.PostgreSQLStatement;
-import org.apache.shardingsphere.transaction.api.TransactionType;
-
-import java.sql.SQLException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Optional;
-
-/**
- * Reactive proxy SQL executor.
- */
-public final class ReactiveProxySQLExecutor {
-
- private static final String TYPE = "Vert.x";
-
- private final VertxBackendConnection backendConnection;
-
- private final ProxyReactiveExecutor reactiveExecutor;
-
- public ReactiveProxySQLExecutor(final VertxBackendConnection backendConnection) {
- this.backendConnection = backendConnection;
- reactiveExecutor = new ProxyReactiveExecutor(new VertxExecutor(BackendExecutorContext.getInstance().getExecutorEngine()));
- }
-
- /**
- * Check execute prerequisites.
- *
- * @param executionContext execution context
- */
- public void checkExecutePrerequisites(final ExecutionContext executionContext) {
- if (isExecuteDDLInXATransaction(executionContext.getSqlStatementContext().getSqlStatement())
- || isExecuteDDLInPostgreSQLOpenGaussTransaction(executionContext.getSqlStatementContext().getSqlStatement())) {
- String tableName = executionContext.getSqlStatementContext() instanceof TableAvailable && !((TableAvailable) executionContext.getSqlStatementContext()).getAllTables().isEmpty()
- ? ((TableAvailable) executionContext.getSqlStatementContext()).getAllTables().iterator().next().getTableName().getIdentifier().getValue()
- : "unknown_table";
- throw new TableModifyInTransactionException(tableName);
- }
- }
-
- private boolean isExecuteDDLInXATransaction(final SQLStatement sqlStatement) {
- TransactionStatus transactionStatus = backendConnection.getConnectionSession().getTransactionStatus();
- return TransactionType.XA == transactionStatus.getTransactionType() && transactionStatus.isInTransaction() && isUnsupportedDDLStatement(sqlStatement);
- }
-
- private boolean isExecuteDDLInPostgreSQLOpenGaussTransaction(final SQLStatement sqlStatement) {
- // TODO implement DDL statement commit/rollback in PostgreSQL/openGauss transaction
- boolean isPostgreSQLOpenGaussStatement = isPostgreSQLOrOpenGaussStatement(sqlStatement);
- boolean isSupportedStatement = isSupportedSQLStatement(sqlStatement);
- return sqlStatement instanceof DDLStatement && !isSupportedStatement && isPostgreSQLOpenGaussStatement && backendConnection.getConnectionSession().getTransactionStatus().isInTransaction();
- }
-
- private boolean isUnsupportedDDLStatement(final SQLStatement sqlStatement) {
- if (isPostgreSQLOrOpenGaussStatement(sqlStatement) && isSupportedSQLStatement(sqlStatement)) {
- return false;
- }
- return sqlStatement instanceof DDLStatement;
- }
-
- private boolean isSupportedSQLStatement(final SQLStatement sqlStatement) {
- return isCursorStatement(sqlStatement) || sqlStatement instanceof TruncateStatement;
- }
-
- private boolean isCursorStatement(final SQLStatement sqlStatement) {
- return sqlStatement instanceof OpenGaussCursorStatement
- || sqlStatement instanceof CloseStatement || sqlStatement instanceof MoveStatement || sqlStatement instanceof FetchStatement;
- }
-
- private boolean isPostgreSQLOrOpenGaussStatement(final SQLStatement sqlStatement) {
- return sqlStatement instanceof PostgreSQLStatement || sqlStatement instanceof OpenGaussStatement;
- }
-
- /**
- * Execute SQL.
- *
- * @param executionContext execution context
- * @return execute results
- * @throws SQLException SQL exception
- */
- public Future<List<ExecuteResult>> execute(final ExecutionContext executionContext) throws SQLException {
- String databaseName = backendConnection.getConnectionSession().getDatabaseName();
- Collection<ShardingSphereRule> rules = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabase(databaseName).getRuleMetaData().getRules();
- int maxConnectionsSizePerQuery = ProxyContext.getInstance()
- .getContextManager().getMetaDataContexts().getMetaData().getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
- return useDriverToExecute(executionContext, rules, maxConnectionsSizePerQuery);
- }
-
- private Future<List<ExecuteResult>> useDriverToExecute(final ExecutionContext executionContext, final Collection<ShardingSphereRule> rules,
- final int maxConnectionsSizePerQuery) throws SQLException {
- VertxBackendStatement statementManager = (VertxBackendStatement) backendConnection.getConnectionSession().getStatementManager();
- DriverExecutionPrepareEngine<VertxExecutionUnit, Future<? extends SqlClient>> prepareEngine = new DriverExecutionPrepareEngine<>(
- TYPE, maxConnectionsSizePerQuery, backendConnection, statementManager, new VertxExecutionContext(), rules,
- ProxyContext.getInstance().getDatabase(backendConnection.getConnectionSession().getDatabaseName()).getResourceMetaData().getStorageTypes());
- ExecutionGroupContext<VertxExecutionUnit> executionGroupContext;
- try {
- executionGroupContext = prepareEngine.prepare(executionContext.getRouteContext(), executionContext.getExecutionUnits());
- } catch (final SQLException ex) {
- return Future.succeededFuture(getSaneExecuteResults(executionContext, ex));
- }
- executionGroupContext.setDatabaseName(backendConnection.getConnectionSession().getDatabaseName());
- executionGroupContext.setGrantee(backendConnection.getConnectionSession().getGrantee());
- executionGroupContext.setExecutionID(backendConnection.getConnectionSession().getExecutionId());
- return reactiveExecutor.execute(executionContext.getQueryContext(), executionGroupContext);
- }
-
- private List<ExecuteResult> getSaneExecuteResults(final ExecutionContext executionContext, final SQLException originalException) throws SQLException {
- DatabaseType databaseType = ProxyContext.getInstance().getDatabase(backendConnection.getConnectionSession().getDatabaseName()).getProtocolType();
- Optional<ExecuteResult> executeResult = SaneQueryResultEngineFactory.getInstance(databaseType)
- .getSaneQueryResult(executionContext.getSqlStatementContext().getSqlStatement(), originalException);
- if (executeResult.isPresent()) {
- return Collections.singletonList(executeResult.get());
- }
- throw originalException;
- }
-}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/TransactionManager.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/TransactionManager.java
index 41eeb61c780..96a3c6842c8 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/TransactionManager.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/TransactionManager.java
@@ -21,59 +21,51 @@ import java.sql.SQLException;
/**
* Transaction manager interface for proxy.
- *
- * @param <T> return type of methods
*/
-public interface TransactionManager<T> {
+public interface TransactionManager {
/**
* Begin transaction.
*
- * @return can be Void or Future
* @throws SQLException SQL exception
*/
- T begin() throws SQLException;
+ void begin() throws SQLException;
/**
* Commit transaction.
*
- * @return can be Void or Future
* @throws SQLException SQL exception
*/
- T commit() throws SQLException;
+ void commit() throws SQLException;
/**
* Rollback transaction.
*
- * @return can be Void or Future
* @throws SQLException SQL exception
*/
- T rollback() throws SQLException;
+ void rollback() throws SQLException;
/**
* Set savepoint.
*
* @param savepointName savepoint name
- * @return can be Void or Future
* @throws SQLException SQL exception
*/
- T setSavepoint(String savepointName) throws SQLException;
+ void setSavepoint(String savepointName) throws SQLException;
/**
* Rollback to savepoint.
*
* @param savepointName savepoint name
- * @return can be Void or Future
* @throws SQLException SQL exception
*/
- T rollbackTo(String savepointName) throws SQLException;
+ void rollbackTo(String savepointName) throws SQLException;
/**
* Release savepoint.
*
* @param savepointName savepoint name
- * @return can be Void or Future
* @throws SQLException SQL exception
*/
- T releaseSavepoint(String savepointName) throws SQLException;
+ void releaseSavepoint(String savepointName) throws SQLException;
}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java
deleted file mode 100644
index ceb2ad2423e..00000000000
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java
+++ /dev/null
@@ -1,243 +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.proxy.backend.communication.jdbc;
-
-import org.apache.shardingsphere.infra.binder.QueryContext;
-import org.apache.shardingsphere.infra.binder.decider.context.SQLFederationDeciderContext;
-import org.apache.shardingsphere.infra.binder.decider.engine.SQLFederationDeciderEngine;
-import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
-import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.database.type.DatabaseTypeEngine;
-import org.apache.shardingsphere.infra.executor.sql.context.ExecutionContext;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.SQLExecutorExceptionHandler;
-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.result.query.QueryResult;
-import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.driver.jdbc.metadata.JDBCQueryResultMetaData;
-import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.driver.jdbc.type.stream.JDBCStreamQueryResult;
-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.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
-import org.apache.shardingsphere.proxy.backend.communication.ProxySQLExecutor;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.ProxyJDBCExecutorCallback;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.ProxyJDBCExecutorCallbackFactory;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.JDBCBackendStatement;
-import org.apache.shardingsphere.proxy.backend.context.BackendExecutorContext;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import org.apache.shardingsphere.proxy.backend.response.header.query.QueryHeaderBuilderEngine;
-import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
-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.rule.SQLFederationRule;
-import org.apache.shardingsphere.sqlfederation.spi.SQLFederationExecutor;
-import org.apache.shardingsphere.sqlfederation.spi.SQLFederationExecutorContext;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-/**
- * JDBC database communication engine.
- */
-public final class JDBCDatabaseCommunicationEngine extends DatabaseCommunicationEngine {
-
- private final ProxySQLExecutor proxySQLExecutor;
-
- private final Collection<Statement> cachedStatements = new CopyOnWriteArrayList<>();
-
- private final Collection<ResultSet> cachedResultSets = new CopyOnWriteArrayList<>();
-
- private final JDBCBackendConnection backendConnection;
-
- private volatile SQLFederationExecutor federationExecutor;
-
- public JDBCDatabaseCommunicationEngine(final String driverType, final ShardingSphereDatabase database, final QueryContext queryContext, final JDBCBackendConnection backendConnection) {
- super(driverType, database, queryContext, backendConnection);
- proxySQLExecutor = new ProxySQLExecutor(driverType, backendConnection, this);
- this.backendConnection = backendConnection;
- }
-
- /**
- * Add statement.
- *
- * @param statement statement to be added
- */
- public void add(final Statement statement) {
- cachedStatements.add(statement);
- }
-
- /**
- * Add result set.
- *
- * @param resultSet result set to be added
- */
- public void add(final ResultSet resultSet) {
- cachedResultSets.add(resultSet);
- }
-
- /**
- * Execute to database.
- *
- * @return backend response
- */
- @SuppressWarnings({"unchecked", "rawtypes"})
- @Override
- public ResponseHeader execute() throws SQLException {
- QueryContext queryContext = getQueryContext();
- MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
- ShardingSphereDatabase database = metaDataContexts.getMetaData().getDatabase(backendConnection.getConnectionSession().getDatabaseName());
- SQLFederationDeciderContext deciderContext = decide(queryContext, metaDataContexts.getMetaData().getProps(), database);
- if (deciderContext.isUseSQLFederation()) {
- prepareFederationExecutor();
- ResultSet resultSet = doExecuteFederation(queryContext, metaDataContexts);
- return processExecuteFederation(resultSet, metaDataContexts);
- }
- ExecutionContext executionContext = getKernelProcessor().generateExecutionContext(queryContext, getDatabase(), metaDataContexts.getMetaData().getGlobalRuleMetaData(),
- metaDataContexts.getMetaData().getProps(), backendConnection.getConnectionSession().getConnectionContext());
- if (executionContext.getExecutionUnits().isEmpty()) {
- return new UpdateResponseHeader(executionContext.getSqlStatementContext().getSqlStatement());
- }
- proxySQLExecutor.checkExecutePrerequisites(executionContext);
- List result = proxySQLExecutor.execute(executionContext);
- refreshMetaData(executionContext);
- Object executeResultSample = result.iterator().next();
- return executeResultSample instanceof QueryResult
- ? processExecuteQuery(executionContext, result, (QueryResult) executeResultSample)
- : processExecuteUpdate(executionContext, result);
- }
-
- private static SQLFederationDeciderContext decide(final QueryContext queryContext, final ConfigurationProperties props, final ShardingSphereDatabase database) {
- SQLFederationDeciderEngine deciderEngine = new SQLFederationDeciderEngine(database.getRuleMetaData().getRules(), props);
- return deciderEngine.decide(queryContext, database);
- }
-
- private void prepareFederationExecutor() {
- MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
- String databaseName = backendConnection.getConnectionSession().getDatabaseName();
- DatabaseType databaseType = getQueryContext().getSqlStatementContext().getDatabaseType();
- String schemaName = getQueryContext().getSqlStatementContext().getTablesContext().getSchemaName().orElseGet(() -> DatabaseTypeEngine.getDefaultSchemaName(databaseType, databaseName));
- SQLFederationRule sqlFederationRule = metaDataContexts.getMetaData().getGlobalRuleMetaData().getSingleRule(SQLFederationRule.class);
- federationExecutor = sqlFederationRule.getSQLFederationExecutor(databaseName, schemaName, metaDataContexts.getMetaData(), metaDataContexts.getShardingSphereData(),
- new JDBCExecutor(BackendExecutorContext.getInstance().getExecutorEngine(), backendConnection.getConnectionSession().getConnectionContext()),
- ProxyContext.getInstance().getContextManager().getInstanceContext().getEventBusContext());
- }
-
- private ResultSet doExecuteFederation(final QueryContext queryContext, final MetaDataContexts metaDataContexts) throws SQLException {
- boolean isReturnGeneratedKeys = queryContext.getSqlStatementContext().getSqlStatement() instanceof MySQLInsertStatement;
- ShardingSphereDatabase database = metaDataContexts.getMetaData().getDatabase(backendConnection.getConnectionSession().getDatabaseName());
- DatabaseType protocolType = database.getProtocolType();
- Map<String, DatabaseType> storageTypes = database.getResourceMetaData().getStorageTypes();
- ProxyJDBCExecutorCallback callback = ProxyJDBCExecutorCallbackFactory.newInstance(getDriverType(), protocolType, storageTypes,
- queryContext.getSqlStatementContext().getSqlStatement(), this, isReturnGeneratedKeys, SQLExecutorExceptionHandler.isExceptionThrown(), true);
- DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine = createDriverExecutionPrepareEngine(isReturnGeneratedKeys, metaDataContexts);
- SQLFederationExecutorContext context = new SQLFederationExecutorContext(false, queryContext, metaDataContexts.getMetaData());
- return federationExecutor.executeQuery(prepareEngine, callback, context);
- }
-
- private DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> createDriverExecutionPrepareEngine(final boolean isReturnGeneratedKeys, final MetaDataContexts metaData) {
- int maxConnectionsSizePerQuery = metaData.getMetaData().getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
- JDBCBackendStatement statementManager = (JDBCBackendStatement) backendConnection.getConnectionSession().getStatementManager();
- return new DriverExecutionPrepareEngine<>(getDriverType(), maxConnectionsSizePerQuery, backendConnection, statementManager,
- new StatementOption(isReturnGeneratedKeys), metaData.getMetaData().getDatabase(backendConnection.getConnectionSession().getDatabaseName()).getRuleMetaData().getRules(),
- metaData.getMetaData().getDatabase(backendConnection.getConnectionSession().getDatabaseName()).getResourceMetaData().getStorageTypes());
- }
-
- private ResponseHeader processExecuteFederation(final ResultSet resultSet, final MetaDataContexts metaDataContexts) throws SQLException {
- int columnCount = resultSet.getMetaData().getColumnCount();
- setQueryHeaders(new ArrayList<>(columnCount));
- ShardingSphereDatabase database = metaDataContexts.getMetaData().getDatabase(backendConnection.getConnectionSession().getDatabaseName());
- QueryHeaderBuilderEngine queryHeaderBuilderEngine = new QueryHeaderBuilderEngine(null == database ? null : database.getProtocolType());
- for (int columnIndex = 1; columnIndex <= columnCount; columnIndex++) {
- getQueryHeaders().add(queryHeaderBuilderEngine.build(new JDBCQueryResultMetaData(resultSet.getMetaData()), database, columnIndex));
- }
- setMergedResult(new IteratorStreamMergedResult(Collections.singletonList(new JDBCStreamQueryResult(resultSet))));
- return new QueryResponseHeader(getQueryHeaders());
- }
-
- /**
- * Close database communication engine.
- *
- * @throws SQLException SQL exception
- */
- @Override
- public void close() throws SQLException {
- Collection<SQLException> result = new LinkedList<>();
- result.addAll(closeResultSets());
- result.addAll(closeStatements());
- closeFederationExecutor().ifPresent(result::add);
- if (result.isEmpty()) {
- return;
- }
- SQLException ex = new SQLException();
- result.forEach(ex::setNextException);
- throw ex;
- }
-
- private Collection<SQLException> closeResultSets() {
- Collection<SQLException> result = new LinkedList<>();
- for (ResultSet each : cachedResultSets) {
- try {
- each.close();
- } catch (final SQLException ex) {
- result.add(ex);
- }
- }
- cachedResultSets.clear();
- return result;
- }
-
- private Collection<SQLException> closeStatements() {
- Collection<SQLException> result = new LinkedList<>();
- for (Statement each : cachedStatements) {
- try {
- each.cancel();
- each.close();
- } catch (final SQLException ex) {
- result.add(ex);
- }
- }
- cachedStatements.clear();
- return result;
- }
-
- private Optional<SQLException> closeFederationExecutor() {
- if (null != federationExecutor) {
- try {
- federationExecutor.close();
- } catch (final SQLException ex) {
- return Optional.of(ex);
- }
- }
- return Optional.empty();
- }
-}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/ConnectionPostProcessor.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/ConnectionPostProcessor.java
index 7a46bf4f144..23d0f31d89c 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/ConnectionPostProcessor.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/ConnectionPostProcessor.java
@@ -17,18 +17,18 @@
package org.apache.shardingsphere.proxy.backend.communication.jdbc.connection;
+import java.sql.Connection;
+
/**
* Connection post processor.
- *
- * @param <T> connection type
*/
@FunctionalInterface
-public interface ConnectionPostProcessor<T> {
+public interface ConnectionPostProcessor {
/**
* Process connection.
*
* @param target target connection
*/
- void process(T target);
+ void process(Connection target);
}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCBackendConnection.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCBackendConnection.java
deleted file mode 100644
index c6e0825df05..00000000000
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCBackendConnection.java
+++ /dev/null
@@ -1,336 +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.proxy.backend.communication.jdbc.connection;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.LinkedHashMultimap;
-import com.google.common.collect.Multimap;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode;
-import org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.ExecutorJDBCConnectionManager;
-import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.JDBCBackendTransactionManager;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.exception.BackendConnectionException;
-import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandler;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.backend.util.TransactionUtil;
-import org.apache.shardingsphere.transaction.api.TransactionType;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-/**
- * JDBC backend connection.
- */
-@RequiredArgsConstructor
-@Getter
-public final class JDBCBackendConnection implements BackendConnection<Void>, ExecutorJDBCConnectionManager {
-
- private final ConnectionSession connectionSession;
-
- private final Multimap<String, Connection> cachedConnections = LinkedHashMultimap.create();
-
- private final Collection<ProxyBackendHandler> backendHandlers = Collections.newSetFromMap(new ConcurrentHashMap<>(64));
-
- private final Collection<ProxyBackendHandler> inUseBackendHandlers = Collections.newSetFromMap(new ConcurrentHashMap<>(64));
-
- private final Collection<ConnectionPostProcessor<Connection>> connectionPostProcessors = new LinkedList<>();
-
- private final ResourceLock resourceLock = new ResourceLock();
-
- private final AtomicBoolean closed = new AtomicBoolean(false);
-
- @Override
- public List<Connection> getConnections(final String dataSourceName, final int connectionSize, final ConnectionMode connectionMode) throws SQLException {
- Preconditions.checkNotNull(connectionSession.getDatabaseName(), "Current database name is null.");
- Collection<Connection> connections;
- synchronized (cachedConnections) {
- connections = cachedConnections.get(connectionSession.getDatabaseName().toLowerCase() + "." + dataSourceName);
- }
- List<Connection> result;
- if (connections.size() >= connectionSize) {
- result = new ArrayList<>(connections).subList(0, connectionSize);
- } else if (!connections.isEmpty()) {
- result = new ArrayList<>(connectionSize);
- result.addAll(connections);
- List<Connection> newConnections = createNewConnections(dataSourceName, connectionSize - connections.size(), connectionMode);
- result.addAll(newConnections);
- synchronized (cachedConnections) {
- cachedConnections.putAll(connectionSession.getDatabaseName().toLowerCase() + "." + dataSourceName, newConnections);
- }
- } else {
- result = createNewConnections(dataSourceName, connectionSize, connectionMode);
- synchronized (cachedConnections) {
- cachedConnections.putAll(connectionSession.getDatabaseName().toLowerCase() + "." + dataSourceName, result);
- }
- }
- return result;
- }
-
- private List<Connection> createNewConnections(final String dataSourceName, final int connectionSize, final ConnectionMode connectionMode) throws SQLException {
- List<Connection> result = ProxyContext.getInstance().getBackendDataSource().getConnections(connectionSession.getDatabaseName().toLowerCase(), dataSourceName, connectionSize, connectionMode);
- setSessionVariablesIfNecessary(result);
- for (Connection each : result) {
- replayTransactionOption(each);
- }
- if (connectionSession.getTransactionStatus().isInTransaction()) {
- for (Connection each : result) {
- replayMethodsInvocation(each);
- }
- }
- return result;
- }
-
- private void setSessionVariablesIfNecessary(final List<Connection> connections) throws SQLException {
- if (connectionSession.getRequiredSessionVariableRecorder().isEmpty() || connections.isEmpty()) {
- return;
- }
- String databaseType = connections.iterator().next().getMetaData().getDatabaseProductName();
- List<String> setSQLs = connectionSession.getRequiredSessionVariableRecorder().toSetSQLs(databaseType);
- SQLException sqlException = null;
- for (Connection each : connections) {
- try (Statement statement = each.createStatement()) {
- for (String eachSetSQL : setSQLs) {
- statement.execute(eachSetSQL);
- }
- } catch (final SQLException ex) {
- sqlException = ex;
- break;
- }
- }
- if (null == sqlException) {
- return;
- }
- for (Connection each : connections) {
- try {
- each.close();
- } catch (final SQLException ex) {
- sqlException.setNextException(ex);
- }
- }
- throw sqlException;
- }
-
- private void replayMethodsInvocation(final Connection target) {
- for (ConnectionPostProcessor<Connection> each : connectionPostProcessors) {
- each.process(target);
- }
- }
-
- private void replayTransactionOption(final Connection connection) throws SQLException {
- if (null == connection) {
- return;
- }
- if (connectionSession.isReadOnly()) {
- connection.setReadOnly(true);
- }
- if (null != connectionSession.getIsolationLevel()) {
- connection.setTransactionIsolation(TransactionUtil.getTransactionIsolationLevel(connectionSession.getIsolationLevel()));
- }
- }
-
- @Override
- public Collection<String> getDataSourceNamesOfCachedConnections() {
- Collection<String> result = new ArrayList<>(cachedConnections.size());
- String databaseName = connectionSession.getDatabaseName().toLowerCase();
- for (String each : cachedConnections.keySet()) {
- String[] split = each.split("\\.", 2);
- String cachedDatabaseName = split[0];
- String cachedDataSourceName = split[1];
- if (databaseName.equals(cachedDatabaseName)) {
- result.add(cachedDataSourceName);
- }
- }
- return result;
- }
-
- /**
- * Whether execute SQL serial or not.
- *
- * @return true or false
- */
- public boolean isSerialExecute() {
- return connectionSession.getTransactionStatus().isInTransaction()
- && (TransactionType.LOCAL == connectionSession.getTransactionStatus().getTransactionType() || TransactionType.XA == connectionSession.getTransactionStatus().getTransactionType());
- }
-
- /**
- * Get connection size.
- *
- * @return connection size
- */
- public int getConnectionSize() {
- return cachedConnections.values().size();
- }
-
- /**
- * Add handler.
- *
- * @param handler handler to be added
- */
- public void add(final ProxyBackendHandler handler) {
- backendHandlers.add(handler);
- }
-
- /**
- * Mark a handler as in use.
- *
- * @param handler handler to be marked
- */
- public void markResourceInUse(final ProxyBackendHandler handler) {
- inUseBackendHandlers.add(handler);
- }
-
- /**
- * Unmark a in use proxy backend handler.
- *
- * @param handler proxy backend handler to be added
- */
- public void unmarkResourceInUse(final ProxyBackendHandler handler) {
- inUseBackendHandlers.remove(handler);
- }
-
- @Override
- public Void prepareForTaskExecution() {
- return null;
- }
-
- @Override
- public Void handleAutoCommit() {
- if (!connectionSession.isAutoCommit() && !connectionSession.getTransactionStatus().isInTransaction()) {
- JDBCBackendTransactionManager transactionManager = new JDBCBackendTransactionManager(this);
- transactionManager.begin();
- }
- return null;
- }
-
- @Override
- public Void closeExecutionResources() throws BackendConnectionException {
- synchronized (this) {
- Collection<Exception> result = new LinkedList<>(closeHandlers(false));
- if (!connectionSession.getTransactionStatus().isInConnectionHeldTransaction()) {
- result.addAll(closeHandlers(true));
- result.addAll(closeConnections(false));
- } else if (closed.get()) {
- result.addAll(closeHandlers(true));
- result.addAll(closeConnections(true));
- }
- if (result.isEmpty()) {
- return null;
- }
- throw new BackendConnectionException(result);
- }
- }
-
- @Override
- public Void closeAllResources() {
- synchronized (this) {
- closed.set(true);
- closeHandlers(true);
- closeConnections(true);
- return null;
- }
- }
-
- /**
- * Close handlers.
- *
- * @param includeInUse include handlers in use
- * @return SQL exception when handler close
- */
- public Collection<SQLException> closeHandlers(final boolean includeInUse) {
- Collection<SQLException> result = new LinkedList<>();
- for (ProxyBackendHandler each : backendHandlers) {
- if (!includeInUse && inUseBackendHandlers.contains(each)) {
- continue;
- }
- try {
- each.close();
- } catch (final SQLException ex) {
- result.add(ex);
- }
- }
- if (includeInUse) {
- inUseBackendHandlers.clear();
- }
- backendHandlers.retainAll(inUseBackendHandlers);
- return result;
- }
-
- /**
- * Close connections.
- *
- * @param forceRollback is force rollback
- * @return SQL exception when connections close
- */
- public Collection<SQLException> closeConnections(final boolean forceRollback) {
- Collection<SQLException> result = new LinkedList<>();
- synchronized (cachedConnections) {
- resetSessionVariablesIfNecessary(cachedConnections.values(), result);
- for (Connection each : cachedConnections.values()) {
- try {
- if (forceRollback && connectionSession.getTransactionStatus().isInTransaction()) {
- each.rollback();
- }
- each.close();
- } catch (final SQLException ex) {
- result.add(ex);
- }
- }
- cachedConnections.clear();
- }
- if (!forceRollback) {
- connectionPostProcessors.clear();
- }
- return result;
- }
-
- private void resetSessionVariablesIfNecessary(final Collection<Connection> values, final Collection<SQLException> exceptions) {
- if (connectionSession.getRequiredSessionVariableRecorder().isEmpty() || values.isEmpty()) {
- return;
- }
- String databaseType;
- try {
- databaseType = values.iterator().next().getMetaData().getDatabaseProductName();
- } catch (final SQLException ex) {
- exceptions.add(ex);
- return;
- }
- List<String> resetSQLs = connectionSession.getRequiredSessionVariableRecorder().toResetSQLs(databaseType);
- for (Connection each : values) {
- try (Statement statement = each.createStatement()) {
- for (String eachResetSQL : resetSQLs) {
- statement.execute(eachResetSQL);
- }
- } catch (final SQLException ex) {
- exceptions.add(ex);
- }
- }
- connectionSession.getRequiredSessionVariableRecorder().removeVariablesWithDefaultValue();
- }
-}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/ProxyJDBCExecutor.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/ProxyJDBCExecutor.java
index 989ccd542c4..61d715f38cb 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/ProxyJDBCExecutor.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/ProxyJDBCExecutor.java
@@ -29,7 +29,7 @@ import org.apache.shardingsphere.infra.executor.sql.execute.result.ExecuteResult
import org.apache.shardingsphere.infra.executor.sql.process.ExecuteProcessEngine;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine;
+import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.ProxyJDBCExecutorCallbackFactory;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
@@ -48,7 +48,7 @@ public final class ProxyJDBCExecutor {
private final ConnectionSession connectionSession;
- private final JDBCDatabaseCommunicationEngine databaseCommunicationEngine;
+ private final DatabaseCommunicationEngine databaseCommunicationEngine;
private final JDBCExecutor jdbcExecutor;
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/callback/ProxyJDBCExecutorCallback.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/callback/ProxyJDBCExecutorCallback.java
index 1a34ae79c2b..702d01e1f03 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/callback/ProxyJDBCExecutorCallback.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/callback/ProxyJDBCExecutorCallback.java
@@ -28,7 +28,7 @@ import org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryRe
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.driver.jdbc.type.memory.JDBCMemoryQueryResult;
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.driver.jdbc.type.stream.JDBCStreamQueryResult;
import org.apache.shardingsphere.infra.executor.sql.execute.result.update.UpdateResult;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine;
+import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
@@ -44,7 +44,7 @@ import java.util.Optional;
*/
public abstract class ProxyJDBCExecutorCallback extends JDBCExecutorCallback<ExecuteResult> {
- private final JDBCDatabaseCommunicationEngine databaseCommunicationEngine;
+ private final DatabaseCommunicationEngine databaseCommunicationEngine;
private final boolean isReturnGeneratedKeys;
@@ -53,7 +53,7 @@ public abstract class ProxyJDBCExecutorCallback extends JDBCExecutorCallback<Exe
private boolean hasMetaData;
public ProxyJDBCExecutorCallback(final DatabaseType protocolType, final Map<String, DatabaseType> storageTypes, final SQLStatement sqlStatement,
- final JDBCDatabaseCommunicationEngine databaseCommunicationEngine,
+ final DatabaseCommunicationEngine databaseCommunicationEngine,
final boolean isReturnGeneratedKeys, final boolean isExceptionThrown, final boolean fetchMetaData) {
super(protocolType, storageTypes, sqlStatement, isExceptionThrown, ProxyContext.getInstance().getContextManager().getInstanceContext().getEventBusContext());
this.databaseCommunicationEngine = databaseCommunicationEngine;
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/callback/ProxyJDBCExecutorCallbackFactory.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/callback/ProxyJDBCExecutorCallbackFactory.java
index 493b26c99e2..b89ea03e46d 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/callback/ProxyJDBCExecutorCallbackFactory.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/callback/ProxyJDBCExecutorCallbackFactory.java
@@ -22,7 +22,7 @@ import lombok.NoArgsConstructor;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.JDBCDriverType;
import org.apache.shardingsphere.infra.util.exception.external.sql.type.generic.UnsupportedSQLOperationException;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine;
+import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.impl.ProxyPreparedStatementExecutorCallback;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.impl.ProxyStatementExecutorCallback;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
@@ -49,7 +49,7 @@ public final class ProxyJDBCExecutorCallbackFactory {
* @return created instance
*/
public static ProxyJDBCExecutorCallback newInstance(final String type, final DatabaseType protocolType, final Map<String, DatabaseType> storageTypes, final SQLStatement sqlStatement,
- final JDBCDatabaseCommunicationEngine databaseCommunicationEngine, final boolean isReturnGeneratedKeys, final boolean isExceptionThrown,
+ final DatabaseCommunicationEngine databaseCommunicationEngine, final boolean isReturnGeneratedKeys, final boolean isExceptionThrown,
final boolean isFetchMetaData) {
if (JDBCDriverType.STATEMENT.equals(type)) {
return new ProxyStatementExecutorCallback(protocolType, storageTypes, sqlStatement, databaseCommunicationEngine, isReturnGeneratedKeys, isExceptionThrown, isFetchMetaData);
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/callback/impl/ProxyPreparedStatementExecutorCallback.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/callback/impl/ProxyPreparedStatementExecutorCallback.java
index 3d028a060d2..5196ab220fb 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/callback/impl/ProxyPreparedStatementExecutorCallback.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/callback/impl/ProxyPreparedStatementExecutorCallback.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.impl;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine;
+import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.ProxyJDBCExecutorCallback;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
@@ -33,7 +33,7 @@ import java.util.Map;
public final class ProxyPreparedStatementExecutorCallback extends ProxyJDBCExecutorCallback {
public ProxyPreparedStatementExecutorCallback(final DatabaseType protocolType, final Map<String, DatabaseType> storageTypes, final SQLStatement sqlStatement,
- final JDBCDatabaseCommunicationEngine databaseCommunicationEngine, final boolean isReturnGeneratedKeys,
+ final DatabaseCommunicationEngine databaseCommunicationEngine, final boolean isReturnGeneratedKeys,
final boolean isExceptionThrown, final boolean fetchMetaData) {
super(protocolType, storageTypes, sqlStatement, databaseCommunicationEngine, isReturnGeneratedKeys, isExceptionThrown, fetchMetaData);
}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/callback/impl/ProxyStatementExecutorCallback.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/callback/impl/ProxyStatementExecutorCallback.java
index 21e3209eaa0..fa8453facb3 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/callback/impl/ProxyStatementExecutorCallback.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/callback/impl/ProxyStatementExecutorCallback.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.impl;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine;
+import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.ProxyJDBCExecutorCallback;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
@@ -32,7 +32,7 @@ import java.util.Map;
public final class ProxyStatementExecutorCallback extends ProxyJDBCExecutorCallback {
public ProxyStatementExecutorCallback(final DatabaseType protocolType, final Map<String, DatabaseType> storageTypes, final SQLStatement sqlStatement,
- final JDBCDatabaseCommunicationEngine databaseCommunicationEngine, final boolean isReturnGeneratedKeys,
+ final DatabaseCommunicationEngine databaseCommunicationEngine, final boolean isReturnGeneratedKeys,
final boolean isExceptionThrown, final boolean fetchMetaData) {
super(protocolType, storageTypes, sqlStatement, databaseCommunicationEngine, isReturnGeneratedKeys, isExceptionThrown, fetchMetaData);
}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/JDBCBackendTransactionManager.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/BackendTransactionManager.java
similarity index 88%
rename from proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/JDBCBackendTransactionManager.java
rename to proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/BackendTransactionManager.java
index 0173ec12529..1b41c533094 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/JDBCBackendTransactionManager.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/BackendTransactionManager.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction;
import org.apache.shardingsphere.proxy.backend.communication.TransactionManager;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.transaction.ConnectionSavepointManager;
import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
@@ -34,9 +34,9 @@ import java.util.LinkedList;
/**
* Backend transaction manager.
*/
-public final class JDBCBackendTransactionManager implements TransactionManager<Void> {
+public final class BackendTransactionManager implements TransactionManager {
- private final JDBCBackendConnection connection;
+ private final BackendConnection connection;
private final TransactionType transactionType;
@@ -44,7 +44,7 @@ public final class JDBCBackendTransactionManager implements TransactionManager<V
private final ShardingSphereTransactionManager shardingSphereTransactionManager;
- public JDBCBackendTransactionManager(final JDBCBackendConnection backendConnection) {
+ public BackendTransactionManager(final BackendConnection backendConnection) {
connection = backendConnection;
transactionType = connection.getConnectionSession().getTransactionStatus().getTransactionType();
localTransactionManager = new LocalTransactionManager(backendConnection);
@@ -54,7 +54,7 @@ public final class JDBCBackendTransactionManager implements TransactionManager<V
}
@Override
- public Void begin() {
+ public void begin() {
if (!connection.getConnectionSession().getTransactionStatus().isInTransaction()) {
connection.getConnectionSession().getTransactionStatus().setInTransaction(true);
connection.getConnectionSession().getConnectionContext().getTransactionConnectionContext().setInTransaction(true);
@@ -66,11 +66,10 @@ public final class JDBCBackendTransactionManager implements TransactionManager<V
} else {
shardingSphereTransactionManager.begin();
}
- return null;
}
@Override
- public Void commit() throws SQLException {
+ public void commit() throws SQLException {
if (connection.getConnectionSession().getTransactionStatus().isInTransaction()) {
try {
if (TransactionType.LOCAL == transactionType || null == shardingSphereTransactionManager) {
@@ -85,11 +84,10 @@ public final class JDBCBackendTransactionManager implements TransactionManager<V
connection.getConnectionSession().getConnectionContext().clearCursorConnectionContext();
}
}
- return null;
}
@Override
- public Void rollback() throws SQLException {
+ public void rollback() throws SQLException {
if (connection.getConnectionSession().getTransactionStatus().isInTransaction()) {
try {
if (TransactionType.LOCAL == transactionType || null == shardingSphereTransactionManager) {
@@ -104,11 +102,10 @@ public final class JDBCBackendTransactionManager implements TransactionManager<V
connection.getConnectionSession().getConnectionContext().clearCursorConnectionContext();
}
}
- return null;
}
@Override
- public Void setSavepoint(final String savepointName) throws SQLException {
+ public void setSavepoint(final String savepointName) throws SQLException {
for (Connection each : connection.getCachedConnections().values()) {
ConnectionSavepointManager.getInstance().setSavepoint(each, savepointName);
}
@@ -119,11 +116,10 @@ public final class JDBCBackendTransactionManager implements TransactionManager<V
throw new RuntimeException(ex);
}
});
- return null;
}
@Override
- public Void rollbackTo(final String savepointName) throws SQLException {
+ public void rollbackTo(final String savepointName) throws SQLException {
Collection<SQLException> result = new LinkedList<>();
for (Connection each : connection.getCachedConnections().values()) {
try {
@@ -135,11 +131,11 @@ public final class JDBCBackendTransactionManager implements TransactionManager<V
if (result.isEmpty() && connection.getConnectionSession().getTransactionStatus().isRollbackOnly()) {
connection.getConnectionSession().getTransactionStatus().setRollbackOnly(false);
}
- return throwSQLExceptionIfNecessary(result);
+ throwSQLExceptionIfNecessary(result);
}
@Override
- public Void releaseSavepoint(final String savepointName) throws SQLException {
+ public void releaseSavepoint(final String savepointName) throws SQLException {
Collection<SQLException> result = new LinkedList<>();
for (Connection each : connection.getCachedConnections().values()) {
try {
@@ -148,12 +144,12 @@ public final class JDBCBackendTransactionManager implements TransactionManager<V
result.add(ex);
}
}
- return throwSQLExceptionIfNecessary(result);
+ throwSQLExceptionIfNecessary(result);
}
- private Void throwSQLExceptionIfNecessary(final Collection<SQLException> exceptions) throws SQLException {
+ private void throwSQLExceptionIfNecessary(final Collection<SQLException> exceptions) throws SQLException {
if (exceptions.isEmpty()) {
- return null;
+ return;
}
SQLException ex = null;
int count = 0;
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/LocalTransactionManager.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/LocalTransactionManager.java
index 528fbb8cff2..9b1f8ecb34b 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/LocalTransactionManager.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/LocalTransactionManager.java
@@ -18,8 +18,7 @@
package org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.communication.TransactionManager;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.transaction.ConnectionSavepointManager;
import java.sql.Connection;
@@ -31,12 +30,14 @@ import java.util.LinkedList;
* Local transaction manager.
*/
@RequiredArgsConstructor
-public final class LocalTransactionManager implements TransactionManager<Void> {
+public final class LocalTransactionManager {
- private final JDBCBackendConnection connection;
+ private final BackendConnection connection;
- @Override
- public Void begin() {
+ /**
+ * Begin transaction.
+ */
+ public void begin() {
connection.getConnectionPostProcessors().add(target -> {
try {
target.setAutoCommit(false);
@@ -44,11 +45,14 @@ public final class LocalTransactionManager implements TransactionManager<Void> {
throw new RuntimeException(ex);
}
});
- return null;
}
- @Override
- public Void commit() throws SQLException {
+ /**
+ * Commit transaction.
+ *
+ * @throws SQLException SQL exception
+ */
+ public void commit() throws SQLException {
Collection<SQLException> exceptions = new LinkedList<>();
if (connection.getConnectionSession().getTransactionStatus().isRollbackOnly()) {
exceptions.addAll(rollbackConnections());
@@ -56,7 +60,6 @@ public final class LocalTransactionManager implements TransactionManager<Void> {
exceptions.addAll(commitConnections());
}
throwSQLExceptionIfNecessary(exceptions);
- return null;
}
private Collection<SQLException> commitConnections() {
@@ -73,13 +76,16 @@ public final class LocalTransactionManager implements TransactionManager<Void> {
return result;
}
- @Override
- public Void rollback() throws SQLException {
+ /**
+ * Rollback transaction.
+ *
+ * @throws SQLException SQL exception
+ */
+ public void rollback() throws SQLException {
if (connection.getConnectionSession().getTransactionStatus().isInTransaction()) {
Collection<SQLException> exceptions = new LinkedList<>(rollbackConnections());
throwSQLExceptionIfNecessary(exceptions);
}
- return null;
}
private Collection<SQLException> rollbackConnections() {
@@ -96,24 +102,9 @@ public final class LocalTransactionManager implements TransactionManager<Void> {
return result;
}
- @Override
- public Void setSavepoint(final String savepointName) {
- return null;
- }
-
- @Override
- public Void rollbackTo(final String savepointName) {
- return null;
- }
-
- @Override
- public Void releaseSavepoint(final String savepointName) {
- return null;
- }
-
- private Void throwSQLExceptionIfNecessary(final Collection<SQLException> exceptions) throws SQLException {
+ private void throwSQLExceptionIfNecessary(final Collection<SQLException> exceptions) throws SQLException {
if (exceptions.isEmpty()) {
- return null;
+ return;
}
SQLException ex = null;
int count = 0;
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendConnection.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendConnection.java
deleted file mode 100644
index 68f2e54996d..00000000000
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendConnection.java
+++ /dev/null
@@ -1,177 +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.proxy.backend.communication.vertx;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.LinkedHashMultimap;
-import com.google.common.collect.Multimap;
-import io.vertx.core.CompositeFuture;
-import io.vertx.core.Future;
-import io.vertx.sqlclient.SqlClient;
-import io.vertx.sqlclient.SqlConnection;
-import lombok.Getter;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode;
-import org.apache.shardingsphere.infra.executor.sql.prepare.driver.vertx.ExecutorVertxConnectionManager;
-import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
-import org.apache.shardingsphere.infra.util.exception.external.sql.type.generic.UnsupportedSQLOperationException;
-import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.ConnectionPostProcessor;
-import org.apache.shardingsphere.proxy.backend.communication.vertx.transaction.VertxLocalTransactionManager;
-import org.apache.shardingsphere.proxy.backend.reactive.context.ReactiveProxyContext;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.transaction.api.TransactionType;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-/**
- * Vert.x backend connection.
- */
-@Getter
-public final class VertxBackendConnection implements BackendConnection<Future<Void>>, ExecutorVertxConnectionManager {
-
- private final ConnectionSession connectionSession;
-
- private final List<ConnectionPostProcessor<Future<SqlConnection>>> connectionPostProcessors = new LinkedList<>();
-
- private final Multimap<String, Future<SqlConnection>> cachedConnections = LinkedHashMultimap.create();
-
- private final AtomicBoolean closed;
-
- public VertxBackendConnection(final ConnectionSession connectionSession) {
- ShardingSpherePreconditions.checkState(TransactionType.LOCAL == connectionSession.getTransactionStatus().getTransactionType(),
- () -> new UnsupportedSQLOperationException("Vert.x backend supports LOCAL transaction only for now"));
- closed = new AtomicBoolean(false);
- this.connectionSession = connectionSession;
- }
-
- @Override
- public List<Future<? extends SqlClient>> getConnections(final String dataSourceName, final int connectionSize, final ConnectionMode connectionMode) {
- return connectionSession.getTransactionStatus().isInTransaction() ? getConnectionsWithTransaction(dataSourceName, connectionSize) : getConnectionsWithoutTransaction(dataSourceName);
- }
-
- private List<Future<? extends SqlClient>> getConnectionsWithTransaction(final String dataSourceName, final int connectionSize) {
- Collection<Future<SqlConnection>> connections;
- synchronized (cachedConnections) {
- connections = cachedConnections.get(connectionSession.getDatabaseName() + "." + dataSourceName);
- }
- List<Future<SqlConnection>> result;
- if (connections.size() >= connectionSize) {
- result = new ArrayList<>(connections).subList(0, connectionSize);
- } else if (!connections.isEmpty()) {
- result = new ArrayList<>(connectionSize);
- result.addAll(connections);
- List<Future<SqlConnection>> newConnections = createNewConnections(dataSourceName, connectionSize - connections.size());
- result.addAll(newConnections);
- synchronized (cachedConnections) {
- cachedConnections.putAll(connectionSession.getDatabaseName() + "." + dataSourceName, newConnections);
- }
- } else {
- result = createNewConnections(dataSourceName, connectionSize);
- synchronized (cachedConnections) {
- cachedConnections.putAll(connectionSession.getDatabaseName() + "." + dataSourceName, result);
- }
- }
- return new ArrayList<>(result);
- }
-
- private List<Future<SqlConnection>> createNewConnections(final String dataSourceName, final int connectionSize) {
- Preconditions.checkNotNull(connectionSession.getDatabaseName(), "Current database is null.");
- List<Future<SqlConnection>> result = ReactiveProxyContext.getInstance().getVertxBackendDataSource().getConnections(connectionSession.getDatabaseName(), dataSourceName, connectionSize);
- for (Future<SqlConnection> each : result) {
- replayMethodsInvocation(each);
- }
- return result;
- }
-
- private void replayMethodsInvocation(final Future<SqlConnection> target) {
- for (ConnectionPostProcessor<Future<SqlConnection>> each : connectionPostProcessors) {
- each.process(target);
- }
- }
-
- private List<Future<? extends SqlClient>> getConnectionsWithoutTransaction(final String dataSourceName) {
- Preconditions.checkNotNull(connectionSession.getDatabaseName(), "Current database is null.");
- // TODO At present, amount of connections without transaction is controlled by Vert.x pool.
- Future<SqlClient> poolFuture = Future.succeededFuture(ReactiveProxyContext.getInstance().getVertxBackendDataSource().getPool(connectionSession.getDatabaseName(), dataSourceName));
- return Collections.singletonList(poolFuture);
- }
-
- @Override
- public Future<Void> prepareForTaskExecution() {
- return Future.succeededFuture();
- }
-
- @Override
- public Future<Void> handleAutoCommit() {
- if (!connectionSession.isAutoCommit() && !connectionSession.getTransactionStatus().isInTransaction()) {
- VertxLocalTransactionManager transactionManager = new VertxLocalTransactionManager(this);
- return transactionManager.begin();
- }
- return Future.succeededFuture();
- }
-
- @Override
- public Future<Void> closeExecutionResources() {
- if (!connectionSession.getTransactionStatus().isInTransaction()) {
- return closeAllConnections(false);
- }
- if (closed.get()) {
- return closeAllConnections(true);
- }
- return Future.succeededFuture();
- }
-
- @Override
- public Future<Void> closeAllResources() {
- closed.set(true);
- return closeAllConnections(true);
- }
-
- @SuppressWarnings("rawtypes")
- private Future<Void> closeAllConnections(final boolean rollbackBeforeClosing) {
- Collection<Future<SqlConnection>> connections = cachedConnections.values();
- if (connections.isEmpty()) {
- return Future.succeededFuture();
- }
- List<Future> closeFutures = new ArrayList<>(connections.size());
- for (Future<SqlConnection> each : connections) {
- closeFutures.add(rollbackBeforeClosing ? each.compose(connection -> connection.query("rollback").execute().compose(unused -> connection.close())) : each.compose(SqlClient::close));
- }
- return CompositeFuture.join(closeFutures).onComplete(unused -> cachedConnections.clear()).compose(unused -> Future.succeededFuture());
- }
-
- /**
- * Execute in all cached connections.
- *
- * @param sql SQL to be executed
- * @return join future
- */
- @SuppressWarnings("rawtypes")
- public Future<Void> executeInAllCachedConnections(final String sql) {
- List<Future> futures = new ArrayList<>(cachedConnections.size());
- for (Future<SqlConnection> each : cachedConnections.values()) {
- futures.add(each.compose(connection -> connection.query(sql).execute()));
- }
- return CompositeFuture.join(futures).compose(result -> Future.succeededFuture());
- }
-}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendDataSource.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendDataSource.java
deleted file mode 100644
index 03404c62c66..00000000000
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendDataSource.java
+++ /dev/null
@@ -1,156 +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.proxy.backend.communication.vertx;
-
-import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
-import com.zaxxer.hikari.HikariDataSource;
-import io.netty.util.NettyRuntime;
-import io.vertx.core.Future;
-import io.vertx.core.Vertx;
-import io.vertx.core.VertxOptions;
-import io.vertx.core.impl.cpu.CpuCoreSensor;
-import io.vertx.mysqlclient.MySQLConnectOptions;
-import io.vertx.mysqlclient.MySQLPool;
-import io.vertx.sqlclient.Pool;
-import io.vertx.sqlclient.PoolOptions;
-import io.vertx.sqlclient.SqlConnection;
-import lombok.Getter;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.shardingsphere.infra.util.exception.external.sql.type.generic.UnsupportedSQLOperationException;
-import org.apache.shardingsphere.proxy.backend.communication.BackendDataSource;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-
-import javax.sql.DataSource;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Vert.x backend data source.
- */
-@Slf4j
-public final class VertxBackendDataSource implements BackendDataSource {
-
- private static volatile VertxBackendDataSource instance;
-
- private final Map<String, Map<String, Pool>> schemaVertxPools = new ConcurrentHashMap<>();
-
- @Getter
- private final Vertx vertx;
-
- private VertxBackendDataSource() {
- vertx = Vertx.vertx(new VertxOptions().setPreferNativeTransport(true).setEventLoopPoolSize(determineEventLoopPoolSize()));
- }
-
- private int determineEventLoopPoolSize() {
- return Math.min(CpuCoreSensor.availableProcessors(), NettyRuntime.availableProcessors());
- }
-
- /**
- * Get instance of VertxBackendDataSource.
- *
- * @return instance of VertxBackendDataSource
- */
- public static VertxBackendDataSource getInstance() {
- if (null == instance) {
- synchronized (VertxBackendDataSource.class) {
- if (null == instance) {
- logWarningBanner();
- instance = new VertxBackendDataSource();
- }
- }
- }
- return instance;
- }
-
- private static void logWarningBanner() {
- log.warn("\n██ ██ █████ ██████ ███ ██ ██ ███ ██ ██████ \n"
- + "██ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██ ██ \n"
- + "██ █ ██ ███████ ██████ ██ ██ ██ ██ ██ ██ ██ ██ ███ \n"
- + "██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ \n"
- + " ███ ███ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██████ \n"
- + "\n Experimental reactive backend enabled!\n");
- }
-
- /**
- * Get Vert.x sql connection future.
- *
- * @param databaseName database name
- * @param dataSourceName data source name
- * @param connectionSize connection size
- * @return futures of sql connections
- */
- public List<Future<SqlConnection>> getConnections(final String databaseName, final String dataSourceName, final int connectionSize) {
- Pool pool = getPool(databaseName, dataSourceName);
- List<Future<SqlConnection>> result = new ArrayList<>(connectionSize);
- for (int i = 0; i < connectionSize; i++) {
- result.add(pool.getConnection());
- }
- return result;
- }
-
- /**
- * Get Vert.x pool.
- *
- * @param databaseName database name
- * @param dataSourceName data source name
- * @return Vert.x pool
- */
- public Pool getPool(final String databaseName, final String dataSourceName) {
- Map<String, Pool> vertxPools = schemaVertxPools.get(databaseName);
- if (null == vertxPools) {
- vertxPools = schemaVertxPools.computeIfAbsent(databaseName, unused -> new ConcurrentHashMap<>());
- }
- Pool result = vertxPools.get(dataSourceName);
- if (null == result) {
- result = vertxPools.computeIfAbsent(dataSourceName, unused -> createPoolFromSchemaDataSource(databaseName, dataSourceName));
- }
- return result;
- }
-
- private Pool createPoolFromSchemaDataSource(final String databaseName, final String dataSourceName) {
- DataSource dataSource = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabase(databaseName).getResourceMetaData().getDataSources().get(dataSourceName);
- Preconditions.checkNotNull(dataSource, "Can not get connection from datasource %s.", dataSourceName);
- HikariDataSource value = (HikariDataSource) dataSource;
- URI uri = URI.create(value.getJdbcUrl().replace("jdbc:", ""));
- switch (uri.getScheme()) {
- case "mysql":
- return createMySQLPool(value, uri);
- case "postgresql":
- case "opengauss":
- throw new UnsupportedSQLOperationException("For now");
- default:
- throw new UnsupportedSQLOperationException("Database " + uri.getScheme() + " unsupported");
- }
- }
-
- private MySQLPool createMySQLPool(final HikariDataSource value, final URI uri) {
- MySQLConnectOptions options = new MySQLConnectOptions().setHost(uri.getHost()).setPort(uri.getPort()).setDatabase(uri.getPath().replace("/", ""))
- .setUser(value.getUsername()).setCachePreparedStatements(true).setPreparedStatementCacheMaxSize(16384);
- if (!Strings.isNullOrEmpty(value.getPassword())) {
- options = options.setPassword(value.getPassword());
- }
- PoolOptions poolOptions = new PoolOptions().setMaxSize(value.getMaximumPoolSize()).setIdleTimeout((int) value.getIdleTimeout()).setIdleTimeoutUnit(TimeUnit.MILLISECONDS)
- .setConnectionTimeout((int) value.getConnectionTimeout()).setConnectionTimeoutUnit(TimeUnit.MILLISECONDS);
- return MySQLPool.pool(vertx, options, poolOptions);
- }
-}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendStatement.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendStatement.java
deleted file mode 100644
index 075df1645a7..00000000000
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendStatement.java
+++ /dev/null
@@ -1,47 +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.proxy.backend.communication.vertx;
-
-import io.vertx.core.Future;
-import io.vertx.sqlclient.Query;
-import io.vertx.sqlclient.Row;
-import io.vertx.sqlclient.RowSet;
-import io.vertx.sqlclient.SqlClient;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode;
-import org.apache.shardingsphere.infra.executor.sql.prepare.driver.vertx.ExecutorVertxStatementManager;
-import org.apache.shardingsphere.infra.executor.sql.prepare.driver.vertx.VertxExecutionContext;
-
-/**
- * Vert.x backend statement.
- */
-public final class VertxBackendStatement implements ExecutorVertxStatementManager {
-
- @Override
- public Future<Query<RowSet<Row>>> createStorageResource(final Future<? extends SqlClient> connection, final ConnectionMode connectionMode, final VertxExecutionContext option,
- final DatabaseType databaseType) {
- return Future.failedFuture(new UnsupportedOperationException("Vert.x query is not like JDBC statement."));
- }
-
- @Override
- public Future<Query<RowSet<Row>>> createStorageResource(final ExecutionUnit executionUnit, final Future<? extends SqlClient> connection,
- final ConnectionMode connectionMode, final VertxExecutionContext option, final DatabaseType databaseType) {
- return Future.failedFuture(new UnsupportedOperationException("Vert.x prepared query is not like JDBC prepared statement."));
- }
-}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxDatabaseCommunicationEngine.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxDatabaseCommunicationEngine.java
deleted file mode 100644
index f6b67ea7fe5..00000000000
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxDatabaseCommunicationEngine.java
+++ /dev/null
@@ -1,99 +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.proxy.backend.communication.vertx;
-
-import io.vertx.core.Future;
-import org.apache.shardingsphere.infra.binder.QueryContext;
-import org.apache.shardingsphere.infra.binder.decider.context.SQLFederationDeciderContext;
-import org.apache.shardingsphere.infra.binder.decider.engine.SQLFederationDeciderEngine;
-import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
-import org.apache.shardingsphere.infra.executor.sql.context.ExecutionContext;
-import org.apache.shardingsphere.infra.executor.sql.execute.result.ExecuteResult;
-import org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryResult;
-import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.util.exception.external.sql.type.generic.UnsupportedSQLOperationException;
-import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
-import org.apache.shardingsphere.proxy.backend.communication.ReactiveProxySQLExecutor;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
-
-import java.sql.SQLException;
-import java.util.List;
-
-/**
- * Vert.x database communication engine.
- */
-public final class VertxDatabaseCommunicationEngine extends DatabaseCommunicationEngine {
-
- private final ReactiveProxySQLExecutor reactiveProxySQLExecutor;
-
- public VertxDatabaseCommunicationEngine(final ShardingSphereDatabase database, final QueryContext queryContext, final VertxBackendConnection vertxBackendConnection) {
- super("Vert.x", database, queryContext, vertxBackendConnection);
- reactiveProxySQLExecutor = new ReactiveProxySQLExecutor(vertxBackendConnection);
- }
-
- /**
- * Execute future.
- *
- * @return Future of response
- */
- @SuppressWarnings({"unchecked", "rawtypes"})
- @Override
- public Future<ResponseHeader> executeFuture() {
- try {
- ShardingSphereMetaData metaData = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData();
- SQLFederationDeciderContext deciderContext = decide(getQueryContext(), metaData.getProps(), getDatabase());
- if (deciderContext.isUseSQLFederation()) {
- return Future.failedFuture(new UnsupportedOperationException("Executing federated query by Vert.x is not supported yet."));
- }
- ExecutionContext executionContext = getKernelProcessor().generateExecutionContext(getQueryContext(), getDatabase(), metaData.getGlobalRuleMetaData(),
- metaData.getProps(), getBackendConnection().getConnectionSession().getConnectionContext());
- if (executionContext.getExecutionUnits().isEmpty()) {
- return Future.succeededFuture(new UpdateResponseHeader(executionContext.getSqlStatementContext().getSqlStatement()));
- }
- reactiveProxySQLExecutor.checkExecutePrerequisites(executionContext);
- return reactiveProxySQLExecutor.execute(executionContext).compose(result -> {
- try {
- refreshMetaData(executionContext);
- ExecuteResult executeResultSample = result.iterator().next();
- return Future.succeededFuture(executeResultSample instanceof QueryResult
- ? processExecuteQuery(executionContext, (List) result, (QueryResult) executeResultSample)
- : processExecuteUpdate(executionContext, (List) result));
- } catch (final SQLException ex) {
- return Future.failedFuture(ex);
- }
- });
- // CHECKSTYLE:OFF
- } catch (final Exception ex) {
- // CHECKSTYLE:ON
- return Future.failedFuture(ex);
- }
- }
-
- private static SQLFederationDeciderContext decide(final QueryContext queryContext, final ConfigurationProperties props, final ShardingSphereDatabase database) {
- SQLFederationDeciderEngine deciderEngine = new SQLFederationDeciderEngine(database.getRuleMetaData().getRules(), props);
- return deciderEngine.decide(queryContext, database);
- }
-
- @Override
- public ResponseHeader execute() {
- throw new UnsupportedSQLOperationException("VertxDatabaseCommunicationEngine.execute()");
- }
-}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/executor/ProxyReactiveExecutor.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/executor/ProxyReactiveExecutor.java
deleted file mode 100644
index 82dd3cdf4f4..00000000000
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/executor/ProxyReactiveExecutor.java
+++ /dev/null
@@ -1,63 +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.proxy.backend.communication.vertx.executor;
-
-import io.vertx.core.CompositeFuture;
-import io.vertx.core.Future;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.binder.QueryContext;
-import org.apache.shardingsphere.infra.executor.kernel.model.ExecutionGroupContext;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.vertx.VertxExecutionUnit;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.vertx.VertxExecutor;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.vertx.VertxExecutorCallback;
-import org.apache.shardingsphere.infra.executor.sql.execute.result.ExecuteResult;
-import org.apache.shardingsphere.infra.executor.sql.process.ExecuteProcessEngine;
-import org.apache.shardingsphere.infra.util.eventbus.EventBusContext;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Reactive executor for ShardingSphere Proxy.
- */
-@RequiredArgsConstructor
-public final class ProxyReactiveExecutor {
-
- private final VertxExecutor vertxExecutor;
-
- /**
- * Execute.
- *
- * @param queryContext query context
- * @param executionGroupContext execution group context
- * @return execute results
- */
- public Future<List<ExecuteResult>> execute(final QueryContext queryContext, final ExecutionGroupContext<VertxExecutionUnit> executionGroupContext) {
- EventBusContext eventBusContext = ProxyContext.getInstance().getContextManager().getInstanceContext().getEventBusContext();
- ExecuteProcessEngine.initializeExecution(queryContext, executionGroupContext, eventBusContext);
- List<Future<ExecuteResult>> futures = vertxExecutor.execute(executionGroupContext, new VertxExecutorCallback());
- return CompositeFuture.all(new ArrayList<>(futures)).compose(compositeFuture -> {
- ExecuteProcessEngine.finishExecution(executionGroupContext.getExecutionID(), eventBusContext);
- return Future.succeededFuture(compositeFuture.<ExecuteResult>list());
- }).eventually(unused -> {
- ExecuteProcessEngine.cleanExecution();
- return Future.succeededFuture();
- });
- }
-}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/transaction/VertxLocalTransactionManager.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/transaction/VertxLocalTransactionManager.java
deleted file mode 100644
index 5a984218b0c..00000000000
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/transaction/VertxLocalTransactionManager.java
+++ /dev/null
@@ -1,77 +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.proxy.backend.communication.vertx.transaction;
-
-import io.vertx.core.Future;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.communication.TransactionManager;
-import org.apache.shardingsphere.proxy.backend.communication.vertx.VertxBackendConnection;
-
-/**
- * Vert.x local transaction manager.
- */
-@RequiredArgsConstructor
-public final class VertxLocalTransactionManager implements TransactionManager<Future<Void>> {
-
- private final VertxBackendConnection connection;
-
- @Override
- public Future<Void> begin() {
- if (connection.getConnectionSession().getTransactionStatus().isInTransaction()) {
- return Future.succeededFuture();
- }
- connection.getConnectionSession().getTransactionStatus().setInTransaction(true);
- connection.getConnectionPostProcessors().add(target -> target.compose(connection -> connection.query("begin").execute().compose(unused -> target)));
- return Future.succeededFuture();
- }
-
- @Override
- public Future<Void> commit() {
- if (!connection.getConnectionSession().getTransactionStatus().isInTransaction()) {
- return Future.succeededFuture();
- }
- connection.getConnectionSession().getTransactionStatus().setInTransaction(false);
- connection.getConnectionPostProcessors().clear();
- return connection.executeInAllCachedConnections("commit");
- }
-
- @Override
- public Future<Void> rollback() {
- if (!connection.getConnectionSession().getTransactionStatus().isInTransaction()) {
- return Future.succeededFuture();
- }
- connection.getConnectionSession().getTransactionStatus().setInTransaction(false);
- connection.getConnectionPostProcessors().clear();
- return connection.executeInAllCachedConnections("rollback");
- }
-
- @Override
- public Future<Void> setSavepoint(final String savepointName) {
- return Future.failedFuture(new UnsupportedOperationException());
- }
-
- @Override
- public Future<Void> rollbackTo(final String savepointName) {
- return Future.failedFuture(new UnsupportedOperationException());
- }
-
- @Override
- public Future<Void> releaseSavepoint(final String savepointName) {
- return Future.failedFuture(new UnsupportedOperationException());
- }
-}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandler.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandler.java
index 58091bf721b..297dbb10dcc 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandler.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandler.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.proxy.backend.handler;
-import io.vertx.core.Future;
import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
@@ -37,19 +36,6 @@ public interface ProxyBackendHandler {
*/
ResponseHeader execute() throws SQLException;
- /**
- * Execute command and return future.
- *
- * @return future of response header
- */
- default Future<ResponseHeader> executeFuture() {
- try {
- return Future.succeededFuture(execute());
- } catch (SQLException ex) {
- return Future.failedFuture(ex);
- }
- }
-
/**
* Goto next result value.
*
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/MySQLAdminExecutorCreator.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/MySQLAdminExecutorCreator.java
index 51f6cbc54a9..5060c30858f 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/MySQLAdminExecutorCreator.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/MySQLAdminExecutorCreator.java
@@ -18,7 +18,6 @@
package org.apache.shardingsphere.proxy.backend.handler.admin.mysql;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
-import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.handler.admin.executor.DatabaseAdminExecutor;
import org.apache.shardingsphere.proxy.backend.handler.admin.executor.DatabaseAdminExecutorCreator;
@@ -53,8 +52,8 @@ import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQ
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowProcessListStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowTablesStatement;
-import java.util.Iterator;
import java.util.Collection;
+import java.util.Iterator;
import java.util.Optional;
/**
@@ -170,8 +169,7 @@ public final class MySQLAdminExecutorCreator implements DatabaseAdminExecutorCre
if (hasNoResource()) {
return Optional.of(new NoResourceShowExecutor(sqlStatement));
}
- String driverType = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps().getValue(ConfigurationPropertyKey.PROXY_BACKEND_DRIVER_TYPE);
- return isNotUseSchema && !"ExperimentalVertx".equals(driverType) ? Optional.of(new UnicastResourceShowExecutor(sqlStatement, sql)) : Optional.empty();
+ return isNotUseSchema ? Optional.of(new UnicastResourceShowExecutor(sqlStatement, sql)) : Optional.empty();
}
private boolean hasNoResource() {
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/UnicastResourceShowExecutor.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/UnicastResourceShowExecutor.java
index 9d73e5ed214..42e26928ae0 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/UnicastResourceShowExecutor.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/executor/UnicastResourceShowExecutor.java
@@ -33,7 +33,7 @@ import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.infra.merge.result.impl.transparent.TransparentMergedResult;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngineFactory;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine;
+import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.exception.StorageUnitNotExistedException;
import org.apache.shardingsphere.proxy.backend.handler.admin.executor.DatabaseAdminQueryExecutor;
@@ -67,7 +67,7 @@ public final class UnicastResourceShowExecutor implements DatabaseAdminQueryExec
private MergedResult mergedResult;
- private JDBCDatabaseCommunicationEngine databaseCommunicationEngine;
+ private DatabaseCommunicationEngine databaseCommunicationEngine;
private ResponseHeader responseHeader;
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/data/DatabaseBackendHandlerFactory.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/data/DatabaseBackendHandlerFactory.java
index 432399b04eb..953baaf628f 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/data/DatabaseBackendHandlerFactory.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/data/DatabaseBackendHandlerFactory.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.proxy.backend.handler.data;
-import io.vertx.core.Future;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.infra.binder.QueryContext;
@@ -56,11 +55,6 @@ public final class DatabaseBackendHandlerFactory {
if (sqlStatement instanceof SetStatement && null == connectionSession.getDatabaseName()) {
return new DatabaseBackendHandler() {
- @Override
- public Future<ResponseHeader> executeFuture() {
- return Future.succeededFuture(new UpdateResponseHeader(sqlStatement));
- }
-
@Override
public ResponseHeader execute() {
return new UpdateResponseHeader(sqlStatement);
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/data/impl/UnicastDatabaseBackendHandler.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/data/impl/UnicastDatabaseBackendHandler.java
index a20583b79e1..c67d3768545 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/data/impl/UnicastDatabaseBackendHandler.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/data/impl/UnicastDatabaseBackendHandler.java
@@ -17,15 +17,14 @@
package org.apache.shardingsphere.proxy.backend.handler.data.impl;
-import io.vertx.core.Future;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
import org.apache.shardingsphere.authority.rule.AuthorityRule;
import org.apache.shardingsphere.dialect.exception.syntax.database.NoDatabaseSelectedException;
import org.apache.shardingsphere.infra.binder.QueryContext;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
-import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngineFactory;
+import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.exception.StorageUnitNotExistedException;
import org.apache.shardingsphere.proxy.backend.handler.data.DatabaseBackendHandler;
@@ -52,19 +51,6 @@ public final class UnicastDatabaseBackendHandler implements DatabaseBackendHandl
private DatabaseCommunicationEngine databaseCommunicationEngine;
- @Override
- public Future<ResponseHeader> executeFuture() {
- String originDatabase = connectionSession.getDatabaseName();
- String databaseName = null == originDatabase ? getFirstDatabaseName() : originDatabase;
- ShardingSpherePreconditions.checkState(ProxyContext.getInstance().getDatabase(databaseName).containsDataSource(), () -> new StorageUnitNotExistedException(databaseName));
- connectionSession.setCurrentDatabase(databaseName);
- databaseCommunicationEngine = databaseCommunicationEngineFactory.newDatabaseCommunicationEngine(queryContext, connectionSession.getBackendConnection(), false);
- return databaseCommunicationEngine.executeFuture().eventually(unused -> {
- connectionSession.setCurrentDatabase(databaseName);
- return Future.succeededFuture();
- });
- }
-
@Override
public ResponseHeader execute() throws SQLException {
String originDatabase = connectionSession.getDefaultDatabaseName();
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariableHandler.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariableHandler.java
index e9a5f79c197..f5a1e4d8802 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariableHandler.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariableHandler.java
@@ -21,10 +21,9 @@ import org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowDist
import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.exception.UnsupportedVariableException;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.QueryableRALBackendHandler;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.enums.VariableEnum;
-import org.apache.shardingsphere.proxy.backend.exception.UnsupportedVariableException;
import org.apache.shardingsphere.proxy.backend.util.SystemPropertyUtil;
import org.apache.shardingsphere.transaction.api.TransactionType;
@@ -71,11 +70,8 @@ public final class ShowDistVariableHandler extends QueryableRALBackendHandler<Sh
case AGENT_PLUGINS_ENABLED:
return SystemPropertyUtil.getSystemProperty(variable.name(), Boolean.TRUE.toString());
case CACHED_CONNECTIONS:
- if (getConnectionSession().getBackendConnection() instanceof JDBCBackendConnection) {
- int connectionSize = ((JDBCBackendConnection) getConnectionSession().getBackendConnection()).getConnectionSize();
- return String.valueOf(connectionSize);
- }
- break;
+ int connectionSize = getConnectionSession().getBackendConnection().getConnectionSize();
+ return String.valueOf(connectionSize);
case TRANSACTION_TYPE:
TransactionType transactionType = getConnectionSession().getTransactionStatus().getTransactionType();
return transactionType.name();
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariablesHandler.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariablesHandler.java
index 5ca09605f0d..fbe687d48db 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariablesHandler.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariablesHandler.java
@@ -22,7 +22,6 @@ import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.QueryableRALBackendHandler;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.enums.VariableEnum;
import org.apache.shardingsphere.proxy.backend.util.SystemPropertyUtil;
@@ -52,9 +51,7 @@ public final class ShowDistVariablesHandler extends QueryableRALBackendHandler<S
.map(each -> new LocalDataQueryResultRow(each.toLowerCase(), props.getValue(ConfigurationPropertyKey.valueOf(each)).toString())).collect(Collectors.toList());
result.add(new LocalDataQueryResultRow(
VariableEnum.AGENT_PLUGINS_ENABLED.name().toLowerCase(), SystemPropertyUtil.getSystemProperty(VariableEnum.AGENT_PLUGINS_ENABLED.name(), Boolean.TRUE.toString())));
- if (getConnectionSession().getBackendConnection() instanceof JDBCBackendConnection) {
- result.add(new LocalDataQueryResultRow(VariableEnum.CACHED_CONNECTIONS.name().toLowerCase(), ((JDBCBackendConnection) getConnectionSession().getBackendConnection()).getConnectionSize()));
- }
+ result.add(new LocalDataQueryResultRow(VariableEnum.CACHED_CONNECTIONS.name().toLowerCase(), getConnectionSession().getBackendConnection().getConnectionSize()));
result.add(new LocalDataQueryResultRow(VariableEnum.TRANSACTION_TYPE.name().toLowerCase(), getConnectionSession().getTransactionStatus().getTransactionType().name()));
return result;
}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/sql/PreviewHandler.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/sql/PreviewHandler.java
index 010cd3b3602..4c98932d321 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/sql/PreviewHandler.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/sql/PreviewHandler.java
@@ -54,7 +54,6 @@ import org.apache.shardingsphere.infra.util.exception.ShardingSpherePrecondition
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.JDBCBackendStatement;
import org.apache.shardingsphere.proxy.backend.context.BackendExecutorContext;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -169,7 +168,7 @@ public final class PreviewHandler extends SQLRULBackendHandler<PreviewStatement>
private DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> createDriverExecutionPrepareEngine(final boolean isReturnGeneratedKeys, final MetaDataContexts metaDataContexts) {
int maxConnectionsSizePerQuery = metaDataContexts.getMetaData().getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
- return new DriverExecutionPrepareEngine<>(JDBCDriverType.STATEMENT, maxConnectionsSizePerQuery, (JDBCBackendConnection) getConnectionSession().getBackendConnection(),
+ return new DriverExecutionPrepareEngine<>(JDBCDriverType.STATEMENT, maxConnectionsSizePerQuery, getConnectionSession().getBackendConnection(),
(JDBCBackendStatement) getConnectionSession().getStatementManager(), new StatementOption(isReturnGeneratedKeys),
metaDataContexts.getMetaData().getDatabase(getDatabaseName()).getRuleMetaData().getRules(),
metaDataContexts.getMetaData().getDatabase(getDatabaseName()).getResourceMetaData().getStorageTypes());
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/transaction/TransactionBackendHandler.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/transaction/TransactionBackendHandler.java
index ff4a8af6e99..0e14be1ba3f 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/transaction/TransactionBackendHandler.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/transaction/TransactionBackendHandler.java
@@ -17,21 +17,17 @@
package org.apache.shardingsphere.proxy.backend.handler.transaction;
-import io.vertx.core.Future;
+import org.apache.shardingsphere.dialect.exception.transaction.InTransactionException;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType;
import org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
-import org.apache.shardingsphere.dialect.exception.transaction.InTransactionException;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
import org.apache.shardingsphere.proxy.backend.communication.TransactionManager;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.JDBCBackendTransactionManager;
-import org.apache.shardingsphere.proxy.backend.communication.vertx.VertxBackendConnection;
-import org.apache.shardingsphere.proxy.backend.communication.vertx.transaction.VertxLocalTransactionManager;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.BackendTransactionManager;
+import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandler;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandler;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.ReleaseSavepointStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.RollbackStatement;
@@ -65,45 +61,7 @@ public final class TransactionBackendHandler implements ProxyBackendHandler {
this.tclStatement = tclStatement;
this.operationType = operationType;
this.connectionSession = connectionSession;
- if (connectionSession.getBackendConnection() instanceof JDBCBackendConnection) {
- backendTransactionManager = new JDBCBackendTransactionManager((JDBCBackendConnection) connectionSession.getBackendConnection());
- } else {
- backendTransactionManager = new VertxLocalTransactionManager((VertxBackendConnection) connectionSession.getBackendConnection());
- }
- }
-
- @Override
- public Future<ResponseHeader> executeFuture() {
- VertxLocalTransactionManager transactionManager = (VertxLocalTransactionManager) backendTransactionManager;
- Future<Void> future = determineFuture(transactionManager);
- return future.compose(unused -> Future.succeededFuture(new UpdateResponseHeader(tclStatement)));
- }
-
- private Future<Void> determineFuture(final VertxLocalTransactionManager transactionManager) {
- switch (operationType) {
- case BEGIN:
- if (connectionSession.getTransactionStatus().isInTransaction()) {
- if (connectionSession.getProtocolType() instanceof MySQLDatabaseType) {
- return transactionManager.commit().compose(unused -> transactionManager.begin());
- }
- if (connectionSession.getProtocolType() instanceof PostgreSQLDatabaseType || connectionSession.getProtocolType() instanceof OpenGaussDatabaseType) {
- return Future.failedFuture(new InTransactionException());
- }
- }
- return transactionManager.begin();
- case SAVEPOINT:
- return transactionManager.setSavepoint(((SavepointStatement) tclStatement).getSavepointName());
- case ROLLBACK_TO_SAVEPOINT:
- return transactionManager.rollbackTo(((RollbackStatement) tclStatement).getSavepointName().get());
- case RELEASE_SAVEPOINT:
- return transactionManager.releaseSavepoint(((ReleaseSavepointStatement) tclStatement).getSavepointName());
- case COMMIT:
- return transactionManager.commit();
- case ROLLBACK:
- return transactionManager.rollback();
- default:
- return Future.failedFuture(new UnsupportedOperationException());
- }
+ backendTransactionManager = new BackendTransactionManager(connectionSession.getBackendConnection());
}
@Override
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/transaction/TransactionXAHandler.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/transaction/TransactionXAHandler.java
index d38bca135b4..ee7b2d1f414 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/transaction/TransactionXAHandler.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/transaction/TransactionXAHandler.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.infra.binder.QueryContext;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngineFactory;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine;
+import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandler;
import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
@@ -46,7 +46,7 @@ public final class TransactionXAHandler implements ProxyBackendHandler {
private final ConnectionSession connectionSession;
- private final JDBCDatabaseCommunicationEngine backendHandler;
+ private final DatabaseCommunicationEngine backendHandler;
public TransactionXAHandler(final SQLStatementContext<? extends TCLStatement> sqlStatementContext, final String sql, final ConnectionSession connectionSession) {
this.tclStatement = (XAStatement) sqlStatementContext.getSqlStatement();
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/reactive/context/ReactiveProxyContext.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/reactive/context/ReactiveProxyContext.java
deleted file mode 100644
index b3262fc9394..00000000000
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/reactive/context/ReactiveProxyContext.java
+++ /dev/null
@@ -1,44 +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.proxy.backend.reactive.context;
-
-import lombok.AccessLevel;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.communication.vertx.VertxBackendDataSource;
-
-/**
- * Reactive proxy context.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-@Getter
-public final class ReactiveProxyContext {
-
- private static final ReactiveProxyContext INSTANCE = new ReactiveProxyContext();
-
- private final VertxBackendDataSource vertxBackendDataSource = VertxBackendDataSource.getInstance();
-
- /**
- * Get instance of reactive proxy context.
- *
- * @return instance of reactive proxy context
- */
- public static ReactiveProxyContext getInstance() {
- return INSTANCE;
- }
-}
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/session/ConnectionSession.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/session/ConnectionSession.java
index 29600d3d4bf..29e1fe2fcc4 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/session/ConnectionSession.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/session/ConnectionSession.java
@@ -22,18 +22,13 @@ import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.infra.binder.QueryContext;
-import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.context.ConnectionContext;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.executor.sql.prepare.driver.CacheableExecutorConnectionManager;
import org.apache.shardingsphere.infra.executor.sql.prepare.driver.ExecutorStatementManager;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.JDBCBackendStatement;
-import org.apache.shardingsphere.proxy.backend.communication.vertx.VertxBackendConnection;
-import org.apache.shardingsphere.proxy.backend.communication.vertx.VertxBackendStatement;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.transaction.TransactionStatus;
import org.apache.shardingsphere.sql.parser.sql.common.enums.TransactionIsolationLevel;
import org.apache.shardingsphere.transaction.api.TransactionType;
@@ -84,21 +79,9 @@ public final class ConnectionSession {
this.protocolType = protocolType;
transactionStatus = new TransactionStatus(initialTransactionType);
this.attributeMap = attributeMap;
- backendConnection = determineBackendConnection();
- statementManager = determineStatementManager();
- connectionContext = backendConnection instanceof CacheableExecutorConnectionManager
- ? new ConnectionContext(((CacheableExecutorConnectionManager<?>) backendConnection)::getDataSourceNamesOfCachedConnections)
- : new ConnectionContext();
- }
-
- private BackendConnection determineBackendConnection() {
- String proxyBackendDriverType = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps().getValue(ConfigurationPropertyKey.PROXY_BACKEND_DRIVER_TYPE);
- return "ExperimentalVertx".equals(proxyBackendDriverType) ? new VertxBackendConnection(this) : new JDBCBackendConnection(this);
- }
-
- private ExecutorStatementManager determineStatementManager() {
- String proxyBackendDriverType = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps().getValue(ConfigurationPropertyKey.PROXY_BACKEND_DRIVER_TYPE);
- return "ExperimentalVertx".equals(proxyBackendDriverType) ? new VertxBackendStatement() : new JDBCBackendStatement();
+ backendConnection = new BackendConnection(this);
+ statementManager = new JDBCBackendStatement();
+ connectionContext = new ConnectionContext(((CacheableExecutorConnectionManager<?>) backendConnection)::getDataSourceNamesOfCachedConnections);
}
/**
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactoryTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactoryTest.java
index 4626e5bbeaf..8e3ec4bee82 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactoryTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactoryTest.java
@@ -27,7 +27,6 @@ import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRule
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.util.ProxyContextRestorer;
import org.junit.Before;
@@ -68,7 +67,7 @@ public final class DatabaseCommunicationEngineFactoryTest extends ProxyContextRe
@Test
public void assertNewDatabaseCommunicationEngineWithoutParameter() {
- JDBCBackendConnection backendConnection = mock(JDBCBackendConnection.class, RETURNS_DEEP_STUBS);
+ BackendConnection backendConnection = mock(BackendConnection.class, RETURNS_DEEP_STUBS);
when(backendConnection.getConnectionSession().getDatabaseName()).thenReturn("db");
SQLStatementContext<?> sqlStatementContext = mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
when(sqlStatementContext.getTablesContext().getSchemaNames()).thenReturn(Collections.emptyList());
@@ -79,7 +78,7 @@ public final class DatabaseCommunicationEngineFactoryTest extends ProxyContextRe
@Test
public void assertNewDatabaseCommunicationEngineWithParameters() {
- JDBCBackendConnection backendConnection = mock(JDBCBackendConnection.class, RETURNS_DEEP_STUBS);
+ BackendConnection backendConnection = mock(BackendConnection.class, RETURNS_DEEP_STUBS);
when(backendConnection.getConnectionSession().getDatabaseName()).thenReturn("db");
SQLStatementContext<?> sqlStatementContext = mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
when(sqlStatementContext.getTablesContext().getSchemaNames()).thenReturn(Collections.emptyList());
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/ProxySQLExecutorTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/ProxySQLExecutorTest.java
index 77e1134e915..00267f1c69c 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/ProxySQLExecutorTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/ProxySQLExecutorTest.java
@@ -38,8 +38,6 @@ import org.apache.shardingsphere.infra.route.context.RouteContext;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.util.ProxyContextRestorer;
@@ -77,7 +75,7 @@ public final class ProxySQLExecutorTest extends ProxyContextRestorer {
private ConnectionSession connectionSession;
@Mock
- private JDBCBackendConnection backendConnection;
+ private BackendConnection backendConnection;
@Before
public void setUp() {
@@ -93,14 +91,14 @@ public final class ProxySQLExecutorTest extends ProxyContextRestorer {
public void assertCheckExecutePrerequisitesWhenExecuteDDLInXATransaction() {
ExecutionContext executionContext = new ExecutionContext(
new QueryContext(createMySQLCreateTableStatementContext(), "", Collections.emptyList()), Collections.emptyList(), mock(RouteContext.class));
- new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(JDBCDatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
+ new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
}
@Test(expected = TableModifyInTransactionException.class)
public void assertCheckExecutePrerequisitesWhenExecuteTruncateInMySQLXATransaction() {
ExecutionContext executionContext = new ExecutionContext(
new QueryContext(createMySQLTruncateStatementContext(), "", Collections.emptyList()), Collections.emptyList(), mock(RouteContext.class));
- new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(JDBCDatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
+ new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
}
@Test
@@ -108,14 +106,14 @@ public final class ProxySQLExecutorTest extends ProxyContextRestorer {
when(connectionSession.getTransactionStatus().getTransactionType()).thenReturn(TransactionType.LOCAL);
ExecutionContext executionContext = new ExecutionContext(
new QueryContext(createMySQLTruncateStatementContext(), "", Collections.emptyList()), Collections.emptyList(), mock(RouteContext.class));
- new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(JDBCDatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
+ new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
}
@Test
public void assertCheckExecutePrerequisitesWhenExecuteDMLInXATransaction() {
ExecutionContext executionContext = new ExecutionContext(
new QueryContext(createMySQLInsertStatementContext(), "", Collections.emptyList()), Collections.emptyList(), mock(RouteContext.class));
- new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(JDBCDatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
+ new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
}
@Test
@@ -123,7 +121,7 @@ public final class ProxySQLExecutorTest extends ProxyContextRestorer {
when(connectionSession.getTransactionStatus().getTransactionType()).thenReturn(TransactionType.BASE);
ExecutionContext executionContext = new ExecutionContext(
new QueryContext(createMySQLCreateTableStatementContext(), "", Collections.emptyList()), Collections.emptyList(), mock(RouteContext.class));
- new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(JDBCDatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
+ new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
}
@Test
@@ -131,7 +129,7 @@ public final class ProxySQLExecutorTest extends ProxyContextRestorer {
when(connectionSession.getTransactionStatus().isInTransaction()).thenReturn(false);
ExecutionContext executionContext = new ExecutionContext(
new QueryContext(createMySQLCreateTableStatementContext(), "", Collections.emptyList()), Collections.emptyList(), mock(RouteContext.class));
- new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(JDBCDatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
+ new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
}
@Test(expected = TableModifyInTransactionException.class)
@@ -139,7 +137,7 @@ public final class ProxySQLExecutorTest extends ProxyContextRestorer {
when(connectionSession.getTransactionStatus().getTransactionType()).thenReturn(TransactionType.LOCAL);
ExecutionContext executionContext = new ExecutionContext(
new QueryContext(createPostgreSQLCreateTableStatementContext(), "", Collections.emptyList()), Collections.emptyList(), mock(RouteContext.class));
- new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(JDBCDatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
+ new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
}
@Test
@@ -147,7 +145,7 @@ public final class ProxySQLExecutorTest extends ProxyContextRestorer {
when(connectionSession.getTransactionStatus().getTransactionType()).thenReturn(TransactionType.LOCAL);
ExecutionContext executionContext = new ExecutionContext(
new QueryContext(createPostgreSQLTruncateStatementContext(), "", Collections.emptyList()), Collections.emptyList(), mock(RouteContext.class));
- new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(JDBCDatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
+ new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
}
@Test
@@ -155,7 +153,7 @@ public final class ProxySQLExecutorTest extends ProxyContextRestorer {
when(connectionSession.getTransactionStatus().getTransactionType()).thenReturn(TransactionType.LOCAL);
ExecutionContext executionContext = new ExecutionContext(
new QueryContext(createCursorStatementContext(), "", Collections.emptyList()), Collections.emptyList(), mock(RouteContext.class));
- new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(JDBCDatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
+ new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
}
@Test
@@ -163,7 +161,7 @@ public final class ProxySQLExecutorTest extends ProxyContextRestorer {
when(connectionSession.getTransactionStatus().getTransactionType()).thenReturn(TransactionType.LOCAL);
ExecutionContext executionContext = new ExecutionContext(
new QueryContext(createPostgreSQLInsertStatementContext(), "", Collections.emptyList()), Collections.emptyList(), mock(RouteContext.class));
- new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(JDBCDatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
+ new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
}
@Test
@@ -171,7 +169,7 @@ public final class ProxySQLExecutorTest extends ProxyContextRestorer {
when(connectionSession.getTransactionStatus().getTransactionType()).thenReturn(TransactionType.LOCAL);
ExecutionContext executionContext = new ExecutionContext(
new QueryContext(createMySQLCreateTableStatementContext(), "", Collections.emptyList()), Collections.emptyList(), mock(RouteContext.class));
- new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(JDBCDatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
+ new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
}
@Test
@@ -180,7 +178,7 @@ public final class ProxySQLExecutorTest extends ProxyContextRestorer {
when(connectionSession.getTransactionStatus().isInTransaction()).thenReturn(false);
ExecutionContext executionContext = new ExecutionContext(
new QueryContext(createPostgreSQLCreateTableStatementContext(), "", Collections.emptyList()), Collections.emptyList(), mock(RouteContext.class));
- new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(JDBCDatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
+ new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
}
private CreateTableStatementContext createMySQLCreateTableStatementContext() {
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngineTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/DatabaseCommunicationEngineTest.java
similarity index 93%
rename from proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngineTest.java
rename to proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/DatabaseCommunicationEngineTest.java
index 32bce1d9328..5d52751e51e 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngineTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/DatabaseCommunicationEngineTest.java
@@ -22,7 +22,6 @@ import org.apache.shardingsphere.infra.binder.QueryContext;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
-import org.apache.shardingsphere.infra.context.kernel.KernelProcessor;
import org.apache.shardingsphere.infra.database.DefaultDatabase;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
@@ -44,9 +43,9 @@ import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngineFactory;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.ProxyJDBCExecutorCallback;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.JDBCBackendStatement;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -97,10 +96,10 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
-public final class JDBCDatabaseCommunicationEngineTest extends ProxyContextRestorer {
+public final class DatabaseCommunicationEngineTest extends ProxyContextRestorer {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private JDBCBackendConnection backendConnection;
+ private BackendConnection backendConnection;
@Mock
private Statement statement;
@@ -134,15 +133,11 @@ public final class JDBCDatabaseCommunicationEngineTest extends ProxyContextResto
}
@Test
- public void assertExecuteFederationAndClose() throws SQLException, NoSuchFieldException, IllegalAccessException {
+ public void assertExecuteFederationAndClose() throws SQLException {
SQLStatementContext<?> sqlStatementContext = mock(SelectStatementContext.class, RETURNS_DEEP_STUBS);
when(sqlStatementContext.getDatabaseType()).thenReturn(new MySQLDatabaseType());
- JDBCDatabaseCommunicationEngine engine =
+ DatabaseCommunicationEngine engine =
DatabaseCommunicationEngineFactory.getInstance().newDatabaseCommunicationEngine(new QueryContext(sqlStatementContext, "schemaName", Collections.emptyList()), backendConnection, true);
- Field kernelProcessorField = DatabaseCommunicationEngine.class.getDeclaredField("kernelProcessor");
- kernelProcessorField.setAccessible(true);
- KernelProcessor kernelProcessor = mock(KernelProcessor.class);
- kernelProcessorField.set(engine, kernelProcessor);
when(backendConnection.getConnectionSession().getStatementManager()).thenReturn(new JDBCBackendStatement());
SQLFederationExecutor federationExecutor = mock(SQLFederationExecutor.class);
try (
@@ -172,7 +167,7 @@ public final class JDBCDatabaseCommunicationEngineTest extends ProxyContextResto
public void assertBinaryProtocolQueryHeader() throws SQLException, NoSuchFieldException, IllegalAccessException {
SQLStatementContext<?> sqlStatementContext = mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
when(sqlStatementContext.getTablesContext().getSchemaNames()).thenReturn(Collections.emptyList());
- JDBCDatabaseCommunicationEngine engine =
+ DatabaseCommunicationEngine engine =
DatabaseCommunicationEngineFactory.getInstance().newDatabaseCommunicationEngine(new QueryContext(sqlStatementContext, "schemaName", Collections.emptyList()), backendConnection, true);
assertNotNull(engine);
assertThat(engine, instanceOf(DatabaseCommunicationEngine.class));
@@ -228,7 +223,7 @@ public final class JDBCDatabaseCommunicationEngineTest extends ProxyContextResto
public void assertAddStatementCorrectly() {
SQLStatementContext<?> sqlStatementContext = mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
when(sqlStatementContext.getTablesContext().getSchemaNames()).thenReturn(Collections.emptyList());
- JDBCDatabaseCommunicationEngine engine =
+ DatabaseCommunicationEngine engine =
DatabaseCommunicationEngineFactory.getInstance().newDatabaseCommunicationEngine(new QueryContext(sqlStatementContext, "schemaName", Collections.emptyList()), backendConnection, false);
engine.add(statement);
Collection<?> actual = getField(engine, "cachedStatements");
@@ -240,7 +235,7 @@ public final class JDBCDatabaseCommunicationEngineTest extends ProxyContextResto
public void assertAddResultSetCorrectly() {
SQLStatementContext<?> sqlStatementContext = mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
when(sqlStatementContext.getTablesContext().getSchemaNames()).thenReturn(Collections.emptyList());
- JDBCDatabaseCommunicationEngine engine =
+ DatabaseCommunicationEngine engine =
DatabaseCommunicationEngineFactory.getInstance().newDatabaseCommunicationEngine(new QueryContext(sqlStatementContext, "schemaName", Collections.emptyList()), backendConnection, false);
engine.add(resultSet);
Collection<?> actual = getField(engine, "cachedResultSets");
@@ -252,7 +247,7 @@ public final class JDBCDatabaseCommunicationEngineTest extends ProxyContextResto
public void assertCloseCorrectly() throws SQLException {
SQLStatementContext<?> sqlStatementContext = mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
when(sqlStatementContext.getTablesContext().getSchemaNames()).thenReturn(Collections.emptyList());
- JDBCDatabaseCommunicationEngine engine =
+ DatabaseCommunicationEngine engine =
DatabaseCommunicationEngineFactory.getInstance().newDatabaseCommunicationEngine(new QueryContext(sqlStatementContext, "schemaName", Collections.emptyList()), backendConnection, false);
Collection<ResultSet> cachedResultSets = getField(engine, "cachedResultSets");
cachedResultSets.add(resultSet);
@@ -270,7 +265,7 @@ public final class JDBCDatabaseCommunicationEngineTest extends ProxyContextResto
public void assertCloseResultSetsWithExceptionThrown() throws SQLException {
SQLStatementContext<?> sqlStatementContext = mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
when(sqlStatementContext.getTablesContext().getSchemaNames()).thenReturn(Collections.emptyList());
- JDBCDatabaseCommunicationEngine engine =
+ DatabaseCommunicationEngine engine =
DatabaseCommunicationEngineFactory.getInstance().newDatabaseCommunicationEngine(new QueryContext(sqlStatementContext, "schemaName", Collections.emptyList()), backendConnection, false);
Collection<ResultSet> cachedResultSets = getField(engine, "cachedResultSets");
SQLException sqlExceptionByResultSet = new SQLException("ResultSet");
@@ -297,8 +292,8 @@ public final class JDBCDatabaseCommunicationEngineTest extends ProxyContextResto
@SuppressWarnings("unchecked")
@SneakyThrows(ReflectiveOperationException.class)
- private <T> T getField(final JDBCDatabaseCommunicationEngine target, final String fieldName) {
- Field field = JDBCDatabaseCommunicationEngine.class.getDeclaredField(fieldName);
+ private <T> T getField(final DatabaseCommunicationEngine target, final String fieldName) {
+ Field field = DatabaseCommunicationEngine.class.getDeclaredField(fieldName);
field.setAccessible(true);
return (T) field.get(target);
}
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCBackendConnectionTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnectionTest.java
similarity index 92%
rename from proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCBackendConnectionTest.java
rename to proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnectionTest.java
index eda71cbbd4d..7ab6ffdf7cc 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCBackendConnectionTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnectionTest.java
@@ -28,7 +28,8 @@ import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRule
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.datasource.JDBCBackendDataSource;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.JDBCBackendStatement;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -82,7 +83,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
-public final class JDBCBackendConnectionTest extends ProxyContextRestorer {
+public final class BackendConnectionTest extends ProxyContextRestorer {
private static final String SCHEMA_PATTERN = "schema_%s";
@@ -92,14 +93,14 @@ public final class JDBCBackendConnectionTest extends ProxyContextRestorer {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private ConnectionSession connectionSession;
- private JDBCBackendConnection backendConnection;
+ private BackendConnection backendConnection;
@Before
public void setUp() throws ReflectiveOperationException {
setContextManager();
setBackendDataSource();
when(connectionSession.getDatabaseName()).thenReturn(String.format(SCHEMA_PATTERN, 0));
- backendConnection = spy(new JDBCBackendConnection(connectionSession));
+ backendConnection = spy(new BackendConnection(connectionSession));
when(connectionSession.getBackendConnection()).thenReturn(backendConnection);
when(connectionSession.getTransactionStatus()).thenReturn(new TransactionStatus(TransactionType.LOCAL));
JDBCBackendStatement backendStatement = new JDBCBackendStatement();
@@ -189,10 +190,10 @@ public final class JDBCBackendConnectionTest extends ProxyContextRestorer {
@SneakyThrows(ReflectiveOperationException.class)
private void setConnectionPostProcessors() {
- ConnectionPostProcessor<?> connectionPostProcessor = mock(ConnectionPostProcessor.class);
- Collection<ConnectionPostProcessor<?>> connectionPostProcessors = new LinkedList<>();
+ ConnectionPostProcessor connectionPostProcessor = mock(ConnectionPostProcessor.class);
+ Collection<ConnectionPostProcessor> connectionPostProcessors = new LinkedList<>();
connectionPostProcessors.add(connectionPostProcessor);
- Field field = JDBCBackendConnection.class.getDeclaredField("connectionPostProcessors");
+ Field field = BackendConnection.class.getDeclaredField("connectionPostProcessors");
field.setAccessible(true);
field.set(backendConnection, connectionPostProcessors);
}
@@ -227,7 +228,7 @@ public final class JDBCBackendConnectionTest extends ProxyContextRestorer {
@SuppressWarnings("unchecked")
@Test
public void assertCloseConnectionsCorrectlyWhenNotForceRollback() throws NoSuchFieldException, IllegalAccessException, SQLException {
- Field field = JDBCBackendConnection.class.getDeclaredField("cachedConnections");
+ Field field = BackendConnection.class.getDeclaredField("cachedConnections");
field.setAccessible(true);
Multimap<String, Connection> cachedConnections = (Multimap<String, Connection>) field.get(backendConnection);
Connection connection = prepareCachedConnections();
@@ -323,7 +324,7 @@ public final class JDBCBackendConnectionTest extends ProxyContextRestorer {
@SuppressWarnings("unchecked")
@SneakyThrows(ReflectiveOperationException.class)
private void assertConnectionsCached(final String dataSourceName, final Collection<Connection> connections) {
- Field field = JDBCBackendConnection.class.getDeclaredField("cachedConnections");
+ Field field = BackendConnection.class.getDeclaredField("cachedConnections");
field.setAccessible(true);
Multimap<String, Connection> cachedConnections = (Multimap<String, Connection>) field.get(backendConnection);
assertTrue(cachedConnections.containsKey(dataSourceName));
@@ -333,7 +334,7 @@ public final class JDBCBackendConnectionTest extends ProxyContextRestorer {
@SuppressWarnings("unchecked")
@SneakyThrows(ReflectiveOperationException.class)
private Connection prepareCachedConnections() {
- Field field = JDBCBackendConnection.class.getDeclaredField("cachedConnections");
+ Field field = BackendConnection.class.getDeclaredField("cachedConnections");
field.setAccessible(true);
Multimap<String, Connection> cachedConnections = (Multimap<String, Connection>) field.get(backendConnection);
Connection connection = mock(Connection.class);
@@ -344,15 +345,15 @@ public final class JDBCBackendConnectionTest extends ProxyContextRestorer {
@SuppressWarnings("unchecked")
@SneakyThrows(ReflectiveOperationException.class)
private void verifyConnectionPostProcessorsEmpty() {
- Field field = JDBCBackendConnection.class.getDeclaredField("connectionPostProcessors");
+ Field field = BackendConnection.class.getDeclaredField("connectionPostProcessors");
field.setAccessible(true);
- Collection<ConnectionPostProcessor<?>> connectionPostProcessors = (Collection<ConnectionPostProcessor<?>>) field.get(backendConnection);
+ Collection<ConnectionPostProcessor> connectionPostProcessors = (Collection<ConnectionPostProcessor>) field.get(backendConnection);
assertTrue(connectionPostProcessors.isEmpty());
}
@Test
public void assertAddDatabaseCommunicationEngine() {
- ProxyBackendHandler expectedEngine = mock(JDBCDatabaseCommunicationEngine.class);
+ ProxyBackendHandler expectedEngine = mock(DatabaseCommunicationEngine.class);
backendConnection.add(expectedEngine);
Collection<ProxyBackendHandler> actual = getDatabaseCommunicationEngines();
assertThat(actual.size(), is(1));
@@ -361,7 +362,7 @@ public final class JDBCBackendConnectionTest extends ProxyContextRestorer {
@Test
public void assertMarkDatabaseCommunicationEngineInUse() {
- ProxyBackendHandler expectedEngine = mock(JDBCDatabaseCommunicationEngine.class);
+ ProxyBackendHandler expectedEngine = mock(DatabaseCommunicationEngine.class);
backendConnection.add(expectedEngine);
backendConnection.markResourceInUse(expectedEngine);
Collection<ProxyBackendHandler> actual = getInUseDatabaseCommunicationEngines();
@@ -371,7 +372,7 @@ public final class JDBCBackendConnectionTest extends ProxyContextRestorer {
@Test
public void assertUnmarkInUseDatabaseCommunicationEngine() {
- ProxyBackendHandler engine = mock(JDBCDatabaseCommunicationEngine.class);
+ ProxyBackendHandler engine = mock(DatabaseCommunicationEngine.class);
Collection<ProxyBackendHandler> actual = getInUseDatabaseCommunicationEngines();
actual.add(engine);
backendConnection.unmarkResourceInUse(engine);
@@ -380,8 +381,8 @@ public final class JDBCBackendConnectionTest extends ProxyContextRestorer {
@Test
public void assertCloseHandlers() throws SQLException {
- ProxyBackendHandler engine = mock(JDBCDatabaseCommunicationEngine.class);
- ProxyBackendHandler inUseEngine = mock(JDBCDatabaseCommunicationEngine.class);
+ ProxyBackendHandler engine = mock(DatabaseCommunicationEngine.class);
+ ProxyBackendHandler inUseEngine = mock(DatabaseCommunicationEngine.class);
SQLException expectedException = mock(SQLException.class);
doThrow(expectedException).when(engine).close();
Collection<ProxyBackendHandler> databaseCommunicationEngines = getDatabaseCommunicationEngines();
@@ -404,7 +405,7 @@ public final class JDBCBackendConnectionTest extends ProxyContextRestorer {
@SuppressWarnings("unchecked")
@SneakyThrows(ReflectiveOperationException.class)
private Collection<ProxyBackendHandler> getDatabaseCommunicationEngines() {
- Field field = JDBCBackendConnection.class.getDeclaredField("backendHandlers");
+ Field field = BackendConnection.class.getDeclaredField("backendHandlers");
field.setAccessible(true);
return (Collection<ProxyBackendHandler>) field.get(backendConnection);
}
@@ -412,16 +413,11 @@ public final class JDBCBackendConnectionTest extends ProxyContextRestorer {
@SuppressWarnings("unchecked")
@SneakyThrows(ReflectiveOperationException.class)
private Collection<ProxyBackendHandler> getInUseDatabaseCommunicationEngines() {
- Field field = JDBCBackendConnection.class.getDeclaredField("inUseBackendHandlers");
+ Field field = BackendConnection.class.getDeclaredField("inUseBackendHandlers");
field.setAccessible(true);
return (Collection<ProxyBackendHandler>) field.get(backendConnection);
}
- @Test
- public void assertPrepareForTaskExecution() {
- backendConnection.prepareForTaskExecution();
- }
-
@Test
public void assertCloseExecutionResources() throws BackendConnectionException {
backendConnection.closeExecutionResources();
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/MockConnectionUtil.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/MockConnectionUtil.java
index 256f4b459c2..e8046efac76 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/MockConnectionUtil.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/MockConnectionUtil.java
@@ -22,6 +22,7 @@ import com.google.common.collect.Multimap;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import java.lang.reflect.Field;
import java.sql.Connection;
@@ -44,7 +45,7 @@ final class MockConnectionUtil {
* @param connectionSize connection size
*/
@SneakyThrows(ReflectiveOperationException.class)
- static void setCachedConnections(final JDBCBackendConnection backendConnection, final String dataSourceName, final int connectionSize) {
+ static void setCachedConnections(final BackendConnection backendConnection, final String dataSourceName, final int connectionSize) {
Multimap<String, Connection> cachedConnections = HashMultimap.create();
cachedConnections.putAll(backendConnection.getConnectionSession().getDatabaseName() + "." + dataSourceName, mockNewConnections(connectionSize));
Field field = backendConnection.getClass().getDeclaredField("cachedConnections");
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/JDBCBackendTransactionManagerTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/BackendTransactionManagerTest.java
similarity index 93%
rename from proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/JDBCBackendTransactionManagerTest.java
rename to proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/BackendTransactionManagerTest.java
index ab39022b51d..7221306dac8 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/JDBCBackendTransactionManagerTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/BackendTransactionManagerTest.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.infra.context.ConnectionContext;
import org.apache.shardingsphere.infra.context.transaction.TransactionConnectionContext;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.session.transaction.TransactionStatus;
@@ -47,13 +47,13 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
-public final class JDBCBackendTransactionManagerTest extends ProxyContextRestorer {
+public final class BackendTransactionManagerTest extends ProxyContextRestorer {
@Mock
private ConnectionSession connectionSession;
@Mock
- private JDBCBackendConnection backendConnection;
+ private BackendConnection backendConnection;
@Mock
private TransactionStatus transactionStatus;
@@ -64,7 +64,7 @@ public final class JDBCBackendTransactionManagerTest extends ProxyContextRestore
@Mock
private ShardingSphereTransactionManager shardingSphereTransactionManager;
- private JDBCBackendTransactionManager backendTransactionManager;
+ private BackendTransactionManager backendTransactionManager;
@Before
public void setUp() {
@@ -166,13 +166,13 @@ public final class JDBCBackendTransactionManagerTest extends ProxyContextRestore
private void newBackendTransactionManager(final TransactionType transactionType, final boolean inTransaction) {
when(connectionSession.getTransactionStatus().getTransactionType()).thenReturn(transactionType);
when(transactionStatus.isInTransaction()).thenReturn(inTransaction);
- backendTransactionManager = new JDBCBackendTransactionManager(backendConnection);
+ backendTransactionManager = new BackendTransactionManager(backendConnection);
setLocalTransactionManager();
}
@SneakyThrows(ReflectiveOperationException.class)
private void setLocalTransactionManager() {
- Field field = JDBCBackendTransactionManager.class.getDeclaredField("localTransactionManager");
+ Field field = BackendTransactionManager.class.getDeclaredField("localTransactionManager");
field.setAccessible(true);
field.set(backendTransactionManager, localTransactionManager);
}
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/LocalTransactionManagerTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/LocalTransactionManagerTest.java
index e4a8a737512..59bd2af4847 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/LocalTransactionManagerTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/LocalTransactionManagerTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import lombok.SneakyThrows;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.session.transaction.TransactionStatus;
import org.junit.Before;
@@ -44,7 +44,7 @@ public final class LocalTransactionManagerTest {
private ConnectionSession connectionSession;
@Mock
- private JDBCBackendConnection backendConnection;
+ private BackendConnection backendConnection;
@Mock
private TransactionStatus transactionStatus;
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java
index 6e5ba757cf2..ebe83b86613 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java
@@ -29,7 +29,7 @@ import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.parser.config.SQLParserRuleConfiguration;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.handler.admin.DatabaseAdminQueryBackendHandler;
import org.apache.shardingsphere.proxy.backend.handler.admin.DatabaseAdminUpdateBackendHandler;
@@ -77,7 +77,7 @@ public final class ProxyBackendHandlerFactoryTest extends ProxyContextRestorer {
private ConnectionSession connectionSession;
@Mock
- private JDBCBackendConnection backendConnection;
+ private BackendConnection backendConnection;
@Before
public void setUp() {
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/MySQLSetVariableAdminExecutorTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/MySQLSetVariableAdminExecutorTest.java
index c492608c1f5..8e50592f7bf 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/MySQLSetVariableAdminExecutorTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/admin/mysql/MySQLSetVariableAdminExecutorTest.java
@@ -22,8 +22,8 @@ import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRule
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.parser.config.SQLParserRuleConfiguration;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.util.ProxyContextRestorer;
@@ -52,7 +52,7 @@ public final class MySQLSetVariableAdminExecutorTest extends ProxyContextRestore
MySQLSetVariableAdminExecutor executor = new MySQLSetVariableAdminExecutor(setStatement);
ConnectionSession connectionSession = mock(ConnectionSession.class);
when(connectionSession.getDatabaseName()).thenReturn("db");
- JDBCBackendConnection backendConnection = mock(JDBCBackendConnection.class);
+ BackendConnection backendConnection = mock(BackendConnection.class);
when(connectionSession.getBackendConnection()).thenReturn(backendConnection);
when(backendConnection.getConnectionSession()).thenReturn(connectionSession);
ProxyContext.init(mock(ContextManager.class, RETURNS_DEEP_STUBS));
@@ -60,7 +60,7 @@ public final class MySQLSetVariableAdminExecutorTest extends ProxyContextRestore
when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().containsDatabase("db")).thenReturn(true);
when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData())
.thenReturn(new ShardingSphereRuleMetaData(Collections.singletonList(new SQLParserRule(new SQLParserRuleConfiguration(false, new CacheOption(1, 1), new CacheOption(1, 1))))));
- try (MockedConstruction<JDBCDatabaseCommunicationEngine> mockConstruction = mockConstruction(JDBCDatabaseCommunicationEngine.class)) {
+ try (MockedConstruction<DatabaseCommunicationEngine> mockConstruction = mockConstruction(DatabaseCommunicationEngine.class)) {
executor.execute(connectionSession);
verify(mockConstruction.constructed().get(0)).execute();
}
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/DatabaseBackendHandlerFactoryTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/DatabaseBackendHandlerFactoryTest.java
index 652021e0449..755b726a3ac 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/DatabaseBackendHandlerFactoryTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/DatabaseBackendHandlerFactoryTest.java
@@ -22,8 +22,7 @@ import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.handler.data.impl.UnicastDatabaseBackendHandler;
@@ -77,9 +76,9 @@ public final class DatabaseBackendHandlerFactoryTest extends ProxyContextRestore
when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().containsDatabase("db")).thenReturn(true);
ConnectionSession connectionSession = mock(ConnectionSession.class);
when(connectionSession.getDatabaseName()).thenReturn("db");
- when(connectionSession.getBackendConnection()).thenReturn(mock(JDBCBackendConnection.class));
+ when(connectionSession.getBackendConnection()).thenReturn(mock(BackendConnection.class));
when(connectionSession.getBackendConnection().getConnectionSession()).thenReturn(connectionSession);
- try (MockedConstruction<JDBCDatabaseCommunicationEngine> unused = mockConstruction(JDBCDatabaseCommunicationEngine.class)) {
+ try (MockedConstruction<DatabaseCommunicationEngine> unused = mockConstruction(DatabaseCommunicationEngine.class)) {
DatabaseBackendHandler actual = DatabaseBackendHandlerFactory.newInstance(new QueryContext(context, sql, Collections.emptyList()), connectionSession, false);
assertThat(actual, instanceOf(DatabaseCommunicationEngine.class));
}
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/impl/UnicastDatabaseBackendHandlerTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/impl/UnicastDatabaseBackendHandlerTest.java
index 75826f154b4..bc6f1fc9f15 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/impl/UnicastDatabaseBackendHandlerTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/impl/UnicastDatabaseBackendHandlerTest.java
@@ -28,9 +28,9 @@ import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRule
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
-import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
-import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngineFactory;
+import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.handler.data.DatabaseBackendHandler;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariableBackendHandlerTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariableBackendHandlerTest.java
index c466904cda0..65a67a4ec16 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariableBackendHandlerTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariableBackendHandlerTest.java
@@ -54,7 +54,7 @@ public final class ShowDistVariableBackendHandlerTest extends ProxyContextRestor
@Before
public void setup() {
ProxyContext.init(mock(ContextManager.class, RETURNS_DEEP_STUBS));
- when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps().getValue(ConfigurationPropertyKey.PROXY_BACKEND_DRIVER_TYPE)).thenReturn("JDBC");
+ when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps().getValue(ConfigurationPropertyKey.PROXY_BACKEND_EXECUTOR_SUITABLE)).thenReturn("OLAP");
connectionSession = new ConnectionSession(mock(MySQLDatabaseType.class), TransactionType.LOCAL, new DefaultAttributeMap());
}
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariablesHandlerTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariablesHandlerTest.java
index 70d394b068b..b9fe9605849 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariablesHandlerTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowDistVariablesHandlerTest.java
@@ -56,7 +56,7 @@ public final class ShowDistVariablesHandlerTest extends ProxyContextRestorer {
private MetaDataContexts mockMetaDataContexts() {
MetaDataContexts result = mock(MetaDataContexts.class, RETURNS_DEEP_STUBS);
Properties props = new Properties();
- props.setProperty(ConfigurationPropertyKey.PROXY_BACKEND_DRIVER_TYPE.getKey(), "JDBC");
+ props.setProperty(ConfigurationPropertyKey.PROXY_BACKEND_EXECUTOR_SUITABLE.getKey(), "OLAP");
when(result.getMetaData().getProps()).thenReturn(new ConfigurationProperties(props));
return result;
}
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataHandlerTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataHandlerTest.java
index 69d33aa8c19..2f0eb5ea15e 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataHandlerTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataHandlerTest.java
@@ -121,7 +121,7 @@ public final class RefreshTableMetaDataHandlerTest extends ProxyContextRestorer
private Properties createProperties() {
Properties result = new Properties();
- result.setProperty(ConfigurationPropertyKey.PROXY_BACKEND_DRIVER_TYPE.getKey(), ConfigurationPropertyKey.PROXY_BACKEND_DRIVER_TYPE.getDefaultValue());
+ result.setProperty(ConfigurationPropertyKey.PROXY_BACKEND_EXECUTOR_SUITABLE.getKey(), ConfigurationPropertyKey.PROXY_BACKEND_EXECUTOR_SUITABLE.getDefaultValue());
return result;
}
}
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableBackendHandlerTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableBackendHandlerTest.java
index 063f27baa6c..833f548a06a 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableBackendHandlerTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableBackendHandlerTest.java
@@ -86,7 +86,7 @@ public final class SetDistVariableBackendHandlerTest extends ProxyContextRestore
private Properties createProperties() {
Properties result = new Properties();
- result.setProperty(ConfigurationPropertyKey.PROXY_BACKEND_DRIVER_TYPE.getKey(), ConfigurationPropertyKey.PROXY_BACKEND_DRIVER_TYPE.getDefaultValue());
+ result.setProperty(ConfigurationPropertyKey.PROXY_BACKEND_EXECUTOR_SUITABLE.getKey(), ConfigurationPropertyKey.PROXY_BACKEND_EXECUTOR_SUITABLE.getDefaultValue());
return result;
}
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/transaction/TransactionBackendHandlerFactoryTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/transaction/TransactionBackendHandlerFactoryTest.java
index e583935822c..5833b4d1210 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/transaction/TransactionBackendHandlerFactoryTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/transaction/TransactionBackendHandlerFactoryTest.java
@@ -22,11 +22,10 @@ import org.apache.shardingsphere.infra.binder.QueryContext;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
-import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngineFactory;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.JDBCBackendTransactionManager;
+import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.BackendTransactionManager;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandler;
@@ -69,7 +68,7 @@ public final class TransactionBackendHandlerFactoryTest extends ProxyContextRest
@Test
public void assertTransactionBackendHandlerReturnedWhenTCLStatementInstanceOfCommitStatement() {
ConnectionSession connectionSession = mock(ConnectionSession.class, Answers.RETURNS_DEEP_STUBS);
- JDBCBackendConnection backendConnection = mock(JDBCBackendConnection.class);
+ BackendConnection backendConnection = mock(BackendConnection.class);
when(backendConnection.getConnectionSession()).thenReturn(connectionSession);
when(connectionSession.getBackendConnection()).thenReturn(backendConnection);
SQLStatementContext<CommitStatement> context = mock(SQLStatementContext.class);
@@ -84,7 +83,7 @@ public final class TransactionBackendHandlerFactoryTest extends ProxyContextRest
@Test
public void assertTransactionBackendHandlerReturnedWhenTCLStatementInstanceOfRollbackStatement() {
ConnectionSession connectionSession = mock(ConnectionSession.class, Answers.RETURNS_DEEP_STUBS);
- JDBCBackendConnection backendConnection = mock(JDBCBackendConnection.class);
+ BackendConnection backendConnection = mock(BackendConnection.class);
when(backendConnection.getConnectionSession()).thenReturn(connectionSession);
when(connectionSession.getBackendConnection()).thenReturn(backendConnection);
SQLStatementContext<RollbackStatement> context = mock(SQLStatementContext.class);
@@ -118,9 +117,9 @@ public final class TransactionBackendHandlerFactoryTest extends ProxyContextRest
}
@SneakyThrows(ReflectiveOperationException.class)
- private JDBCBackendTransactionManager getBackendTransactionManager(final TransactionBackendHandler transactionBackendHandler) {
+ private BackendTransactionManager getBackendTransactionManager(final TransactionBackendHandler transactionBackendHandler) {
Field field = transactionBackendHandler.getClass().getDeclaredField("backendTransactionManager");
field.setAccessible(true);
- return (JDBCBackendTransactionManager) field.get(transactionBackendHandler);
+ return (BackendTransactionManager) field.get(transactionBackendHandler);
}
}
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/transaction/TransactionBackendHandlerTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/transaction/TransactionBackendHandlerTest.java
index fb648dce2f1..d4ca1d864ff 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/transaction/TransactionBackendHandlerTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/transaction/TransactionBackendHandlerTest.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.proxy.backend.handler.transaction;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
@@ -53,7 +53,7 @@ public final class TransactionBackendHandlerTest extends ProxyContextRestorer {
@Test
public void assertExecute() throws SQLException {
- JDBCBackendConnection backendConnection = mock(JDBCBackendConnection.class);
+ BackendConnection backendConnection = mock(BackendConnection.class);
when(connectionSession.getBackendConnection()).thenReturn(backendConnection);
when(backendConnection.getConnectionSession()).thenReturn(connectionSession);
assertThat(new TransactionBackendHandler(mock(TCLStatement.class), TransactionOperationType.BEGIN, connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
diff --git a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/session/ConnectionSessionTest.java b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/session/ConnectionSessionTest.java
index 4e5648414f6..3915dbda0e4 100644
--- a/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/session/ConnectionSessionTest.java
+++ b/proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/session/ConnectionSessionTest.java
@@ -21,8 +21,8 @@ import org.apache.shardingsphere.infra.binder.QueryContext;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.JDBCBackendTransactionManager;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.BackendTransactionManager;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.util.ProxyContextRestorer;
import org.apache.shardingsphere.transaction.api.TransactionType;
@@ -51,7 +51,7 @@ public final class ConnectionSessionTest extends ProxyContextRestorer {
private ContextManager contextManager;
@Mock
- private JDBCBackendConnection backendConnection;
+ private BackendConnection backendConnection;
private ConnectionSession connectionSession;
@@ -74,7 +74,7 @@ public final class ConnectionSessionTest extends ProxyContextRestorer {
@Test(expected = SwitchTypeInTransactionException.class)
public void assertFailedSwitchTransactionTypeWhileBegin() {
connectionSession.setCurrentDatabase("db");
- JDBCBackendTransactionManager transactionManager = new JDBCBackendTransactionManager(backendConnection);
+ BackendTransactionManager transactionManager = new BackendTransactionManager(backendConnection);
transactionManager.begin();
connectionSession.getTransactionStatus().setTransactionType(TransactionType.XA);
}
@@ -82,7 +82,7 @@ public final class ConnectionSessionTest extends ProxyContextRestorer {
@Test
public void assertSwitchSchemaWhileBegin() {
connectionSession.setCurrentDatabase("db");
- JDBCBackendTransactionManager transactionManager = new JDBCBackendTransactionManager(backendConnection);
+ BackendTransactionManager transactionManager = new BackendTransactionManager(backendConnection);
transactionManager.begin();
connectionSession.setCurrentDatabase("newDB");
assertThat(connectionSession.getDefaultDatabaseName(), is("newDB"));
diff --git a/proxy/bootstrap/pom.xml b/proxy/bootstrap/pom.xml
index 1dbd83bdd75..9545f220340 100644
--- a/proxy/bootstrap/pom.xml
+++ b/proxy/bootstrap/pom.xml
@@ -58,11 +58,6 @@
<artifactId>shardingsphere-proxy-frontend-mysql</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-proxy-frontend-reactive-mysql</artifactId>
- <version>${project.version}</version>
- </dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-proxy-frontend-postgresql</artifactId>
diff --git a/proxy/bootstrap/src/main/resources/conf/server.yaml b/proxy/bootstrap/src/main/resources/conf/server.yaml
index 166959eaa3c..32e1770b598 100644
--- a/proxy/bootstrap/src/main/resources/conf/server.yaml
+++ b/proxy/bootstrap/src/main/resources/conf/server.yaml
@@ -76,8 +76,6 @@
# proxy-frontend-max-connections: 0 # Less than or equal to 0 means no limitation.
# # Available sql federation type: NONE (default), ORIGINAL, ADVANCED
# sql-federation-type: NONE
-# # Available proxy backend driver type: JDBC (default), ExperimentalVertx
-# proxy-backend-driver-type: JDBC
# proxy-mysql-default-version: 5.7.22 # In the absence of schema name, the default version will be used.
# proxy-default-port: 3307 # Proxy default port.
# proxy-netty-backlog: 1024 # Proxy netty backlog.
diff --git a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/ShardingSphereProxy.java b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/ShardingSphereProxy.java
index 62ff0b88a88..dda35855b07 100644
--- a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/ShardingSphereProxy.java
+++ b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/ShardingSphereProxy.java
@@ -33,7 +33,6 @@ import io.netty.handler.logging.LoggingHandler;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
-import org.apache.shardingsphere.proxy.backend.communication.vertx.VertxBackendDataSource;
import org.apache.shardingsphere.proxy.backend.context.BackendExecutorContext;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.frontend.netty.ServerHandlerInitializer;
@@ -95,11 +94,6 @@ public final class ShardingSphereProxy {
}
private EventLoopGroup getWorkerGroup() {
- String driverType = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps().getValue(ConfigurationPropertyKey.PROXY_BACKEND_DRIVER_TYPE);
- boolean reactiveBackendEnabled = "ExperimentalVertx".equalsIgnoreCase(driverType);
- if (reactiveBackendEnabled) {
- return VertxBackendDataSource.getInstance().getVertx().nettyEventLoopGroup();
- }
int workerThreads = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps().<Integer>getValue(ConfigurationPropertyKey.PROXY_FRONTEND_EXECUTOR_SIZE);
return Epoll.isAvailable() ? new EpollEventLoopGroup(workerThreads) : new NioEventLoopGroup(workerThreads);
}
diff --git a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java
index 217593b3340..fc01b8bd9b2 100644
--- a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java
+++ b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java
@@ -74,7 +74,6 @@ public final class CommandExecutorTask implements Runnable {
if (sqlShowEnabled) {
fillLogMDC();
}
- connectionSession.getBackendConnection().prepareForTaskExecution();
isNeedFlush = executeCommand(context, payload);
// CHECKSTYLE:OFF
} catch (final Exception ex) {
diff --git a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandler.java b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandler.java
index a38a5ea0e4a..ed111c51aaf 100644
--- a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandler.java
+++ b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandler.java
@@ -27,7 +27,6 @@ import org.apache.shardingsphere.db.protocol.payload.PacketPayload;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
import org.apache.shardingsphere.infra.executor.sql.process.ExecuteProcessEngine;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.authentication.AuthenticationResult;
@@ -109,7 +108,7 @@ public final class FrontendChannelInboundHandler extends ChannelInboundHandlerAd
@Override
public void channelWritabilityChanged(final ChannelHandlerContext context) {
if (context.channel().isWritable()) {
- ((JDBCBackendConnection) connectionSession.getBackendConnection()).getResourceLock().doNotify();
+ connectionSession.getBackendConnection().getResourceLock().doNotify();
}
}
}
diff --git a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/ProxyStateContext.java b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/ProxyStateContext.java
index 0b1d32f93a7..776cd423594 100644
--- a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/ProxyStateContext.java
+++ b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/ProxyStateContext.java
@@ -20,15 +20,13 @@ package org.apache.shardingsphere.proxy.frontend.state;
import io.netty.channel.ChannelHandlerContext;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.state.StateType;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine;
import org.apache.shardingsphere.proxy.frontend.state.impl.CircuitBreakProxyState;
-import org.apache.shardingsphere.proxy.frontend.state.impl.LockProxyState;
import org.apache.shardingsphere.proxy.frontend.state.impl.OKProxyState;
-import org.apache.shardingsphere.proxy.frontend.state.impl.OKProxyStateFactory;
+import org.apache.shardingsphere.proxy.frontend.state.impl.LockProxyState;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -42,16 +40,11 @@ public final class ProxyStateContext {
private static final Map<StateType, ProxyState> STATES = new ConcurrentHashMap<>(3, 1);
static {
- STATES.put(StateType.OK, determineOKProxyState());
+ STATES.put(StateType.OK, new OKProxyState());
STATES.put(StateType.LOCK, new LockProxyState());
STATES.put(StateType.CIRCUIT_BREAK, new CircuitBreakProxyState());
}
- private static OKProxyState determineOKProxyState() {
- String backendDriverType = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps().getValue(ConfigurationPropertyKey.PROXY_BACKEND_DRIVER_TYPE);
- return OKProxyStateFactory.getInstance(backendDriverType);
- }
-
/**
* Execute command.
* @param context channel handler context
diff --git a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/JDBCOKProxyState.java b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/JDBCOKProxyState.java
deleted file mode 100644
index 4bc525845f0..00000000000
--- a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/JDBCOKProxyState.java
+++ /dev/null
@@ -1,73 +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.proxy.frontend.state.impl;
-
-import io.netty.channel.ChannelHandlerContext;
-import org.apache.shardingsphere.infra.config.props.BackendExecutorType;
-import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask;
-import org.apache.shardingsphere.proxy.frontend.executor.ConnectionThreadExecutorGroup;
-import org.apache.shardingsphere.proxy.frontend.executor.UserExecutorGroup;
-import org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine;
-import org.apache.shardingsphere.transaction.api.TransactionType;
-
-import java.util.concurrent.ExecutorService;
-
-/**
- * JDBC OK proxy state.
- */
-public final class JDBCOKProxyState implements OKProxyState {
-
- @Override
- public void execute(final ChannelHandlerContext context, final Object message, final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine, final ConnectionSession connectionSession) {
- CommandExecutorTask commandExecutorTask = new CommandExecutorTask(databaseProtocolFrontendEngine, connectionSession, context, message);
- ExecutorService executorService = determineSuitableExecutorService(context, message, databaseProtocolFrontendEngine, connectionSession);
- executorService.execute(commandExecutorTask);
- }
-
- private ExecutorService determineSuitableExecutorService(final ChannelHandlerContext context, final Object message, final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine,
- final ConnectionSession connectionSession) {
- if (requireOccupyThreadForConnection(connectionSession)) {
- return ConnectionThreadExecutorGroup.getInstance().get(connectionSession.getConnectionId());
- }
- if (isPreferNettyEventLoop()) {
- return context.executor();
- }
- if (databaseProtocolFrontendEngine.getFrontendContext().isRequiredSameThreadForConnection(message)) {
- return ConnectionThreadExecutorGroup.getInstance().get(connectionSession.getConnectionId());
- }
- return UserExecutorGroup.getInstance().getExecutorService();
- }
-
- private boolean requireOccupyThreadForConnection(final ConnectionSession connectionSession) {
- return ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps().<Boolean>getValue(ConfigurationPropertyKey.PROXY_HINT_ENABLED)
- || TransactionType.isDistributedTransaction(connectionSession.getTransactionStatus().getTransactionType());
- }
-
- private boolean isPreferNettyEventLoop() {
- return BackendExecutorType.OLTP == ProxyContext.getInstance()
- .getContextManager().getMetaDataContexts().getMetaData().getProps().<BackendExecutorType>getValue(ConfigurationPropertyKey.PROXY_BACKEND_EXECUTOR_SUITABLE);
- }
-
- @Override
- public String getType() {
- return "JDBC";
- }
-}
diff --git a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyState.java b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyState.java
index f49ab768004..cecac1a52bb 100644
--- a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyState.java
+++ b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyState.java
@@ -17,13 +17,53 @@
package org.apache.shardingsphere.proxy.frontend.state.impl;
+import io.netty.channel.ChannelHandlerContext;
+import org.apache.shardingsphere.infra.config.props.BackendExecutorType;
+import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask;
+import org.apache.shardingsphere.proxy.frontend.executor.ConnectionThreadExecutorGroup;
+import org.apache.shardingsphere.proxy.frontend.executor.UserExecutorGroup;
+import org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine;
import org.apache.shardingsphere.proxy.frontend.state.ProxyState;
-import org.apache.shardingsphere.infra.util.spi.annotation.SingletonSPI;
-import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPI;
+import org.apache.shardingsphere.transaction.api.TransactionType;
+
+import java.util.concurrent.ExecutorService;
/**
* OK proxy state.
*/
-@SingletonSPI
-public interface OKProxyState extends ProxyState, TypedSPI {
+public final class OKProxyState implements ProxyState {
+
+ @Override
+ public void execute(final ChannelHandlerContext context, final Object message, final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine, final ConnectionSession connectionSession) {
+ CommandExecutorTask commandExecutorTask = new CommandExecutorTask(databaseProtocolFrontendEngine, connectionSession, context, message);
+ ExecutorService executorService = determineSuitableExecutorService(context, message, databaseProtocolFrontendEngine, connectionSession);
+ executorService.execute(commandExecutorTask);
+ }
+
+ private ExecutorService determineSuitableExecutorService(final ChannelHandlerContext context, final Object message, final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine,
+ final ConnectionSession connectionSession) {
+ if (requireOccupyThreadForConnection(connectionSession)) {
+ return ConnectionThreadExecutorGroup.getInstance().get(connectionSession.getConnectionId());
+ }
+ if (isPreferNettyEventLoop()) {
+ return context.executor();
+ }
+ if (databaseProtocolFrontendEngine.getFrontendContext().isRequiredSameThreadForConnection(message)) {
+ return ConnectionThreadExecutorGroup.getInstance().get(connectionSession.getConnectionId());
+ }
+ return UserExecutorGroup.getInstance().getExecutorService();
+ }
+
+ private boolean requireOccupyThreadForConnection(final ConnectionSession connectionSession) {
+ return ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps().<Boolean>getValue(ConfigurationPropertyKey.PROXY_HINT_ENABLED)
+ || TransactionType.isDistributedTransaction(connectionSession.getTransactionStatus().getTransactionType());
+ }
+
+ private boolean isPreferNettyEventLoop() {
+ return BackendExecutorType.OLTP == ProxyContext.getInstance()
+ .getContextManager().getMetaDataContexts().getMetaData().getProps().<BackendExecutorType>getValue(ConfigurationPropertyKey.PROXY_BACKEND_EXECUTOR_SUITABLE);
+ }
}
diff --git a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyStateFactory.java b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyStateFactory.java
deleted file mode 100644
index ee66805a10a..00000000000
--- a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyStateFactory.java
+++ /dev/null
@@ -1,44 +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.proxy.frontend.state.impl;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.infra.util.spi.ShardingSphereServiceLoader;
-import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPIRegistry;
-
-/**
- * OK proxy state factory.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class OKProxyStateFactory {
-
- static {
- ShardingSphereServiceLoader.register(OKProxyState.class);
- }
-
- /**
- * Get instance of OK proxy state.
- *
- * @param type type
- * @return got instance
- */
- public static OKProxyState getInstance(final String type) {
- return TypedSPIRegistry.getRegisteredService(OKProxyState.class, type);
- }
-}
diff --git a/proxy/frontend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.frontend.state.impl.OKProxyState b/proxy/frontend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.frontend.state.impl.OKProxyState
deleted file mode 100644
index 7e53c0e1b01..00000000000
--- a/proxy/frontend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.frontend.state.impl.OKProxyState
+++ /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.proxy.frontend.state.impl.JDBCOKProxyState
diff --git a/proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTaskTest.java b/proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTaskTest.java
index db63ccce12b..8107e31851a 100644
--- a/proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTaskTest.java
+++ b/proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTaskTest.java
@@ -29,7 +29,7 @@ import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.exception.BackendConnectionException;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
@@ -70,7 +70,7 @@ public final class CommandExecutorTaskTest extends ProxyContextRestorer {
private ConnectionSession connectionSession;
@Mock
- private JDBCBackendConnection backendConnection;
+ private BackendConnection backendConnection;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private ChannelHandlerContext handlerContext;
diff --git a/proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/fixture/FixtureOKProxyState.java b/proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/fixture/FixtureOKProxyState.java
deleted file mode 100644
index 29034271d70..00000000000
--- a/proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/fixture/FixtureOKProxyState.java
+++ /dev/null
@@ -1,36 +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.proxy.frontend.fixture;
-
-import io.netty.channel.ChannelHandlerContext;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine;
-import org.apache.shardingsphere.proxy.frontend.state.impl.OKProxyState;
-import org.apache.shardingsphere.test.fixture.infra.database.type.MockedDatabaseType;
-
-public final class FixtureOKProxyState implements OKProxyState {
-
- @Override
- public void execute(final ChannelHandlerContext context, final Object message, final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine, final ConnectionSession connectionSession) {
- }
-
- @Override
- public String getType() {
- return new MockedDatabaseType().getType();
- }
-}
diff --git a/proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyStateFactoryTest.java b/proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyStateFactoryTest.java
deleted file mode 100644
index 8790cf78e4b..00000000000
--- a/proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyStateFactoryTest.java
+++ /dev/null
@@ -1,33 +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.proxy.frontend.state.impl;
-
-import org.apache.shardingsphere.proxy.frontend.fixture.FixtureOKProxyState;
-import org.apache.shardingsphere.test.fixture.infra.database.type.MockedDatabaseType;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-public final class OKProxyStateFactoryTest {
-
- @Test
- public void assertGetInstance() {
- assertThat(OKProxyStateFactory.getInstance(new MockedDatabaseType().getType()), instanceOf(FixtureOKProxyState.class));
- }
-}
diff --git a/proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/state/impl/JDBCOKProxyStateTest.java b/proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyStateTest.java
similarity index 91%
rename from proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/state/impl/JDBCOKProxyStateTest.java
rename to proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyStateTest.java
index 672c5e6a721..fb38bc0620a 100644
--- a/proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/state/impl/JDBCOKProxyStateTest.java
+++ b/proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyStateTest.java
@@ -23,7 +23,7 @@ import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.config.props.BackendExecutorType;
import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.ProxyContextRestorer;
@@ -49,7 +49,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
-public final class JDBCOKProxyStateTest extends ProxyContextRestorer {
+public final class OKProxyStateTest extends ProxyContextRestorer {
@Mock
private ChannelHandlerContext context;
@@ -63,7 +63,7 @@ public final class JDBCOKProxyStateTest extends ProxyContextRestorer {
@Before
public void setup() {
when(connectionSession.getConnectionId()).thenReturn(1);
- when(connectionSession.getBackendConnection()).thenReturn(mock(JDBCBackendConnection.class));
+ when(connectionSession.getBackendConnection()).thenReturn(mock(BackendConnection.class));
ProxyContext.init(mock(ContextManager.class, RETURNS_DEEP_STUBS));
}
@@ -71,7 +71,7 @@ public final class JDBCOKProxyStateTest extends ProxyContextRestorer {
public void assertExecuteWithProxyHintEnabled() {
when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps().<Boolean>getValue(ConfigurationPropertyKey.PROXY_HINT_ENABLED)).thenReturn(true);
ExecutorService executorService = registerMockExecutorService(1);
- new JDBCOKProxyState().execute(context, null, frontendEngine, connectionSession);
+ new OKProxyState().execute(context, null, frontendEngine, connectionSession);
verify(executorService).execute(any(CommandExecutorTask.class));
ConnectionThreadExecutorGroup.getInstance().unregisterAndAwaitTermination(1);
}
@@ -81,7 +81,7 @@ public final class JDBCOKProxyStateTest extends ProxyContextRestorer {
when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps().<Boolean>getValue(ConfigurationPropertyKey.PROXY_HINT_ENABLED)).thenReturn(false);
when(connectionSession.getTransactionStatus().getTransactionType()).thenReturn(TransactionType.XA);
ExecutorService executorService = registerMockExecutorService(1);
- new JDBCOKProxyState().execute(context, null, frontendEngine, connectionSession);
+ new OKProxyState().execute(context, null, frontendEngine, connectionSession);
verify(executorService).execute(any(CommandExecutorTask.class));
ConnectionThreadExecutorGroup.getInstance().unregisterAndAwaitTermination(1);
}
@@ -93,7 +93,7 @@ public final class JDBCOKProxyStateTest extends ProxyContextRestorer {
.getMetaDataContexts().getMetaData().getProps().<BackendExecutorType>getValue(ConfigurationPropertyKey.PROXY_BACKEND_EXECUTOR_SUITABLE)).thenReturn(BackendExecutorType.OLTP);
EventExecutor eventExecutor = mock(EventExecutor.class);
when(context.executor()).thenReturn(eventExecutor);
- new JDBCOKProxyState().execute(context, null, frontendEngine, connectionSession);
+ new OKProxyState().execute(context, null, frontendEngine, connectionSession);
verify(eventExecutor).execute(any(CommandExecutorTask.class));
}
@@ -104,7 +104,7 @@ public final class JDBCOKProxyStateTest extends ProxyContextRestorer {
.getMetaDataContexts().getMetaData().getProps().<BackendExecutorType>getValue(ConfigurationPropertyKey.PROXY_BACKEND_EXECUTOR_SUITABLE)).thenReturn(BackendExecutorType.OLAP);
when(frontendEngine.getFrontendContext().isRequiredSameThreadForConnection(null)).thenReturn(true);
ExecutorService executorService = registerMockExecutorService(1);
- new JDBCOKProxyState().execute(context, null, frontendEngine, connectionSession);
+ new OKProxyState().execute(context, null, frontendEngine, connectionSession);
verify(executorService).execute(any(CommandExecutorTask.class));
ConnectionThreadExecutorGroup.getInstance().unregisterAndAwaitTermination(1);
}
diff --git a/proxy/frontend/core/src/test/resources/META-INF/services/org.apache.shardingsphere.proxy.frontend.state.impl.OKProxyState b/proxy/frontend/core/src/test/resources/META-INF/services/org.apache.shardingsphere.proxy.frontend.state.impl.OKProxyState
deleted file mode 100644
index 87b1502f294..00000000000
--- a/proxy/frontend/core/src/test/resources/META-INF/services/org.apache.shardingsphere.proxy.frontend.state.impl.OKProxyState
+++ /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.proxy.frontend.fixture.FixtureOKProxyState
diff --git a/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecuteEngine.java b/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecuteEngine.java
index 29cd561f2d9..307d9a81c30 100644
--- a/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecuteEngine.java
+++ b/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecuteEngine.java
@@ -31,7 +31,6 @@ import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.CommandExecuteEngine;
@@ -88,7 +87,7 @@ public final class MySQLCommandExecuteEngine implements CommandExecuteEngine {
count++;
while (!context.channel().isWritable() && context.channel().isActive()) {
context.flush();
- ((JDBCBackendConnection) backendConnection).getResourceLock().doAwait();
+ backendConnection.getResourceLock().doAwait();
}
DatabasePacket<?> dataValue = queryCommandExecutor.getQueryRowPacket();
context.write(dataValue);
diff --git a/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/MySQLComResetConnectionExecutor.java b/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/MySQLComResetConnectionExecutor.java
index b3df71e411b..d068432ec2c 100644
--- a/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/MySQLComResetConnectionExecutor.java
+++ b/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/MySQLComResetConnectionExecutor.java
@@ -20,8 +20,7 @@ package org.apache.shardingsphere.proxy.frontend.mysql.command.admin;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLOKPacket;
import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.JDBCBackendTransactionManager;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.BackendTransactionManager;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
import org.apache.shardingsphere.proxy.frontend.mysql.command.ServerStatusFlagCalculator;
@@ -40,9 +39,7 @@ public final class MySQLComResetConnectionExecutor implements CommandExecutor {
@Override
public Collection<DatabasePacket<?>> execute() throws SQLException {
- if (connectionSession.getBackendConnection() instanceof JDBCBackendConnection) {
- new JDBCBackendTransactionManager((JDBCBackendConnection) connectionSession.getBackendConnection()).rollback();
- }
+ new BackendTransactionManager(connectionSession.getBackendConnection()).rollback();
connectionSession.setAutoCommit(true);
connectionSession.setDefaultIsolationLevel(null);
connectionSession.setIsolationLevel(null);
diff --git a/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/fieldlist/MySQLComFieldListPacketExecutor.java b/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/fieldlist/MySQLComFieldListPacketExecutor.java
index 3b470f10c4a..012522aa928 100644
--- a/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/fieldlist/MySQLComFieldListPacketExecutor.java
+++ b/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/fieldlist/MySQLComFieldListPacketExecutor.java
@@ -31,8 +31,8 @@ import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngineFactory;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
@@ -56,7 +56,7 @@ public final class MySQLComFieldListPacketExecutor implements CommandExecutor {
private final ConnectionSession connectionSession;
- private JDBCDatabaseCommunicationEngine databaseCommunicationEngine;
+ private DatabaseCommunicationEngine databaseCommunicationEngine;
private int currentSequenceId;
@@ -68,7 +68,7 @@ public final class MySQLComFieldListPacketExecutor implements CommandExecutor {
SQLParserRule sqlParserRule = metaDataContexts.getMetaData().getGlobalRuleMetaData().getSingleRule(SQLParserRule.class);
SQLStatement sqlStatement = sqlParserRule.getSQLParserEngine(DatabaseTypeFactory.getInstance("MySQL").getType()).parse(sql, false);
SQLStatementContext<?> sqlStatementContext = SQLStatementContextFactory.newInstance(metaDataContexts.getMetaData(), sqlStatement, databaseName);
- JDBCBackendConnection backendConnection = (JDBCBackendConnection) connectionSession.getBackendConnection();
+ BackendConnection backendConnection = connectionSession.getBackendConnection();
QueryContext queryContext = new QueryContext(sqlStatementContext, sql, Collections.emptyList());
databaseCommunicationEngine = DatabaseCommunicationEngineFactory.getInstance().newDatabaseCommunicationEngine(queryContext, backendConnection, false);
databaseCommunicationEngine.execute();
diff --git a/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandler.java b/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandler.java
index 766092f2438..d20b1103a91 100644
--- a/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandler.java
+++ b/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandler.java
@@ -42,7 +42,6 @@ import org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.JDBCBackendStatement;
import org.apache.shardingsphere.proxy.backend.context.BackendExecutorContext;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -137,7 +136,7 @@ public final class MySQLMultiStatementsHandler implements ProxyBackendHandler {
public ResponseHeader execute() throws SQLException {
Collection<ShardingSphereRule> rules = metaDataContexts.getMetaData().getDatabase(connectionSession.getDatabaseName()).getRuleMetaData().getRules();
DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine = new DriverExecutionPrepareEngine<>(JDBCDriverType.STATEMENT, metaDataContexts.getMetaData().getProps()
- .<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY), (JDBCBackendConnection) connectionSession.getBackendConnection(),
+ .<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY), connectionSession.getBackendConnection(),
(JDBCBackendStatement) connectionSession.getStatementManager(), new StatementOption(false), rules,
metaDataContexts.getMetaData().getDatabase(connectionSession.getDatabaseName()).getResourceMetaData().getStorageTypes());
ExecutionGroupContext<JDBCExecutionUnit> executionGroupContext = prepareEngine.prepare(anyExecutionContext.getRouteContext(), samplingExecutionUnit());
diff --git a/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactoryTest.java b/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactoryTest.java
index 92f9c1e6aad..80aa76a56c9 100644
--- a/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactoryTest.java
+++ b/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactoryTest.java
@@ -38,7 +38,7 @@ import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRule
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.mysql.ProxyContextRestorer;
@@ -81,7 +81,7 @@ public final class MySQLCommandExecutorFactoryTest extends ProxyContextRestorer
private ConnectionSession connectionSession;
@Mock
- private JDBCBackendConnection backendConnection;
+ private BackendConnection backendConnection;
@Before
public void setUp() {
diff --git a/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/MySQLComResetConnectionExecutorTest.java b/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/MySQLComResetConnectionExecutorTest.java
index 4ef5e825897..f785b8c0132 100644
--- a/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/MySQLComResetConnectionExecutorTest.java
+++ b/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/MySQLComResetConnectionExecutorTest.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.proxy.frontend.mysql.command.admin;
import org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLOKPacket;
import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.JDBCBackendTransactionManager;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.BackendTransactionManager;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.session.ServerPreparedStatementRegistry;
import org.apache.shardingsphere.proxy.backend.session.transaction.TransactionStatus;
@@ -46,14 +46,14 @@ public final class MySQLComResetConnectionExecutorTest {
@Test
public void assertExecute() throws SQLException {
ConnectionSession connectionSession = mock(ConnectionSession.class);
- JDBCBackendConnection backendConnection = mock(JDBCBackendConnection.class);
+ BackendConnection backendConnection = mock(BackendConnection.class);
when(connectionSession.getBackendConnection()).thenReturn(backendConnection);
when(connectionSession.getTransactionStatus()).thenReturn(new TransactionStatus(TransactionType.LOCAL));
when(connectionSession.getServerPreparedStatementRegistry()).thenReturn(new ServerPreparedStatementRegistry());
int statementId = 1;
connectionSession.getServerPreparedStatementRegistry().addPreparedStatement(statementId, new MySQLServerPreparedStatement("", null));
Collection<DatabasePacket<?>> actual;
- try (MockedConstruction<JDBCBackendTransactionManager> ignored = mockConstruction(JDBCBackendTransactionManager.class)) {
+ try (MockedConstruction<BackendTransactionManager> ignored = mockConstruction(BackendTransactionManager.class)) {
actual = new MySQLComResetConnectionExecutor(connectionSession).execute();
}
assertThat(actual.size(), is(1));
diff --git a/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java b/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java
index d455c75f7fe..f1e8f88aaf3 100644
--- a/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java
+++ b/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java
@@ -41,7 +41,7 @@ import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRule
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandler;
import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandlerFactory;
@@ -104,7 +104,7 @@ public final class MySQLComStmtExecuteExecutorTest extends ProxyContextRestorer
private ConnectionSession connectionSession;
@Mock
- private JDBCBackendConnection backendConnection;
+ private BackendConnection backendConnection;
@Before
public void setUp() {
diff --git a/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandlerTest.java b/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandlerTest.java
index afc600bce4a..e247ae0474b 100644
--- a/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandlerTest.java
+++ b/proxy/frontend/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandlerTest.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.Statemen
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.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.JDBCBackendStatement;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
@@ -65,7 +65,7 @@ public final class MySQLMultiStatementsHandlerTest {
private ConnectionSession connectionSession;
@Mock
- private JDBCBackendConnection backendConnection;
+ private BackendConnection backendConnection;
@Mock
private JDBCBackendStatement backendStatement;
diff --git a/proxy/frontend/opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/simple/OpenGaussComQueryExecutor.java b/proxy/frontend/opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/simple/OpenGaussComQueryExecutor.java
index ae8fab09700..7be2c595ebe 100644
--- a/proxy/frontend/opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/simple/OpenGaussComQueryExecutor.java
+++ b/proxy/frontend/opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/simple/OpenGaussComQueryExecutor.java
@@ -95,7 +95,7 @@ public final class OpenGaussComQueryExecutor implements QueryCommandExecutor {
return result;
}
- private List<DatabasePacket<?>> createUpdatePacket(final UpdateResponseHeader updateResponseHeader) {
+ private List<DatabasePacket<?>> createUpdatePacket(final UpdateResponseHeader updateResponseHeader) throws SQLException {
SQLStatement sqlStatement = updateResponseHeader.getSqlStatement();
if (sqlStatement instanceof CommitStatement || sqlStatement instanceof RollbackStatement) {
portalContext.closeAll();
diff --git a/proxy/frontend/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutorTest.java b/proxy/frontend/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutorTest.java
index 9a5ae65edee..29513036ae7 100644
--- a/proxy/frontend/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutorTest.java
+++ b/proxy/frontend/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutorTest.java
@@ -34,7 +34,7 @@ import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.JDBCBackendStatement;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
@@ -96,7 +96,7 @@ public final class OpenGaussComBatchBindExecutorTest extends ProxyContextRestore
when(connectionSession.getConnectionContext()).thenReturn(new ConnectionContext());
when(connectionSession.getDatabaseName()).thenReturn("db");
when(connectionSession.getConnectionId()).thenReturn(1);
- JDBCBackendConnection backendConnection = mock(JDBCBackendConnection.class);
+ BackendConnection backendConnection = mock(BackendConnection.class);
Connection connection = mock(Connection.class, RETURNS_DEEP_STUBS);
when(connection.getMetaData().getURL()).thenReturn("jdbc:opengauss://127.0.0.1/db");
when(backendConnection.getConnections(nullable(String.class), anyInt(), any(ConnectionMode.class))).thenReturn(Collections.singletonList(connection));
diff --git a/proxy/frontend/pom.xml b/proxy/frontend/pom.xml
index 3d4078d9d89..f9791c8388a 100644
--- a/proxy/frontend/pom.xml
+++ b/proxy/frontend/pom.xml
@@ -34,8 +34,5 @@
<module>mysql</module>
<module>postgresql</module>
<module>opengauss</module>
- <module>reactive-core</module>
- <module>reactive-mysql</module>
- <module>reactive-spi</module>
</modules>
</project>
diff --git a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PortalContext.java b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PortalContext.java
index e6d80ccc79e..7c1c965d04c 100644
--- a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PortalContext.java
+++ b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PortalContext.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.proxy.frontend.postgresql.command;
import com.google.common.base.Preconditions;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.Portal;
+import java.sql.SQLException;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -28,17 +29,18 @@ import java.util.Map;
*/
public final class PortalContext {
- private final Map<String, Portal<?>> portals = new LinkedHashMap<>();
+ private final Map<String, Portal> portals = new LinkedHashMap<>();
/**
* Add portal.
*
* @param portal portal name
+ * @throws SQLException SQL exception
*/
- public void add(final Portal<?> portal) {
+ public void add(final Portal portal) throws SQLException {
boolean isNamedPortal = !portal.getName().isEmpty();
Preconditions.checkState(!isNamedPortal || !portals.containsKey(portal.getName()), "Named portal `%s` must be explicitly closed", portal.getName());
- Portal<?> previousPortal = portals.put(portal.getName(), portal);
+ Portal previousPortal = portals.put(portal.getName(), portal);
if (null != previousPortal) {
previousPortal.close();
}
@@ -47,21 +49,21 @@ public final class PortalContext {
/**
* Get portal.
*
- * @param <T> type of portal
* @param portalName portal name
* @return portal
*/
- public <T extends Portal<?>> T get(final String portalName) {
- return (T) portals.get(portalName);
+ public Portal get(final String portalName) {
+ return portals.get(portalName);
}
/**
* Close portal.
*
* @param portalName portal name
+ * @throws SQLException SQL exception
*/
- public void close(final String portalName) {
- Portal<?> result = portals.remove(portalName);
+ public void close(final String portalName) throws SQLException {
+ Portal result = portals.remove(portalName);
if (null != result) {
result.close();
}
@@ -69,9 +71,13 @@ public final class PortalContext {
/**
* Close all portals.
+ *
+ * @throws SQLException SQL exception
*/
- public void closeAll() {
- portals.values().forEach(Portal::close);
+ public void closeAll() throws SQLException {
+ for (Portal portal : portals.values()) {
+ portal.close();
+ }
portals.clear();
}
}
diff --git a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngine.java b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngine.java
index 980e3f3e5bd..98f7e90c296 100644
--- a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngine.java
+++ b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngine.java
@@ -32,7 +32,6 @@ import org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQ
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.CommandExecuteEngine;
@@ -83,10 +82,10 @@ public final class PostgreSQLCommandExecuteEngine implements CommandExecuteEngin
context.write(new PostgreSQLCommandCompletePacket(PostgreSQLCommand.SELECT.name(), 0));
return;
}
- processSimpleQuery(context, (JDBCBackendConnection) backendConnection, queryCommandExecutor);
+ processSimpleQuery(context, backendConnection, queryCommandExecutor);
}
- private void processSimpleQuery(final ChannelHandlerContext context, final JDBCBackendConnection backendConnection, final QueryCommandExecutor queryExecutor) throws SQLException {
+ private void processSimpleQuery(final ChannelHandlerContext context, final BackendConnection backendConnection, final QueryCommandExecutor queryExecutor) throws SQLException {
if (ResponseType.UPDATE == queryExecutor.getResponseType()) {
context.write(backendConnection.getConnectionSession().getTransactionStatus().isInTransaction() ? PostgreSQLReadyForQueryPacket.IN_TRANSACTION
: PostgreSQLReadyForQueryPacket.NOT_IN_TRANSACTION);
@@ -100,7 +99,7 @@ public final class PostgreSQLCommandExecuteEngine implements CommandExecuteEngin
: PostgreSQLReadyForQueryPacket.NOT_IN_TRANSACTION);
}
- private long writeDataPackets(final ChannelHandlerContext context, final JDBCBackendConnection backendConnection, final QueryCommandExecutor queryCommandExecutor) throws SQLException {
+ private long writeDataPackets(final ChannelHandlerContext context, final BackendConnection backendConnection, final QueryCommandExecutor queryCommandExecutor) throws SQLException {
long dataRows = 0;
int flushCount = 0;
int proxyFrontendFlushThreshold = ProxyContext.getInstance()
diff --git a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/JDBCPortal.java b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/JDBCPortal.java
deleted file mode 100644
index 6fd864ea50e..00000000000
--- a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/JDBCPortal.java
+++ /dev/null
@@ -1,207 +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.proxy.frontend.postgresql.command.query.extended;
-
-import lombok.Getter;
-import lombok.SneakyThrows;
-import org.apache.shardingsphere.db.protocol.binary.BinaryCell;
-import org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLValueFormat;
-import org.apache.shardingsphere.db.protocol.postgresql.packet.PostgreSQLPacket;
-import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLColumnDescription;
-import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLDataRowPacket;
-import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLEmptyQueryResponsePacket;
-import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLNoDataPacket;
-import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLRowDescriptionPacket;
-import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
-import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.execute.PostgreSQLPortalSuspendedPacket;
-import org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQLCommandCompletePacket;
-import org.apache.shardingsphere.db.protocol.postgresql.packet.handshake.PostgreSQLParameterStatusPacket;
-import org.apache.shardingsphere.db.protocol.postgresql.packet.identifier.PostgreSQLIdentifierPacket;
-import org.apache.shardingsphere.infra.binder.QueryContext;
-import org.apache.shardingsphere.infra.binder.aware.ParameterAware;
-import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandler;
-import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandlerFactory;
-import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseCell;
-import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import org.apache.shardingsphere.proxy.backend.response.header.query.QueryHeader;
-import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
-import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
-import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.PostgreSQLCommand;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dal.VariableAssignSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
-import org.apache.shardingsphere.sql.parser.sql.common.statement.dal.EmptyStatement;
-import org.apache.shardingsphere.sql.parser.sql.common.statement.dal.SetStatement;
-import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
-
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * PostgreSQL portal using JDBC backend.
- */
-public final class JDBCPortal implements Portal<Void> {
-
- @Getter
- private final String name;
-
- @Getter
- private final SQLStatement sqlStatement;
-
- private final List<PostgreSQLValueFormat> resultFormats;
-
- private final ProxyBackendHandler proxyBackendHandler;
-
- private final JDBCBackendConnection backendConnection;
-
- private ResponseHeader responseHeader;
-
- public JDBCPortal(final String name, final PostgreSQLServerPreparedStatement preparedStatement, final List<Object> params, final List<PostgreSQLValueFormat> resultFormats,
- final JDBCBackendConnection backendConnection) throws SQLException {
- this.name = name;
- this.sqlStatement = preparedStatement.getSqlStatementContext().getSqlStatement();
- this.resultFormats = resultFormats;
- this.backendConnection = backendConnection;
- String databaseName = backendConnection.getConnectionSession().getDefaultDatabaseName();
- SQLStatementContext<?> sqlStatementContext = preparedStatement.getSqlStatementContext();
- if (sqlStatementContext instanceof ParameterAware) {
- ((ParameterAware) sqlStatementContext).setUpParameters(params);
- }
- DatabaseType protocolType = ProxyContext.getInstance().getDatabase(databaseName).getProtocolType();
- QueryContext queryContext = new QueryContext(sqlStatementContext, preparedStatement.getSql(), params);
- backendConnection.getConnectionSession().setQueryContext(queryContext);
- proxyBackendHandler = ProxyBackendHandlerFactory.newInstance(protocolType, queryContext, backendConnection.getConnectionSession(), true);
- }
-
- @SneakyThrows(SQLException.class)
- @Override
- public Void bind() {
- responseHeader = proxyBackendHandler.execute();
- return null;
- }
-
- @Override
- public PostgreSQLPacket describe() {
- if (responseHeader instanceof QueryResponseHeader) {
- return createRowDescriptionPacket((QueryResponseHeader) responseHeader);
- }
- if (responseHeader instanceof UpdateResponseHeader) {
- return PostgreSQLNoDataPacket.getInstance();
- }
- throw new IllegalStateException(String.format("Can not describe portal `%s` before bind", name));
- }
-
- private PostgreSQLRowDescriptionPacket createRowDescriptionPacket(final QueryResponseHeader queryResponseHeader) {
- return new PostgreSQLRowDescriptionPacket(createColumnDescriptions(queryResponseHeader));
- }
-
- private Collection<PostgreSQLColumnDescription> createColumnDescriptions(final QueryResponseHeader queryResponseHeader) {
- Collection<PostgreSQLColumnDescription> result = new LinkedList<>();
- int columnIndex = 0;
- for (QueryHeader each : queryResponseHeader.getQueryHeaders()) {
- result.add(new PostgreSQLColumnDescription(each.getColumnLabel(), ++columnIndex, each.getColumnType(), each.getColumnLength(), each.getColumnTypeName()));
- }
- return result;
- }
-
- @SneakyThrows(SQLException.class)
- @Override
- public List<PostgreSQLPacket> execute(final int maxRows) {
- int fetchSize = maxRows > 0 ? maxRows : Integer.MAX_VALUE;
- List<PostgreSQLPacket> result = new LinkedList<>();
- for (int i = 0; i < fetchSize && hasNext(); i++) {
- result.add(nextPacket());
- }
- if (responseHeader instanceof UpdateResponseHeader && sqlStatement instanceof SetStatement) {
- result.addAll(createParameterStatusResponse((SetStatement) sqlStatement));
- return result;
- }
- result.add(createExecutionCompletedPacket(maxRows > 0 && maxRows == result.size(), result.size()));
- return result;
- }
-
- private List<PostgreSQLPacket> createParameterStatusResponse(final SetStatement sqlStatement) {
- List<PostgreSQLPacket> result = new ArrayList<>(2);
- result.add(new PostgreSQLCommandCompletePacket("SET", 0));
- for (VariableAssignSegment each : sqlStatement.getVariableAssigns()) {
- result.add(new PostgreSQLParameterStatusPacket(each.getVariable().getVariable(), IdentifierValue.getQuotedContent(each.getAssignValue())));
- }
- return result;
- }
-
- private boolean hasNext() throws SQLException {
- return proxyBackendHandler.next();
- }
-
- private PostgreSQLPacket nextPacket() throws SQLException {
- return new PostgreSQLDataRowPacket(getData(proxyBackendHandler.getRowData()));
- }
-
- private List<Object> getData(final QueryResponseRow queryResponseRow) {
- Collection<QueryResponseCell> cells = queryResponseRow.getCells();
- List<Object> result = new ArrayList<>(cells.size());
- List<QueryResponseCell> columns = new ArrayList<>(cells);
- for (int i = 0; i < columns.size(); i++) {
- PostgreSQLValueFormat format = determineValueFormat(i);
- result.add(PostgreSQLValueFormat.BINARY == format ? createBinaryCell(columns.get(i)) : columns.get(i).getData());
- }
- return result;
- }
-
- private PostgreSQLValueFormat determineValueFormat(final int columnIndex) {
- return resultFormats.isEmpty() ? PostgreSQLValueFormat.TEXT : resultFormats.get(columnIndex % resultFormats.size());
- }
-
- private BinaryCell createBinaryCell(final QueryResponseCell cell) {
- return new BinaryCell(PostgreSQLColumnType.valueOfJDBCType(cell.getJdbcType()), cell.getData());
- }
-
- private PostgreSQLIdentifierPacket createExecutionCompletedPacket(final boolean isSuspended, final int fetchedRows) {
- if (isSuspended) {
- suspendPortal();
- return new PostgreSQLPortalSuspendedPacket();
- }
- if (getSqlStatement() instanceof EmptyStatement) {
- return new PostgreSQLEmptyQueryResponsePacket();
- }
- String sqlCommand = PostgreSQLCommand.valueOf(getSqlStatement().getClass()).map(PostgreSQLCommand::getTag).orElse("");
- return new PostgreSQLCommandCompletePacket(sqlCommand, Math.max(fetchedRows, getUpdateCount()));
- }
-
- private void suspendPortal() {
- backendConnection.markResourceInUse(proxyBackendHandler);
- }
-
- private long getUpdateCount() {
- return responseHeader instanceof UpdateResponseHeader ? ((UpdateResponseHeader) responseHeader).getUpdateCount() : 0;
- }
-
- @SneakyThrows(SQLException.class)
- @Override
- public void close() {
- backendConnection.unmarkResourceInUse(proxyBackendHandler);
- proxyBackendHandler.close();
- }
-}
diff --git a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/Portal.java b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/Portal.java
index e775cf3539f..ff8c4a9f77b 100644
--- a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/Portal.java
+++ b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/Portal.java
@@ -17,56 +17,204 @@
package org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended;
+import lombok.Getter;
+import org.apache.shardingsphere.db.protocol.binary.BinaryCell;
+import org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLValueFormat;
import org.apache.shardingsphere.db.protocol.postgresql.packet.PostgreSQLPacket;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLColumnDescription;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLDataRowPacket;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLEmptyQueryResponsePacket;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLNoDataPacket;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLRowDescriptionPacket;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.execute.PostgreSQLPortalSuspendedPacket;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQLCommandCompletePacket;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.handshake.PostgreSQLParameterStatusPacket;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.identifier.PostgreSQLIdentifierPacket;
+import org.apache.shardingsphere.infra.binder.QueryContext;
+import org.apache.shardingsphere.infra.binder.aware.ParameterAware;
+import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
+import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandler;
+import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandlerFactory;
+import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseCell;
+import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.response.header.query.QueryHeader;
+import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
+import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
+import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.PostgreSQLCommand;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dal.VariableAssignSegment;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.dal.EmptyStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.dal.SetStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedList;
import java.util.List;
/**
* PostgreSQL portal.
- *
- * @param <T> type of bind result
*/
-public interface Portal<T> {
+public final class Portal {
- /**
- * Get portal's name.
- *
- * @return portal's name
- */
- String getName();
+ @Getter
+ private final String name;
- /**
- * Get SQL statement.
- *
- * @return SQL statement
- */
- SQLStatement getSqlStatement();
+ @Getter
+ private final SQLStatement sqlStatement;
+
+ private final List<PostgreSQLValueFormat> resultFormats;
+
+ private final ProxyBackendHandler proxyBackendHandler;
+
+ private final BackendConnection backendConnection;
+
+ private ResponseHeader responseHeader;
+
+ public Portal(final String name, final PostgreSQLServerPreparedStatement preparedStatement, final List<Object> params, final List<PostgreSQLValueFormat> resultFormats,
+ final BackendConnection backendConnection) throws SQLException {
+ this.name = name;
+ this.sqlStatement = preparedStatement.getSqlStatementContext().getSqlStatement();
+ this.resultFormats = resultFormats;
+ this.backendConnection = backendConnection;
+ String databaseName = backendConnection.getConnectionSession().getDefaultDatabaseName();
+ SQLStatementContext<?> sqlStatementContext = preparedStatement.getSqlStatementContext();
+ if (sqlStatementContext instanceof ParameterAware) {
+ ((ParameterAware) sqlStatementContext).setUpParameters(params);
+ }
+ DatabaseType protocolType = ProxyContext.getInstance().getDatabase(databaseName).getProtocolType();
+ QueryContext queryContext = new QueryContext(sqlStatementContext, preparedStatement.getSql(), params);
+ backendConnection.getConnectionSession().setQueryContext(queryContext);
+ proxyBackendHandler = ProxyBackendHandlerFactory.newInstance(protocolType, queryContext, backendConnection.getConnectionSession(), true);
+ }
/**
* Do bind.
- *
- * @return bind result, could be null
+ *
+ * @throws SQLException SQL exception
*/
- T bind();
+ public void bind() throws SQLException {
+ responseHeader = proxyBackendHandler.execute();
+ }
/**
* Describe portal.
*
* @return portal description packet
*/
- PostgreSQLPacket describe();
+ public PostgreSQLPacket describe() {
+ if (responseHeader instanceof QueryResponseHeader) {
+ return createRowDescriptionPacket((QueryResponseHeader) responseHeader);
+ }
+ if (responseHeader instanceof UpdateResponseHeader) {
+ return PostgreSQLNoDataPacket.getInstance();
+ }
+ throw new IllegalStateException(String.format("Can not describe portal `%s` before bind", name));
+ }
+
+ private PostgreSQLRowDescriptionPacket createRowDescriptionPacket(final QueryResponseHeader queryResponseHeader) {
+ return new PostgreSQLRowDescriptionPacket(createColumnDescriptions(queryResponseHeader));
+ }
+
+ private Collection<PostgreSQLColumnDescription> createColumnDescriptions(final QueryResponseHeader queryResponseHeader) {
+ Collection<PostgreSQLColumnDescription> result = new LinkedList<>();
+ int columnIndex = 0;
+ for (QueryHeader each : queryResponseHeader.getQueryHeaders()) {
+ result.add(new PostgreSQLColumnDescription(each.getColumnLabel(), ++columnIndex, each.getColumnType(), each.getColumnLength(), each.getColumnTypeName()));
+ }
+ return result;
+ }
/**
* Execute portal.
*
* @param maxRows max rows of query result
* @return execute result
+ * @throws SQLException SQL exception
*/
- List<PostgreSQLPacket> execute(int maxRows);
+ public List<PostgreSQLPacket> execute(final int maxRows) throws SQLException {
+ int fetchSize = maxRows > 0 ? maxRows : Integer.MAX_VALUE;
+ List<PostgreSQLPacket> result = new LinkedList<>();
+ for (int i = 0; i < fetchSize && hasNext(); i++) {
+ result.add(nextPacket());
+ }
+ if (responseHeader instanceof UpdateResponseHeader && sqlStatement instanceof SetStatement) {
+ result.addAll(createParameterStatusResponse((SetStatement) sqlStatement));
+ return result;
+ }
+ result.add(createExecutionCompletedPacket(maxRows > 0 && maxRows == result.size(), result.size()));
+ return result;
+ }
+
+ private List<PostgreSQLPacket> createParameterStatusResponse(final SetStatement sqlStatement) {
+ List<PostgreSQLPacket> result = new ArrayList<>(2);
+ result.add(new PostgreSQLCommandCompletePacket("SET", 0));
+ for (VariableAssignSegment each : sqlStatement.getVariableAssigns()) {
+ result.add(new PostgreSQLParameterStatusPacket(each.getVariable().getVariable(), IdentifierValue.getQuotedContent(each.getAssignValue())));
+ }
+ return result;
+ }
+
+ private boolean hasNext() throws SQLException {
+ return proxyBackendHandler.next();
+ }
+
+ private PostgreSQLPacket nextPacket() throws SQLException {
+ return new PostgreSQLDataRowPacket(getData(proxyBackendHandler.getRowData()));
+ }
+
+ private List<Object> getData(final QueryResponseRow queryResponseRow) {
+ Collection<QueryResponseCell> cells = queryResponseRow.getCells();
+ List<Object> result = new ArrayList<>(cells.size());
+ List<QueryResponseCell> columns = new ArrayList<>(cells);
+ for (int i = 0; i < columns.size(); i++) {
+ PostgreSQLValueFormat format = determineValueFormat(i);
+ result.add(PostgreSQLValueFormat.BINARY == format ? createBinaryCell(columns.get(i)) : columns.get(i).getData());
+ }
+ return result;
+ }
+
+ private PostgreSQLValueFormat determineValueFormat(final int columnIndex) {
+ return resultFormats.isEmpty() ? PostgreSQLValueFormat.TEXT : resultFormats.get(columnIndex % resultFormats.size());
+ }
+
+ private BinaryCell createBinaryCell(final QueryResponseCell cell) {
+ return new BinaryCell(PostgreSQLColumnType.valueOfJDBCType(cell.getJdbcType()), cell.getData());
+ }
+
+ private PostgreSQLIdentifierPacket createExecutionCompletedPacket(final boolean isSuspended, final int fetchedRows) {
+ if (isSuspended) {
+ suspendPortal();
+ return new PostgreSQLPortalSuspendedPacket();
+ }
+ if (getSqlStatement() instanceof EmptyStatement) {
+ return new PostgreSQLEmptyQueryResponsePacket();
+ }
+ String sqlCommand = PostgreSQLCommand.valueOf(getSqlStatement().getClass()).map(PostgreSQLCommand::getTag).orElse("");
+ return new PostgreSQLCommandCompletePacket(sqlCommand, Math.max(fetchedRows, getUpdateCount()));
+ }
+
+ private void suspendPortal() {
+ backendConnection.markResourceInUse(proxyBackendHandler);
+ }
+
+ private long getUpdateCount() {
+ return responseHeader instanceof UpdateResponseHeader ? ((UpdateResponseHeader) responseHeader).getUpdateCount() : 0;
+ }
/**
* Close portal.
+ *
+ * @throws SQLException SQL exception
*/
- void close();
+ public void close() throws SQLException {
+ backendConnection.unmarkResourceInUse(proxyBackendHandler);
+ proxyBackendHandler.close();
+ }
}
diff --git a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutor.java b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutor.java
index 54a4eefb7b2..96993cc3496 100644
--- a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutor.java
+++ b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutor.java
@@ -41,7 +41,6 @@ import org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.Statemen
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.JDBCBackendStatement;
import org.apache.shardingsphere.proxy.backend.context.BackendExecutorContext;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -149,7 +148,7 @@ public final class PostgreSQLBatchedStatementsExecutor {
Collection<ShardingSphereRule> rules = metaDataContexts.getMetaData().getDatabase(connectionSession.getDatabaseName()).getRuleMetaData().getRules();
DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine = new DriverExecutionPrepareEngine<>(JDBCDriverType.PREPARED_STATEMENT,
metaDataContexts.getMetaData().getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY),
- (JDBCBackendConnection) connectionSession.getBackendConnection(), (JDBCBackendStatement) connectionSession.getStatementManager(),
+ connectionSession.getBackendConnection(), (JDBCBackendStatement) connectionSession.getStatementManager(),
new StatementOption(false), rules, metaDataContexts.getMetaData().getDatabase(connectionSession.getDatabaseName()).getResourceMetaData().getStorageTypes());
executionGroupContext = prepareEngine.prepare(anyExecutionContext.getRouteContext(), executionUnitParams.keySet());
for (ExecutionGroup<JDBCExecutionUnit> eachGroup : executionGroupContext.getInputGroups()) {
diff --git a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutor.java b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutor.java
index 066fcc9b24e..af486d7766a 100644
--- a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutor.java
+++ b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutor.java
@@ -22,11 +22,11 @@ import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.PostgreSQLServerPreparedStatement;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.PostgreSQLBindCompletePacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.PostgreSQLComBindPacket;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.PortalContext;
-import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.JDBCPortal;
+import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.Portal;
import java.sql.SQLException;
import java.util.Collection;
@@ -47,8 +47,8 @@ public final class PostgreSQLComBindExecutor implements CommandExecutor {
@Override
public Collection<DatabasePacket<?>> execute() throws SQLException {
PostgreSQLServerPreparedStatement preparedStatement = connectionSession.getServerPreparedStatementRegistry().getPreparedStatement(packet.getStatementId());
- JDBCBackendConnection backendConnection = (JDBCBackendConnection) connectionSession.getBackendConnection();
- JDBCPortal portal = new JDBCPortal(packet.getPortal(), preparedStatement, packet.readParameters(preparedStatement.getParameterTypes()), packet.readResultFormats(), backendConnection);
+ BackendConnection backendConnection = connectionSession.getBackendConnection();
+ Portal portal = new Portal(packet.getPortal(), preparedStatement, packet.readParameters(preparedStatement.getParameterTypes()), packet.readResultFormats(), backendConnection);
portalContext.add(portal);
portal.bind();
return Collections.singletonList(PostgreSQLBindCompletePacket.getInstance());
diff --git a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutor.java b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutor.java
index 49a0d2b4c51..95c54c1feb0 100644
--- a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutor.java
+++ b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutor.java
@@ -26,6 +26,7 @@ import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.PortalContext;
+import java.sql.SQLException;
import java.util.Collection;
import java.util.Collections;
@@ -42,7 +43,7 @@ public final class PostgreSQLComCloseExecutor implements CommandExecutor {
private final ConnectionSession connectionSession;
@Override
- public Collection<DatabasePacket<?>> execute() {
+ public Collection<DatabasePacket<?>> execute() throws SQLException {
switch (packet.getType()) {
case PREPARED_STATEMENT:
connectionSession.getServerPreparedStatementRegistry().removePreparedStatement(packet.getName());
diff --git a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java
index 9a64c83c115..dfcc56abc82 100644
--- a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java
+++ b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java
@@ -40,7 +40,7 @@ import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.util.exception.external.sql.type.generic.UnsupportedSQLOperationException;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
@@ -243,9 +243,6 @@ public final class PostgreSQLComDescribeExecutor implements CommandExecutor {
}
private void tryDescribePreparedStatementByJDBC(final PostgreSQLServerPreparedStatement logicPreparedStatement) throws SQLException {
- if (!(connectionSession.getBackendConnection() instanceof JDBCBackendConnection)) {
- return;
- }
MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
String databaseName = connectionSession.getDatabaseName();
SQLStatementContext<?> sqlStatementContext =
@@ -255,7 +252,7 @@ public final class PostgreSQLComDescribeExecutor implements CommandExecutor {
ExecutionContext executionContext = new KernelProcessor().generateExecutionContext(
queryContext, database, metaDataContexts.getMetaData().getGlobalRuleMetaData(), metaDataContexts.getMetaData().getProps(), connectionSession.getConnectionContext());
ExecutionUnit executionUnitSample = executionContext.getExecutionUnits().iterator().next();
- JDBCBackendConnection backendConnection = (JDBCBackendConnection) connectionSession.getBackendConnection();
+ BackendConnection backendConnection = connectionSession.getBackendConnection();
Connection connection = backendConnection.getConnections(executionUnitSample.getDataSourceName(), 1, ConnectionMode.CONNECTION_STRICTLY).iterator().next();
try (PreparedStatement actualPreparedStatement = connection.prepareStatement(executionUnitSample.getSqlUnit().getSql())) {
populateParameterTypes(logicPreparedStatement, actualPreparedStatement);
diff --git a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/execute/PostgreSQLComExecuteExecutor.java b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/execute/PostgreSQLComExecuteExecutor.java
index 176d368fd46..1ebadb0ad01 100644
--- a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/execute/PostgreSQLComExecuteExecutor.java
+++ b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/execute/PostgreSQLComExecuteExecutor.java
@@ -25,6 +25,7 @@ import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extende
import org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.CommitStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.RollbackStatement;
+import java.sql.SQLException;
import java.util.List;
/**
@@ -39,13 +40,13 @@ public final class PostgreSQLComExecuteExecutor implements CommandExecutor {
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
- public List execute() {
+ public List execute() throws SQLException {
return portalContext.get(packet.getPortal()).execute(packet.getMaxRows());
}
@Override
- public void close() {
- Portal<?> portal = portalContext.get(packet.getPortal());
+ public void close() throws SQLException {
+ Portal portal = portalContext.get(packet.getPortal());
if (portal.getSqlStatement() instanceof CommitStatement || portal.getSqlStatement() instanceof RollbackStatement) {
portalContext.closeAll();
}
diff --git a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutor.java b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutor.java
index 2d1f1cfcb76..f41ee447426 100644
--- a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutor.java
+++ b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutor.java
@@ -95,7 +95,7 @@ public final class PostgreSQLComQueryExecutor implements QueryCommandExecutor {
return result;
}
- private List<DatabasePacket<?>> createUpdatePacket(final UpdateResponseHeader updateResponseHeader) {
+ private List<DatabasePacket<?>> createUpdatePacket(final UpdateResponseHeader updateResponseHeader) throws SQLException {
SQLStatement sqlStatement = updateResponseHeader.getSqlStatement();
if (sqlStatement instanceof CommitStatement || sqlStatement instanceof RollbackStatement) {
portalContext.closeAll();
diff --git a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PortalContextTest.java b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PortalContextTest.java
index 4ef0d7d91c9..20097f129c5 100644
--- a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PortalContextTest.java
+++ b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PortalContextTest.java
@@ -17,10 +17,11 @@
package org.apache.shardingsphere.proxy.frontend.postgresql.command;
-import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.JDBCPortal;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.Portal;
import org.junit.Test;
+import java.sql.SQLException;
+
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.mock;
@@ -32,33 +33,33 @@ public final class PortalContextTest {
private final PortalContext portalContext = new PortalContext();
@Test
- public void assertAddAndGetUnnamedPortal() {
+ public void assertAddAndGetUnnamedPortal() throws SQLException {
assertAddAndGetPortal("");
}
@Test
- public void assertAddAndGetNamedPortal() {
+ public void assertAddAndGetNamedPortal() throws SQLException {
assertAddAndGetPortal("P_1");
}
- private void assertAddAndGetPortal(final String portalName) {
- Portal<?> portal = mock(Portal.class);
+ private void assertAddAndGetPortal(final String portalName) throws SQLException {
+ Portal portal = mock(Portal.class);
when(portal.getName()).thenReturn(portalName);
portalContext.add(portal);
assertThat(portalContext.get(portalName), is(portal));
}
@Test(expected = IllegalStateException.class)
- public void assertAddDuplicateNamedPortal() {
- Portal<?> portal = mock(Portal.class);
+ public void assertAddDuplicateNamedPortal() throws SQLException {
+ Portal portal = mock(Portal.class);
when(portal.getName()).thenReturn("P_1");
portalContext.add(portal);
portalContext.add(portal);
}
@Test
- public void assertCloseSinglePortal() {
- Portal<?> portal = mock(Portal.class);
+ public void assertCloseSinglePortal() throws SQLException {
+ Portal portal = mock(Portal.class);
String portalName = "P_1";
when(portal.getName()).thenReturn(portalName);
portalContext.add(portal);
@@ -67,10 +68,10 @@ public final class PortalContextTest {
}
@Test
- public void assertCloseAllPortals() {
- Portal<?> portal1 = mock(JDBCPortal.class);
+ public void assertCloseAllPortals() throws SQLException {
+ Portal portal1 = mock(Portal.class);
when(portal1.getName()).thenReturn("P_1");
- Portal<?> portal2 = mock(JDBCPortal.class);
+ Portal portal2 = mock(Portal.class);
when(portal2.getName()).thenReturn("P_2");
portalContext.add(portal1);
portalContext.add(portal2);
diff --git a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngineTest.java b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngineTest.java
index 51448cdece0..21823ad2075 100644
--- a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngineTest.java
+++ b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngineTest.java
@@ -27,7 +27,7 @@ import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.ResourceLock;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
@@ -78,7 +78,7 @@ public final class PostgreSQLCommandExecuteEngineTest extends ProxyContextRestor
PostgreSQLComQueryExecutor comQueryExecutor = mock(PostgreSQLComQueryExecutor.class);
when(comQueryExecutor.getResponseType()).thenReturn(ResponseType.UPDATE);
PostgreSQLCommandExecuteEngine commandExecuteEngine = new PostgreSQLCommandExecuteEngine();
- JDBCBackendConnection backendConnection = mock(JDBCBackendConnection.class);
+ BackendConnection backendConnection = mock(BackendConnection.class);
when(backendConnection.getConnectionSession()).thenReturn(connectionSession);
commandExecuteEngine.writeQueryData(channelHandlerContext, backendConnection, comQueryExecutor, 0);
verify(channelHandlerContext).write(any(PostgreSQLReadyForQueryPacket.class));
@@ -88,7 +88,7 @@ public final class PostgreSQLCommandExecuteEngineTest extends ProxyContextRestor
public void assertWriteQueryDataWithUpdate() throws SQLException {
PostgreSQLCommandExecuteEngine commandExecuteEngine = new PostgreSQLCommandExecuteEngine();
when(queryCommandExecutor.getResponseType()).thenReturn(ResponseType.UPDATE);
- JDBCBackendConnection backendConnection = mock(JDBCBackendConnection.class, RETURNS_DEEP_STUBS);
+ BackendConnection backendConnection = mock(BackendConnection.class, RETURNS_DEEP_STUBS);
when(backendConnection.getConnectionSession()).thenReturn(connectionSession);
commandExecuteEngine.writeQueryData(channelHandlerContext, backendConnection, queryCommandExecutor, 0);
verify(channelHandlerContext).write(PostgreSQLReadyForQueryPacket.NOT_IN_TRANSACTION);
@@ -99,7 +99,7 @@ public final class PostgreSQLCommandExecuteEngineTest extends ProxyContextRestor
PostgreSQLCommandExecuteEngine commandExecuteEngine = new PostgreSQLCommandExecuteEngine();
when(queryCommandExecutor.getResponseType()).thenReturn(ResponseType.QUERY);
when(channel.isActive()).thenReturn(false);
- commandExecuteEngine.writeQueryData(channelHandlerContext, mock(JDBCBackendConnection.class), queryCommandExecutor, 0);
+ commandExecuteEngine.writeQueryData(channelHandlerContext, mock(BackendConnection.class), queryCommandExecutor, 0);
verify(channelHandlerContext).write(isA(PostgreSQLCommandCompletePacket.class));
}
@@ -111,7 +111,7 @@ public final class PostgreSQLCommandExecuteEngineTest extends ProxyContextRestor
when(queryCommandExecutor.next()).thenReturn(true, false);
when(channel.isWritable()).thenReturn(false, true);
ResourceLock resourceLock = mock(ResourceLock.class);
- JDBCBackendConnection backendConnection = mock(JDBCBackendConnection.class);
+ BackendConnection backendConnection = mock(BackendConnection.class);
when(backendConnection.getResourceLock()).thenReturn(resourceLock);
when(backendConnection.getConnectionSession()).thenReturn(connectionSession);
PostgreSQLPacket packet = mock(PostgreSQLPacket.class);
diff --git a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/JDBCPortalTest.java b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PortalTest.java
similarity index 92%
rename from proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/JDBCPortalTest.java
rename to proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PortalTest.java
index 053a438a25c..d3329023f9d 100644
--- a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/JDBCPortalTest.java
+++ b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PortalTest.java
@@ -35,7 +35,7 @@ import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandler;
import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandlerFactory;
@@ -84,7 +84,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
-public final class JDBCPortalTest extends ProxyContextRestorer {
+public final class PortalTest extends ProxyContextRestorer {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private ContextManager mockContextManager;
@@ -96,7 +96,7 @@ public final class JDBCPortalTest extends ProxyContextRestorer {
private ConnectionSession connectionSession;
@Mock
- private JDBCBackendConnection backendConnection;
+ private BackendConnection backendConnection;
private MockedStatic<ProxyBackendHandlerFactory> mockedStatic;
@@ -124,7 +124,7 @@ public final class JDBCPortalTest extends ProxyContextRestorer {
@Test
public void assertGetName() throws SQLException {
- JDBCPortal portal = new JDBCPortal("", new PostgreSQLServerPreparedStatement("",
+ Portal portal = new Portal("", new PostgreSQLServerPreparedStatement("",
new CommonSQLStatementContext<>(new PostgreSQLEmptyStatement()), Collections.emptyList()), Collections.emptyList(), Collections.emptyList(), backendConnection);
assertThat(portal.getName(), is(""));
}
@@ -143,7 +143,7 @@ public final class JDBCPortalTest extends ProxyContextRestorer {
PostgreSQLServerPreparedStatement preparedStatement =
new PostgreSQLServerPreparedStatement("", sqlStatementContext, Collections.emptyList());
List<PostgreSQLValueFormat> resultFormats = new ArrayList<>(Arrays.asList(PostgreSQLValueFormat.TEXT, PostgreSQLValueFormat.BINARY));
- JDBCPortal portal = new JDBCPortal("", preparedStatement, Collections.emptyList(), resultFormats, backendConnection);
+ Portal portal = new Portal("", preparedStatement, Collections.emptyList(), resultFormats, backendConnection);
portal.bind();
assertThat(portal.describe(), instanceOf(PostgreSQLRowDescriptionPacket.class));
List<PostgreSQLPacket> actualPackets = portal.execute(0);
@@ -169,7 +169,7 @@ public final class JDBCPortalTest extends ProxyContextRestorer {
PostgreSQLServerPreparedStatement preparedStatement =
new PostgreSQLServerPreparedStatement("", selectStatementContext, Collections.emptyList());
List<PostgreSQLValueFormat> resultFormats = new ArrayList<>(Arrays.asList(PostgreSQLValueFormat.TEXT, PostgreSQLValueFormat.BINARY));
- JDBCPortal portal = new JDBCPortal("", preparedStatement, Collections.emptyList(), resultFormats, backendConnection);
+ Portal portal = new Portal("", preparedStatement, Collections.emptyList(), resultFormats, backendConnection);
portal.bind();
assertThat(portal.describe(), instanceOf(PostgreSQLRowDescriptionPacket.class));
List<PostgreSQLPacket> actualPackets = portal.execute(2);
@@ -188,7 +188,7 @@ public final class JDBCPortalTest extends ProxyContextRestorer {
when(insertStatementContext.getSqlStatement()).thenReturn(new PostgreSQLInsertStatement());
PostgreSQLServerPreparedStatement preparedStatement =
new PostgreSQLServerPreparedStatement("", insertStatementContext, Collections.emptyList());
- JDBCPortal portal = new JDBCPortal("insert into t values (1)", preparedStatement, Collections.emptyList(), Collections.emptyList(), backendConnection);
+ Portal portal = new Portal("insert into t values (1)", preparedStatement, Collections.emptyList(), Collections.emptyList(), backendConnection);
portal.bind();
assertThat(portal.describe(), is(PostgreSQLNoDataPacket.getInstance()));
List<PostgreSQLPacket> actualPackets = portal.execute(0);
@@ -200,7 +200,7 @@ public final class JDBCPortalTest extends ProxyContextRestorer {
when(proxyBackendHandler.execute()).thenReturn(mock(UpdateResponseHeader.class));
when(proxyBackendHandler.next()).thenReturn(false);
PostgreSQLServerPreparedStatement preparedStatement = new PostgreSQLServerPreparedStatement("", new CommonSQLStatementContext<>(new PostgreSQLEmptyStatement()), Collections.emptyList());
- JDBCPortal portal = new JDBCPortal("", preparedStatement, Collections.emptyList(), Collections.emptyList(), backendConnection);
+ Portal portal = new Portal("", preparedStatement, Collections.emptyList(), Collections.emptyList(), backendConnection);
portal.bind();
assertThat(portal.describe(), is(PostgreSQLNoDataPacket.getInstance()));
List<PostgreSQLPacket> actualPackets = portal.execute(0);
@@ -217,7 +217,7 @@ public final class JDBCPortalTest extends ProxyContextRestorer {
variableAssignSegment.setVariable(new VariableSegment());
setStatement.getVariableAssigns().add(variableAssignSegment);
PostgreSQLServerPreparedStatement preparedStatement = new PostgreSQLServerPreparedStatement(sql, new CommonSQLStatementContext<>(setStatement), Collections.emptyList());
- JDBCPortal portal = new JDBCPortal("", preparedStatement, Collections.emptyList(), Collections.emptyList(), backendConnection);
+ Portal portal = new Portal("", preparedStatement, Collections.emptyList(), Collections.emptyList(), backendConnection);
portal.bind();
List<PostgreSQLPacket> actualPackets = portal.execute(0);
assertThat(actualPackets.size(), is(2));
@@ -231,13 +231,13 @@ public final class JDBCPortalTest extends ProxyContextRestorer {
PostgreSQLServerPreparedStatement preparedStatement = mock(PostgreSQLServerPreparedStatement.class);
when(preparedStatement.getSql()).thenReturn("");
when(preparedStatement.getSqlStatementContext()).thenReturn(mock(SQLStatementContext.class));
- new JDBCPortal("", preparedStatement, Collections.emptyList(), Collections.emptyList(), backendConnection).describe();
+ new Portal("", preparedStatement, Collections.emptyList(), Collections.emptyList(), backendConnection).describe();
}
@Test
public void assertClose() throws SQLException {
PostgreSQLServerPreparedStatement preparedStatement = new PostgreSQLServerPreparedStatement("", new CommonSQLStatementContext<>(new PostgreSQLEmptyStatement()), Collections.emptyList());
- JDBCPortal portal = new JDBCPortal("", preparedStatement, Collections.emptyList(), Collections.emptyList(), backendConnection);
+ Portal portal = new Portal("", preparedStatement, Collections.emptyList(), Collections.emptyList(), backendConnection);
portal.close();
verify(backendConnection).unmarkResourceInUse(proxyBackendHandler);
verify(proxyBackendHandler).close();
diff --git a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java
index 1b12f8573b7..e5e70e34d36 100644
--- a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java
+++ b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java
@@ -39,7 +39,7 @@ import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.JDBCBackendStatement;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
@@ -109,7 +109,7 @@ public final class PostgreSQLAggregatedBatchedStatementsCommandExecutorTest exte
connectionSession.getServerPreparedStatementRegistry().addPreparedStatement(STATEMENT_ID,
new PostgreSQLServerPreparedStatement(SQL, sqlStatementContext, Collections.singletonList(PostgreSQLColumnType.POSTGRESQL_TYPE_INT4)));
when(connectionSession.getConnectionId()).thenReturn(CONNECTION_ID);
- JDBCBackendConnection backendConnection = mock(JDBCBackendConnection.class);
+ BackendConnection backendConnection = mock(BackendConnection.class);
Connection connection = mock(Connection.class, RETURNS_DEEP_STUBS);
when(connection.getMetaData().getURL()).thenReturn("jdbc:postgresql://127.0.0.1/db");
when(backendConnection.getConnections(nullable(String.class), anyInt(), any(ConnectionMode.class))).thenReturn(Collections.singletonList(connection));
diff --git a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutorTest.java b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutorTest.java
index 0ee7652967b..92c57f0c17a 100644
--- a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutorTest.java
+++ b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutorTest.java
@@ -31,7 +31,7 @@ import org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.Statemen
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.JDBCBackendStatement;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
@@ -74,7 +74,7 @@ public final class PostgreSQLBatchedStatementsExecutorTest extends ProxyContextR
private ConnectionSession connectionSession;
@Mock
- private JDBCBackendConnection backendConnection;
+ private BackendConnection backendConnection;
@Mock
private JDBCBackendStatement backendStatement;
diff --git a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutorTest.java b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutorTest.java
index a4719d4cbb3..2447372b435 100644
--- a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutorTest.java
+++ b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutorTest.java
@@ -24,14 +24,14 @@ import org.apache.shardingsphere.infra.binder.statement.CommonSQLStatementContex
import org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.session.ServerPreparedStatementRegistry;
import org.apache.shardingsphere.proxy.backend.session.transaction.TransactionStatus;
import org.apache.shardingsphere.proxy.frontend.postgresql.ProxyContextRestorer;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.PortalContext;
-import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.JDBCPortal;
+import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.Portal;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.PostgreSQLServerPreparedStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.dal.PostgreSQLEmptyStatement;
import org.apache.shardingsphere.transaction.api.TransactionType;
@@ -78,7 +78,7 @@ public final class PostgreSQLComBindExecutorTest extends ProxyContextRestorer {
when(ProxyContext.getInstance().getDatabase(databaseName)).thenReturn(database);
when(database.getProtocolType()).thenReturn(new PostgreSQLDatabaseType());
when(connectionSession.getServerPreparedStatementRegistry()).thenReturn(new ServerPreparedStatementRegistry());
- JDBCBackendConnection backendConnection = mock(JDBCBackendConnection.class);
+ BackendConnection backendConnection = mock(BackendConnection.class);
when(connectionSession.getBackendConnection()).thenReturn(backendConnection);
when(connectionSession.getDefaultDatabaseName()).thenReturn(databaseName);
when(connectionSession.getTransactionStatus()).thenReturn(new TransactionStatus(TransactionType.LOCAL));
@@ -93,6 +93,6 @@ public final class PostgreSQLComBindExecutorTest extends ProxyContextRestorer {
Collection<DatabasePacket<?>> actual = executor.execute();
assertThat(actual.size(), is(1));
assertThat(actual.iterator().next(), is(PostgreSQLBindCompletePacket.getInstance()));
- verify(portalContext).add(any(JDBCPortal.class));
+ verify(portalContext).add(any(Portal.class));
}
}
diff --git a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutorTest.java b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutorTest.java
index 404219e9a69..36ec6aadef9 100644
--- a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutorTest.java
+++ b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutorTest.java
@@ -28,6 +28,7 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import java.sql.SQLException;
import java.util.Collection;
import static org.hamcrest.CoreMatchers.instanceOf;
@@ -49,7 +50,7 @@ public final class PostgreSQLComCloseExecutorTest {
private ConnectionSession connectionSession;
@Test
- public void assertExecuteClosePreparedStatement() {
+ public void assertExecuteClosePreparedStatement() throws SQLException {
when(connectionSession.getServerPreparedStatementRegistry()).thenReturn(new ServerPreparedStatementRegistry());
when(packet.getType()).thenReturn(PostgreSQLComClosePacket.Type.PREPARED_STATEMENT);
when(packet.getName()).thenReturn("S_1");
@@ -60,7 +61,7 @@ public final class PostgreSQLComCloseExecutorTest {
}
@Test
- public void assertExecuteClosePortal() {
+ public void assertExecuteClosePortal() throws SQLException {
when(packet.getType()).thenReturn(PostgreSQLComClosePacket.Type.PORTAL);
String portalName = "C_1";
when(packet.getName()).thenReturn(portalName);
diff --git a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java
index 2b0db7e5f9f..c750c9ba559 100644
--- a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java
+++ b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java
@@ -40,7 +40,7 @@ import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.
import org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine;
import org.apache.shardingsphere.infra.util.exception.external.sql.type.generic.UnsupportedSQLOperationException;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.session.ServerPreparedStatementRegistry;
@@ -140,7 +140,7 @@ public final class PostgreSQLComDescribeExecutorTest extends ProxyContextRestore
public void assertDescribePortal() throws SQLException {
when(packet.getType()).thenReturn('P');
when(packet.getName()).thenReturn("P_1");
- Portal<?> portal = mock(Portal.class);
+ Portal portal = mock(Portal.class);
PostgreSQLRowDescriptionPacket expected = mock(PostgreSQLRowDescriptionPacket.class);
when(portal.describe()).thenReturn(expected);
when(portalContext.get("P_1")).thenReturn(portal);
@@ -360,7 +360,7 @@ public final class PostgreSQLComDescribeExecutorTest extends ProxyContextRestore
}
private void prepareJDBCBackendConnection(final String sql) throws SQLException {
- JDBCBackendConnection backendConnection = mock(JDBCBackendConnection.class);
+ BackendConnection backendConnection = mock(BackendConnection.class);
Connection connection = mock(Connection.class, RETURNS_DEEP_STUBS);
ParameterMetaData parameterMetaData = mock(ParameterMetaData.class);
when(parameterMetaData.getParameterType(1)).thenReturn(Types.INTEGER);
diff --git a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/execute/PostgreSQLComExecuteExecutorTest.java b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/execute/PostgreSQLComExecuteExecutorTest.java
index 852b817a58d..6f4631833ec 100644
--- a/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/execute/PostgreSQLComExecuteExecutorTest.java
+++ b/proxy/frontend/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/execute/PostgreSQLComExecuteExecutorTest.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.PostgreSQLPacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.execute.PostgreSQLComExecutePacket;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.PortalContext;
-import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.JDBCPortal;
+import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.Portal;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.CommitStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.RollbackStatement;
@@ -32,6 +32,7 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import java.sql.SQLException;
import java.util.Collections;
import java.util.List;
@@ -54,7 +55,7 @@ public final class PostgreSQLComExecuteExecutorTest {
private PostgreSQLComExecutePacket packet;
@Mock
- private JDBCPortal portal;
+ private Portal portal;
@InjectMocks
private PostgreSQLComExecuteExecutor executor;
@@ -66,7 +67,7 @@ public final class PostgreSQLComExecuteExecutorTest {
}
@Test
- public void assertExecute() {
+ public void assertExecute() throws SQLException {
PostgreSQLPacket expectedPacket = mock(PostgreSQLPacket.class);
when(portal.execute(anyInt())).thenReturn(Collections.singletonList(expectedPacket));
List<DatabasePacket<?>> actualPackets = executor.execute();
@@ -75,21 +76,21 @@ public final class PostgreSQLComExecuteExecutorTest {
}
@Test
- public void assertCloseExecutorWhenPortalIsNotAnyTclStatement() {
+ public void assertCloseExecutorWhenPortalIsNotAnyTclStatement() throws SQLException {
when(portal.getSqlStatement()).thenReturn(mock(SQLStatement.class));
executor.close();
verify(portalContext, never()).closeAll();
}
@Test
- public void assertCloseExecutorWhenPortalCommitStatement() {
+ public void assertCloseExecutorWhenPortalCommitStatement() throws SQLException {
when(portal.getSqlStatement()).thenReturn(mock(CommitStatement.class));
executor.close();
verify(portalContext).closeAll();
}
@Test
- public void assertCloseExecutorWhenPortalRollbackStatement() {
+ public void assertCloseExecutorWhenPortalRollbackStatement() throws SQLException {
when(portal.getSqlStatement()).thenReturn(mock(RollbackStatement.class));
executor.close();
verify(portalContext).closeAll();
diff --git a/proxy/frontend/reactive-core/pom.xml b/proxy/frontend/reactive-core/pom.xml
deleted file mode 100644
index 059fcf8077b..00000000000
--- a/proxy/frontend/reactive-core/pom.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ 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.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-proxy-frontend</artifactId>
- <version>5.3.1-SNAPSHOT</version>
- </parent>
- <artifactId>shardingsphere-proxy-frontend-reactive-core</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-proxy-frontend-reactive-spi</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-proxy-frontend-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-</project>
diff --git a/proxy/frontend/reactive-core/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/command/ReactiveCommandExecuteTask.java b/proxy/frontend/reactive-core/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/command/ReactiveCommandExecuteTask.java
deleted file mode 100644
index e429fc33bf6..00000000000
--- a/proxy/frontend/reactive-core/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/command/ReactiveCommandExecuteTask.java
+++ /dev/null
@@ -1,133 +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.proxy.frontend.reactive.command;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.channel.ChannelHandlerContext;
-import io.vertx.core.AsyncResult;
-import io.vertx.core.Future;
-import lombok.RequiredArgsConstructor;
-import lombok.SneakyThrows;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.shardingsphere.db.protocol.CommonConstants;
-import org.apache.shardingsphere.db.protocol.packet.CommandPacket;
-import org.apache.shardingsphere.db.protocol.packet.CommandPacketType;
-import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
-import org.apache.shardingsphere.db.protocol.payload.PacketPayload;
-import org.apache.shardingsphere.proxy.backend.exception.BackendConnectionException;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.frontend.command.CommandExecuteEngine;
-import org.apache.shardingsphere.proxy.frontend.exception.ExpectedExceptions;
-import org.apache.shardingsphere.proxy.frontend.reactive.command.executor.ReactiveCommandExecutor;
-import org.apache.shardingsphere.proxy.frontend.reactive.spi.ReactiveDatabaseProtocolFrontendEngine;
-
-import java.sql.SQLException;
-import java.util.Collection;
-import java.util.Optional;
-
-/**
- * Reactive command executor task.
- */
-@SuppressWarnings("unchecked")
-@RequiredArgsConstructor
-@Slf4j
-public final class ReactiveCommandExecuteTask implements Runnable {
-
- private final ReactiveDatabaseProtocolFrontendEngine reactiveDatabaseProtocolFrontendEngine;
-
- private final ConnectionSession connectionSession;
-
- private final ChannelHandlerContext context;
-
- private final Object message;
-
- private volatile boolean isNeedFlush;
-
- private volatile boolean writeInEventLoop;
-
- @Override
- public void run() {
- PacketPayload payload = reactiveDatabaseProtocolFrontendEngine.getCodecEngine().createPacketPayload((ByteBuf) message, context.channel().attr(CommonConstants.CHARSET_ATTRIBUTE_KEY).get());
- try {
- ((Future<Void>) connectionSession.getBackendConnection().prepareForTaskExecution())
- .compose(unused -> executeCommand(payload).eventually(unused0 -> closeResources(payload)))
- .onFailure(this::processThrowable);
- // CHECKSTYLE:OFF
- } catch (final Exception ex) {
- // CHECKSTYLE:ON
- processException(ex);
- closeResources(payload);
- }
- }
-
- @SneakyThrows(SQLException.class)
- private Future<Void> executeCommand(final PacketPayload payload) {
- CommandExecuteEngine commandExecuteEngine = reactiveDatabaseProtocolFrontendEngine.getCommandExecuteEngine();
- ReactiveCommandExecuteEngine reactiveCommandExecuteEngine = reactiveDatabaseProtocolFrontendEngine.getReactiveCommandExecuteEngine();
- CommandPacketType type = commandExecuteEngine.getCommandPacketType(payload);
- CommandPacket commandPacket = commandExecuteEngine.getCommandPacket(payload, type, connectionSession);
- ReactiveCommandExecutor commandExecutor = reactiveCommandExecuteEngine.getReactiveCommandExecutor(type, commandPacket, connectionSession);
- return commandExecutor.executeFuture()
- .compose(this::handleResponsePackets)
- .eventually(unused -> commandExecutor.closeFuture());
- }
-
- private Future<Void> handleResponsePackets(final Collection<DatabasePacket<?>> responsePackets) {
- responsePackets.forEach(context::write);
- writeInEventLoop = (isNeedFlush = !responsePackets.isEmpty()) && context.executor().inEventLoop();
- return Future.succeededFuture();
- }
-
- @SneakyThrows(BackendConnectionException.class)
- private Future<Void> closeResources(final PacketPayload payload) {
- try {
- payload.close();
- // CHECKSTYLE:OFF
- } catch (final Exception ignored) {
- // CHECKSTYLE:ON
- }
- connectionSession.clearQueryContext();
- return ((Future<Void>) connectionSession.getBackendConnection().closeExecutionResources()).onComplete(this::doFlushIfNecessary);
- }
-
- private void doFlushIfNecessary(final AsyncResult<Void> unused) {
- if (!isNeedFlush) {
- return;
- }
- if (!writeInEventLoop && context.executor().inEventLoop()) {
- context.executor().execute(context::flush);
- } else {
- context.flush();
- }
- }
-
- private void processThrowable(final Throwable throwable) {
- Exception ex = throwable instanceof Exception ? (Exception) throwable : new Exception(throwable);
- processException(ex);
- }
-
- private void processException(final Exception cause) {
- if (!ExpectedExceptions.isExpected(cause.getClass())) {
- log.error("Exception occur: ", cause);
- }
- context.write(reactiveDatabaseProtocolFrontendEngine.getCommandExecuteEngine().getErrorPacket(cause));
- Optional<DatabasePacket<?>> databasePacket = reactiveDatabaseProtocolFrontendEngine.getCommandExecuteEngine().getOtherPacket(connectionSession);
- databasePacket.ifPresent(context::write);
- context.flush();
- }
-}
diff --git a/proxy/frontend/reactive-core/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/protocol/ReactiveDatabaseProtocolFrontendEngineFactory.java b/proxy/frontend/reactive-core/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/protocol/ReactiveDatabaseProtocolFrontendEngineFactory.java
deleted file mode 100644
index 298edbefc46..00000000000
--- a/proxy/frontend/reactive-core/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/protocol/ReactiveDatabaseProtocolFrontendEngineFactory.java
+++ /dev/null
@@ -1,47 +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.proxy.frontend.reactive.protocol;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.proxy.frontend.reactive.spi.ReactiveDatabaseProtocolFrontendEngine;
-import org.apache.shardingsphere.infra.util.spi.ShardingSphereServiceLoader;
-import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPIRegistry;
-
-import java.util.Properties;
-
-/**
- * Reactive database protocol frontend engine factory.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class ReactiveDatabaseProtocolFrontendEngineFactory {
-
- static {
- ShardingSphereServiceLoader.register(ReactiveDatabaseProtocolFrontendEngine.class);
- }
-
- /**
- * Create new instance of reactive database protocol frontend engine.
- *
- * @param databaseType database type
- * @return created instance
- */
- public static ReactiveDatabaseProtocolFrontendEngine newInstance(final String databaseType) {
- return TypedSPIRegistry.getRegisteredService(ReactiveDatabaseProtocolFrontendEngine.class, databaseType, new Properties());
- }
-}
diff --git a/proxy/frontend/reactive-core/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/state/impl/ReactiveOKProxyState.java b/proxy/frontend/reactive-core/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/state/impl/ReactiveOKProxyState.java
deleted file mode 100644
index 9f7eba0ad5c..00000000000
--- a/proxy/frontend/reactive-core/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/state/impl/ReactiveOKProxyState.java
+++ /dev/null
@@ -1,56 +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.proxy.frontend.reactive.state.impl;
-
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.util.Attribute;
-import io.netty.util.AttributeKey;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.frontend.reactive.command.ReactiveCommandExecuteTask;
-import org.apache.shardingsphere.proxy.frontend.reactive.protocol.ReactiveDatabaseProtocolFrontendEngineFactory;
-import org.apache.shardingsphere.proxy.frontend.reactive.spi.ReactiveDatabaseProtocolFrontendEngine;
-import org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine;
-import org.apache.shardingsphere.proxy.frontend.state.impl.OKProxyState;
-
-/**
- * Reactive OK proxy state.
- */
-public final class ReactiveOKProxyState implements OKProxyState {
-
- @Override
- public void execute(final ChannelHandlerContext context, final Object message, final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine, final ConnectionSession connectionSession) {
- ReactiveDatabaseProtocolFrontendEngine reactiveDatabaseProtocolFrontendEngine = getOrCreateReactiveEngine(context.channel(), databaseProtocolFrontendEngine);
- context.executor().execute(new ReactiveCommandExecuteTask(reactiveDatabaseProtocolFrontendEngine, connectionSession, context, message));
- }
-
- private ReactiveDatabaseProtocolFrontendEngine getOrCreateReactiveEngine(final Channel channel, final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine) {
- Attribute<ReactiveDatabaseProtocolFrontendEngine> attr = channel.attr(AttributeKey.valueOf(ReactiveDatabaseProtocolFrontendEngine.class.getName()));
- ReactiveDatabaseProtocolFrontendEngine result = attr.get();
- if (null == result) {
- result = ReactiveDatabaseProtocolFrontendEngineFactory.newInstance(databaseProtocolFrontendEngine.getType());
- attr.setIfAbsent(result);
- }
- return result;
- }
-
- @Override
- public String getType() {
- return "ExperimentalVertx";
- }
-}
diff --git a/proxy/frontend/reactive-core/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/wrap/WrappedReactiveCommandExecutor.java b/proxy/frontend/reactive-core/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/wrap/WrappedReactiveCommandExecutor.java
deleted file mode 100644
index 0e94ee09141..00000000000
--- a/proxy/frontend/reactive-core/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/wrap/WrappedReactiveCommandExecutor.java
+++ /dev/null
@@ -1,57 +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.proxy.frontend.reactive.wrap;
-
-import io.vertx.core.Future;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
-import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
-import org.apache.shardingsphere.proxy.frontend.reactive.command.executor.ReactiveCommandExecutor;
-
-import java.sql.SQLException;
-import java.util.Collection;
-
-/**
- * Reactive command executor on {@link CommandExecutor}.
- */
-@RequiredArgsConstructor
-public final class WrappedReactiveCommandExecutor implements ReactiveCommandExecutor {
-
- private final CommandExecutor delegated;
-
- @Override
- public Future<Collection<DatabasePacket<?>>> executeFuture() {
- try {
- return Future.succeededFuture(delegated.execute());
- // CHECKSTYLE:OFF
- } catch (final Exception ex) {
- // CHECKSTYLE:ON
- return Future.failedFuture(ex);
- }
- }
-
- @Override
- public Future<Void> closeFuture() {
- try {
- delegated.close();
- return Future.succeededFuture();
- } catch (SQLException e) {
- return Future.failedFuture(e);
- }
- }
-}
diff --git a/proxy/frontend/reactive-core/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.frontend.state.impl.OKProxyState b/proxy/frontend/reactive-core/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.frontend.state.impl.OKProxyState
deleted file mode 100644
index c5b365847e7..00000000000
--- a/proxy/frontend/reactive-core/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.frontend.state.impl.OKProxyState
+++ /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.proxy.frontend.reactive.state.impl.ReactiveOKProxyState
diff --git a/proxy/frontend/reactive-core/src/test/java/org/apache/shardingsphere/proxy/frontend/reactive/command/ReactiveCommandExecuteTaskTest.java b/proxy/frontend/reactive-core/src/test/java/org/apache/shardingsphere/proxy/frontend/reactive/command/ReactiveCommandExecuteTaskTest.java
deleted file mode 100644
index 6a84bd4be22..00000000000
--- a/proxy/frontend/reactive-core/src/test/java/org/apache/shardingsphere/proxy/frontend/reactive/command/ReactiveCommandExecuteTaskTest.java
+++ /dev/null
@@ -1,139 +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.proxy.frontend.reactive.command;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.channel.ChannelHandlerContext;
-import io.vertx.core.Future;
-import org.apache.shardingsphere.db.protocol.packet.CommandPacket;
-import org.apache.shardingsphere.db.protocol.packet.CommandPacketType;
-import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
-import org.apache.shardingsphere.proxy.backend.exception.BackendConnectionException;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.frontend.reactive.command.executor.ReactiveCommandExecutor;
-import org.apache.shardingsphere.proxy.frontend.reactive.spi.ReactiveDatabaseProtocolFrontendEngine;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Optional;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.ArgumentMatchers.nullable;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public final class ReactiveCommandExecuteTaskTest {
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private ReactiveDatabaseProtocolFrontendEngine frontendEngine;
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private ConnectionSession connectionSession;
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private ChannelHandlerContext channelHandlerContext;
-
- @Mock
- private ByteBuf message;
-
- private ReactiveCommandExecuteTask reactiveCommandExecuteTask;
-
- @Mock
- private ReactiveCommandExecutor reactiveCommandExecutor;
-
- @Before
- public void setup() throws BackendConnectionException {
- reactiveCommandExecuteTask = new ReactiveCommandExecuteTask(frontendEngine, connectionSession, channelHandlerContext, message);
- when(connectionSession.getBackendConnection().prepareForTaskExecution()).thenReturn(Future.succeededFuture());
- when(connectionSession.getBackendConnection().closeExecutionResources()).thenReturn(Future.succeededFuture());
- when(frontendEngine.getReactiveCommandExecuteEngine().getReactiveCommandExecutor(nullable(CommandPacketType.class), nullable(CommandPacket.class), eq(connectionSession)))
- .thenReturn(reactiveCommandExecutor);
- }
-
- @Test
- public void assertExecuteAndWriteInEventLoop() {
- when(channelHandlerContext.executor().inEventLoop()).thenReturn(true);
- DatabasePacket<?> packet0 = mock(DatabasePacket.class);
- DatabasePacket<?> packet1 = mock(DatabasePacket.class);
- when(reactiveCommandExecutor.executeFuture()).thenReturn(Future.succeededFuture(Arrays.asList(packet0, packet1)));
- when(reactiveCommandExecutor.closeFuture()).thenReturn(Future.succeededFuture());
- reactiveCommandExecuteTask.run();
- verify(channelHandlerContext).write(packet0);
- verify(channelHandlerContext).write(packet1);
- verify(channelHandlerContext).flush();
- }
-
- @Test
- public void assertExecuteAndWriteNotInEventLoop() {
- when(channelHandlerContext.executor().inEventLoop()).thenReturn(false, true);
- DatabasePacket<?> packet0 = mock(DatabasePacket.class);
- DatabasePacket<?> packet1 = mock(DatabasePacket.class);
- when(reactiveCommandExecutor.executeFuture()).thenReturn(Future.succeededFuture(Arrays.asList(packet0, packet1)));
- when(reactiveCommandExecutor.closeFuture()).thenReturn(Future.succeededFuture());
- reactiveCommandExecuteTask.run();
- verify(channelHandlerContext).write(packet0);
- verify(channelHandlerContext).write(packet1);
- verify(channelHandlerContext.executor()).execute(any(Runnable.class));
- }
-
- @Test
- public void assertExecuteAndNoResponse() {
- when(reactiveCommandExecutor.executeFuture()).thenReturn(Future.succeededFuture(Collections.emptyList()));
- when(reactiveCommandExecutor.closeFuture()).thenReturn(Future.succeededFuture());
- reactiveCommandExecuteTask.run();
- verify(channelHandlerContext, never()).write(any());
- }
-
- @Test
- public void assertExecuteAndExceptionOccur() {
- RuntimeException ex = new RuntimeException("");
- when(connectionSession.getBackendConnection().prepareForTaskExecution()).thenThrow(ex);
- DatabasePacket errorPacket = mock(DatabasePacket.class);
- when(frontendEngine.getCommandExecuteEngine().getErrorPacket(ex)).thenReturn(errorPacket);
- DatabasePacket otherPacket = mock(DatabasePacket.class);
- when(frontendEngine.getCommandExecuteEngine().getOtherPacket(connectionSession)).thenReturn(Optional.of(otherPacket));
- reactiveCommandExecuteTask.run();
- verify(channelHandlerContext).write(errorPacket);
- verify(channelHandlerContext).write(otherPacket);
- verify(channelHandlerContext).flush();
- }
-
- @Test
- public void assertExecuteAndThrowableOccur() {
- Throwable throwable = mock(Throwable.class);
- when(reactiveCommandExecutor.executeFuture()).thenReturn(Future.failedFuture(throwable));
- DatabasePacket errorPacket = mock(DatabasePacket.class);
- when(frontendEngine.getCommandExecuteEngine().getErrorPacket(any(Exception.class))).thenReturn(errorPacket);
- DatabasePacket otherPacket = mock(DatabasePacket.class);
- when(frontendEngine.getCommandExecuteEngine().getOtherPacket(connectionSession)).thenReturn(Optional.of(otherPacket));
- reactiveCommandExecuteTask.run();
- verify(channelHandlerContext).write(errorPacket);
- verify(channelHandlerContext).write(otherPacket);
- verify(channelHandlerContext).flush();
- }
-}
diff --git a/proxy/frontend/reactive-core/src/test/java/org/apache/shardingsphere/proxy/frontend/reactive/protocol/ReactiveDatabaseProtocolFrontendEngineFactoryTest.java b/proxy/frontend/reactive-core/src/test/java/org/apache/shardingsphere/proxy/frontend/reactive/protocol/ReactiveDatabaseProtocolFrontendEngineFactoryTest.java
deleted file mode 100644
index 17ad616a6cf..00000000000
--- a/proxy/frontend/reactive-core/src/test/java/org/apache/shardingsphere/proxy/frontend/reactive/protocol/ReactiveDatabaseProtocolFrontendEngineFactoryTest.java
+++ /dev/null
@@ -1,38 +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.proxy.frontend.reactive.protocol;
-
-import org.apache.shardingsphere.infra.util.spi.exception.ServiceProviderNotFoundServerException;
-import org.apache.shardingsphere.proxy.frontend.reactive.protocol.fixture.DummyReactiveDatabaseProtocolFrontendEngine;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-public final class ReactiveDatabaseProtocolFrontendEngineFactoryTest {
-
- @Test
- public void assertNewInstance() {
- assertThat(ReactiveDatabaseProtocolFrontendEngineFactory.newInstance("Dummy"), instanceOf(DummyReactiveDatabaseProtocolFrontendEngine.class));
- }
-
- @Test(expected = ServiceProviderNotFoundServerException.class)
- public void assertNewInstanceWithUnknownType() {
- ReactiveDatabaseProtocolFrontendEngineFactory.newInstance("Unknown");
- }
-}
diff --git a/proxy/frontend/reactive-core/src/test/java/org/apache/shardingsphere/proxy/frontend/reactive/protocol/fixture/DummyReactiveDatabaseProtocolFrontendEngine.java b/proxy/frontend/reactive-core/src/test/java/org/apache/shardingsphere/proxy/frontend/reactive/protocol/fixture/DummyReactiveDatabaseProtocolFrontendEngine.java
deleted file mode 100644
index 18cfc4d4ad3..00000000000
--- a/proxy/frontend/reactive-core/src/test/java/org/apache/shardingsphere/proxy/frontend/reactive/protocol/fixture/DummyReactiveDatabaseProtocolFrontendEngine.java
+++ /dev/null
@@ -1,67 +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.proxy.frontend.reactive.protocol.fixture;
-
-import org.apache.shardingsphere.db.protocol.codec.DatabasePacketCodecEngine;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.frontend.authentication.AuthenticationEngine;
-import org.apache.shardingsphere.proxy.frontend.command.CommandExecuteEngine;
-import org.apache.shardingsphere.proxy.frontend.context.FrontendContext;
-import org.apache.shardingsphere.proxy.frontend.reactive.command.ReactiveCommandExecuteEngine;
-import org.apache.shardingsphere.proxy.frontend.reactive.spi.ReactiveDatabaseProtocolFrontendEngine;
-
-public final class DummyReactiveDatabaseProtocolFrontendEngine implements ReactiveDatabaseProtocolFrontendEngine {
-
- @Override
- public ReactiveCommandExecuteEngine getReactiveCommandExecuteEngine() {
- return null;
- }
-
- @Override
- public FrontendContext getFrontendContext() {
- return null;
- }
-
- @Override
- public DatabasePacketCodecEngine<?> getCodecEngine() {
- return null;
- }
-
- @Override
- public AuthenticationEngine getAuthenticationEngine() {
- return null;
- }
-
- @Override
- public CommandExecuteEngine getCommandExecuteEngine() {
- return null;
- }
-
- @Override
- public void release(final ConnectionSession connectionSession) {
- }
-
- @Override
- public void handleException(final ConnectionSession connectionSession, final Exception exception) {
- }
-
- @Override
- public String getType() {
- return "Dummy";
- }
-}
diff --git a/proxy/frontend/reactive-core/src/test/java/org/apache/shardingsphere/proxy/frontend/reactive/state/impl/ReactiveOKProxyStateTest.java b/proxy/frontend/reactive-core/src/test/java/org/apache/shardingsphere/proxy/frontend/reactive/state/impl/ReactiveOKProxyStateTest.java
deleted file mode 100644
index d8a82aafeb9..00000000000
--- a/proxy/frontend/reactive-core/src/test/java/org/apache/shardingsphere/proxy/frontend/reactive/state/impl/ReactiveOKProxyStateTest.java
+++ /dev/null
@@ -1,56 +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.proxy.frontend.reactive.state.impl;
-
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.util.Attribute;
-import io.netty.util.AttributeKey;
-import io.netty.util.concurrent.EventExecutor;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.frontend.reactive.command.ReactiveCommandExecuteTask;
-import org.apache.shardingsphere.proxy.frontend.reactive.protocol.fixture.DummyReactiveDatabaseProtocolFrontendEngine;
-import org.apache.shardingsphere.proxy.frontend.reactive.spi.ReactiveDatabaseProtocolFrontendEngine;
-import org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine;
-import org.junit.Test;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public final class ReactiveOKProxyStateTest {
-
- @SuppressWarnings("unchecked")
- @Test
- public void assertExecute() {
- ChannelHandlerContext channelHandlerContext = mock(ChannelHandlerContext.class);
- EventExecutor eventExecutor = mock(EventExecutor.class);
- when(channelHandlerContext.executor()).thenReturn(eventExecutor);
- Channel channel = mock(Channel.class);
- Attribute<ReactiveDatabaseProtocolFrontendEngine> attribute = mock(Attribute.class);
- when(channel.<ReactiveDatabaseProtocolFrontendEngine>attr(AttributeKey.valueOf(ReactiveDatabaseProtocolFrontendEngine.class.getName()))).thenReturn(attribute);
- when(channelHandlerContext.channel()).thenReturn(channel);
- DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine = mock(DatabaseProtocolFrontendEngine.class);
- when(databaseProtocolFrontendEngine.getType()).thenReturn("Dummy");
- ConnectionSession connectionSession = mock(ConnectionSession.class);
- new ReactiveOKProxyState().execute(channelHandlerContext, null, databaseProtocolFrontendEngine, connectionSession);
- verify(attribute).setIfAbsent(any(DummyReactiveDatabaseProtocolFrontendEngine.class));
- verify(eventExecutor).execute(any(ReactiveCommandExecuteTask.class));
- }
-}
diff --git a/proxy/frontend/reactive-core/src/test/java/org/apache/shardingsphere/proxy/frontend/reactive/wrap/WrappedReactiveCommandExecutorTest.java b/proxy/frontend/reactive-core/src/test/java/org/apache/shardingsphere/proxy/frontend/reactive/wrap/WrappedReactiveCommandExecutorTest.java
deleted file mode 100644
index 6615787d832..00000000000
--- a/proxy/frontend/reactive-core/src/test/java/org/apache/shardingsphere/proxy/frontend/reactive/wrap/WrappedReactiveCommandExecutorTest.java
+++ /dev/null
@@ -1,79 +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.proxy.frontend.reactive.wrap;
-
-import io.vertx.core.Future;
-import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
-import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-
-import java.sql.SQLException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public final class WrappedReactiveCommandExecutorTest {
-
- @Mock
- private CommandExecutor commandExecutor;
-
- @InjectMocks
- private WrappedReactiveCommandExecutor executor;
-
- @Test
- public void assertExecuteFutureSucceeded() throws SQLException {
- DatabasePacket<?> expectedPacket = mock(DatabasePacket.class);
- List<DatabasePacket<?>> expected = Collections.singletonList(expectedPacket);
- when(commandExecutor.execute()).thenReturn(expected);
- Future<Collection<DatabasePacket<?>>> actualFuture = executor.executeFuture();
- assertThat(actualFuture.result(), is(expected));
- }
-
- @Test
- public void assertExecuteFutureFailed() throws SQLException {
- RuntimeException expected = new RuntimeException();
- when(commandExecutor.execute()).thenThrow(expected);
- Future<Collection<DatabasePacket<?>>> actualFuture = executor.executeFuture();
- assertThat(actualFuture.cause(), is(expected));
- }
-
- @Test
- public void assertCloseFutureSucceeded() throws SQLException {
- assertThat(executor.closeFuture(), is(Future.succeededFuture()));
- verify(commandExecutor).close();
- }
-
- @Test
- public void assertCloseFutureFailed() throws SQLException {
- SQLException expected = mock(SQLException.class);
- doThrow(expected).when(commandExecutor).close();
- assertThat(executor.closeFuture().cause(), is(expected));
- }
-}
diff --git a/proxy/frontend/reactive-core/src/test/resources/META-INF/services/org.apache.shardingsphere.proxy.frontend.reactive.spi.ReactiveDatabaseProtocolFrontendEngine b/proxy/frontend/reactive-core/src/test/resources/META-INF/services/org.apache.shardingsphere.proxy.frontend.reactive.spi.ReactiveDatabaseProtocolFrontendEngine
deleted file mode 100644
index e3a354c96fe..00000000000
--- a/proxy/frontend/reactive-core/src/test/resources/META-INF/services/org.apache.shardingsphere.proxy.frontend.reactive.spi.ReactiveDatabaseProtocolFrontendEngine
+++ /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.proxy.frontend.reactive.protocol.fixture.DummyReactiveDatabaseProtocolFrontendEngine
diff --git a/proxy/frontend/reactive-core/src/test/resources/logback-test.xml b/proxy/frontend/reactive-core/src/test/resources/logback-test.xml
deleted file mode 100644
index 9cf667fcad5..00000000000
--- a/proxy/frontend/reactive-core/src/test/resources/logback-test.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.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.
- -->
-
-<configuration>
- <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %logger{36} - %msg%n</pattern>
- </encoder>
- </appender>
- <logger name="org.apache.shardingsphere.proxy.frontend.reactive.command.ReactiveCommandExecuteTask" level="off" />
- <root>
- <level value="warn" />
- <appender-ref ref="console" />
- </root>
-</configuration>
diff --git a/proxy/frontend/reactive-mysql/pom.xml b/proxy/frontend/reactive-mysql/pom.xml
deleted file mode 100644
index 13ea5843448..00000000000
--- a/proxy/frontend/reactive-mysql/pom.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ 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.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-proxy-frontend</artifactId>
- <version>5.3.1-SNAPSHOT</version>
- </parent>
- <artifactId>shardingsphere-proxy-frontend-reactive-mysql</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-proxy-frontend-reactive-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-proxy-frontend-mysql</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-</project>
diff --git a/proxy/frontend/reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/ReactiveMySQLCommandExecutorFactory.java b/proxy/frontend/reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/ReactiveMySQLCommandExecutorFactory.java
deleted file mode 100644
index e633dbdf496..00000000000
--- a/proxy/frontend/reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/ReactiveMySQLCommandExecutorFactory.java
+++ /dev/null
@@ -1,68 +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.proxy.frontend.reactive.mysql.command;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import lombok.SneakyThrows;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.shardingsphere.db.protocol.mysql.packet.command.MySQLCommandPacketType;
-import org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary.execute.MySQLComStmtExecutePacket;
-import org.apache.shardingsphere.db.protocol.mysql.packet.command.query.text.fieldlist.MySQLComFieldListPacket;
-import org.apache.shardingsphere.db.protocol.mysql.packet.command.query.text.query.MySQLComQueryPacket;
-import org.apache.shardingsphere.db.protocol.packet.CommandPacket;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.frontend.mysql.command.MySQLCommandExecutorFactory;
-import org.apache.shardingsphere.proxy.frontend.reactive.command.executor.ReactiveCommandExecutor;
-import org.apache.shardingsphere.proxy.frontend.reactive.mysql.command.query.binary.execute.ReactiveMySQLComStmtExecuteExecutor;
-import org.apache.shardingsphere.proxy.frontend.reactive.mysql.command.query.text.fieldlist.ReactiveMySQLComFieldListPacketExecutor;
-import org.apache.shardingsphere.proxy.frontend.reactive.mysql.command.query.text.query.ReactiveMySQLComQueryPacketExecutor;
-import org.apache.shardingsphere.proxy.frontend.reactive.wrap.WrappedReactiveCommandExecutor;
-
-import java.sql.SQLException;
-
-/**
- * Reactive command executor factory for MySQL.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-@Slf4j
-public final class ReactiveMySQLCommandExecutorFactory {
-
- /**
- * Create new instance of reactive packet executor.
- *
- * @param commandPacketType command packet type for MySQL
- * @param commandPacket command packet for MySQL
- * @param connectionSession connection session
- * @return command executor
- */
- @SneakyThrows(SQLException.class)
- public static ReactiveCommandExecutor newInstance(final MySQLCommandPacketType commandPacketType, final CommandPacket commandPacket, final ConnectionSession connectionSession) {
- log.debug("Execute packet type: {}, value: {}", commandPacketType, commandPacket);
- switch (commandPacketType) {
- case COM_FIELD_LIST:
- return new ReactiveMySQLComFieldListPacketExecutor((MySQLComFieldListPacket) commandPacket, connectionSession);
- case COM_QUERY:
- return new ReactiveMySQLComQueryPacketExecutor((MySQLComQueryPacket) commandPacket, connectionSession);
- case COM_STMT_EXECUTE:
- return new ReactiveMySQLComStmtExecuteExecutor((MySQLComStmtExecutePacket) commandPacket, connectionSession);
- default:
- return new WrappedReactiveCommandExecutor(MySQLCommandExecutorFactory.newInstance(commandPacketType, commandPacket, connectionSession));
- }
- }
-}
diff --git a/proxy/frontend/reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/ReactiveMySQLFrontendEngine.java b/proxy/frontend/reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/ReactiveMySQLFrontendEngine.java
deleted file mode 100644
index 52a968ebf76..00000000000
--- a/proxy/frontend/reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/ReactiveMySQLFrontendEngine.java
+++ /dev/null
@@ -1,78 +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.proxy.frontend.reactive.mysql.command;
-
-import org.apache.shardingsphere.db.protocol.codec.DatabasePacketCodecEngine;
-import org.apache.shardingsphere.db.protocol.mysql.packet.command.MySQLCommandPacketType;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.frontend.authentication.AuthenticationEngine;
-import org.apache.shardingsphere.proxy.frontend.command.CommandExecuteEngine;
-import org.apache.shardingsphere.proxy.frontend.context.FrontendContext;
-import org.apache.shardingsphere.proxy.frontend.mysql.MySQLFrontendEngine;
-import org.apache.shardingsphere.proxy.frontend.reactive.command.ReactiveCommandExecuteEngine;
-import org.apache.shardingsphere.proxy.frontend.reactive.spi.ReactiveDatabaseProtocolFrontendEngine;
-
-/**
- * Reactive MySQL frontend engine.
- */
-public final class ReactiveMySQLFrontendEngine implements ReactiveDatabaseProtocolFrontendEngine {
-
- private final MySQLFrontendEngine delegated = new MySQLFrontendEngine();
-
- private final ReactiveCommandExecuteEngine reactiveCommandExecuteEngine = (type, packet, connectionSession) -> ReactiveMySQLCommandExecutorFactory.newInstance((MySQLCommandPacketType) type,
- packet, connectionSession);
-
- @Override
- public FrontendContext getFrontendContext() {
- return delegated.getFrontendContext();
- }
-
- @Override
- public DatabasePacketCodecEngine<?> getCodecEngine() {
- return delegated.getCodecEngine();
- }
-
- @Override
- public AuthenticationEngine getAuthenticationEngine() {
- return delegated.getAuthenticationEngine();
- }
-
- @Override
- public CommandExecuteEngine getCommandExecuteEngine() {
- return delegated.getCommandExecuteEngine();
- }
-
- @Override
- public void release(final ConnectionSession connectionSession) {
- delegated.release(connectionSession);
- }
-
- @Override
- public void handleException(final ConnectionSession connectionSession, final Exception exception) {
- }
-
- @Override
- public ReactiveCommandExecuteEngine getReactiveCommandExecuteEngine() {
- return reactiveCommandExecuteEngine;
- }
-
- @Override
- public String getType() {
- return delegated.getType();
- }
-}
diff --git a/proxy/frontend/reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/query/binary/execute/ReactiveMySQLComStmtExecuteExecutor.java b/proxy/frontend/reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/query/binary/execute/ReactiveMySQLComStmtExecuteExecutor.java
deleted file mode 100644
index 79a812a50cd..00000000000
--- a/proxy/frontend/reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/query/binary/execute/ReactiveMySQLComStmtExecuteExecutor.java
+++ /dev/null
@@ -1,182 +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.proxy.frontend.reactive.mysql.command.query.binary.execute;
-
-import io.vertx.core.Future;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import lombok.SneakyThrows;
-import org.apache.shardingsphere.db.protocol.binary.BinaryCell;
-import org.apache.shardingsphere.db.protocol.binary.BinaryRow;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLConstants;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLNewParametersBoundFlag;
-import org.apache.shardingsphere.db.protocol.mysql.packet.MySQLPacket;
-import org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary.execute.MySQLBinaryResultSetRowPacket;
-import org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary.execute.MySQLComStmtExecutePacket;
-import org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLEofPacket;
-import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
-import org.apache.shardingsphere.infra.binder.QueryContext;
-import org.apache.shardingsphere.infra.binder.aware.ParameterAware;
-import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
-import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
-import org.apache.shardingsphere.infra.executor.check.SQLCheckEngine;
-import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngineFactory;
-import org.apache.shardingsphere.proxy.backend.communication.vertx.VertxDatabaseCommunicationEngine;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandler;
-import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandlerFactory;
-import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseCell;
-import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
-import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
-import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.frontend.command.executor.ResponseType;
-import org.apache.shardingsphere.proxy.frontend.mysql.command.ServerStatusFlagCalculator;
-import org.apache.shardingsphere.proxy.frontend.mysql.command.query.binary.MySQLServerPreparedStatement;
-import org.apache.shardingsphere.proxy.frontend.mysql.command.query.builder.ResponsePacketBuilder;
-import org.apache.shardingsphere.proxy.frontend.reactive.command.executor.ReactiveCommandExecutor;
-import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
-import org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.TCLStatement;
-
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Reactive COM_STMT_EXECUTE command executor for MySQL.
- */
-@RequiredArgsConstructor
-public final class ReactiveMySQLComStmtExecuteExecutor implements ReactiveCommandExecutor {
-
- private final MySQLComStmtExecutePacket packet;
-
- private final ConnectionSession connectionSession;
-
- private VertxDatabaseCommunicationEngine databaseCommunicationEngine;
-
- private ProxyBackendHandler proxyBackendHandler;
-
- @Getter
- private ResponseType responseType;
-
- private int currentSequenceId;
-
- @SneakyThrows(SQLException.class)
- @Override
- public Future<Collection<DatabasePacket<?>>> executeFuture() {
- MySQLServerPreparedStatement preparedStatement = updateAndGetPreparedStatement();
- List<Object> params = packet.readParameters(preparedStatement.getParameterTypes(), preparedStatement.getLongData().keySet());
- preparedStatement.getLongData().forEach(params::set);
- SQLStatementContext<?> sqlStatementContext = preparedStatement.getSqlStatementContext();
- if (sqlStatementContext instanceof ParameterAware) {
- ((ParameterAware) sqlStatementContext).setUpParameters(params);
- }
- QueryContext queryContext = new QueryContext(sqlStatementContext, preparedStatement.getSql(), params);
- connectionSession.setQueryContext(queryContext);
- SQLStatement sqlStatement = preparedStatement.getSqlStatementContext().getSqlStatement();
- String databaseName = connectionSession.getDatabaseName();
- MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
- SQLCheckEngine.check(sqlStatementContext, params, getRules(databaseName), databaseName, metaDataContexts.getMetaData().getDatabases(), connectionSession.getGrantee());
- int characterSet = connectionSession.getAttributeMap().attr(MySQLConstants.MYSQL_CHARACTER_SET_ATTRIBUTE_KEY).get().getId();
- // TODO Refactor the following branch
- if (sqlStatement instanceof TCLStatement) {
- proxyBackendHandler = ProxyBackendHandlerFactory.newInstance(DatabaseTypeFactory.getInstance("MySQL"), preparedStatement.getSql(), sqlStatement, connectionSession);
- } else {
- databaseCommunicationEngine = DatabaseCommunicationEngineFactory.getInstance().newDatabaseCommunicationEngine(queryContext, connectionSession.getBackendConnection(), true);
- }
- return (null != databaseCommunicationEngine ? databaseCommunicationEngine.executeFuture() : proxyBackendHandler.executeFuture()).compose(responseHeader -> {
- Collection<DatabasePacket<?>> headerPackets = responseHeader instanceof QueryResponseHeader ? processQuery((QueryResponseHeader) responseHeader, characterSet)
- : processUpdate((UpdateResponseHeader) responseHeader);
- List<DatabasePacket<?>> result = new LinkedList<>(headerPackets);
- if (ResponseType.UPDATE == responseType) {
- return Future.succeededFuture(result);
- }
- try {
- while (next()) {
- result.add(getQueryRowPacket());
- }
- result.add(new MySQLEofPacket(++currentSequenceId, ServerStatusFlagCalculator.calculateFor(connectionSession)));
- return Future.succeededFuture(result);
- } catch (SQLException ex) {
- return Future.failedFuture(ex);
- }
- });
- }
-
- private MySQLServerPreparedStatement updateAndGetPreparedStatement() {
- MySQLServerPreparedStatement result = connectionSession.getServerPreparedStatementRegistry().getPreparedStatement(packet.getStatementId());
- if (MySQLNewParametersBoundFlag.PARAMETER_TYPE_EXIST == packet.getNewParametersBoundFlag()) {
- result.getParameterTypes().clear();
- result.getParameterTypes().addAll(packet.getNewParameterTypes());
- }
- return result;
- }
-
- private static Collection<ShardingSphereRule> getRules(final String databaseName) {
- Collection<ShardingSphereRule> result;
- result = new LinkedList<>(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabase(databaseName).getRuleMetaData().getRules());
- result.addAll(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getRules());
- return result;
- }
-
- private Collection<DatabasePacket<?>> processQuery(final QueryResponseHeader queryResponseHeader, final int characterSet) {
- responseType = ResponseType.QUERY;
- Collection<DatabasePacket<?>> result = ResponsePacketBuilder.buildQueryResponsePackets(queryResponseHeader, characterSet, ServerStatusFlagCalculator.calculateFor(connectionSession));
- currentSequenceId = result.size();
- return result;
- }
-
- private Collection<DatabasePacket<?>> processUpdate(final UpdateResponseHeader updateResponseHeader) {
- responseType = ResponseType.UPDATE;
- return ResponsePacketBuilder.buildUpdateResponsePackets(updateResponseHeader, ServerStatusFlagCalculator.calculateFor(connectionSession));
- }
-
- private boolean next() throws SQLException {
- return null != databaseCommunicationEngine && databaseCommunicationEngine.next();
- }
-
- private MySQLPacket getQueryRowPacket() throws SQLException {
- QueryResponseRow queryResponseRow = databaseCommunicationEngine.getRowData();
- return new MySQLBinaryResultSetRowPacket(++currentSequenceId, createBinaryRow(queryResponseRow));
- }
-
- private BinaryRow createBinaryRow(final QueryResponseRow queryResponseRow) {
- List<BinaryCell> result = new ArrayList<>(queryResponseRow.getCells().size());
- for (QueryResponseCell each : queryResponseRow.getCells()) {
- result.add(new BinaryCell(MySQLBinaryColumnType.valueOfJDBCType(each.getJdbcType()), each.getData()));
- }
- return new BinaryRow(result);
- }
-
- @Override
- public Future<Void> closeFuture() {
- try {
- if (null != proxyBackendHandler) {
- proxyBackendHandler.close();
- }
- return Future.succeededFuture();
- } catch (final SQLException ex) {
- return Future.failedFuture(ex);
- }
- }
-}
diff --git a/proxy/frontend/reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/query/text/fieldlist/ReactiveMySQLComFieldListPacketExecutor.java b/proxy/frontend/reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/query/text/fieldlist/ReactiveMySQLComFieldListPacketExecutor.java
deleted file mode 100644
index e73ea08f60a..00000000000
--- a/proxy/frontend/reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/query/text/fieldlist/ReactiveMySQLComFieldListPacketExecutor.java
+++ /dev/null
@@ -1,100 +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.proxy.frontend.reactive.mysql.command.query.text.fieldlist;
-
-import io.vertx.core.Future;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLConstants;
-import org.apache.shardingsphere.db.protocol.mysql.packet.command.query.MySQLColumnDefinition41Packet;
-import org.apache.shardingsphere.db.protocol.mysql.packet.command.query.text.fieldlist.MySQLComFieldListPacket;
-import org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLEofPacket;
-import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
-import org.apache.shardingsphere.infra.binder.QueryContext;
-import org.apache.shardingsphere.infra.binder.SQLStatementContextFactory;
-import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
-import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
-import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.parser.rule.SQLParserRule;
-import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngineFactory;
-import org.apache.shardingsphere.proxy.backend.communication.vertx.VertxDatabaseCommunicationEngine;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.frontend.mysql.command.ServerStatusFlagCalculator;
-import org.apache.shardingsphere.proxy.frontend.reactive.command.executor.ReactiveCommandExecutor;
-import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
-
-import java.sql.SQLException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-
-/**
- * Reactive COM_FIELD_LIST packet executor for MySQL.
- */
-public final class ReactiveMySQLComFieldListPacketExecutor implements ReactiveCommandExecutor {
-
- private static final String SQL = "SHOW COLUMNS FROM %s FROM %s";
-
- private final MySQLComFieldListPacket packet;
-
- private final ConnectionSession connectionSession;
-
- private final String databaseName;
-
- private final VertxDatabaseCommunicationEngine databaseCommunicationEngine;
-
- private final int characterSet;
-
- private int currentSequenceId;
-
- public ReactiveMySQLComFieldListPacketExecutor(final MySQLComFieldListPacket packet, final ConnectionSession connectionSession) {
- this.packet = packet;
- this.connectionSession = connectionSession;
- databaseName = connectionSession.getDefaultDatabaseName();
- String sql = String.format(SQL, packet.getTable(), databaseName);
- MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
- SQLParserRule sqlParserRule = metaDataContexts.getMetaData().getGlobalRuleMetaData().getSingleRule(SQLParserRule.class);
- SQLStatement sqlStatement = sqlParserRule.getSQLParserEngine(DatabaseTypeFactory.getInstance("MySQL").getType()).parse(sql, false);
- SQLStatementContext<?> sqlStatementContext = SQLStatementContextFactory.newInstance(metaDataContexts.getMetaData(), sqlStatement, databaseName);
- databaseCommunicationEngine = DatabaseCommunicationEngineFactory.getInstance().newDatabaseCommunicationEngine(new QueryContext(sqlStatementContext, sql, Collections.emptyList()),
- connectionSession.getBackendConnection(), false);
- characterSet = connectionSession.getAttributeMap().attr(MySQLConstants.MYSQL_CHARACTER_SET_ATTRIBUTE_KEY).get().getId();
- }
-
- @Override
- public Future<Collection<DatabasePacket<?>>> executeFuture() {
- return databaseCommunicationEngine.executeFuture().compose(unused -> {
- try {
- return Future.succeededFuture(createColumnDefinition41Packets());
- } catch (SQLException ex) {
- return Future.failedFuture(ex);
- }
- });
- }
-
- private Collection<DatabasePacket<?>> createColumnDefinition41Packets() throws SQLException {
- Collection<DatabasePacket<?>> result = new LinkedList<>();
- while (databaseCommunicationEngine.next()) {
- String columnName = databaseCommunicationEngine.getRowData().getCells().iterator().next().getData().toString();
- result.add(new MySQLColumnDefinition41Packet(
- ++currentSequenceId, characterSet, databaseName, packet.getTable(), packet.getTable(), columnName, columnName, 100, MySQLBinaryColumnType.MYSQL_TYPE_VARCHAR, 0, true));
- }
- result.add(new MySQLEofPacket(++currentSequenceId, ServerStatusFlagCalculator.calculateFor(connectionSession)));
- return result;
- }
-}
diff --git a/proxy/frontend/reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/query/text/query/ReactiveMySQLComQueryPacketExecutor.java b/proxy/frontend/reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/query/text/query/ReactiveMySQLComQueryPacketExecutor.java
deleted file mode 100644
index b7e57be7f43..00000000000
--- a/proxy/frontend/reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/query/text/query/ReactiveMySQLComQueryPacketExecutor.java
+++ /dev/null
@@ -1,103 +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.proxy.frontend.reactive.mysql.command.query.text.query;
-
-import io.vertx.core.Future;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLConstants;
-import org.apache.shardingsphere.db.protocol.mysql.packet.command.query.text.MySQLTextResultSetRowPacket;
-import org.apache.shardingsphere.db.protocol.mysql.packet.command.query.text.query.MySQLComQueryPacket;
-import org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLEofPacket;
-import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
-import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
-import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
-import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandler;
-import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandlerFactory;
-import org.apache.shardingsphere.proxy.frontend.command.executor.ResponseType;
-import org.apache.shardingsphere.proxy.frontend.mysql.command.ServerStatusFlagCalculator;
-import org.apache.shardingsphere.proxy.frontend.mysql.command.query.builder.ResponsePacketBuilder;
-import org.apache.shardingsphere.proxy.frontend.reactive.command.executor.ReactiveCommandExecutor;
-
-import java.sql.SQLException;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Reactive COM_QUERY command packet executor for MySQL.
- */
-public final class ReactiveMySQLComQueryPacketExecutor implements ReactiveCommandExecutor {
-
- private final ConnectionSession connectionSession;
-
- private final ProxyBackendHandler proxyBackendHandler;
-
- private final int characterSet;
-
- private ResponseType responseType;
-
- private int currentSequenceId;
-
- public ReactiveMySQLComQueryPacketExecutor(final MySQLComQueryPacket packet, final ConnectionSession connectionSession) throws SQLException {
- this.connectionSession = connectionSession;
- proxyBackendHandler = ProxyBackendHandlerFactory.newInstance(DatabaseTypeFactory.getInstance("MySQL"), packet.getSql(), connectionSession, packet.getHintValueContext());
- characterSet = connectionSession.getAttributeMap().attr(MySQLConstants.MYSQL_CHARACTER_SET_ATTRIBUTE_KEY).get().getId();
- }
-
- @Override
- public Future<Collection<DatabasePacket<?>>> executeFuture() {
- return proxyBackendHandler.executeFuture().compose(responseHeader -> {
- List<DatabasePacket<?>> result = new LinkedList<>(
- responseHeader instanceof QueryResponseHeader ? processQuery((QueryResponseHeader) responseHeader) : processUpdate((UpdateResponseHeader) responseHeader));
- try {
- if (ResponseType.QUERY == responseType) {
- while (proxyBackendHandler.next()) {
- result.add(new MySQLTextResultSetRowPacket(++currentSequenceId, proxyBackendHandler.getRowData().getData()));
- }
- result.add(new MySQLEofPacket(++currentSequenceId, ServerStatusFlagCalculator.calculateFor(connectionSession)));
- }
- return Future.succeededFuture(result);
- } catch (final SQLException ex) {
- return Future.failedFuture(ex);
- }
- });
- }
-
- private Collection<DatabasePacket<?>> processQuery(final QueryResponseHeader queryResponseHeader) {
- responseType = ResponseType.QUERY;
- Collection<DatabasePacket<?>> result = ResponsePacketBuilder.buildQueryResponsePackets(queryResponseHeader, characterSet, ServerStatusFlagCalculator.calculateFor(connectionSession));
- currentSequenceId = result.size();
- return result;
- }
-
- private Collection<DatabasePacket<?>> processUpdate(final UpdateResponseHeader updateResponseHeader) {
- responseType = ResponseType.UPDATE;
- return ResponsePacketBuilder.buildUpdateResponsePackets(updateResponseHeader, ServerStatusFlagCalculator.calculateFor(connectionSession));
- }
-
- @Override
- public Future<Void> closeFuture() {
- try {
- proxyBackendHandler.close();
- return Future.succeededFuture();
- } catch (final SQLException ex) {
- return Future.failedFuture(ex);
- }
- }
-}
diff --git a/proxy/frontend/reactive-mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.frontend.reactive.spi.ReactiveDatabaseProtocolFrontendEngine b/proxy/frontend/reactive-mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.frontend.reactive.spi.ReactiveDatabaseProtocolFrontendEngine
deleted file mode 100644
index 54112b63c8d..00000000000
--- a/proxy/frontend/reactive-mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.frontend.reactive.spi.ReactiveDatabaseProtocolFrontendEngine
+++ /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.proxy.frontend.reactive.mysql.command.ReactiveMySQLFrontendEngine
diff --git a/proxy/frontend/reactive-spi/pom.xml b/proxy/frontend/reactive-spi/pom.xml
deleted file mode 100644
index 13112224161..00000000000
--- a/proxy/frontend/reactive-spi/pom.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ 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.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-proxy-frontend</artifactId>
- <version>5.3.1-SNAPSHOT</version>
- </parent>
- <artifactId>shardingsphere-proxy-frontend-reactive-spi</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-proxy-frontend-spi</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-</project>
diff --git a/proxy/frontend/reactive-spi/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/command/ReactiveCommandExecuteEngine.java b/proxy/frontend/reactive-spi/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/command/ReactiveCommandExecuteEngine.java
deleted file mode 100644
index 23fe6435100..00000000000
--- a/proxy/frontend/reactive-spi/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/command/ReactiveCommandExecuteEngine.java
+++ /dev/null
@@ -1,39 +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.proxy.frontend.reactive.command;
-
-import org.apache.shardingsphere.db.protocol.packet.CommandPacket;
-import org.apache.shardingsphere.db.protocol.packet.CommandPacketType;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.frontend.reactive.command.executor.ReactiveCommandExecutor;
-
-/**
- * Command execute engine for reactive.
- */
-public interface ReactiveCommandExecuteEngine {
-
- /**
- * Get command executor.
- *
- * @param type command packet type
- * @param packet command packet
- * @param connectionSession connection session
- * @return command executor
- */
- ReactiveCommandExecutor getReactiveCommandExecutor(CommandPacketType type, CommandPacket packet, ConnectionSession connectionSession);
-}
diff --git a/proxy/frontend/reactive-spi/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/command/executor/ReactiveCommandExecutor.java b/proxy/frontend/reactive-spi/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/command/executor/ReactiveCommandExecutor.java
deleted file mode 100644
index ec12d5ac721..00000000000
--- a/proxy/frontend/reactive-spi/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/command/executor/ReactiveCommandExecutor.java
+++ /dev/null
@@ -1,45 +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.proxy.frontend.reactive.command.executor;
-
-import io.vertx.core.Future;
-import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
-
-import java.util.Collection;
-
-/**
- * Reactive command executor.
- */
-public interface ReactiveCommandExecutor {
-
- /**
- * Execute command and return future.
- *
- * @return future
- */
- Future<Collection<DatabasePacket<?>>> executeFuture();
-
- /**
- * Close future.
- *
- * @return close future
- */
- default Future<Void> closeFuture() {
- return Future.succeededFuture();
- }
-}
diff --git a/proxy/frontend/reactive-spi/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/spi/ReactiveDatabaseProtocolFrontendEngine.java b/proxy/frontend/reactive-spi/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/spi/ReactiveDatabaseProtocolFrontendEngine.java
deleted file mode 100644
index e1f6c80e66b..00000000000
--- a/proxy/frontend/reactive-spi/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/spi/ReactiveDatabaseProtocolFrontendEngine.java
+++ /dev/null
@@ -1,34 +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.proxy.frontend.reactive.spi;
-
-import org.apache.shardingsphere.proxy.frontend.reactive.command.ReactiveCommandExecuteEngine;
-import org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine;
-
-/**
- * Reactive database protocol frontend engine.
- */
-public interface ReactiveDatabaseProtocolFrontendEngine extends DatabaseProtocolFrontendEngine {
-
- /**
- * Get reactive command execute engine.
- *
- * @return reactive command execute engine
- */
- ReactiveCommandExecuteEngine getReactiveCommandExecuteEngine();
-}
diff --git a/test/e2e/pipeline/src/test/resources/env/opengauss/server.yaml b/test/e2e/pipeline/src/test/resources/env/opengauss/server.yaml
index f4f585614ab..058ca03240c 100644
--- a/test/e2e/pipeline/src/test/resources/env/opengauss/server.yaml
+++ b/test/e2e/pipeline/src/test/resources/env/opengauss/server.yaml
@@ -46,5 +46,4 @@ props:
proxy-frontend-max-connections: 0 # Less than or equal to 0 means no limitation.
# Available sql federation type: NONE (default), ORIGINAL, ADVANCED
sql-federation-type: NONE
- proxy-backend-driver-type: JDBC
proxy-frontend-database-protocol-type: openGauss
diff --git a/test/e2e/pipeline/src/test/resources/env/postgresql/server.yaml b/test/e2e/pipeline/src/test/resources/env/postgresql/server.yaml
index 5349fa341a5..b45af6f1615 100644
--- a/test/e2e/pipeline/src/test/resources/env/postgresql/server.yaml
+++ b/test/e2e/pipeline/src/test/resources/env/postgresql/server.yaml
@@ -51,6 +51,4 @@ props:
proxy-frontend-max-connections: 0 # Less than or equal to 0 means no limitation.
# Available sql federation type: NONE (default), ORIGINAL, ADVANCED
sql-federation-type: NONE
- # Available proxy backend driver type: JDBC (default), ExperimentalVertx
- proxy-backend-driver-type: JDBC
proxy-frontend-database-protocol-type: PostgreSQL
diff --git a/test/e2e/suite/src/test/resources/cases/ral/dataset/empty_rules/cluster/show_dist_variables.xml b/test/e2e/suite/src/test/resources/cases/ral/dataset/empty_rules/cluster/show_dist_variables.xml
index 453d5431587..a3e755790e2 100644
--- a/test/e2e/suite/src/test/resources/cases/ral/dataset/empty_rules/cluster/show_dist_variables.xml
+++ b/test/e2e/suite/src/test/resources/cases/ral/dataset/empty_rules/cluster/show_dist_variables.xml
@@ -33,7 +33,6 @@
<row values="proxy_frontend_executor_size| 0" />
<row values="proxy_backend_executor_suitable| OLAP" />
<row values="proxy_frontend_max_connections| 0" />
- <row values="proxy_backend_driver_type| JDBC" />
<row values="proxy_mysql_default_version| 5.7.22" />
<row values="proxy_default_port| 3307" />
<row values="proxy_netty_backlog| 1024" />
diff --git a/test/e2e/suite/src/test/resources/cases/ral/dataset/empty_rules/standalone/show_dist_variables.xml b/test/e2e/suite/src/test/resources/cases/ral/dataset/empty_rules/standalone/show_dist_variables.xml
index 453d5431587..a3e755790e2 100644
--- a/test/e2e/suite/src/test/resources/cases/ral/dataset/empty_rules/standalone/show_dist_variables.xml
+++ b/test/e2e/suite/src/test/resources/cases/ral/dataset/empty_rules/standalone/show_dist_variables.xml
@@ -33,7 +33,6 @@
<row values="proxy_frontend_executor_size| 0" />
<row values="proxy_backend_executor_suitable| OLAP" />
<row values="proxy_frontend_max_connections| 0" />
- <row values="proxy_backend_driver_type| JDBC" />
<row values="proxy_mysql_default_version| 5.7.22" />
<row values="proxy_default_port| 3307" />
<row values="proxy_netty_backlog| 1024" />
diff --git a/test/e2e/transaction/src/test/resources/env/opengauss/server.yaml b/test/e2e/transaction/src/test/resources/env/opengauss/server.yaml
index 1885167a386..64aac3d2848 100644
--- a/test/e2e/transaction/src/test/resources/env/opengauss/server.yaml
+++ b/test/e2e/transaction/src/test/resources/env/opengauss/server.yaml
@@ -45,5 +45,4 @@ props:
proxy-backend-executor-suitable: OLAP
proxy-frontend-max-connections: 0 # Less than or equal to 0 means no limitation.
sql-federation-type: ADVANCED
- proxy-backend-driver-type: JDBC
proxy-frontend-database-protocol-type: openGauss
diff --git a/test/e2e/transaction/src/test/resources/env/postgresql/server.yaml b/test/e2e/transaction/src/test/resources/env/postgresql/server.yaml
index 0cdbf4008cd..3fb08aca5e2 100644
--- a/test/e2e/transaction/src/test/resources/env/postgresql/server.yaml
+++ b/test/e2e/transaction/src/test/resources/env/postgresql/server.yaml
@@ -50,6 +50,4 @@ props:
proxy-backend-executor-suitable: OLAP
proxy-frontend-max-connections: 0 # Less than or equal to 0 means no limitation.
sql-federation-type: ADVANCED
- # Available proxy backend driver type: JDBC (default), ExperimentalVertx
- proxy-backend-driver-type: JDBC
proxy-frontend-database-protocol-type: PostgreSQL