You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2021/12/06 16:51:52 UTC
[shardingsphere] branch master updated: Extract ConnectionSession to decoupling JDBC from BackendConnection (#13956)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 5ca75d7 Extract ConnectionSession to decoupling JDBC from BackendConnection (#13956)
5ca75d7 is described below
commit 5ca75d723bd8fa4ac61e8d2ab2444f2ff3dc4095
Author: 吴伟杰 <wu...@apache.org>
AuthorDate: Tue Dec 7 00:51:00 2021 +0800
Extract ConnectionSession to decoupling JDBC from BackendConnection (#13956)
* Extract ConnectionSession from BackendConnection
* Use ConnectionSession as possible
* Rename BackendConnection to JDBCConnectionSession
* Fix checkstyle
---
.../jaeger/advice/CommandExecutorTaskAdvice.java | 6 +-
.../advice/CommandExecutorTaskAdviceTest.java | 4 +-
.../AbstractCommandExecutorTaskAdviceTest.java | 4 +-
.../zipkin/advice/CommandExecutorTaskAdvice.java | 6 +-
.../communication/DatabaseCommunicationEngine.java | 8 +-
.../DatabaseCommunicationEngineFactory.java | 22 +--
.../backend/communication/ProxySQLExecutor.java | 40 +++---
...dConnection.java => JDBCConnectionSession.java} | 67 ++--------
.../jdbc/executor/ProxyJDBCExecutor.java | 6 +-
.../transaction/BackendTransactionManager.java | 10 +-
.../jdbc/transaction/LocalTransactionManager.java | 4 +-
.../proxy/backend/session/ConnectionSession.java | 107 +++++++++++++++
.../backend/text/SchemaRequiredBackendHandler.java | 10 +-
.../text/TextProtocolBackendHandlerFactory.java | 31 ++---
.../admin/DatabaseAdminBackendHandlerFactory.java | 18 +--
.../admin/DatabaseAdminQueryBackendHandler.java | 8 +-
.../admin/DatabaseAdminUpdateBackendHandler.java | 6 +-
.../executor/AbstractDatabaseMetadataExecutor.java | 4 +-
.../text/admin/executor/DatabaseAdminExecutor.java | 6 +-
.../mysql/executor/ShowConnectionIdExecutor.java | 6 +-
.../mysql/executor/ShowCreateDatabaseExecutor.java | 4 +-
.../executor/ShowCurrentDatabaseExecutor.java | 6 +-
.../mysql/executor/ShowCurrentUserExecutor.java | 6 +-
.../mysql/executor/ShowDatabasesExecutor.java | 10 +-
.../mysql/executor/ShowFunctionStatusExecutor.java | 4 +-
.../executor/ShowProcedureStatusExecutor.java | 4 +-
.../mysql/executor/ShowProcessListExecutor.java | 4 +-
.../admin/mysql/executor/ShowTablesExecutor.java | 8 +-
.../mysql/executor/ShowTablesStatusExecutor.java | 6 +-
.../admin/mysql/executor/ShowVersionExecutor.java | 4 +-
.../admin/mysql/executor/UseDatabaseExecutor.java | 8 +-
.../text/data/DatabaseBackendHandlerFactory.java | 12 +-
.../data/impl/BroadcastDatabaseBackendHandler.java | 12 +-
.../impl/SchemaAssignedDatabaseBackendHandler.java | 8 +-
.../data/impl/UnicastDatabaseBackendHandler.java | 12 +-
.../DatabaseOperateBackendHandlerFactory.java | 12 +-
.../text/database/DropDatabaseBackendHandler.java | 8 +-
.../text/distsql/DistSQLBackendHandlerFactory.java | 12 +-
.../text/distsql/ral/RALBackendHandlerFactory.java | 12 +-
.../AdvancedDistSQLBackendHandlerFactory.java | 11 +-
.../ral/advanced/ParseDistSQLBackendHandler.java | 10 +-
.../ral/advanced/PreviewDistSQLBackendHandler.java | 8 +-
.../common/CommonDistSQLBackendHandlerFactory.java | 14 +-
.../ral/common/HintDistSQLBackendHandler.java | 6 +-
.../ral/common/RefreshTableMetadataHandler.java | 6 +-
.../ral/common/SetDistSQLBackendHandler.java | 6 +-
.../ral/common/ShowDistSQLBackendHandler.java | 6 +-
.../common/hint/HintStatementExecutorFactory.java | 8 +-
.../executor/ShowShardingHintStatusExecutor.java | 6 +-
.../common/set/SetStatementExecutorFactory.java | 10 +-
.../SetReadwriteSplittingStatusExecutor.java | 6 +-
.../common/set/excutor/SetVariableExecutor.java | 6 +-
.../common/show/ShowStatementExecutorFactory.java | 12 +-
.../show/executor/ShowAllVariablesExecutor.java | 8 +-
...howReadwriteSplittingReadResourcesExecutor.java | 6 +-
.../common/show/executor/ShowVariableExecutor.java | 8 +-
.../ral/query/QueryableRALBackendHandler.java | 6 +-
.../query/QueryableRALBackendHandlerFactory.java | 8 +-
.../text/distsql/rdl/RDLBackendHandlerFactory.java | 18 +--
.../rdl/resource/AddResourceBackendHandler.java | 6 +-
.../rdl/resource/AlterResourceBackendHandler.java | 6 +-
.../rdl/resource/DropResourceBackendHandler.java | 6 +-
.../rdl/rule/RuleDefinitionBackendHandler.java | 6 +-
.../text/distsql/rql/RQLBackendHandler.java | 6 +-
.../text/distsql/rql/RQLBackendHandlerFactory.java | 8 +-
.../transaction/TransactionAutoCommitHandler.java | 6 +-
.../transaction/TransactionBackendHandler.java | 13 +-
.../TransactionBackendHandlerFactory.java | 22 +--
.../DatabaseCommunicationEngineFactoryTest.java | 20 +--
.../DatabaseCommunicationEngineTest.java | 16 +--
.../communication/ProxySQLExecutorTest.java | 38 +++---
...ionTest.java => JDBCConnectionSessionTest.java} | 148 ++++++++++-----------
.../jdbc/connection/MockConnectionUtil.java | 10 +-
.../transaction/BackendTransactionManagerTest.java | 18 +--
.../transaction/LocalTransactionManagerTest.java | 12 +-
.../TextProtocolBackendHandlerFactoryTest.java | 52 ++++----
.../DatabaseOperateBackendHandlerFactoryTest.java | 8 +-
.../executor/ShowConnectionIdExecutorTest.java | 8 +-
.../executor/ShowCreateDatabaseExecutorTest.java | 10 +-
.../executor/ShowCurrentUserExecutorTest.java | 10 +-
.../mysql/executor/ShowDatabasesExecutorTest.java | 18 +--
.../executor/ShowFunctionStatusExecutorTest.java | 10 +-
.../executor/ShowProcedureStatusExecutorTest.java | 10 +-
.../executor/ShowProcessListExecutorTest.java | 4 +-
.../mysql/executor/ShowTablesExecutorTest.java | 10 +-
.../executor/ShowTablesStatusExecutorTest.java | 10 +-
.../mysql/executor/ShowVersionExecutorTest.java | 4 +-
.../mysql/executor/UseDatabaseExecutorTest.java | 10 +-
.../information/SelectInformationExecutorTest.java | 12 +-
.../executor/SelectDatabaseExecutorTest.java | 10 +-
.../executor/SelectTableExecutorTest.java | 4 +-
.../data/DatabaseBackendHandlerFactoryTest.java | 12 +-
.../impl/BroadcastDatabaseBackendHandlerTest.java | 8 +-
.../SchemaAssignedDatabaseBackendHandlerTest.java | 8 +-
.../impl/UnicastDatabaseBackendHandlerTest.java | 8 +-
.../database/DropDatabaseBackendHandlerTest.java | 16 +--
.../distsql/DistSQLBackendHandlerFactoryTest.java | 42 +++---
.../distsql/ral/SetVariableBackendHandlerTest.java | 42 +++---
.../ral/ShowAllVariablesBackendHandlerTest.java | 8 +-
.../ral/ShowVariableBackendHandlerTest.java | 24 ++--
.../advance/ParseDistSQLBackendHandlerTest.java | 6 +-
.../hint/HintStatementExecutorFactoryTest.java | 22 +--
.../set/SetStatementExecutorFactoryTest.java | 10 +-
.../set/executor/SetVariableExecutorTest.java | 8 +-
.../resource/AddResourceBackendHandlerTest.java | 6 +-
.../resource/AlterResourceBackendHandlerTest.java | 6 +-
.../resource/DropResourceBackendHandlerTest.java | 6 +-
.../text/distsql/rql/RQLBackendHandlerTest.java | 6 +-
.../rql/RuleDefinitionBackendHandlerTest.java | 10 +-
.../TransactionBackendHandlerFactoryTest.java | 14 +-
.../transaction/TransactionBackendHandlerTest.java | 6 +-
.../frontend/command/CommandExecutorTask.java | 38 +++---
.../executor/ConnectionThreadExecutorGroup.java | 2 +-
.../netty/FrontendChannelInboundHandler.java | 28 ++--
.../proxy/frontend/state/ProxyState.java | 6 +-
.../proxy/frontend/state/ProxyStateContext.java | 8 +-
.../state/impl/CircuitBreakProxyState.java | 8 +-
.../proxy/frontend/state/impl/LockProxyState.java | 4 +-
.../proxy/frontend/state/impl/OKProxyState.java | 21 +--
.../frontend/command/CommandExecutorTaskTest.java | 70 +++++-----
.../DatabaseProtocolFrontendEngineFixture.java | 4 +-
.../frontend/state/impl/OKProxyStateTest.java | 4 +-
.../proxy/frontend/mysql/MySQLFrontendEngine.java | 6 +-
.../mysql/command/MySQLCommandExecuteEngine.java | 19 +--
.../mysql/command/MySQLCommandExecutorFactory.java | 18 +--
.../admin/initdb/MySQLComInitDbExecutor.java | 8 +-
.../execute/MySQLComStmtExecuteExecutor.java | 16 +--
.../prepare/MySQLComStmtPrepareExecutor.java | 16 +--
.../fieldlist/MySQLComFieldListPacketExecutor.java | 10 +-
.../text/query/MySQLComQueryPacketExecutor.java | 8 +-
.../command/MySQLCommandExecutorFactoryTest.java | 30 ++---
.../execute/MySQLComStmtExecuteExecutorTest.java | 24 ++--
.../query/MySQLComQueryPacketExecutorTest.java | 10 +-
.../opengauss/OpenGaussFrontendEngine.java | 6 +-
.../command/OpenGaussCommandExecuteEngine.java | 25 ++--
.../command/OpenGaussCommandExecutorFactory.java | 10 +-
.../bind/OpenGaussComBatchBindExecutor.java | 12 +-
.../opengauss/OpenGaussFrontendEngineTest.java | 4 +-
.../postgresql/PostgreSQLFrontendEngine.java | 8 +-
.../command/PostgreSQLCommandExecuteEngine.java | 43 +++---
.../command/PostgreSQLCommandExecutorFactory.java | 16 +--
.../command/PostgreSQLConnectionContext.java | 8 +-
.../PostgreSQLConnectionContextRegistry.java | 4 +-
.../command/query/extended/PostgreSQLPortal.java | 18 +--
.../extended/bind/PostgreSQLComBindExecutor.java | 8 +-
.../extended/close/PostgreSQLComCloseExecutor.java | 6 +-
.../extended/parse/PostgreSQLComParseExecutor.java | 8 +-
.../extended/sync/PostgreSQLComSyncExecutor.java | 6 +-
.../query/simple/PostgreSQLComQueryExecutor.java | 6 +-
.../postgresql/PostgreSQLFrontendEngineTest.java | 8 +-
.../PostgreSQLCommandExecuteEngineTest.java | 18 +--
.../PostgreSQLCommandExecutorFactoryTest.java | 16 +--
.../command/PostgreSQLConnectionContextTest.java | 4 +-
.../query/extended/PostgreSQLPortalTest.java | 10 +-
.../bind/PostgreSQLComBindExecutorTest.java | 16 +--
.../close/PostgreSQLComCloseExecutorTest.java | 10 +-
.../parse/PostgreSQLComParseExecutorTest.java | 12 +-
.../sync/PostgreSQLComSyncExecutorTest.java | 12 +-
.../simple/PostgreSQLComQueryExecutorTest.java | 6 +-
.../frontend/command/CommandExecuteEngine.java | 23 ++--
.../spi/DatabaseProtocolFrontendEngine.java | 6 +-
161 files changed, 1122 insertions(+), 1058 deletions(-)
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/CommandExecutorTaskAdvice.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/CommandExecutorTaskAdvice.java
index 8206ba1..29fecf1 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/CommandExecutorTaskAdvice.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/CommandExecutorTaskAdvice.java
@@ -27,7 +27,7 @@ import org.apache.shardingsphere.agent.api.result.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.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask;
import java.lang.reflect.Field;
@@ -52,9 +52,9 @@ public final class CommandExecutorTaskAdvice implements InstanceMethodAroundAdvi
@SneakyThrows
public void afterMethod(final AdviceTargetObject target, final Method method, final Object[] args, final MethodInvocationResult result) {
ExecutorDataMap.getValue().remove(JaegerConstants.ROOT_SPAN);
- Field field = CommandExecutorTask.class.getDeclaredField("backendConnection");
+ Field field = CommandExecutorTask.class.getDeclaredField("connectionSession");
field.setAccessible(true);
- BackendConnection connection = (BackendConnection) field.get(target);
+ JDBCConnectionSession connection = (JDBCConnectionSession) field.get(target);
Scope scope = GlobalTracer.get().scopeManager().active();
scope.span().setTag(JaegerConstants.ShardingSphereTags.CONNECTION_COUNT.getKey(), connection.getConnectionSize());
scope.close();
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/CommandExecutorTaskAdviceTest.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/CommandExecutorTaskAdviceTest.java
index 4367724..6639bfe 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/CommandExecutorTaskAdviceTest.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/CommandExecutorTaskAdviceTest.java
@@ -25,7 +25,7 @@ import io.opentracing.util.GlobalTracer;
import lombok.SneakyThrows;
import org.apache.shardingsphere.agent.api.result.MethodInvocationResult;
import org.apache.shardingsphere.db.protocol.payload.PacketPayload;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -58,7 +58,7 @@ public final class CommandExecutorTaskAdviceTest {
}
FieldReader fieldReader = new FieldReader(GlobalTracer.get(), GlobalTracer.class.getDeclaredField("tracer"));
tracer = (MockTracer) fieldReader.read();
- executeCommandMethod = CommandExecutorTask.class.getDeclaredMethod("executeCommand", ChannelHandlerContext.class, PacketPayload.class, BackendConnection.class);
+ executeCommandMethod = CommandExecutorTask.class.getDeclaredMethod("executeCommand", ChannelHandlerContext.class, PacketPayload.class, JDBCConnectionSession.class);
}
@Before
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-test/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/advice/AbstractCommandExecutorTaskAdviceTest.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-test/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/advice/AbstractCommandExecutorTaskAdviceTest.java
index 0eed75b..44b03cc 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-test/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/advice/AbstractCommandExecutorTaskAdviceTest.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-test/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/advice/AbstractCommandExecutorTaskAdviceTest.java
@@ -21,7 +21,7 @@ import io.netty.util.DefaultAttributeMap;
import lombok.Getter;
import org.apache.shardingsphere.agent.api.advice.AdviceTargetObject;
import org.apache.shardingsphere.agent.plugin.tracing.AgentRunner;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask;
import org.apache.shardingsphere.transaction.core.TransactionType;
import org.junit.runner.RunWith;
@@ -35,7 +35,7 @@ public abstract class AbstractCommandExecutorTaskAdviceTest implements AdviceTes
@SuppressWarnings("ConstantConditions")
@Override
public final void prepare() {
- Object executorTask = new CommandExecutorTask(null, new BackendConnection(TransactionType.BASE, new DefaultAttributeMap()), null, null);
+ Object executorTask = new CommandExecutorTask(null, new JDBCConnectionSession(TransactionType.BASE, new DefaultAttributeMap()), null, null);
targetObject = (AdviceTargetObject) executorTask;
}
}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/CommandExecutorTaskAdvice.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/CommandExecutorTaskAdvice.java
index 940432c..084640a 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/CommandExecutorTaskAdvice.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/CommandExecutorTaskAdvice.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.agent.api.advice.AdviceTargetObject;
import org.apache.shardingsphere.agent.api.result.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.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask;
import java.lang.reflect.Field;
@@ -49,9 +49,9 @@ public final class CommandExecutorTaskAdvice implements InstanceMethodAroundAdvi
@SneakyThrows
@Override
public void afterMethod(final AdviceTargetObject target, final Method method, final Object[] args, final MethodInvocationResult result) {
- Field field = CommandExecutorTask.class.getDeclaredField("backendConnection");
+ Field field = CommandExecutorTask.class.getDeclaredField("connectionSession");
field.setAccessible(true);
- BackendConnection connection = (BackendConnection) field.get(target);
+ JDBCConnectionSession connection = (JDBCConnectionSession) field.get(target);
Span span = (Span) ExecutorDataMap.getValue().remove(ZipkinConstants.ROOT_SPAN);
span.tag(ZipkinConstants.Tags.CONNECTION_COUNT, String.valueOf(connection.getConnectionSize()));
span.finish();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngine.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngine.java
index 0927e8e..2c98643 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngine.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngine.java
@@ -33,7 +33,7 @@ import org.apache.shardingsphere.infra.merge.MergeEngine;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.rule.identifier.type.DataNodeContainedRule;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseCell;
import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
@@ -83,14 +83,14 @@ public final class DatabaseCommunicationEngine {
private final Collection<ResultSet> cachedResultSets = new CopyOnWriteArrayList<>();
- public DatabaseCommunicationEngine(final String driverType, final ShardingSphereMetaData metaData, final LogicSQL logicSQL, final BackendConnection backendConnection) {
+ public DatabaseCommunicationEngine(final String driverType, final ShardingSphereMetaData metaData, final LogicSQL logicSQL, final JDBCConnectionSession connectionSession) {
this.driverType = driverType;
this.metaData = metaData;
this.logicSQL = logicSQL;
- proxySQLExecutor = new ProxySQLExecutor(driverType, backendConnection, this);
+ proxySQLExecutor = new ProxySQLExecutor(driverType, connectionSession, this);
kernelProcessor = new KernelProcessor();
metadataRefreshEngine = new MetaDataRefreshEngine(metaData,
- ProxyContext.getInstance().getContextManager().getMetaDataContexts().getOptimizerContext().getMetaData().getSchemas().get(backendConnection.getSchemaName()),
+ ProxyContext.getInstance().getContextManager().getMetaDataContexts().getOptimizerContext().getMetaData().getSchemas().get(connectionSession.getSchemaName()),
ProxyContext.getInstance().getContextManager().getMetaDataContexts().getProps());
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactory.java
index 38f00d2..c992a70 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactory.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.infra.binder.LogicSQL;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.JDBCDriverType;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import java.util.Collections;
@@ -51,14 +51,14 @@ public final class DatabaseCommunicationEngineFactory {
*
* @param sqlStatementContext SQL statement context
* @param sql SQL to be executed
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @return text protocol backend handler
*/
- public DatabaseCommunicationEngine newTextProtocolInstance(final SQLStatementContext<?> sqlStatementContext, final String sql, final BackendConnection backendConnection) {
- ShardingSphereMetaData metaData = ProxyContext.getInstance().getMetaData(backendConnection.getSchemaName());
+ public DatabaseCommunicationEngine newTextProtocolInstance(final SQLStatementContext<?> sqlStatementContext, final String sql, final JDBCConnectionSession connectionSession) {
+ ShardingSphereMetaData metaData = ProxyContext.getInstance().getMetaData(connectionSession.getSchemaName());
LogicSQL logicSQL = new LogicSQL(sqlStatementContext, sql, Collections.emptyList());
- DatabaseCommunicationEngine result = new DatabaseCommunicationEngine(JDBCDriverType.STATEMENT, metaData, logicSQL, backendConnection);
- backendConnection.add(result);
+ DatabaseCommunicationEngine result = new DatabaseCommunicationEngine(JDBCDriverType.STATEMENT, metaData, logicSQL, connectionSession);
+ connectionSession.add(result);
return result;
}
@@ -68,15 +68,15 @@ public final class DatabaseCommunicationEngineFactory {
* @param sqlStatementContext SQL statement context
* @param sql SQL to be executed
* @param parameters SQL parameters
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @return binary protocol backend handler
*/
public DatabaseCommunicationEngine newBinaryProtocolInstance(final SQLStatementContext<?> sqlStatementContext, final String sql,
- final List<Object> parameters, final BackendConnection backendConnection) {
- ShardingSphereMetaData metaData = ProxyContext.getInstance().getMetaData(backendConnection.getSchemaName());
+ final List<Object> parameters, final JDBCConnectionSession connectionSession) {
+ ShardingSphereMetaData metaData = ProxyContext.getInstance().getMetaData(connectionSession.getSchemaName());
LogicSQL logicSQL = new LogicSQL(sqlStatementContext, sql, parameters);
- DatabaseCommunicationEngine result = new DatabaseCommunicationEngine(JDBCDriverType.PREPARED_STATEMENT, metaData, logicSQL, backendConnection);
- backendConnection.add(result);
+ DatabaseCommunicationEngine result = new DatabaseCommunicationEngine(JDBCDriverType.PREPARED_STATEMENT, metaData, logicSQL, connectionSession);
+ connectionSession.add(result);
return result;
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/ProxySQLExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/ProxySQLExecutor.java
index 89e6ac6..9f2554b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/ProxySQLExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/ProxySQLExecutor.java
@@ -38,7 +38,7 @@ import org.apache.shardingsphere.infra.federation.executor.FederationExecutorFac
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.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.ProxyJDBCExecutor;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.ProxyJDBCExecutorCallback;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.ProxyJDBCExecutorCallbackFactory;
@@ -67,7 +67,7 @@ public final class ProxySQLExecutor {
private final String type;
- private final BackendConnection backendConnection;
+ private final JDBCConnectionSession connectionSession;
private final DatabaseCommunicationEngine databaseCommunicationEngine;
@@ -77,17 +77,17 @@ public final class ProxySQLExecutor {
private final FederationExecutor federationExecutor;
- public ProxySQLExecutor(final String type, final BackendConnection backendConnection, final DatabaseCommunicationEngine databaseCommunicationEngine) {
+ public ProxySQLExecutor(final String type, final JDBCConnectionSession connectionSession, final DatabaseCommunicationEngine databaseCommunicationEngine) {
this.type = type;
- this.backendConnection = backendConnection;
+ this.connectionSession = connectionSession;
this.databaseCommunicationEngine = databaseCommunicationEngine;
ExecutorEngine executorEngine = BackendExecutorContext.getInstance().getExecutorEngine();
- boolean isSerialExecute = backendConnection.isSerialExecute();
+ boolean isSerialExecute = connectionSession.isSerialExecute();
MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
- jdbcExecutor = new ProxyJDBCExecutor(type, backendConnection, databaseCommunicationEngine, new JDBCExecutor(executorEngine, isSerialExecute));
+ jdbcExecutor = new ProxyJDBCExecutor(type, connectionSession, databaseCommunicationEngine, new JDBCExecutor(executorEngine, isSerialExecute));
rawExecutor = new RawExecutor(executorEngine, isSerialExecute, metaDataContexts.getProps());
federationExecutor = FederationExecutorFactory.newInstance(
- backendConnection.getSchemaName(), metaDataContexts.getOptimizerContext(), metaDataContexts.getProps(), new JDBCExecutor(executorEngine, isSerialExecute));
+ connectionSession.getSchemaName(), metaDataContexts.getOptimizerContext(), metaDataContexts.getProps(), new JDBCExecutor(executorEngine, isSerialExecute));
}
/**
@@ -103,14 +103,14 @@ public final class ProxySQLExecutor {
}
private boolean isExecuteDDLInXATransaction(final SQLStatement sqlStatement) {
- TransactionStatus transactionStatus = backendConnection.getTransactionStatus();
+ TransactionStatus transactionStatus = connectionSession.getTransactionStatus();
return TransactionType.XA == transactionStatus.getTransactionType() && sqlStatement instanceof DDLStatement && transactionStatus.isInTransaction();
}
private boolean isExecuteDDLInPostgreSQLOpenGaussTransaction(final SQLStatement sqlStatement) {
// TODO implement DDL statement commit/rollback in PostgreSQL/openGauss transaction
boolean isPostgreSQLOpenGaussStatement = sqlStatement instanceof PostgreSQLStatement || sqlStatement instanceof OpenGaussStatement;
- return sqlStatement instanceof DDLStatement && isPostgreSQLOpenGaussStatement && backendConnection.getTransactionStatus().isInTransaction();
+ return sqlStatement instanceof DDLStatement && isPostgreSQLOpenGaussStatement && connectionSession.getTransactionStatus().isInTransaction();
}
/**
@@ -121,7 +121,7 @@ public final class ProxySQLExecutor {
* @throws SQLException SQL exception
*/
public Collection<ExecuteResult> execute(final ExecutionContext executionContext) throws SQLException {
- Collection<ShardingSphereRule> rules = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData(backendConnection.getSchemaName()).getRuleMetaData().getRules();
+ Collection<ShardingSphereRule> rules = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData(connectionSession.getSchemaName()).getRuleMetaData().getRules();
int maxConnectionsSizePerQuery = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
boolean isReturnGeneratedKeys = executionContext.getSqlStatementContext().getSqlStatement() instanceof MySQLInsertStatement;
return execute(executionContext, rules, maxConnectionsSizePerQuery, isReturnGeneratedKeys);
@@ -146,8 +146,8 @@ public final class ProxySQLExecutor {
} catch (final SQLException ex) {
return getSaneExecuteResults(executionContext, ex);
}
- executionGroupContext.setSchemaName(backendConnection.getSchemaName());
- executionGroupContext.setGrantee(backendConnection.getGrantee());
+ executionGroupContext.setSchemaName(connectionSession.getSchemaName());
+ executionGroupContext.setGrantee(connectionSession.getGrantee());
// TODO handle query header
return rawExecutor.execute(executionGroupContext, executionContext.getLogicSQL(), new RawSQLExecutorCallback());
}
@@ -157,36 +157,36 @@ public final class ProxySQLExecutor {
return Collections.emptyList();
}
MetaDataContexts metaData = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
- ProxyJDBCExecutorCallback callback = ProxyJDBCExecutorCallbackFactory.newInstance(type, metaData.getMetaData(backendConnection.getSchemaName()).getResource().getDatabaseType(),
+ ProxyJDBCExecutorCallback callback = ProxyJDBCExecutorCallbackFactory.newInstance(type, metaData.getMetaData(connectionSession.getSchemaName()).getResource().getDatabaseType(),
executionContext.getSqlStatementContext().getSqlStatement(), databaseCommunicationEngine, isReturnGeneratedKeys, isExceptionThrown, true);
- backendConnection.setFederationExecutor(federationExecutor);
+ connectionSession.setFederationExecutor(federationExecutor);
DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine = createDriverExecutionPrepareEngine(isReturnGeneratedKeys, metaData);
return federationExecutor.executeQuery(prepareEngine, callback, executionContext).stream().map(each -> (ExecuteResult) each).collect(Collectors.toList());
}
private DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> createDriverExecutionPrepareEngine(final boolean isReturnGeneratedKeys, final MetaDataContexts metaData) {
int maxConnectionsSizePerQuery = metaData.getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
- return new DriverExecutionPrepareEngine<>(type, maxConnectionsSizePerQuery, backendConnection, new StatementOption(isReturnGeneratedKeys),
- metaData.getMetaData(backendConnection.getSchemaName()).getRuleMetaData().getRules());
+ return new DriverExecutionPrepareEngine<>(type, maxConnectionsSizePerQuery, connectionSession, new StatementOption(isReturnGeneratedKeys),
+ metaData.getMetaData(connectionSession.getSchemaName()).getRuleMetaData().getRules());
}
private Collection<ExecuteResult> useDriverToExecute(final ExecutionContext executionContext, final Collection<ShardingSphereRule> rules,
final int maxConnectionsSizePerQuery, final boolean isReturnGeneratedKeys, final boolean isExceptionThrown) throws SQLException {
DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine = new DriverExecutionPrepareEngine<>(
- type, maxConnectionsSizePerQuery, backendConnection, new StatementOption(isReturnGeneratedKeys), rules);
+ type, maxConnectionsSizePerQuery, connectionSession, new StatementOption(isReturnGeneratedKeys), rules);
ExecutionGroupContext<JDBCExecutionUnit> executionGroupContext;
try {
executionGroupContext = prepareEngine.prepare(executionContext.getRouteContext(), executionContext.getExecutionUnits());
} catch (final SQLException ex) {
return getSaneExecuteResults(executionContext, ex);
}
- executionGroupContext.setSchemaName(backendConnection.getSchemaName());
- executionGroupContext.setGrantee(backendConnection.getGrantee());
+ executionGroupContext.setSchemaName(connectionSession.getSchemaName());
+ executionGroupContext.setGrantee(connectionSession.getGrantee());
return jdbcExecutor.execute(executionContext.getLogicSQL(), executionGroupContext, isReturnGeneratedKeys, isExceptionThrown);
}
private Collection<ExecuteResult> getSaneExecuteResults(final ExecutionContext executionContext, final SQLException originalException) throws SQLException {
- DatabaseType databaseType = ProxyContext.getInstance().getMetaData(backendConnection.getSchemaName()).getResource().getDatabaseType();
+ DatabaseType databaseType = ProxyContext.getInstance().getMetaData(connectionSession.getSchemaName()).getResource().getDatabaseType();
Optional<ExecuteResult> executeResult = JDBCSaneQueryResultEngineFactory.newInstance(databaseType).getSaneQueryResult(executionContext.getSqlStatementContext().getSqlStatement());
if (executeResult.isPresent()) {
return Collections.singleton(executeResult.get());
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnection.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCConnectionSession.java
similarity index 84%
rename from shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnection.java
rename to shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCConnectionSession.java
index 7cb8d8e..f7a6620 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnection.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCConnectionSession.java
@@ -21,22 +21,18 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Multimap;
import io.netty.util.AttributeMap;
-import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.db.protocol.parameter.TypeUnspecifiedSQLParameter;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.exception.ShardingSphereException;
import org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode;
import org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.ExecutorJDBCManager;
import org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.StatementOption;
import org.apache.shardingsphere.infra.federation.executor.FederationExecutor;
-import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
-import org.apache.shardingsphere.proxy.backend.communication.SQLStatementSchemaHolder;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.StatementMemoryStrictlyFetchSizeSetter;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.TransactionStatus;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.spi.typed.TypedSPI;
import org.apache.shardingsphere.transaction.core.TransactionType;
@@ -57,23 +53,16 @@ import java.util.function.Function;
import java.util.stream.Collectors;
/**
- * Backend connection.
+ * JDBC connection session.
*/
@Getter
@Setter
-public final class BackendConnection implements ExecutorJDBCManager {
+public final class JDBCConnectionSession extends ConnectionSession implements ExecutorJDBCManager {
static {
ShardingSphereServiceLoader.register(StatementMemoryStrictlyFetchSizeSetter.class);
}
- @Setter(AccessLevel.NONE)
- private volatile String schemaName;
-
- private volatile int connectionId;
-
- private volatile Grantee grantee;
-
private volatile FederationExecutor federationExecutor;
private final Multimap<String, Connection> cachedConnections = LinkedHashMultimap.create();
@@ -88,57 +77,17 @@ public final class BackendConnection implements ExecutorJDBCManager {
private final ConnectionStatus connectionStatus = new ConnectionStatus();
- private final TransactionStatus transactionStatus;
-
private final Map<String, StatementMemoryStrictlyFetchSizeSetter> fetchSizeSetters;
- private final AttributeMap attributeMap;
-
- private boolean autoCommit = true;
-
- public BackendConnection(final TransactionType initialTransactionType, final AttributeMap attributeMap) {
- transactionStatus = new TransactionStatus(initialTransactionType);
+ public JDBCConnectionSession(final TransactionType initialTransactionType, final AttributeMap attributeMap) {
+ super(initialTransactionType, attributeMap);
fetchSizeSetters = ShardingSphereServiceLoader.getSingletonServiceInstances(StatementMemoryStrictlyFetchSizeSetter.class).stream()
.collect(Collectors.toMap(TypedSPI::getType, Function.identity()));
- this.attributeMap = attributeMap;
- }
-
- /**
- * Change schema of current channel.
- *
- * @param schemaName schema name
- */
- public void setCurrentSchema(final String schemaName) {
- if (null != schemaName && schemaName.equals(this.schemaName)) {
- return;
- }
- if (transactionStatus.isInTransaction()) {
- throw new ShardingSphereException("Failed to switch schema, please terminate current transaction.");
- }
- this.schemaName = schemaName;
- }
-
- /**
- * Get schema name.
- *
- * @return schema name
- */
- public String getSchemaName() {
- return null == SQLStatementSchemaHolder.get() ? schemaName : SQLStatementSchemaHolder.get();
- }
-
- /**
- * Get default schema name.
- *
- * @return default schema name
- */
- public String getDefaultSchemaName() {
- return schemaName;
}
@Override
public List<Connection> getConnections(final String dataSourceName, final int connectionSize, final ConnectionMode connectionMode) throws SQLException {
- return transactionStatus.isInTransaction()
+ return getTransactionStatus().isInTransaction()
? getConnectionsWithTransaction(dataSourceName, connectionSize, connectionMode) : getConnectionsWithoutTransaction(dataSourceName, connectionSize, connectionMode);
}
@@ -232,7 +181,7 @@ public final class BackendConnection implements ExecutorJDBCManager {
* @return true or false
*/
public boolean isSerialExecute() {
- return transactionStatus.isInTransaction() && (TransactionType.LOCAL == transactionStatus.getTransactionType() || TransactionType.XA == transactionStatus.getTransactionType());
+ return getTransactionStatus().isInTransaction() && (TransactionType.LOCAL == getTransactionStatus().getTransactionType() || TransactionType.XA == getTransactionStatus().getTransactionType());
}
/**
@@ -306,7 +255,7 @@ public final class BackendConnection implements ExecutorJDBCManager {
Collection<SQLException> result = new LinkedList<>();
for (Connection each : cachedConnections.values()) {
try {
- if (forceRollback && transactionStatus.isInTransaction()) {
+ if (forceRollback && getTransactionStatus().isInTransaction()) {
each.rollback();
}
each.close();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/ProxyJDBCExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/ProxyJDBCExecutor.java
index 29bfb00..e95bd54 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/ProxyJDBCExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/ProxyJDBCExecutor.java
@@ -29,9 +29,9 @@ import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.J
import org.apache.shardingsphere.infra.executor.sql.execute.result.ExecuteResult;
import org.apache.shardingsphere.infra.executor.sql.process.ExecuteProcessEngine;
import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
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;
import java.sql.SQLException;
import java.util.Collection;
@@ -44,7 +44,7 @@ public final class ProxyJDBCExecutor {
private final String type;
- private final BackendConnection backendConnection;
+ private final ConnectionSession connectionSession;
private final DatabaseCommunicationEngine databaseCommunicationEngine;
@@ -65,7 +65,7 @@ public final class ProxyJDBCExecutor {
final boolean isReturnGeneratedKeys, final boolean isExceptionThrown) throws SQLException {
try {
MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
- DatabaseType databaseType = metaDataContexts.getMetaData(backendConnection.getSchemaName()).getResource().getDatabaseType();
+ DatabaseType databaseType = metaDataContexts.getMetaData(connectionSession.getSchemaName()).getResource().getDatabaseType();
ExecuteProcessEngine.initialize(logicSQL, executionGroupContext, metaDataContexts.getProps());
SQLStatementContext<?> context = logicSQL.getSqlStatementContext();
Collection<ExecuteResult> result = jdbcExecutor.execute(executionGroupContext,
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/BackendTransactionManager.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/BackendTransactionManager.java
index 3310444..12fd4c5 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/BackendTransactionManager.java
+++ b/shardingsphere-proxy/shardingsphere-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.transaction.TransactionHolder;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
import org.apache.shardingsphere.transaction.core.TransactionType;
@@ -31,7 +31,7 @@ import java.sql.SQLException;
*/
public final class BackendTransactionManager implements TransactionManager {
- private final BackendConnection connection;
+ private final JDBCConnectionSession connection;
private final TransactionType transactionType;
@@ -39,10 +39,10 @@ public final class BackendTransactionManager implements TransactionManager {
private final ShardingSphereTransactionManager shardingSphereTransactionManager;
- public BackendTransactionManager(final BackendConnection backendConnection) {
- connection = backendConnection;
+ public BackendTransactionManager(final JDBCConnectionSession connectionSession) {
+ connection = connectionSession;
transactionType = connection.getTransactionStatus().getTransactionType();
- localTransactionManager = new LocalTransactionManager(backendConnection);
+ localTransactionManager = new LocalTransactionManager(connectionSession);
ShardingSphereTransactionManagerEngine engine = ProxyContext.getInstance().getContextManager().getTransactionContexts().getEngines().get(connection.getSchemaName());
shardingSphereTransactionManager = null == engine ? null : engine.getTransactionManager(transactionType);
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/LocalTransactionManager.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/LocalTransactionManager.java
index 7d3db71..4b74ce0 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/LocalTransactionManager.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/LocalTransactionManager.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import java.sql.Connection;
import java.sql.SQLException;
@@ -31,7 +31,7 @@ import java.util.LinkedList;
@RequiredArgsConstructor
public final class LocalTransactionManager implements TransactionManager {
- private final BackendConnection connection;
+ private final JDBCConnectionSession connection;
@Override
public void begin() {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/session/ConnectionSession.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/session/ConnectionSession.java
new file mode 100644
index 0000000..db31a88
--- /dev/null
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/session/ConnectionSession.java
@@ -0,0 +1,107 @@
+/*
+ * 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.session;
+
+import io.netty.util.AttributeMap;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.shardingsphere.infra.exception.ShardingSphereException;
+import org.apache.shardingsphere.infra.metadata.user.Grantee;
+import org.apache.shardingsphere.proxy.backend.communication.SQLStatementSchemaHolder;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.TransactionStatus;
+import org.apache.shardingsphere.transaction.core.TransactionType;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * Connection session.
+ */
+@Getter
+@Setter
+public abstract class ConnectionSession {
+
+ @Setter(AccessLevel.NONE)
+ private volatile String schemaName;
+
+ private volatile int connectionId;
+
+ private volatile Grantee grantee;
+
+ private final TransactionStatus transactionStatus;
+
+ private final AttributeMap attributeMap;
+
+ private final AtomicBoolean autoCommit = new AtomicBoolean(true);
+
+ public ConnectionSession(final TransactionType initialTransactionType, final AttributeMap attributeMap) {
+ transactionStatus = new TransactionStatus(initialTransactionType);
+ this.attributeMap = attributeMap;
+ }
+
+ /**
+ * Change schema of current channel.
+ *
+ * @param schemaName schema name
+ */
+ public void setCurrentSchema(final String schemaName) {
+ if (null != schemaName && schemaName.equals(this.schemaName)) {
+ return;
+ }
+ if (transactionStatus.isInTransaction()) {
+ throw new ShardingSphereException("Failed to switch schema, please terminate current transaction.");
+ }
+ this.schemaName = schemaName;
+ }
+
+ /**
+ * Get schema name.
+ *
+ * @return schema name
+ */
+ public String getSchemaName() {
+ return null == SQLStatementSchemaHolder.get() ? schemaName : SQLStatementSchemaHolder.get();
+ }
+
+ /**
+ * Get default schema name.
+ *
+ * @return default schema name
+ */
+ public String getDefaultSchemaName() {
+ return schemaName;
+ }
+
+ /**
+ * Is autocommit.
+ *
+ * @return is autocommit
+ */
+ public boolean isAutoCommit() {
+ return autoCommit.get();
+ }
+
+ /**
+ * Set autocommit.
+ *
+ * @param autoCommit autocommit
+ */
+ public void setAutoCommit(final boolean autoCommit) {
+ this.autoCommit.set(autoCommit);
+ }
+}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/SchemaRequiredBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/SchemaRequiredBackendHandler.java
index 23e7f50..72bf2c6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/SchemaRequiredBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/SchemaRequiredBackendHandler.java
@@ -19,11 +19,11 @@ package org.apache.shardingsphere.proxy.backend.text;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.exception.NoDatabaseSelectedException;
import org.apache.shardingsphere.proxy.backend.exception.UnknownDatabaseException;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.SchemaSegment;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.available.FromSchemaAvailable;
@@ -42,20 +42,20 @@ public abstract class SchemaRequiredBackendHandler<T extends SQLStatement> imple
private final T sqlStatement;
- private final BackendConnection backendConnection;
+ private final ConnectionSession connectionSession;
@Override
public final ResponseHeader execute() throws SQLException {
- String schemaName = getSchemaName(backendConnection, sqlStatement);
+ String schemaName = getSchemaName(connectionSession, sqlStatement);
checkSchema(schemaName);
return execute(schemaName, sqlStatement);
}
protected abstract ResponseHeader execute(String schemaName, T sqlStatement) throws SQLException;
- private String getSchemaName(final BackendConnection backendConnection, final T sqlStatement) {
+ private String getSchemaName(final ConnectionSession connectionSession, final T sqlStatement) {
Optional<SchemaSegment> schemaFromSQL = sqlStatement instanceof FromSchemaAvailable ? ((FromSchemaAvailable) sqlStatement).getSchema() : Optional.empty();
- return schemaFromSQL.isPresent() ? schemaFromSQL.get().getIdentifier().getValue() : backendConnection.getSchemaName();
+ return schemaFromSQL.isPresent() ? schemaFromSQL.get().getIdentifier().getValue() : connectionSession.getSchemaName();
}
private void checkSchema(final String schemaName) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactory.java
index f1a83f4..228646c 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactory.java
@@ -31,8 +31,9 @@ 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.SQLStatementSchemaHolder;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.admin.DatabaseAdminBackendHandlerFactory;
import org.apache.shardingsphere.proxy.backend.text.data.DatabaseBackendHandlerFactory;
import org.apache.shardingsphere.proxy.backend.text.database.DatabaseOperateBackendHandlerFactory;
@@ -72,28 +73,28 @@ public final class TextProtocolBackendHandlerFactory {
*
* @param databaseType database type
* @param sql SQL to be executed
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @return text protocol backend handler
* @throws SQLException SQL exception
*/
@SuppressWarnings("unchecked")
- public static TextProtocolBackendHandler newInstance(final DatabaseType databaseType, final String sql, final BackendConnection backendConnection) throws SQLException {
+ public static TextProtocolBackendHandler newInstance(final DatabaseType databaseType, final String sql, final JDBCConnectionSession connectionSession) throws SQLException {
String trimSQL = SQLUtil.trimComment(sql);
if (Strings.isNullOrEmpty(trimSQL)) {
return new SkipBackendHandler(new EmptyStatement());
}
Optional<SQLParserRule> sqlParserRule = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getGlobalRuleMetaData().findSingleRule(SQLParserRule.class);
- SQLStatement sqlStatement = new ShardingSphereSQLParserEngine(getBackendDatabaseType(databaseType, backendConnection).getName(), sqlParserRule.orElse(null)).parse(sql, false);
+ SQLStatement sqlStatement = new ShardingSphereSQLParserEngine(getBackendDatabaseType(databaseType, connectionSession).getName(), sqlParserRule.orElse(null)).parse(sql, false);
checkUnsupportedSQLStatement(sqlStatement);
if (sqlStatement instanceof DistSQLStatement) {
- return DistSQLBackendHandlerFactory.newInstance(databaseType, (DistSQLStatement) sqlStatement, backendConnection);
+ return DistSQLBackendHandlerFactory.newInstance(databaseType, (DistSQLStatement) sqlStatement, connectionSession);
}
- Optional<TextProtocolBackendHandler> backendHandler = DatabaseAdminBackendHandlerFactory.newInstance(databaseType, sqlStatement, backendConnection, sql);
+ Optional<TextProtocolBackendHandler> backendHandler = DatabaseAdminBackendHandlerFactory.newInstance(databaseType, sqlStatement, connectionSession, sql);
if (backendHandler.isPresent()) {
return backendHandler.get();
}
SQLStatementContext<?> sqlStatementContext = SQLStatementContextFactory.newInstance(
- ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaDataMap(), Collections.emptyList(), sqlStatement, backendConnection.getDefaultSchemaName());
+ ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaDataMap(), Collections.emptyList(), sqlStatement, connectionSession.getDefaultSchemaName());
// TODO optimize SQLStatementSchemaHolder
if (sqlStatementContext instanceof TableAvailable) {
((TableAvailable) sqlStatementContext).getTablesContext().getSchemaName().ifPresent(SQLStatementSchemaHolder::set);
@@ -102,21 +103,21 @@ public final class TextProtocolBackendHandlerFactory {
if (extraHandler.isPresent()) {
return extraHandler.get();
}
- String schemaName = backendConnection.getSchemaName();
+ String schemaName = connectionSession.getSchemaName();
SQLCheckEngine.check(sqlStatement, Collections.emptyList(),
- getRules(schemaName), schemaName, ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaDataMap(), backendConnection.getGrantee());
+ getRules(schemaName), schemaName, ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaDataMap(), connectionSession.getGrantee());
if (sqlStatement instanceof TCLStatement) {
- return TransactionBackendHandlerFactory.newInstance((SQLStatementContext<TCLStatement>) sqlStatementContext, sql, backendConnection);
+ return TransactionBackendHandlerFactory.newInstance((SQLStatementContext<TCLStatement>) sqlStatementContext, sql, connectionSession);
}
if (sqlStatement instanceof CreateDatabaseStatement || sqlStatement instanceof DropDatabaseStatement) {
- return DatabaseOperateBackendHandlerFactory.newInstance(sqlStatement, backendConnection);
+ return DatabaseOperateBackendHandlerFactory.newInstance(sqlStatement, connectionSession);
}
- backendHandler = DatabaseAdminBackendHandlerFactory.newInstance(databaseType, sqlStatement, backendConnection);
- return backendHandler.orElseGet(() -> DatabaseBackendHandlerFactory.newInstance(sqlStatementContext, sql, backendConnection));
+ backendHandler = DatabaseAdminBackendHandlerFactory.newInstance(databaseType, sqlStatement, connectionSession);
+ return backendHandler.orElseGet(() -> DatabaseBackendHandlerFactory.newInstance(sqlStatementContext, sql, connectionSession));
}
- private static DatabaseType getBackendDatabaseType(final DatabaseType defaultDatabaseType, final BackendConnection backendConnection) {
- String schemaName = backendConnection.getSchemaName();
+ private static DatabaseType getBackendDatabaseType(final DatabaseType defaultDatabaseType, final ConnectionSession connectionSession) {
+ String schemaName = connectionSession.getSchemaName();
return Strings.isNullOrEmpty(schemaName) || !ProxyContext.getInstance().schemaExists(schemaName)
? defaultDatabaseType : ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData(schemaName).getResource().getDatabaseType();
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseAdminBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseAdminBackendHandlerFactory.java
index 4177fbf..19bd777 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseAdminBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseAdminBackendHandlerFactory.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.backend.text.admin;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseAdminExecutor;
import org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseAdminExecutorFactory;
@@ -48,16 +48,16 @@ public final class DatabaseAdminBackendHandlerFactory {
*
* @param databaseType database type
* @param sqlStatement SQL statement
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @return new instance of database admin backend handler
*/
- public static Optional<TextProtocolBackendHandler> newInstance(final DatabaseType databaseType, final SQLStatement sqlStatement, final BackendConnection backendConnection) {
+ public static Optional<TextProtocolBackendHandler> newInstance(final DatabaseType databaseType, final SQLStatement sqlStatement, final JDBCConnectionSession connectionSession) {
Optional<DatabaseAdminExecutorFactory> executorFactory = TypedSPIRegistry.findRegisteredService(DatabaseAdminExecutorFactory.class, databaseType.getName(), new Properties());
if (!executorFactory.isPresent()) {
return Optional.empty();
}
Optional<DatabaseAdminExecutor> executor = executorFactory.get().newInstance(sqlStatement);
- return executor.map(optional -> createTextProtocolBackendHandler(sqlStatement, backendConnection, optional));
+ return executor.map(optional -> createTextProtocolBackendHandler(sqlStatement, connectionSession, optional));
}
/**
@@ -65,22 +65,22 @@ public final class DatabaseAdminBackendHandlerFactory {
*
* @param databaseType database type
* @param sqlStatement SQL statement
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @param sql SQL being executed
* @return new instance of database admin backend handler
*/
public static Optional<TextProtocolBackendHandler> newInstance(final DatabaseType databaseType, final SQLStatement sqlStatement,
- final BackendConnection backendConnection, final String sql) {
+ final JDBCConnectionSession connectionSession, final String sql) {
Optional<DatabaseAdminExecutorFactory> executorFactory = TypedSPIRegistry.findRegisteredService(DatabaseAdminExecutorFactory.class, databaseType.getName(), new Properties());
if (!executorFactory.isPresent()) {
return Optional.empty();
}
Optional<DatabaseAdminExecutor> executor = executorFactory.get().newInstance(sqlStatement, sql);
- return executor.map(optional -> createTextProtocolBackendHandler(sqlStatement, backendConnection, optional));
+ return executor.map(optional -> createTextProtocolBackendHandler(sqlStatement, connectionSession, optional));
}
- private static TextProtocolBackendHandler createTextProtocolBackendHandler(final SQLStatement sqlStatement, final BackendConnection backendConnection, final DatabaseAdminExecutor executor) {
+ private static TextProtocolBackendHandler createTextProtocolBackendHandler(final SQLStatement sqlStatement, final JDBCConnectionSession connectionSession, final DatabaseAdminExecutor executor) {
return executor instanceof DatabaseAdminQueryExecutor
- ? new DatabaseAdminQueryBackendHandler(backendConnection, (DatabaseAdminQueryExecutor) executor) : new DatabaseAdminUpdateBackendHandler(backendConnection, sqlStatement, executor);
+ ? new DatabaseAdminQueryBackendHandler(connectionSession, (DatabaseAdminQueryExecutor) executor) : new DatabaseAdminUpdateBackendHandler(connectionSession, sqlStatement, executor);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseAdminQueryBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseAdminQueryBackendHandler.java
index 9442eb1..bbef040 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseAdminQueryBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseAdminQueryBackendHandler.java
@@ -21,12 +21,12 @@ import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryResultMetaData;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
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.QueryResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeaderBuilder;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseAdminQueryExecutor;
@@ -42,7 +42,7 @@ import java.util.List;
@RequiredArgsConstructor
public final class DatabaseAdminQueryBackendHandler implements TextProtocolBackendHandler {
- private final BackendConnection backendConnection;
+ private final ConnectionSession connectionSession;
private final DatabaseAdminQueryExecutor executor;
@@ -52,7 +52,7 @@ public final class DatabaseAdminQueryBackendHandler implements TextProtocolBacke
@Override
public ResponseHeader execute() throws SQLException {
- executor.execute(backendConnection);
+ executor.execute(connectionSession);
queryResultMetaData = executor.getQueryResultMetaData();
mergedResult = executor.getMergedResult();
return new QueryResponseHeader(createResponseHeader());
@@ -60,7 +60,7 @@ public final class DatabaseAdminQueryBackendHandler implements TextProtocolBacke
private List<QueryHeader> createResponseHeader() throws SQLException {
List<QueryHeader> result = new ArrayList<>(queryResultMetaData.getColumnCount());
- ShardingSphereMetaData metaData = null == backendConnection.getSchemaName() ? null : ProxyContext.getInstance().getMetaData(backendConnection.getSchemaName());
+ ShardingSphereMetaData metaData = null == connectionSession.getSchemaName() ? null : ProxyContext.getInstance().getMetaData(connectionSession.getSchemaName());
for (int columnIndex = 1; columnIndex <= queryResultMetaData.getColumnCount(); columnIndex++) {
result.add(QueryHeaderBuilder.build(queryResultMetaData, metaData, columnIndex));
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseAdminUpdateBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseAdminUpdateBackendHandler.java
index e9a73f4..cd1155f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseAdminUpdateBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseAdminUpdateBackendHandler.java
@@ -18,9 +18,9 @@
package org.apache.shardingsphere.proxy.backend.text.admin;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
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.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseAdminExecutor;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
@@ -33,7 +33,7 @@ import java.sql.SQLException;
@RequiredArgsConstructor
public final class DatabaseAdminUpdateBackendHandler implements TextProtocolBackendHandler {
- private final BackendConnection backendConnection;
+ private final ConnectionSession connectionSession;
private final SQLStatement sqlStatement;
@@ -41,7 +41,7 @@ public final class DatabaseAdminUpdateBackendHandler implements TextProtocolBack
@Override
public ResponseHeader execute() throws SQLException {
- executor.execute(backendConnection);
+ executor.execute(connectionSession);
return new UpdateResponseHeader(sqlStatement);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/executor/AbstractDatabaseMetadataExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/executor/AbstractDatabaseMetadataExecutor.java
index 40541cd..e4838c8 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/executor/AbstractDatabaseMetadataExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/executor/AbstractDatabaseMetadataExecutor.java
@@ -27,9 +27,9 @@ import org.apache.shardingsphere.infra.executor.sql.execute.result.query.type.me
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.infra.merge.result.impl.transparent.TransparentMergedResult;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.exception.DatabaseNotExistedException;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.admin.FunctionWithException;
import javax.sql.DataSource;
@@ -64,7 +64,7 @@ public abstract class AbstractDatabaseMetadataExecutor implements DatabaseAdminQ
private final LinkedList<Map<String, Object>> rows = new LinkedList<>();
@Override
- public final void execute(final BackendConnection backendConnection) throws SQLException {
+ public final void execute(final ConnectionSession connectionSession) throws SQLException {
List<String> schemaNames = getSchemaNames();
for (String schemaName : schemaNames) {
initSchemaData(schemaName);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/executor/DatabaseAdminExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/executor/DatabaseAdminExecutor.java
index 6f7ae19..127ae4e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/executor/DatabaseAdminExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/executor/DatabaseAdminExecutor.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.proxy.backend.text.admin.executor;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import java.sql.SQLException;
@@ -29,8 +29,8 @@ public interface DatabaseAdminExecutor {
/**
* Execute.
*
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @throws SQLException SQLException
*/
- void execute(BackendConnection backendConnection) throws SQLException;
+ void execute(ConnectionSession connectionSession) throws SQLException;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowConnectionIdExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowConnectionIdExecutor.java
index 4b25934..67a04b2 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowConnectionIdExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowConnectionIdExecutor.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryRe
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.raw.metadata.RawQueryResultColumnMetaData;
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.raw.metadata.RawQueryResultMetaData;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseAdminQueryExecutor;
import org.apache.shardingsphere.sharding.merge.dal.common.SingleLocalDataMergedResult;
@@ -40,8 +40,8 @@ public final class ShowConnectionIdExecutor implements DatabaseAdminQueryExecuto
private MergedResult mergedResult;
@Override
- public void execute(final BackendConnection backendConnection) {
- mergedResult = new SingleLocalDataMergedResult(Collections.singleton(backendConnection.getConnectionId()));
+ public void execute(final ConnectionSession connectionSession) {
+ mergedResult = new SingleLocalDataMergedResult(Collections.singleton(connectionSession.getConnectionId()));
}
@Override
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowCreateDatabaseExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowCreateDatabaseExecutor.java
index 009cb50..05ce187 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowCreateDatabaseExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowCreateDatabaseExecutor.java
@@ -28,8 +28,8 @@ import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.ra
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.type.memory.row.MemoryQueryResultDataRow;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.infra.merge.result.impl.transparent.TransparentMergedResult;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseAdminQueryExecutor;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowCreateDatabaseStatement;
@@ -58,7 +58,7 @@ public final class ShowCreateDatabaseExecutor implements DatabaseAdminQueryExecu
private MergedResult mergedResult;
@Override
- public void execute(final BackendConnection backendConnection) {
+ public void execute(final ConnectionSession connectionSession) {
queryResultMetaData = createQueryResultMetaData();
mergedResult = new TransparentMergedResult(getQueryResult(showCreateDatabaseStatement.getSchema()));
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowCurrentDatabaseExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowCurrentDatabaseExecutor.java
index ec1b80c..10d5077 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowCurrentDatabaseExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowCurrentDatabaseExecutor.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryRe
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.raw.metadata.RawQueryResultColumnMetaData;
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.raw.metadata.RawQueryResultMetaData;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseAdminQueryExecutor;
import org.apache.shardingsphere.sharding.merge.dal.common.SingleLocalDataMergedResult;
@@ -40,8 +40,8 @@ public final class ShowCurrentDatabaseExecutor implements DatabaseAdminQueryExec
private MergedResult mergedResult;
@Override
- public void execute(final BackendConnection backendConnection) {
- mergedResult = new SingleLocalDataMergedResult(Collections.singleton(backendConnection.getSchemaName()));
+ public void execute(final ConnectionSession connectionSession) {
+ mergedResult = new SingleLocalDataMergedResult(Collections.singleton(connectionSession.getSchemaName()));
}
@Override
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowCurrentUserExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowCurrentUserExecutor.java
index fb98da7..3cf11d8 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowCurrentUserExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowCurrentUserExecutor.java
@@ -26,8 +26,8 @@ import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseAdminQueryExecutor;
import org.apache.shardingsphere.sharding.merge.dal.common.SingleLocalDataMergedResult;
@@ -47,10 +47,10 @@ public final class ShowCurrentUserExecutor implements DatabaseAdminQueryExecutor
private MergedResult mergedResult;
@Override
- public void execute(final BackendConnection backendConnection) {
+ public void execute(final ConnectionSession connectionSession) {
Collection<ShardingSphereRule> rules = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getGlobalRuleMetaData().getRules();
Optional<Grantee> grantee = rules.stream().filter(each -> each instanceof AuthorityRule)
- .map(each -> ((AuthorityRule) each).findUser(backendConnection.getGrantee())).filter(Optional::isPresent)
+ .map(each -> ((AuthorityRule) each).findUser(connectionSession.getGrantee())).filter(Optional::isPresent)
.map(Optional::get).map(ShardingSphereUser::getGrantee).findFirst();
mergedResult = new SingleLocalDataMergedResult(Collections.singleton(grantee.isPresent() ? grantee.get().toString() : ""));
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowDatabasesExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowDatabasesExecutor.java
index 7253943..70143c2 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowDatabasesExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowDatabasesExecutor.java
@@ -25,8 +25,8 @@ import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.ra
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.raw.metadata.RawQueryResultMetaData;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseAdminQueryExecutor;
import org.apache.shardingsphere.sharding.merge.dal.common.SingleLocalDataMergedResult;
import org.apache.shardingsphere.sql.parser.sql.common.util.SQLUtil;
@@ -50,14 +50,14 @@ public final class ShowDatabasesExecutor implements DatabaseAdminQueryExecutor {
private MergedResult mergedResult;
@Override
- public void execute(final BackendConnection backendConnection) {
- mergedResult = new SingleLocalDataMergedResult(getSchemaNames(backendConnection));
+ public void execute(final ConnectionSession connectionSession) {
+ mergedResult = new SingleLocalDataMergedResult(getSchemaNames(connectionSession));
}
- private Collection<Object> getSchemaNames(final BackendConnection backendConnection) {
+ private Collection<Object> getSchemaNames(final ConnectionSession connectionSession) {
Collection<Object> result = new LinkedList<>();
for (String each : ProxyContext.getInstance().getAllSchemaNames()) {
- if (checkLikePattern(each) && SQLCheckEngine.check(each, getRules(each), backendConnection.getGrantee())) {
+ if (checkLikePattern(each) && SQLCheckEngine.check(each, getRules(each), connectionSession.getGrantee())) {
result.add(each);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowFunctionStatusExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowFunctionStatusExecutor.java
index e8dee57..8629cc9 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowFunctionStatusExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowFunctionStatusExecutor.java
@@ -26,7 +26,7 @@ import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.ra
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.raw.type.RawMemoryQueryResult;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.infra.merge.result.impl.transparent.TransparentMergedResult;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseAdminQueryExecutor;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowFunctionStatusStatement;
@@ -49,7 +49,7 @@ public final class ShowFunctionStatusExecutor implements DatabaseAdminQueryExecu
private MergedResult mergedResult;
@Override
- public void execute(final BackendConnection backendConnection) {
+ public void execute(final ConnectionSession connectionSession) {
queryResultMetaData = createQueryResultMetaData();
mergedResult = new TransparentMergedResult(getQueryResult());
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowProcedureStatusExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowProcedureStatusExecutor.java
index 7af5eef..e0b3e34 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowProcedureStatusExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowProcedureStatusExecutor.java
@@ -26,7 +26,7 @@ import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.ra
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.raw.type.RawMemoryQueryResult;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.infra.merge.result.impl.transparent.TransparentMergedResult;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseAdminQueryExecutor;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowProcedureStatusStatement;
@@ -49,7 +49,7 @@ public final class ShowProcedureStatusExecutor implements DatabaseAdminQueryExec
private MergedResult mergedResult;
@Override
- public void execute(final BackendConnection backendConnection) {
+ public void execute(final ConnectionSession connectionSession) {
queryResultMetaData = createQueryResultMetaData();
mergedResult = new TransparentMergedResult(getQueryResult());
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowProcessListExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowProcessListExecutor.java
index b29d4c4..25abd12 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowProcessListExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowProcessListExecutor.java
@@ -33,7 +33,7 @@ import org.apache.shardingsphere.infra.merge.result.impl.transparent.Transparent
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.process.event.ShowProcessListRequestEvent;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.process.event.ShowProcessListResponseEvent;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseAdminQueryExecutor;
import java.sql.Types;
@@ -72,7 +72,7 @@ public final class ShowProcessListExecutor implements DatabaseAdminQueryExecutor
}
@Override
- public void execute(final BackendConnection backendConnection) {
+ public void execute(final ConnectionSession connectionSession) {
queryResultMetaData = createQueryResultMetaData();
mergedResult = new TransparentMergedResult(getQueryResult());
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesExecutor.java
index 3a38062..3123258 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesExecutor.java
@@ -27,8 +27,8 @@ import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.ra
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.type.memory.row.MemoryQueryResultDataRow;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.infra.merge.result.impl.transparent.TransparentMergedResult;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseAdminQueryExecutor;
import org.apache.shardingsphere.sql.parser.sql.common.util.SQLUtil;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowTablesStatement;
@@ -57,9 +57,9 @@ public final class ShowTablesExecutor implements DatabaseAdminQueryExecutor {
private MergedResult mergedResult;
@Override
- public void execute(final BackendConnection backendConnection) {
- queryResultMetaData = createQueryResultMetaData(backendConnection.getSchemaName());
- mergedResult = new TransparentMergedResult(getQueryResult(backendConnection.getSchemaName()));
+ public void execute(final ConnectionSession connectionSession) {
+ queryResultMetaData = createQueryResultMetaData(connectionSession.getSchemaName());
+ mergedResult = new TransparentMergedResult(getQueryResult(connectionSession.getSchemaName()));
}
private QueryResult getQueryResult(final String schemaName) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesStatusExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesStatusExecutor.java
index 6526b6b..cfd5cbf 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesStatusExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesStatusExecutor.java
@@ -27,8 +27,8 @@ import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.ra
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.type.memory.row.MemoryQueryResultDataRow;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.infra.merge.result.impl.transparent.TransparentMergedResult;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseAdminQueryExecutor;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowTableStatusStatement;
@@ -53,9 +53,9 @@ public final class ShowTablesStatusExecutor implements DatabaseAdminQueryExecuto
private MergedResult mergedResult;
@Override
- public void execute(final BackendConnection backendConnection) {
+ public void execute(final ConnectionSession connectionSession) {
queryResultMetaData = createQueryResultMetaData();
- mergedResult = new TransparentMergedResult(getQueryResult(backendConnection.getSchemaName()));
+ mergedResult = new TransparentMergedResult(getQueryResult(connectionSession.getSchemaName()));
}
private QueryResult getQueryResult(final String schemaName) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowVersionExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowVersionExecutor.java
index 158fbb4..776b4b5 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowVersionExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowVersionExecutor.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryRe
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.raw.metadata.RawQueryResultColumnMetaData;
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.raw.metadata.RawQueryResultMetaData;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseAdminQueryExecutor;
import org.apache.shardingsphere.sharding.merge.dal.common.SingleLocalDataMergedResult;
@@ -41,7 +41,7 @@ public final class ShowVersionExecutor implements DatabaseAdminQueryExecutor {
private MergedResult mergedResult;
@Override
- public void execute(final BackendConnection backendConnection) {
+ public void execute(final ConnectionSession connectionSession) {
mergedResult = new SingleLocalDataMergedResult(Collections.singleton(MySQLServerInfo.getServerVersion()));
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/UseDatabaseExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/UseDatabaseExecutor.java
index f30a811..d9af61b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/UseDatabaseExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/UseDatabaseExecutor.java
@@ -20,9 +20,9 @@ package org.apache.shardingsphere.proxy.backend.text.admin.mysql.executor;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.executor.check.SQLCheckEngine;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.exception.UnknownDatabaseException;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.admin.executor.DatabaseAdminExecutor;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dal.UseStatement;
import org.apache.shardingsphere.sql.parser.sql.common.util.SQLUtil;
@@ -40,12 +40,12 @@ public final class UseDatabaseExecutor implements DatabaseAdminExecutor {
private final UseStatement useStatement;
@Override
- public void execute(final BackendConnection backendConnection) {
+ public void execute(final ConnectionSession connectionSession) {
String schemaName = SQLUtil.getExactlyValue(useStatement.getSchema());
- if (!ProxyContext.getInstance().schemaExists(schemaName) && SQLCheckEngine.check(schemaName, getRules(schemaName), backendConnection.getGrantee())) {
+ if (!ProxyContext.getInstance().schemaExists(schemaName) && SQLCheckEngine.check(schemaName, getRules(schemaName), connectionSession.getGrantee())) {
throw new UnknownDatabaseException(schemaName);
}
- backendConnection.setCurrentSchema(schemaName);
+ connectionSession.setCurrentSchema(schemaName);
}
private Collection<ShardingSphereRule> getRules(final String schemaName) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/data/DatabaseBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/data/DatabaseBackendHandlerFactory.java
index 0e9aa9f..9331555 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/data/DatabaseBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/data/DatabaseBackendHandlerFactory.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.backend.text.data;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.data.impl.BroadcastDatabaseBackendHandler;
import org.apache.shardingsphere.proxy.backend.text.data.impl.SchemaAssignedDatabaseBackendHandler;
import org.apache.shardingsphere.proxy.backend.text.data.impl.UnicastDatabaseBackendHandler;
@@ -41,17 +41,17 @@ public final class DatabaseBackendHandlerFactory {
*
* @param sqlStatementContext SQL statement context
* @param sql SQL
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @return database backend handler
*/
- public static DatabaseBackendHandler newInstance(final SQLStatementContext<?> sqlStatementContext, final String sql, final BackendConnection backendConnection) {
+ public static DatabaseBackendHandler newInstance(final SQLStatementContext<?> sqlStatementContext, final String sql, final JDBCConnectionSession connectionSession) {
SQLStatement sqlStatement = sqlStatementContext.getSqlStatement();
if (sqlStatement instanceof SetStatement || sqlStatement instanceof DCLStatement) {
- return new BroadcastDatabaseBackendHandler(sqlStatementContext, sql, backendConnection);
+ return new BroadcastDatabaseBackendHandler(sqlStatementContext, sql, connectionSession);
}
if (sqlStatement instanceof DALStatement || (sqlStatement instanceof SelectStatement && null == ((SelectStatement) sqlStatement).getFrom())) {
- return new UnicastDatabaseBackendHandler(sqlStatementContext, sql, backendConnection);
+ return new UnicastDatabaseBackendHandler(sqlStatementContext, sql, connectionSession);
}
- return new SchemaAssignedDatabaseBackendHandler(sqlStatementContext, sql, backendConnection);
+ return new SchemaAssignedDatabaseBackendHandler(sqlStatementContext, sql, connectionSession);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/data/impl/BroadcastDatabaseBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/data/impl/BroadcastDatabaseBackendHandler.java
index 84131a6..05ee7a3 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/data/impl/BroadcastDatabaseBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/data/impl/BroadcastDatabaseBackendHandler.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.backend.text.data.impl;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngineFactory;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.exception.DatabaseNotExistedException;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
@@ -44,19 +44,19 @@ public final class BroadcastDatabaseBackendHandler implements DatabaseBackendHan
private final String sql;
- private final BackendConnection backendConnection;
+ private final JDBCConnectionSession connectionSession;
@Override
public ResponseHeader execute() throws SQLException {
List<String> schemaNames = getSchemaNamesWithDataSource().orElseThrow(DatabaseNotExistedException::new);
- String originalSchema = backendConnection.getSchemaName();
+ String originalSchema = connectionSession.getSchemaName();
try {
for (String each : schemaNames) {
- backendConnection.setCurrentSchema(each);
- databaseCommunicationEngineFactory.newTextProtocolInstance(sqlStatementContext, sql, backendConnection).execute();
+ connectionSession.setCurrentSchema(each);
+ databaseCommunicationEngineFactory.newTextProtocolInstance(sqlStatementContext, sql, connectionSession).execute();
}
} finally {
- backendConnection.setCurrentSchema(originalSchema);
+ connectionSession.setCurrentSchema(originalSchema);
}
return new UpdateResponseHeader(sqlStatementContext.getSqlStatement());
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/data/impl/SchemaAssignedDatabaseBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/data/impl/SchemaAssignedDatabaseBackendHandler.java
index 5e4627c..20fd12d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/data/impl/SchemaAssignedDatabaseBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/data/impl/SchemaAssignedDatabaseBackendHandler.java
@@ -21,7 +21,7 @@ import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
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.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.exception.RuleNotExistedException;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
@@ -42,16 +42,16 @@ public final class SchemaAssignedDatabaseBackendHandler implements DatabaseBacke
private final String sql;
- private final BackendConnection backendConnection;
+ private final JDBCConnectionSession connectionSession;
private DatabaseCommunicationEngine databaseCommunicationEngine;
@Override
public ResponseHeader execute() throws SQLException {
- if (!ProxyContext.getInstance().getMetaData(backendConnection.getSchemaName()).isComplete()) {
+ if (!ProxyContext.getInstance().getMetaData(connectionSession.getSchemaName()).isComplete()) {
throw new RuleNotExistedException();
}
- databaseCommunicationEngine = databaseCommunicationEngineFactory.newTextProtocolInstance(sqlStatementContext, sql, backendConnection);
+ databaseCommunicationEngine = databaseCommunicationEngineFactory.newTextProtocolInstance(sqlStatementContext, sql, connectionSession);
return databaseCommunicationEngine.execute();
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/data/impl/UnicastDatabaseBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/data/impl/UnicastDatabaseBackendHandler.java
index cb21508..c579e50 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/data/impl/UnicastDatabaseBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/data/impl/UnicastDatabaseBackendHandler.java
@@ -21,7 +21,7 @@ import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
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.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.exception.NoDatabaseSelectedException;
import org.apache.shardingsphere.proxy.backend.exception.RuleNotExistedException;
@@ -44,23 +44,23 @@ public final class UnicastDatabaseBackendHandler implements DatabaseBackendHandl
private final String sql;
- private final BackendConnection backendConnection;
+ private final JDBCConnectionSession connectionSession;
private DatabaseCommunicationEngine databaseCommunicationEngine;
@Override
public ResponseHeader execute() throws SQLException {
- String originSchema = backendConnection.getSchemaName();
+ String originSchema = connectionSession.getSchemaName();
String schemaName = null == originSchema ? getFirstSchemaName() : originSchema;
if (!ProxyContext.getInstance().getMetaData(schemaName).hasDataSource()) {
throw new RuleNotExistedException();
}
try {
- backendConnection.setCurrentSchema(schemaName);
- databaseCommunicationEngine = databaseCommunicationEngineFactory.newTextProtocolInstance(sqlStatementContext, sql, backendConnection);
+ connectionSession.setCurrentSchema(schemaName);
+ databaseCommunicationEngine = databaseCommunicationEngineFactory.newTextProtocolInstance(sqlStatementContext, sql, connectionSession);
return databaseCommunicationEngine.execute();
} finally {
- backendConnection.setCurrentSchema(originSchema);
+ connectionSession.setCurrentSchema(originSchema);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/database/DatabaseOperateBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/database/DatabaseOperateBackendHandlerFactory.java
index 34e36c5..85c36e4 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/database/DatabaseOperateBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/database/DatabaseOperateBackendHandlerFactory.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.proxy.backend.text.database;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateDatabaseStatement;
@@ -37,20 +37,20 @@ public final class DatabaseOperateBackendHandlerFactory {
* Create new instance of database operate backend handler.
*
* @param sqlStatement SQL statement
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @return database operate backend handler
* @throws SQLException SQL exception
*/
- public static TextProtocolBackendHandler newInstance(final SQLStatement sqlStatement, final BackendConnection backendConnection) throws SQLException {
- return createBackendHandler(sqlStatement, backendConnection);
+ public static TextProtocolBackendHandler newInstance(final SQLStatement sqlStatement, final JDBCConnectionSession connectionSession) throws SQLException {
+ return createBackendHandler(sqlStatement, connectionSession);
}
- private static TextProtocolBackendHandler createBackendHandler(final SQLStatement sqlStatement, final BackendConnection backendConnection) {
+ private static TextProtocolBackendHandler createBackendHandler(final SQLStatement sqlStatement, final JDBCConnectionSession connectionSession) {
if (sqlStatement instanceof CreateDatabaseStatement) {
return new CreateDatabaseBackendHandler((CreateDatabaseStatement) sqlStatement);
}
if (sqlStatement instanceof DropDatabaseStatement) {
- return new DropDatabaseBackendHandler((DropDatabaseStatement) sqlStatement, backendConnection);
+ return new DropDatabaseBackendHandler((DropDatabaseStatement) sqlStatement, connectionSession);
}
throw new UnsupportedOperationException(sqlStatement.getClass().getCanonicalName());
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/database/DropDatabaseBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/database/DropDatabaseBackendHandler.java
index 108302b..0fbe27b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/database/DropDatabaseBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/database/DropDatabaseBackendHandler.java
@@ -19,11 +19,11 @@ package org.apache.shardingsphere.proxy.backend.text.database;
import com.google.common.base.Strings;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.exception.DBDropExistsException;
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.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropDatabaseStatement;
@@ -35,13 +35,13 @@ public final class DropDatabaseBackendHandler implements TextProtocolBackendHand
private final DropDatabaseStatement sqlStatement;
- private final BackendConnection backendConnection;
+ private final ConnectionSession connectionSession;
@Override
public ResponseHeader execute() {
check(sqlStatement);
if (isDropCurrentDatabase(sqlStatement.getDatabaseName())) {
- backendConnection.setCurrentSchema(null);
+ connectionSession.setCurrentSchema(null);
}
ProxyContext.getInstance().getContextManager().deleteSchema(sqlStatement.getDatabaseName());
ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaDataPersistService().ifPresent(
@@ -56,6 +56,6 @@ public final class DropDatabaseBackendHandler implements TextProtocolBackendHand
}
private boolean isDropCurrentDatabase(final String databaseName) {
- return !Strings.isNullOrEmpty(backendConnection.getSchemaName()) && backendConnection.getSchemaName().equals(databaseName);
+ return !Strings.isNullOrEmpty(connectionSession.getSchemaName()) && connectionSession.getSchemaName().equals(databaseName);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactory.java
index 228ed83..7b1eec2 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactory.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
import org.apache.shardingsphere.distsql.parser.statement.rdl.RDLStatement;
import org.apache.shardingsphere.distsql.parser.statement.rql.RQLStatement;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.RALBackendHandlerFactory;
import org.apache.shardingsphere.proxy.backend.text.distsql.rdl.RDLBackendHandlerFactory;
@@ -44,19 +44,19 @@ public final class DistSQLBackendHandlerFactory {
*
* @param databaseType database type
* @param sqlStatement dist SQL statement
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @return text protocol backend handler
* @throws SQLException SQL exception
*/
- public static TextProtocolBackendHandler newInstance(final DatabaseType databaseType, final DistSQLStatement sqlStatement, final BackendConnection backendConnection) throws SQLException {
+ public static TextProtocolBackendHandler newInstance(final DatabaseType databaseType, final DistSQLStatement sqlStatement, final JDBCConnectionSession connectionSession) throws SQLException {
if (sqlStatement instanceof RQLStatement) {
- return RQLBackendHandlerFactory.newInstance((RQLStatement) sqlStatement, backendConnection);
+ return RQLBackendHandlerFactory.newInstance((RQLStatement) sqlStatement, connectionSession);
}
if (sqlStatement instanceof RDLStatement) {
- return RDLBackendHandlerFactory.newInstance(databaseType, (RDLStatement) sqlStatement, backendConnection);
+ return RDLBackendHandlerFactory.newInstance(databaseType, (RDLStatement) sqlStatement, connectionSession);
}
if (sqlStatement instanceof RALStatement) {
- return RALBackendHandlerFactory.newInstance(databaseType, (RALStatement) sqlStatement, backendConnection);
+ return RALBackendHandlerFactory.newInstance(databaseType, (RALStatement) sqlStatement, connectionSession);
}
throw new UnsupportedTypeException(sqlStatement.getClass().getCanonicalName());
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandlerFactory.java
index 88e9f4f..bea581f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandlerFactory.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.distsql.parser.statement.ral.QueryableRALStatem
import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.UpdatableRALStatement;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.advanced.AdvancedDistSQLBackendHandlerFactory;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.query.QueryableRALBackendHandlerFactory;
@@ -45,22 +45,22 @@ public final class RALBackendHandlerFactory {
*
* @param databaseType database type
* @param sqlStatement RAL statement
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @return RAL backend handler
* @throws SQLException SQL exception
*/
- public static TextProtocolBackendHandler newInstance(final DatabaseType databaseType, final RALStatement sqlStatement, final BackendConnection backendConnection) throws SQLException {
+ public static TextProtocolBackendHandler newInstance(final DatabaseType databaseType, final RALStatement sqlStatement, final JDBCConnectionSession connectionSession) throws SQLException {
if (sqlStatement instanceof QueryableRALStatement) {
- return QueryableRALBackendHandlerFactory.newInstance((QueryableRALStatement) sqlStatement, backendConnection);
+ return QueryableRALBackendHandlerFactory.newInstance((QueryableRALStatement) sqlStatement, connectionSession);
}
if (sqlStatement instanceof UpdatableRALStatement) {
return UpdatableRALBackendHandlerFactory.newInstance((UpdatableRALStatement) sqlStatement);
}
if (sqlStatement instanceof CommonDistSQLStatement) {
- return CommonDistSQLBackendHandlerFactory.newInstance((CommonDistSQLStatement) sqlStatement, backendConnection);
+ return CommonDistSQLBackendHandlerFactory.newInstance((CommonDistSQLStatement) sqlStatement, connectionSession);
}
if (sqlStatement instanceof AdvancedDistSQLStatement) {
- return AdvancedDistSQLBackendHandlerFactory.newInstance(databaseType, (AdvancedDistSQLStatement) sqlStatement, backendConnection);
+ return AdvancedDistSQLBackendHandlerFactory.newInstance(databaseType, (AdvancedDistSQLStatement) sqlStatement, connectionSession);
}
throw new UnsupportedOperationException(sqlStatement.getClass().getCanonicalName());
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advanced/AdvancedDistSQLBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advanced/AdvancedDistSQLBackendHandlerFactory.java
index 5b0370b..b3ebe1f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advanced/AdvancedDistSQLBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advanced/AdvancedDistSQLBackendHandlerFactory.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.distsql.parser.statement.ral.AdvancedDistSQLSta
import org.apache.shardingsphere.distsql.parser.statement.ral.advanced.parse.ParseStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.advanced.preview.PreviewStatement;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
import java.sql.SQLException;
@@ -40,15 +40,16 @@ public final class AdvancedDistSQLBackendHandlerFactory {
*
* @param databaseType database type
* @param sqlStatement advanced dist sql statement
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @return advanced dist sql backend handler
* @throws SQLException SQL exception
*/
- public static TextProtocolBackendHandler newInstance(final DatabaseType databaseType, final AdvancedDistSQLStatement sqlStatement, final BackendConnection backendConnection) throws SQLException {
+ public static TextProtocolBackendHandler newInstance(final DatabaseType databaseType, final AdvancedDistSQLStatement sqlStatement,
+ final JDBCConnectionSession connectionSession) throws SQLException {
if (sqlStatement instanceof PreviewStatement) {
- return new PreviewDistSQLBackendHandler((PreviewStatement) sqlStatement, backendConnection);
+ return new PreviewDistSQLBackendHandler((PreviewStatement) sqlStatement, connectionSession);
} else if (sqlStatement instanceof ParseStatement) {
- return new ParseDistSQLBackendHandler(databaseType, (ParseStatement) sqlStatement, backendConnection);
+ return new ParseDistSQLBackendHandler(databaseType, (ParseStatement) sqlStatement, connectionSession);
}
throw new UnsupportedTypeException(sqlStatement.getClass().getCanonicalName());
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advanced/ParseDistSQLBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advanced/ParseDistSQLBackendHandler.java
index 5cbc85f..933f43d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advanced/ParseDistSQLBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advanced/ParseDistSQLBackendHandler.java
@@ -25,11 +25,11 @@ import org.apache.shardingsphere.distsql.parser.statement.ral.advanced.parse.Par
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
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.QueryResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.sql.parser.exception.SQLParsingException;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
@@ -53,7 +53,7 @@ public final class ParseDistSQLBackendHandler implements TextProtocolBackendHand
private final ParseStatement previewStatement;
- private final BackendConnection backendConnection;
+ private final ConnectionSession connectionSession;
private final List<QueryHeader> queryHeaders = new ArrayList<>(1);
@@ -64,7 +64,7 @@ public final class ParseDistSQLBackendHandler implements TextProtocolBackendHand
Optional<SQLParserRule> sqlParserRule = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getGlobalRuleMetaData().findSingleRule(SQLParserRule.class);
SQLStatement sqlStatement;
try {
- sqlStatement = new ShardingSphereSQLParserEngine(getBackendDatabaseType(databaseType, backendConnection).getName(), sqlParserRule.orElse(null)).parse(previewStatement.getSql(), false);
+ sqlStatement = new ShardingSphereSQLParserEngine(getBackendDatabaseType(databaseType, connectionSession).getName(), sqlParserRule.orElse(null)).parse(previewStatement.getSql(), false);
} catch (SQLParsingException ex) {
throw new SQLParsingException("You have an error in your SQL syntax that you are parsed");
}
@@ -73,8 +73,8 @@ public final class ParseDistSQLBackendHandler implements TextProtocolBackendHand
return new QueryResponseHeader(queryHeaders);
}
- private static DatabaseType getBackendDatabaseType(final DatabaseType defaultDatabaseType, final BackendConnection backendConnection) {
- String schemaName = backendConnection.getSchemaName();
+ private static DatabaseType getBackendDatabaseType(final DatabaseType defaultDatabaseType, final ConnectionSession connectionSession) {
+ String schemaName = connectionSession.getSchemaName();
return Strings.isNullOrEmpty(schemaName) || !ProxyContext.getInstance().schemaExists(schemaName)
? defaultDatabaseType : ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData(schemaName).getResource().getDatabaseType();
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advanced/PreviewDistSQLBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advanced/PreviewDistSQLBackendHandler.java
index 11f55af..301d0b3 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advanced/PreviewDistSQLBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advanced/PreviewDistSQLBackendHandler.java
@@ -32,12 +32,12 @@ import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
import org.apache.shardingsphere.proxy.backend.communication.SQLStatementSchemaHolder;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.exception.RuleNotExistedException;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
@@ -59,7 +59,7 @@ public final class PreviewDistSQLBackendHandler implements TextProtocolBackendHa
private final PreviewStatement previewStatement;
- private final BackendConnection backendConnection;
+ private final ConnectionSession connectionSession;
private final KernelProcessor kernelProcessor = new KernelProcessor();
@@ -70,7 +70,7 @@ public final class PreviewDistSQLBackendHandler implements TextProtocolBackendHa
@Override
public ResponseHeader execute() {
MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
- String defaultSchemaName = backendConnection.getDefaultSchemaName();
+ String defaultSchemaName = connectionSession.getDefaultSchemaName();
String databaseType = DatabaseTypeRegistry.getTrunkDatabaseTypeName(metaDataContexts.getMetaData(defaultSchemaName).getResource().getDatabaseType());
Optional<SQLParserRule> sqlParserRule = metaDataContexts.getGlobalRuleMetaData().findSingleRule(SQLParserRule.class);
SQLStatement sqlStatement = new ShardingSphereSQLParserEngine(databaseType, sqlParserRule.get()).parse(previewStatement.getSql(), false);
@@ -79,7 +79,7 @@ public final class PreviewDistSQLBackendHandler implements TextProtocolBackendHa
if (sqlStatementContext instanceof TableAvailable) {
((TableAvailable) sqlStatementContext).getTablesContext().getSchemaName().ifPresent(SQLStatementSchemaHolder::set);
}
- ShardingSphereMetaData metaData = ProxyContext.getInstance().getMetaData(backendConnection.getSchemaName());
+ ShardingSphereMetaData metaData = ProxyContext.getInstance().getMetaData(connectionSession.getSchemaName());
if (!metaData.isComplete()) {
throw new RuleNotExistedException();
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/CommonDistSQLBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/CommonDistSQLBackendHandlerFactory.java
index 950e4d9..c61e1c0 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/CommonDistSQLBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/CommonDistSQLBackendHandlerFactory.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.distsql.parser.statement.ral.common.HintDistSQL
import org.apache.shardingsphere.distsql.parser.statement.ral.common.RefreshTableMetadataStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.SetDistSQLStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.ShowDistSQLStatement;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
import java.sql.SQLException;
@@ -40,22 +40,22 @@ public final class CommonDistSQLBackendHandlerFactory {
* Create new instance of common dist sql backend handler.
*
* @param sqlStatement common dist sql statement
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @return common dist sql backend handler
* @throws SQLException SQL exception
*/
- public static TextProtocolBackendHandler newInstance(final CommonDistSQLStatement sqlStatement, final BackendConnection backendConnection) throws SQLException {
+ public static TextProtocolBackendHandler newInstance(final CommonDistSQLStatement sqlStatement, final JDBCConnectionSession connectionSession) throws SQLException {
if (sqlStatement instanceof SetDistSQLStatement) {
- return new SetDistSQLBackendHandler((SetDistSQLStatement) sqlStatement, backendConnection);
+ return new SetDistSQLBackendHandler((SetDistSQLStatement) sqlStatement, connectionSession);
}
if (sqlStatement instanceof ShowDistSQLStatement) {
- return new ShowDistSQLBackendHandler((ShowDistSQLStatement) sqlStatement, backendConnection);
+ return new ShowDistSQLBackendHandler((ShowDistSQLStatement) sqlStatement, connectionSession);
}
if (sqlStatement instanceof HintDistSQLStatement) {
- return new HintDistSQLBackendHandler((HintDistSQLStatement) sqlStatement, backendConnection);
+ return new HintDistSQLBackendHandler((HintDistSQLStatement) sqlStatement, connectionSession);
}
if (sqlStatement instanceof RefreshTableMetadataStatement) {
- return new RefreshTableMetadataHandler((RefreshTableMetadataStatement) sqlStatement, backendConnection);
+ return new RefreshTableMetadataHandler((RefreshTableMetadataStatement) sqlStatement, connectionSession);
}
throw new UnsupportedTypeException(sqlStatement.getClass().getCanonicalName());
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/HintDistSQLBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/HintDistSQLBackendHandler.java
index ea738ed..1a4f748 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/HintDistSQLBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/HintDistSQLBackendHandler.java
@@ -21,7 +21,7 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.HintDistSQLStatement;
import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
@@ -40,7 +40,7 @@ public final class HintDistSQLBackendHandler implements TextProtocolBackendHandl
private final HintDistSQLStatement sqlStatement;
- private final BackendConnection backendConnection;
+ private final JDBCConnectionSession connectionSession;
private HintStatementExecutor hintStatementExecutor;
@@ -49,7 +49,7 @@ public final class HintDistSQLBackendHandler implements TextProtocolBackendHandl
if (!ProxyContext.getInstance().getContextManager().getMetaDataContexts().getProps().<Boolean>getValue(ConfigurationPropertyKey.PROXY_HINT_ENABLED)) {
throw new UnsupportedOperationException(String.format("%s should be true, please check your config", ConfigurationPropertyKey.PROXY_HINT_ENABLED.getKey()));
}
- hintStatementExecutor = HintStatementExecutorFactory.newInstance(sqlStatement, backendConnection);
+ hintStatementExecutor = HintStatementExecutorFactory.newInstance(sqlStatement, connectionSession);
return hintStatementExecutor.execute();
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/RefreshTableMetadataHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/RefreshTableMetadataHandler.java
index 8148004..e809bf9 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/RefreshTableMetadataHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/RefreshTableMetadataHandler.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common;
import lombok.Getter;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.RefreshTableMetadataStatement;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
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;
@@ -34,8 +34,8 @@ import java.sql.SQLException;
@Getter
public final class RefreshTableMetadataHandler extends SchemaRequiredBackendHandler<RefreshTableMetadataStatement> {
- public RefreshTableMetadataHandler(final RefreshTableMetadataStatement sqlStatement, final BackendConnection backendConnection) {
- super(sqlStatement, backendConnection);
+ public RefreshTableMetadataHandler(final RefreshTableMetadataStatement sqlStatement, final JDBCConnectionSession connectionSession) {
+ super(sqlStatement, connectionSession);
}
@Override
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/SetDistSQLBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/SetDistSQLBackendHandler.java
index 7325b683..51a207d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/SetDistSQLBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/SetDistSQLBackendHandler.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.SetDistSQLStatement;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.set.SetStatementExecutor;
@@ -37,11 +37,11 @@ public final class SetDistSQLBackendHandler implements TextProtocolBackendHandle
private final SetDistSQLStatement sqlStatement;
- private final BackendConnection backendConnection;
+ private final JDBCConnectionSession connectionSession;
@Override
public ResponseHeader execute() throws SQLException {
- SetStatementExecutor setStatementExecutor = SetStatementExecutorFactory.newInstance(sqlStatement, backendConnection);
+ SetStatementExecutor setStatementExecutor = SetStatementExecutorFactory.newInstance(sqlStatement, connectionSession);
return setStatementExecutor.execute();
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/ShowDistSQLBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/ShowDistSQLBackendHandler.java
index 27d6136..536df4f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/ShowDistSQLBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/ShowDistSQLBackendHandler.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.ShowDistSQLStatement;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.show.ShowStatementExecutor;
@@ -38,13 +38,13 @@ public final class ShowDistSQLBackendHandler implements TextProtocolBackendHandl
private final ShowDistSQLStatement sqlStatement;
- private final BackendConnection backendConnection;
+ private final JDBCConnectionSession connectionSession;
private ShowStatementExecutor showStatementExecutor;
@Override
public ResponseHeader execute() throws SQLException {
- showStatementExecutor = ShowStatementExecutorFactory.newInstance(sqlStatement, backendConnection);
+ showStatementExecutor = ShowStatementExecutorFactory.newInstance(sqlStatement, connectionSession);
return showStatementExecutor.execute();
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/HintStatementExecutorFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/HintStatementExecutorFactory.java
index d593071..e8943e3 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/HintStatementExecutorFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/HintStatementExecutorFactory.java
@@ -22,7 +22,7 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.HintDistSQLStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.hint.ClearHintStatement;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.executor.AddShardingHintDatabaseValueExecutor;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.executor.AddShardingHintTableValueExecutor;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.executor.ClearHintExecutor;
@@ -53,11 +53,11 @@ public final class HintStatementExecutorFactory {
* Create hint statement executor instance.
*
* @param sqlStatement hint statement
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @return hint command executor
* @throws SQLException SQL exception
*/
- public static HintStatementExecutor newInstance(final HintDistSQLStatement sqlStatement, final BackendConnection backendConnection) throws SQLException {
+ public static HintStatementExecutor newInstance(final HintDistSQLStatement sqlStatement, final JDBCConnectionSession connectionSession) throws SQLException {
if (sqlStatement instanceof SetReadwriteSplittingHintStatement) {
return new SetReadwriteSplittingHintExecutor((SetReadwriteSplittingHintStatement) sqlStatement);
}
@@ -80,7 +80,7 @@ public final class HintStatementExecutorFactory {
return new AddShardingHintTableValueExecutor((AddShardingHintTableValueStatement) sqlStatement);
}
if (sqlStatement instanceof ShowShardingHintStatusStatement) {
- return new ShowShardingHintStatusExecutor(backendConnection);
+ return new ShowShardingHintStatusExecutor(connectionSession);
}
if (sqlStatement instanceof ClearShardingHintStatement) {
return new ClearShardingHintExecutor();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ShowShardingHintStatusExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ShowShardingHintStatusExecutor.java
index b461c34..4076e95 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ShowShardingHintStatusExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ShowShardingHintStatusExecutor.java
@@ -22,10 +22,10 @@ import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.hint.HintManager;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.exception.RuleNotExistedException;
import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.HintShardingType;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.result.ShowShardingHintStatusResult;
import org.apache.shardingsphere.sharding.distsql.parser.statement.hint.ShowShardingHintStatusStatement;
@@ -45,7 +45,7 @@ import java.util.Map;
@RequiredArgsConstructor
public final class ShowShardingHintStatusExecutor extends AbstractHintQueryExecutor<ShowShardingHintStatusStatement> {
- private final BackendConnection backendConnection;
+ private final ConnectionSession connectionSession;
@Override
protected List<QueryHeader> createQueryHeaders() {
@@ -60,7 +60,7 @@ public final class ShowShardingHintStatusExecutor extends AbstractHintQueryExecu
@Override
protected MergedResult createMergedResult() {
Map<String, ShowShardingHintStatusResult> results = new HashMap<>();
- ShardingSphereMetaData metaData = ProxyContext.getInstance().getMetaData(backendConnection.getSchemaName());
+ ShardingSphereMetaData metaData = ProxyContext.getInstance().getMetaData(connectionSession.getSchemaName());
if (!metaData.isComplete()) {
throw new RuleNotExistedException();
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/set/SetStatementExecutorFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/set/SetStatementExecutorFactory.java
index a80441a..71dd10e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/set/SetStatementExecutorFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/set/SetStatementExecutorFactory.java
@@ -21,7 +21,7 @@ import com.mchange.v1.db.sql.UnsupportedTypeException;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.SetDistSQLStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.set.SetInstanceStatusStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.set.SetVariableStatement;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.set.excutor.SetInstanceStatusExecutor;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.set.excutor.SetReadwriteSplittingStatusExecutor;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.set.excutor.SetVariableExecutor;
@@ -38,16 +38,16 @@ public final class SetStatementExecutorFactory {
* Create set statement executor instance.
*
* @param sqlStatement set statement
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @return set command executor
* @throws SQLException SQL exception
*/
- public static SetStatementExecutor newInstance(final SetDistSQLStatement sqlStatement, final BackendConnection backendConnection) throws SQLException {
+ public static SetStatementExecutor newInstance(final SetDistSQLStatement sqlStatement, final JDBCConnectionSession connectionSession) throws SQLException {
if (sqlStatement instanceof SetVariableStatement) {
- return new SetVariableExecutor((SetVariableStatement) sqlStatement, backendConnection);
+ return new SetVariableExecutor((SetVariableStatement) sqlStatement, connectionSession);
}
if (sqlStatement instanceof SetReadwriteSplittingStatusStatement) {
- return new SetReadwriteSplittingStatusExecutor((SetReadwriteSplittingStatusStatement) sqlStatement, backendConnection);
+ return new SetReadwriteSplittingStatusExecutor((SetReadwriteSplittingStatusStatement) sqlStatement, connectionSession);
}
if (sqlStatement instanceof SetInstanceStatusStatement) {
return new SetInstanceStatusExecutor((SetInstanceStatusStatement) sqlStatement);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/set/excutor/SetReadwriteSplittingStatusExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/set/excutor/SetReadwriteSplittingStatusExecutor.java
index bbf40b5..7190211 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/set/excutor/SetReadwriteSplittingStatusExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/set/excutor/SetReadwriteSplittingStatusExecutor.java
@@ -23,11 +23,11 @@ import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResour
import org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
import org.apache.shardingsphere.infra.exception.SchemaNotExistedException;
import org.apache.shardingsphere.infra.rule.event.impl.DataSourceDisabledEvent;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.exception.NoDatabaseSelectedException;
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.text.distsql.ral.common.set.SetStatementExecutor;
import org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.status.SetReadwriteSplittingStatusStatement;
@@ -42,11 +42,11 @@ public final class SetReadwriteSplittingStatusExecutor implements SetStatementEx
private final SetReadwriteSplittingStatusStatement sqlStatement;
- private final BackendConnection backendConnection;
+ private final ConnectionSession connectionSession;
@Override
public ResponseHeader execute() throws DistSQLException {
- String schemaName = sqlStatement.getSchema().isPresent() ? sqlStatement.getSchema().get().getIdentifier().getValue() : backendConnection.getSchemaName();
+ String schemaName = sqlStatement.getSchema().isPresent() ? sqlStatement.getSchema().get().getIdentifier().getValue() : connectionSession.getSchemaName();
if (null == schemaName) {
throw new NoDatabaseSelectedException();
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/set/excutor/SetVariableExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/set/excutor/SetVariableExecutor.java
index ad7b790..cad1070 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/set/excutor/SetVariableExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/set/excutor/SetVariableExecutor.java
@@ -25,10 +25,10 @@ import org.apache.shardingsphere.infra.properties.TypedPropertyValue;
import org.apache.shardingsphere.infra.properties.TypedPropertyValueException;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
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 org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.enums.VariableEnum;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.exception.InvalidValueException;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.exception.UnsupportedVariableException;
@@ -47,7 +47,7 @@ public final class SetVariableExecutor implements SetStatementExecutor {
private final SetVariableStatement sqlStatement;
- private final BackendConnection backendConnection;
+ private final ConnectionSession connectionSession;
@Override
public ResponseHeader execute() {
@@ -97,7 +97,7 @@ public final class SetVariableExecutor implements SetStatementExecutor {
SystemPropertyUtil.setSystemProperty(variable.name(), null == agentPluginsEnabled ? Boolean.FALSE.toString() : agentPluginsEnabled.toString());
break;
case TRANSACTION_TYPE:
- backendConnection.getTransactionStatus().setTransactionType(getTransactionType(sqlStatement.getValue()));
+ connectionSession.getTransactionStatus().setTransactionType(getTransactionType(sqlStatement.getValue()));
break;
default:
throw new UnsupportedVariableException(setVariableStatement.getName());
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/ShowStatementExecutorFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/ShowStatementExecutorFactory.java
index 476ad16..8658bda 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/ShowStatementExecutorFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/ShowStatementExecutorFactory.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.distsql.parser.statement.ral.common.ShowDistSQL
import org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowAllVariablesStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowInstanceStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowVariableStatement;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.show.executor.ShowAllVariablesExecutor;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.show.executor.ShowInstanceExecutor;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.show.executor.ShowReadwriteSplittingReadResourcesExecutor;
@@ -40,22 +40,22 @@ public final class ShowStatementExecutorFactory {
* Create show statement executor instance.
*
* @param sqlStatement show statement
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @return show command executor
* @throws SQLException SQL exception
*/
- public static ShowStatementExecutor newInstance(final ShowDistSQLStatement sqlStatement, final BackendConnection backendConnection) throws SQLException {
+ public static ShowStatementExecutor newInstance(final ShowDistSQLStatement sqlStatement, final JDBCConnectionSession connectionSession) throws SQLException {
if (sqlStatement instanceof ShowInstanceStatement) {
return new ShowInstanceExecutor();
}
if (sqlStatement instanceof ShowReadwriteSplittingReadResourcesStatement) {
- return new ShowReadwriteSplittingReadResourcesExecutor((ShowReadwriteSplittingReadResourcesStatement) sqlStatement, backendConnection);
+ return new ShowReadwriteSplittingReadResourcesExecutor((ShowReadwriteSplittingReadResourcesStatement) sqlStatement, connectionSession);
}
if (sqlStatement instanceof ShowAllVariablesStatement) {
- return new ShowAllVariablesExecutor(backendConnection);
+ return new ShowAllVariablesExecutor(connectionSession);
}
if (sqlStatement instanceof ShowVariableStatement) {
- return new ShowVariableExecutor((ShowVariableStatement) sqlStatement, backendConnection);
+ return new ShowVariableExecutor((ShowVariableStatement) sqlStatement, connectionSession);
}
throw new UnsupportedTypeException(sqlStatement.getClass().getCanonicalName());
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowAllVariablesExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowAllVariablesExecutor.java
index e246b65..2b94278 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowAllVariablesExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowAllVariablesExecutor.java
@@ -21,7 +21,7 @@ import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.enums.VariableEnum;
@@ -39,7 +39,7 @@ import java.util.List;
@RequiredArgsConstructor
public final class ShowAllVariablesExecutor extends AbstractShowExecutor {
- private final BackendConnection backendConnection;
+ private final JDBCConnectionSession connectionSession;
@Override
protected List<QueryHeader> createQueryHeaders() {
@@ -58,8 +58,8 @@ public final class ShowAllVariablesExecutor extends AbstractShowExecutor {
rows.add(Arrays.asList(each.toLowerCase(), propertyValue));
});
rows.add(Arrays.asList(VariableEnum.AGENT_PLUGINS_ENABLED.name().toLowerCase(), SystemPropertyUtil.getSystemProperty(VariableEnum.AGENT_PLUGINS_ENABLED.name(), Boolean.FALSE.toString())));
- rows.add(Arrays.asList(VariableEnum.CACHED_CONNECTIONS.name().toLowerCase(), backendConnection.getConnectionSize()));
- rows.add(Arrays.asList(VariableEnum.TRANSACTION_TYPE.name().toLowerCase(), backendConnection.getTransactionStatus().getTransactionType().name()));
+ rows.add(Arrays.asList(VariableEnum.CACHED_CONNECTIONS.name().toLowerCase(), connectionSession.getConnectionSize()));
+ rows.add(Arrays.asList(VariableEnum.TRANSACTION_TYPE.name().toLowerCase(), connectionSession.getTransactionStatus().getTransactionType().name()));
return new MultipleLocalDataMergedResult(rows);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowReadwriteSplittingReadResourcesExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowReadwriteSplittingReadResourcesExecutor.java
index ae68713..7b3cf424 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowReadwriteSplittingReadResourcesExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowReadwriteSplittingReadResourcesExecutor.java
@@ -24,10 +24,10 @@ import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.storage.StorageNodeStatus;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.storage.node.StorageStatusNode;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.exception.NoDatabaseSelectedException;
import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
import org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
import org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.ShowReadwriteSplittingReadResourcesStatement;
@@ -62,7 +62,7 @@ public final class ShowReadwriteSplittingReadResourcesExecutor extends AbstractS
private final ShowReadwriteSplittingReadResourcesStatement sqlStatement;
- private final BackendConnection backendConnection;
+ private final ConnectionSession connectionSession;
@Override
protected List<QueryHeader> createQueryHeaders() {
@@ -73,7 +73,7 @@ public final class ShowReadwriteSplittingReadResourcesExecutor extends AbstractS
@Override
protected MergedResult createMergedResult() {
- String schemaName = sqlStatement.getSchema().isPresent() ? sqlStatement.getSchema().get().getIdentifier().getValue() : backendConnection.getSchemaName();
+ String schemaName = sqlStatement.getSchema().isPresent() ? sqlStatement.getSchema().get().getIdentifier().getValue() : connectionSession.getSchemaName();
if (null == schemaName) {
throw new NoDatabaseSelectedException();
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowVariableExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowVariableExecutor.java
index e66d21f..0ebb137 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowVariableExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowVariableExecutor.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowVa
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.enums.VariableEnum;
@@ -44,7 +44,7 @@ public final class ShowVariableExecutor extends AbstractShowExecutor {
private final ShowVariableStatement sqlStatement;
- private final BackendConnection backendConnection;
+ private final JDBCConnectionSession connectionSession;
@Override
protected List<QueryHeader> createQueryHeaders() {
@@ -63,9 +63,9 @@ public final class ShowVariableExecutor extends AbstractShowExecutor {
case AGENT_PLUGINS_ENABLED:
return new MultipleLocalDataMergedResult(Collections.singletonList(Collections.singletonList(SystemPropertyUtil.getSystemProperty(variable.name(), Boolean.FALSE.toString()))));
case CACHED_CONNECTIONS:
- return new MultipleLocalDataMergedResult(Collections.singletonList(Collections.singletonList(backendConnection.getConnectionSize())));
+ return new MultipleLocalDataMergedResult(Collections.singletonList(Collections.singletonList(connectionSession.getConnectionSize())));
case TRANSACTION_TYPE:
- return new MultipleLocalDataMergedResult(Collections.singletonList(Collections.singletonList(backendConnection.getTransactionStatus().getTransactionType().name())));
+ return new MultipleLocalDataMergedResult(Collections.singletonList(Collections.singletonList(connectionSession.getTransactionStatus().getTransactionType().name())));
default:
throw new UnsupportedVariableException(sqlStatement.getName());
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/query/QueryableRALBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/query/QueryableRALBackendHandler.java
index 3f9540c..4f3e3ea 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/query/QueryableRALBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/query/QueryableRALBackendHandler.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.ral.query;
import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
import org.apache.shardingsphere.infra.distsql.query.DistSQLResultSet;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
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.QueryResponseHeader;
@@ -38,8 +38,8 @@ public final class QueryableRALBackendHandler extends SchemaRequiredBackendHandl
private final DistSQLResultSet resultSet;
- public QueryableRALBackendHandler(final RALStatement sqlStatement, final BackendConnection backendConnection, final DistSQLResultSet resultSet) {
- super(sqlStatement, backendConnection);
+ public QueryableRALBackendHandler(final RALStatement sqlStatement, final JDBCConnectionSession connectionSession, final DistSQLResultSet resultSet) {
+ super(sqlStatement, connectionSession);
this.resultSet = resultSet;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/query/QueryableRALBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/query/QueryableRALBackendHandlerFactory.java
index fa11153..b9f5f77 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/query/QueryableRALBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/query/QueryableRALBackendHandlerFactory.java
@@ -21,7 +21,7 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.distsql.parser.statement.ral.QueryableRALStatement;
import org.apache.shardingsphere.infra.distsql.query.DistSQLResultSet;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.spi.typed.TypedSPIRegistry;
@@ -42,11 +42,11 @@ public final class QueryableRALBackendHandlerFactory {
* Create new instance of queryable RAL backend handler.
*
* @param sqlStatement queryable RAL statement
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @return queryable RAL backend handler
*/
- public static TextProtocolBackendHandler newInstance(final QueryableRALStatement sqlStatement, final BackendConnection backendConnection) {
+ public static TextProtocolBackendHandler newInstance(final QueryableRALStatement sqlStatement, final JDBCConnectionSession connectionSession) {
DistSQLResultSet resultSet = TypedSPIRegistry.getRegisteredService(DistSQLResultSet.class, sqlStatement.getClass().getCanonicalName(), new Properties());
- return new QueryableRALBackendHandler(sqlStatement, backendConnection, resultSet);
+ return new QueryableRALBackendHandler(sqlStatement, connectionSession, resultSet);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/RDLBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/RDLBackendHandlerFactory.java
index 963fa29..34e27a4 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/RDLBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/RDLBackendHandlerFactory.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.distsql.parser.statement.rdl.alter.AlterResourc
import org.apache.shardingsphere.distsql.parser.statement.rdl.create.AddResourceStatement;
import org.apache.shardingsphere.distsql.parser.statement.rdl.drop.DropResourceStatement;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.proxy.backend.text.distsql.rdl.resource.AddResourceBackendHandler;
import org.apache.shardingsphere.proxy.backend.text.distsql.rdl.resource.AlterResourceBackendHandler;
@@ -45,24 +45,24 @@ public final class RDLBackendHandlerFactory {
*
* @param databaseType database type
* @param sqlStatement RDL statement
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @return RDL backend handler
* @throws SQLException SQL exception
*/
- public static TextProtocolBackendHandler newInstance(final DatabaseType databaseType, final RDLStatement sqlStatement, final BackendConnection backendConnection) throws SQLException {
- return createBackendHandler(databaseType, sqlStatement, backendConnection);
+ public static TextProtocolBackendHandler newInstance(final DatabaseType databaseType, final RDLStatement sqlStatement, final JDBCConnectionSession connectionSession) throws SQLException {
+ return createBackendHandler(databaseType, sqlStatement, connectionSession);
}
- private static TextProtocolBackendHandler createBackendHandler(final DatabaseType databaseType, final RDLStatement sqlStatement, final BackendConnection backendConnection) {
+ private static TextProtocolBackendHandler createBackendHandler(final DatabaseType databaseType, final RDLStatement sqlStatement, final JDBCConnectionSession connectionSession) {
if (sqlStatement instanceof AddResourceStatement) {
- return new AddResourceBackendHandler(databaseType, (AddResourceStatement) sqlStatement, backendConnection);
+ return new AddResourceBackendHandler(databaseType, (AddResourceStatement) sqlStatement, connectionSession);
}
if (sqlStatement instanceof AlterResourceStatement) {
- return new AlterResourceBackendHandler(databaseType, (AlterResourceStatement) sqlStatement, backendConnection);
+ return new AlterResourceBackendHandler(databaseType, (AlterResourceStatement) sqlStatement, connectionSession);
}
if (sqlStatement instanceof DropResourceStatement) {
- return new DropResourceBackendHandler((DropResourceStatement) sqlStatement, backendConnection);
+ return new DropResourceBackendHandler((DropResourceStatement) sqlStatement, connectionSession);
}
- return new RuleDefinitionBackendHandler<>((RuleDefinitionStatement) sqlStatement, backendConnection);
+ return new RuleDefinitionBackendHandler<>((RuleDefinitionStatement) sqlStatement, connectionSession);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AddResourceBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AddResourceBackendHandler.java
index 9b5c320..8a08301 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AddResourceBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AddResourceBackendHandler.java
@@ -26,7 +26,7 @@ import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.resource.DuplicateResourceException;
import org.apache.shardingsphere.infra.distsql.exception.resource.InvalidResourcesException;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
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;
@@ -49,8 +49,8 @@ public final class AddResourceBackendHandler extends SchemaRequiredBackendHandle
private final DataSourceConfigurationValidator dataSourceConfigValidator;
- public AddResourceBackendHandler(final DatabaseType databaseType, final AddResourceStatement sqlStatement, final BackendConnection backendConnection) {
- super(sqlStatement, backendConnection);
+ public AddResourceBackendHandler(final DatabaseType databaseType, final AddResourceStatement sqlStatement, final JDBCConnectionSession connectionSession) {
+ super(sqlStatement, connectionSession);
this.databaseType = databaseType;
dataSourceConfigValidator = new DataSourceConfigurationValidator();
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AlterResourceBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AlterResourceBackendHandler.java
index 37ba1db..4fc24e5 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AlterResourceBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AlterResourceBackendHandler.java
@@ -27,7 +27,7 @@ import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.resource.DuplicateResourceException;
import org.apache.shardingsphere.infra.distsql.exception.resource.InvalidResourcesException;
import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
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;
@@ -49,8 +49,8 @@ public final class AlterResourceBackendHandler extends SchemaRequiredBackendHand
private final DataSourceConfigurationValidator dataSourceConfigValidator;
- public AlterResourceBackendHandler(final DatabaseType databaseType, final AlterResourceStatement sqlStatement, final BackendConnection backendConnection) {
- super(sqlStatement, backendConnection);
+ public AlterResourceBackendHandler(final DatabaseType databaseType, final AlterResourceStatement sqlStatement, final JDBCConnectionSession connectionSession) {
+ super(sqlStatement, connectionSession);
this.databaseType = databaseType;
dataSourceConfigValidator = new DataSourceConfigurationValidator();
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/DropResourceBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/DropResourceBackendHandler.java
index 7cb1450..f6eea72 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/DropResourceBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/DropResourceBackendHandler.java
@@ -27,7 +27,7 @@ import org.apache.shardingsphere.infra.distsql.exception.resource.ResourceInUsed
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.rule.identifier.type.DataNodeContainedRule;
import org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
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;
@@ -46,8 +46,8 @@ import java.util.stream.Collectors;
*/
public final class DropResourceBackendHandler extends SchemaRequiredBackendHandler<DropResourceStatement> {
- public DropResourceBackendHandler(final DropResourceStatement sqlStatement, final BackendConnection backendConnection) {
- super(sqlStatement, backendConnection);
+ public DropResourceBackendHandler(final DropResourceStatement sqlStatement, final JDBCConnectionSession connectionSession) {
+ super(sqlStatement, connectionSession);
}
@Override
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/rule/RuleDefinitionBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/rule/RuleDefinitionBackendHandler.java
index 9d0b50f..b99c4c6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/rule/RuleDefinitionBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/rule/RuleDefinitionBackendHandler.java
@@ -26,7 +26,7 @@ import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionCreateUpdate
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionUpdater;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
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;
@@ -51,8 +51,8 @@ public final class RuleDefinitionBackendHandler<T extends RuleDefinitionStatemen
ShardingSphereServiceLoader.register(RuleDefinitionAlterPreprocessor.class);
}
- public RuleDefinitionBackendHandler(final T sqlStatement, final BackendConnection backendConnection) {
- super(sqlStatement, backendConnection);
+ public RuleDefinitionBackendHandler(final T sqlStatement, final JDBCConnectionSession connectionSession) {
+ super(sqlStatement, connectionSession);
}
@SuppressWarnings({"rawtypes", "unchecked"})
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RQLBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RQLBackendHandler.java
index ed86e7a..46ccc2d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RQLBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RQLBackendHandler.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.rql;
import org.apache.shardingsphere.distsql.parser.statement.rql.RQLStatement;
import org.apache.shardingsphere.infra.distsql.query.DistSQLResultSet;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
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.QueryResponseHeader;
@@ -38,8 +38,8 @@ public final class RQLBackendHandler extends SchemaRequiredBackendHandler<RQLSta
private final DistSQLResultSet resultSet;
- public RQLBackendHandler(final RQLStatement sqlStatement, final BackendConnection backendConnection, final DistSQLResultSet resultSet) {
- super(sqlStatement, backendConnection);
+ public RQLBackendHandler(final RQLStatement sqlStatement, final JDBCConnectionSession connectionSession, final DistSQLResultSet resultSet) {
+ super(sqlStatement, connectionSession);
this.resultSet = resultSet;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RQLBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RQLBackendHandlerFactory.java
index 710fd89..d907e6f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RQLBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RQLBackendHandlerFactory.java
@@ -21,7 +21,7 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.distsql.parser.statement.rql.RQLStatement;
import org.apache.shardingsphere.infra.distsql.query.DistSQLResultSet;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.spi.typed.TypedSPIRegistry;
@@ -42,11 +42,11 @@ public final class RQLBackendHandlerFactory {
* Create new instance of RDL backend handler.
*
* @param sqlStatement RQL statement
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @return RDL backend handler
*/
- public static TextProtocolBackendHandler newInstance(final RQLStatement sqlStatement, final BackendConnection backendConnection) {
+ public static TextProtocolBackendHandler newInstance(final RQLStatement sqlStatement, final JDBCConnectionSession connectionSession) {
DistSQLResultSet resultSet = TypedSPIRegistry.getRegisteredService(DistSQLResultSet.class, sqlStatement.getClass().getCanonicalName(), new Properties());
- return new RQLBackendHandler(sqlStatement, backendConnection, resultSet);
+ return new RQLBackendHandler(sqlStatement, connectionSession, resultSet);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionAutoCommitHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionAutoCommitHandler.java
index efe4623..427ed9e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionAutoCommitHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionAutoCommitHandler.java
@@ -18,9 +18,9 @@
package org.apache.shardingsphere.proxy.backend.text.transaction;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
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.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.SetAutoCommitStatement;
@@ -34,11 +34,11 @@ public final class TransactionAutoCommitHandler implements TextProtocolBackendHa
private final SetAutoCommitStatement sqlStatement;
- private final BackendConnection backendConnection;
+ private final ConnectionSession connectionSession;
@Override
public ResponseHeader execute() throws SQLException {
- backendConnection.setAutoCommit(sqlStatement.isAutoCommit());
+ connectionSession.setAutoCommit(sqlStatement.isAutoCommit());
return new UpdateResponseHeader(sqlStatement);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionBackendHandler.java
index be944a2..5592050 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionBackendHandler.java
@@ -17,10 +17,11 @@
package org.apache.shardingsphere.proxy.backend.text.transaction;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.BackendTransactionManager;
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.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.ReleaseSavepointStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.RollbackToSavepointStatement;
@@ -43,20 +44,20 @@ public final class TransactionBackendHandler implements TextProtocolBackendHandl
private final BackendTransactionManager backendTransactionManager;
- private final BackendConnection backendConnection;
+ private final ConnectionSession connectionSession;
- public TransactionBackendHandler(final TCLStatement tclStatement, final TransactionOperationType operationType, final BackendConnection backendConnection) {
+ public TransactionBackendHandler(final TCLStatement tclStatement, final TransactionOperationType operationType, final JDBCConnectionSession connectionSession) {
this.tclStatement = tclStatement;
this.operationType = operationType;
- this.backendConnection = backendConnection;
- backendTransactionManager = new BackendTransactionManager(backendConnection);
+ this.connectionSession = connectionSession;
+ backendTransactionManager = new BackendTransactionManager(connectionSession);
}
@Override
public ResponseHeader execute() throws SQLException {
switch (operationType) {
case BEGIN:
- if (tclStatement instanceof MySQLBeginTransactionStatement && backendConnection.getTransactionStatus().isInTransaction()) {
+ if (tclStatement instanceof MySQLBeginTransactionStatement && connectionSession.getTransactionStatus().isInTransaction()) {
backendTransactionManager.commit();
}
backendTransactionManager.begin();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionBackendHandlerFactory.java
index a2d63c2..1babbbe 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionBackendHandlerFactory.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.backend.text.transaction;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.proxy.backend.text.data.impl.BroadcastDatabaseBackendHandler;
import org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.BeginTransactionStatement;
@@ -44,32 +44,32 @@ public final class TransactionBackendHandlerFactory {
*
* @param sqlStatementContext SQL statement context
* @param sql SQL
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @return backend handler
*/
- public static TextProtocolBackendHandler newInstance(final SQLStatementContext<? extends TCLStatement> sqlStatementContext, final String sql, final BackendConnection backendConnection) {
+ public static TextProtocolBackendHandler newInstance(final SQLStatementContext<? extends TCLStatement> sqlStatementContext, final String sql, final JDBCConnectionSession connectionSession) {
TCLStatement tclStatement = sqlStatementContext.getSqlStatement();
if (tclStatement instanceof BeginTransactionStatement) {
- return new TransactionBackendHandler(tclStatement, TransactionOperationType.BEGIN, backendConnection);
+ return new TransactionBackendHandler(tclStatement, TransactionOperationType.BEGIN, connectionSession);
}
if (tclStatement instanceof SetAutoCommitStatement) {
- return new TransactionAutoCommitHandler((SetAutoCommitStatement) tclStatement, backendConnection);
+ return new TransactionAutoCommitHandler((SetAutoCommitStatement) tclStatement, connectionSession);
}
if (tclStatement instanceof SavepointStatement) {
- return new TransactionBackendHandler(tclStatement, TransactionOperationType.SAVEPOINT, backendConnection);
+ return new TransactionBackendHandler(tclStatement, TransactionOperationType.SAVEPOINT, connectionSession);
}
if (tclStatement instanceof ReleaseSavepointStatement) {
- return new TransactionBackendHandler(tclStatement, TransactionOperationType.RELEASE_SAVEPOINT, backendConnection);
+ return new TransactionBackendHandler(tclStatement, TransactionOperationType.RELEASE_SAVEPOINT, connectionSession);
}
if (tclStatement instanceof RollbackToSavepointStatement) {
- return new TransactionBackendHandler(tclStatement, TransactionOperationType.ROLLBACK_TO_SAVEPOINT, backendConnection);
+ return new TransactionBackendHandler(tclStatement, TransactionOperationType.ROLLBACK_TO_SAVEPOINT, connectionSession);
}
if (tclStatement instanceof CommitStatement) {
- return new TransactionBackendHandler(tclStatement, TransactionOperationType.COMMIT, backendConnection);
+ return new TransactionBackendHandler(tclStatement, TransactionOperationType.COMMIT, connectionSession);
}
if (tclStatement instanceof RollbackStatement) {
- return new TransactionBackendHandler(tclStatement, TransactionOperationType.ROLLBACK, backendConnection);
+ return new TransactionBackendHandler(tclStatement, TransactionOperationType.ROLLBACK, connectionSession);
}
- return new BroadcastDatabaseBackendHandler(sqlStatementContext, sql, backendConnection);
+ return new BroadcastDatabaseBackendHandler(sqlStatementContext, sql, connectionSession);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactoryTest.java
index fe150e1..148f6c5 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactoryTest.java
@@ -27,7 +27,7 @@ import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerCon
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.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.junit.Before;
import org.junit.Test;
@@ -54,9 +54,9 @@ public final class DatabaseCommunicationEngineFactoryTest {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
contextManagerField.set(ProxyContext.getInstance(), contextManager);
- BackendConnection backendConnection = mock(BackendConnection.class, RETURNS_DEEP_STUBS);
- when(backendConnection.getSchemaName()).thenReturn("schema");
- when(backendConnection.isSerialExecute()).thenReturn(true);
+ JDBCConnectionSession connectionSession = mock(JDBCConnectionSession.class, RETURNS_DEEP_STUBS);
+ when(connectionSession.getSchemaName()).thenReturn("schema");
+ when(connectionSession.isSerialExecute()).thenReturn(true);
}
private Map<String, ShardingSphereMetaData> getMetaDataMap() {
@@ -68,18 +68,18 @@ public final class DatabaseCommunicationEngineFactoryTest {
@Test
public void assertNewTextProtocolInstance() {
- BackendConnection backendConnection = mock(BackendConnection.class);
- when(backendConnection.getSchemaName()).thenReturn("schema");
- DatabaseCommunicationEngine engine = DatabaseCommunicationEngineFactory.getInstance().newTextProtocolInstance(mock(SQLStatementContext.class), "schemaName", backendConnection);
+ JDBCConnectionSession connectionSession = mock(JDBCConnectionSession.class);
+ when(connectionSession.getSchemaName()).thenReturn("schema");
+ DatabaseCommunicationEngine engine = DatabaseCommunicationEngineFactory.getInstance().newTextProtocolInstance(mock(SQLStatementContext.class), "schemaName", connectionSession);
assertThat(engine, instanceOf(DatabaseCommunicationEngine.class));
}
@Test
public void assertNewBinaryProtocolInstance() {
- BackendConnection backendConnection = mock(BackendConnection.class);
- when(backendConnection.getSchemaName()).thenReturn("schema");
+ JDBCConnectionSession connectionSession = mock(JDBCConnectionSession.class);
+ when(connectionSession.getSchemaName()).thenReturn("schema");
DatabaseCommunicationEngine engine =
- DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(mock(SQLStatementContext.class), "schemaName", Collections.emptyList(), backendConnection);
+ DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(mock(SQLStatementContext.class), "schemaName", Collections.emptyList(), connectionSession);
assertThat(engine, instanceOf(DatabaseCommunicationEngine.class));
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineTest.java
index 5a455cd..f1ddbe7 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineTest.java
@@ -37,7 +37,7 @@ 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.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeaderBuilder;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
@@ -76,7 +76,7 @@ import static org.mockito.Mockito.when;
public final class DatabaseCommunicationEngineTest {
@Mock
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
@Mock
private Statement statement;
@@ -86,7 +86,7 @@ public final class DatabaseCommunicationEngineTest {
@Before
public void setUp() {
- when(backendConnection.getSchemaName()).thenReturn("schema");
+ when(connectionSession.getSchemaName()).thenReturn("schema");
MetaDataContexts metaDataContexts = new MetaDataContexts(
mock(MetaDataPersistService.class), mockMetaDataMap(), mock(ShardingSphereRuleMetaData.class), mock(ExecutorEngine.class),
new ConfigurationProperties(new Properties()), mock(OptimizerContext.class, RETURNS_DEEP_STUBS));
@@ -105,7 +105,7 @@ public final class DatabaseCommunicationEngineTest {
@Test
public void assertBinaryProtocolQueryHeader() throws SQLException, NoSuchFieldException {
DatabaseCommunicationEngine engine =
- DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(mock(SQLStatementContext.class), "schemaName", Collections.emptyList(), backendConnection);
+ DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(mock(SQLStatementContext.class), "schemaName", Collections.emptyList(), connectionSession);
assertNotNull(engine);
assertThat(engine, instanceOf(DatabaseCommunicationEngine.class));
Field queryHeadersField = engine.getClass().getDeclaredField("queryHeaders");
@@ -161,7 +161,7 @@ public final class DatabaseCommunicationEngineTest {
@Test
public void assertAddStatementCorrectly() {
DatabaseCommunicationEngine engine =
- DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(mock(SQLStatementContext.class), "schemaName", Collections.emptyList(), backendConnection);
+ DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(mock(SQLStatementContext.class), "schemaName", Collections.emptyList(), connectionSession);
engine.add(statement);
Collection<?> actual = getField(engine, "cachedStatements");
assertThat(actual.size(), is(1));
@@ -171,7 +171,7 @@ public final class DatabaseCommunicationEngineTest {
@Test
public void assertAddResultSetCorrectly() {
DatabaseCommunicationEngine engine =
- DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(mock(SQLStatementContext.class), "schemaName", Collections.emptyList(), backendConnection);
+ DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(mock(SQLStatementContext.class), "schemaName", Collections.emptyList(), connectionSession);
engine.add(resultSet);
Collection<?> actual = getField(engine, "cachedResultSets");
assertThat(actual.size(), is(1));
@@ -181,7 +181,7 @@ public final class DatabaseCommunicationEngineTest {
@Test
public void assertCloseCorrectly() throws SQLException {
DatabaseCommunicationEngine engine =
- DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(mock(SQLStatementContext.class), "schemaName", Collections.emptyList(), backendConnection);
+ DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(mock(SQLStatementContext.class), "schemaName", Collections.emptyList(), connectionSession);
Collection<ResultSet> cachedResultSets = getField(engine, "cachedResultSets");
cachedResultSets.add(resultSet);
Collection<Statement> cachedStatements = getField(engine, "cachedStatements");
@@ -196,7 +196,7 @@ public final class DatabaseCommunicationEngineTest {
@Test
public void assertCloseResultSetsWithExceptionThrown() throws SQLException {
DatabaseCommunicationEngine engine =
- DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(mock(SQLStatementContext.class), "schemaName", Collections.emptyList(), backendConnection);
+ DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(mock(SQLStatementContext.class), "schemaName", Collections.emptyList(), connectionSession);
Collection<ResultSet> cachedResultSets = getField(engine, "cachedResultSets");
SQLException sqlExceptionByResultSet = new SQLException("ResultSet");
doThrow(sqlExceptionByResultSet).when(resultSet).close();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/ProxySQLExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/ProxySQLExecutorTest.java
index 743de28..f9ba599 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/ProxySQLExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/ProxySQLExecutorTest.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.JDBCDriv
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
import org.apache.shardingsphere.infra.route.context.RouteContext;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.exception.TableModifyInTransactionException;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.TableNameSegment;
@@ -51,75 +51,75 @@ import static org.mockito.Mockito.when;
public final class ProxySQLExecutorTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
@Before
public void setUp() {
- when(backendConnection.getTransactionStatus().getTransactionType()).thenReturn(TransactionType.XA);
- when(backendConnection.getTransactionStatus().isInTransaction()).thenReturn(true);
+ when(connectionSession.getTransactionStatus().getTransactionType()).thenReturn(TransactionType.XA);
+ when(connectionSession.getTransactionStatus().isInTransaction()).thenReturn(true);
}
@Test(expected = TableModifyInTransactionException.class)
public void assertCheckExecutePrerequisitesWhenExecuteDDLInXATransaction() {
ExecutionContext executionContext = new ExecutionContext(
new LogicSQL(createMySQLCreateTableStatementContext(), "", Collections.emptyList()), Collections.emptyList(), mock(RouteContext.class));
- new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
+ new ProxySQLExecutor(JDBCDriverType.STATEMENT, connectionSession, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
}
@Test
public void assertCheckExecutePrerequisitesWhenExecuteDMLInXATransaction() {
ExecutionContext executionContext = new ExecutionContext(
new LogicSQL(createMySQLInsertStatementContext(), "", Collections.emptyList()), Collections.emptyList(), mock(RouteContext.class));
- new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
+ new ProxySQLExecutor(JDBCDriverType.STATEMENT, connectionSession, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
}
@Test
public void assertCheckExecutePrerequisitesWhenExecuteDDLInBaseTransaction() {
- when(backendConnection.getTransactionStatus().getTransactionType()).thenReturn(TransactionType.BASE);
+ when(connectionSession.getTransactionStatus().getTransactionType()).thenReturn(TransactionType.BASE);
ExecutionContext executionContext = new ExecutionContext(
new LogicSQL(createMySQLCreateTableStatementContext(), "", Collections.emptyList()), Collections.emptyList(), mock(RouteContext.class));
- new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
+ new ProxySQLExecutor(JDBCDriverType.STATEMENT, connectionSession, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
}
@Test
public void assertCheckExecutePrerequisitesWhenExecuteDDLNotInXATransaction() {
- when(backendConnection.getTransactionStatus().isInTransaction()).thenReturn(false);
+ when(connectionSession.getTransactionStatus().isInTransaction()).thenReturn(false);
ExecutionContext executionContext = new ExecutionContext(
new LogicSQL(createMySQLCreateTableStatementContext(), "", Collections.emptyList()), Collections.emptyList(), mock(RouteContext.class));
- new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
+ new ProxySQLExecutor(JDBCDriverType.STATEMENT, connectionSession, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
}
@Test(expected = TableModifyInTransactionException.class)
public void assertCheckExecutePrerequisitesWhenExecuteDDLInPostgreSQLTransaction() {
- when(backendConnection.getTransactionStatus().getTransactionType()).thenReturn(TransactionType.LOCAL);
+ when(connectionSession.getTransactionStatus().getTransactionType()).thenReturn(TransactionType.LOCAL);
ExecutionContext executionContext = new ExecutionContext(
new LogicSQL(createPostgreSQLCreateTableStatementContext(), "", Collections.emptyList()), Collections.emptyList(), mock(RouteContext.class));
- new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
+ new ProxySQLExecutor(JDBCDriverType.STATEMENT, connectionSession, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
}
@Test
public void assertCheckExecutePrerequisitesWhenExecuteDMLInPostgreSQLTransaction() {
- when(backendConnection.getTransactionStatus().getTransactionType()).thenReturn(TransactionType.LOCAL);
+ when(connectionSession.getTransactionStatus().getTransactionType()).thenReturn(TransactionType.LOCAL);
ExecutionContext executionContext = new ExecutionContext(
new LogicSQL(createPostgreSQLInsertStatementContext(), "", Collections.emptyList()), Collections.emptyList(), mock(RouteContext.class));
- new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
+ new ProxySQLExecutor(JDBCDriverType.STATEMENT, connectionSession, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
}
@Test
public void assertCheckExecutePrerequisitesWhenExecuteDDLInMySQLTransaction() {
- when(backendConnection.getTransactionStatus().getTransactionType()).thenReturn(TransactionType.LOCAL);
+ when(connectionSession.getTransactionStatus().getTransactionType()).thenReturn(TransactionType.LOCAL);
ExecutionContext executionContext = new ExecutionContext(
new LogicSQL(createMySQLCreateTableStatementContext(), "", Collections.emptyList()), Collections.emptyList(), mock(RouteContext.class));
- new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
+ new ProxySQLExecutor(JDBCDriverType.STATEMENT, connectionSession, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
}
@Test
public void assertCheckExecutePrerequisitesWhenExecuteDDLNotInPostgreSQLTransaction() {
- when(backendConnection.getTransactionStatus().getTransactionType()).thenReturn(TransactionType.LOCAL);
- when(backendConnection.getTransactionStatus().isInTransaction()).thenReturn(false);
+ when(connectionSession.getTransactionStatus().getTransactionType()).thenReturn(TransactionType.LOCAL);
+ when(connectionSession.getTransactionStatus().isInTransaction()).thenReturn(false);
ExecutionContext executionContext = new ExecutionContext(
new LogicSQL(createPostgreSQLCreateTableStatementContext(), "", Collections.emptyList()), Collections.emptyList(), mock(RouteContext.class));
- new ProxySQLExecutor(JDBCDriverType.STATEMENT, backendConnection, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
+ new ProxySQLExecutor(JDBCDriverType.STATEMENT, connectionSession, mock(DatabaseCommunicationEngine.class)).checkExecutePrerequisites(executionContext);
}
private CreateTableStatementContext createMySQLCreateTableStatementContext() {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnectionTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCConnectionSessionTest.java
similarity index 79%
rename from shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnectionTest.java
rename to shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCConnectionSessionTest.java
index b3742a2..c6700fb 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnectionTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCConnectionSessionTest.java
@@ -75,20 +75,20 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
-public final class BackendConnectionTest {
+public final class JDBCConnectionSessionTest {
private static final String SCHEMA_PATTERN = "schema_%s";
@Mock
private JDBCBackendDataSource backendDataSource;
- private final BackendConnection backendConnection = new BackendConnection(TransactionType.LOCAL, new DefaultAttributeMap());
+ private final JDBCConnectionSession connectionSession = new JDBCConnectionSession(TransactionType.LOCAL, new DefaultAttributeMap());
@Before
public void setUp() throws ReflectiveOperationException {
setContextManager();
setBackendDataSource();
- backendConnection.setCurrentSchema(String.format(SCHEMA_PATTERN, 0));
+ connectionSession.setCurrentSchema(String.format(SCHEMA_PATTERN, 0));
}
private void setContextManager() throws ReflectiveOperationException {
@@ -141,44 +141,44 @@ public final class BackendConnectionTest {
@Test
public void assertGetConnectionCacheIsEmpty() throws SQLException {
- backendConnection.getTransactionStatus().setInTransaction(true);
+ connectionSession.getTransactionStatus().setInTransaction(true);
when(backendDataSource.getConnections(anyString(), anyString(), eq(2), any())).thenReturn(MockConnectionUtil.mockNewConnections(2));
- List<Connection> actualConnections = backendConnection.getConnections("ds1", 2, ConnectionMode.MEMORY_STRICTLY);
+ List<Connection> actualConnections = connectionSession.getConnections("ds1", 2, ConnectionMode.MEMORY_STRICTLY);
assertThat(actualConnections.size(), is(2));
- assertThat(backendConnection.getConnectionSize(), is(2));
- assertTrue(backendConnection.getTransactionStatus().isInTransaction());
+ assertThat(connectionSession.getConnectionSize(), is(2));
+ assertTrue(connectionSession.getTransactionStatus().isInTransaction());
}
@Test
public void assertGetConnectionSizeLessThanCache() throws SQLException {
- backendConnection.getTransactionStatus().setInTransaction(true);
- MockConnectionUtil.setCachedConnections(backendConnection, "ds1", 10);
- List<Connection> actualConnections = backendConnection.getConnections("ds1", 2, ConnectionMode.MEMORY_STRICTLY);
+ connectionSession.getTransactionStatus().setInTransaction(true);
+ MockConnectionUtil.setCachedConnections(connectionSession, "ds1", 10);
+ List<Connection> actualConnections = connectionSession.getConnections("ds1", 2, ConnectionMode.MEMORY_STRICTLY);
assertThat(actualConnections.size(), is(2));
- assertThat(backendConnection.getConnectionSize(), is(10));
- assertTrue(backendConnection.getTransactionStatus().isInTransaction());
+ assertThat(connectionSession.getConnectionSize(), is(10));
+ assertTrue(connectionSession.getTransactionStatus().isInTransaction());
}
@Test
public void assertGetConnectionSizeGreaterThanCache() throws SQLException {
- backendConnection.getTransactionStatus().setInTransaction(true);
- MockConnectionUtil.setCachedConnections(backendConnection, "ds1", 10);
+ connectionSession.getTransactionStatus().setInTransaction(true);
+ MockConnectionUtil.setCachedConnections(connectionSession, "ds1", 10);
when(backendDataSource.getConnections(anyString(), anyString(), eq(2), any())).thenReturn(MockConnectionUtil.mockNewConnections(2));
- List<Connection> actualConnections = backendConnection.getConnections("ds1", 12, ConnectionMode.MEMORY_STRICTLY);
+ List<Connection> actualConnections = connectionSession.getConnections("ds1", 12, ConnectionMode.MEMORY_STRICTLY);
assertThat(actualConnections.size(), is(12));
- assertThat(backendConnection.getConnectionSize(), is(12));
- assertTrue(backendConnection.getTransactionStatus().isInTransaction());
+ assertThat(connectionSession.getConnectionSize(), is(12));
+ assertTrue(connectionSession.getTransactionStatus().isInTransaction());
}
@Test
public void assertGetConnectionWithConnectionPostProcessors() throws SQLException {
- backendConnection.getTransactionStatus().setInTransaction(true);
+ connectionSession.getTransactionStatus().setInTransaction(true);
when(backendDataSource.getConnections(anyString(), anyString(), eq(2), any())).thenReturn(MockConnectionUtil.mockNewConnections(2));
setConnectionPostProcessors();
- List<Connection> actualConnections = backendConnection.getConnections("ds1", 2, ConnectionMode.MEMORY_STRICTLY);
- verify(backendConnection.getConnectionPostProcessors().iterator().next(), times(2)).process(any());
+ List<Connection> actualConnections = connectionSession.getConnections("ds1", 2, ConnectionMode.MEMORY_STRICTLY);
+ verify(connectionSession.getConnectionPostProcessors().iterator().next(), times(2)).process(any());
assertThat(actualConnections.size(), is(2));
- assertTrue(backendConnection.getTransactionStatus().isInTransaction());
+ assertTrue(connectionSession.getTransactionStatus().isInTransaction());
}
@SneakyThrows(ReflectiveOperationException.class)
@@ -186,14 +186,14 @@ public final class BackendConnectionTest {
ConnectionPostProcessor invocation = mock(ConnectionPostProcessor.class);
Collection<ConnectionPostProcessor> connectionPostProcessors = new LinkedList<>();
connectionPostProcessors.add(invocation);
- Field field = backendConnection.getClass().getDeclaredField("connectionPostProcessors");
+ Field field = connectionSession.getClass().getDeclaredField("connectionPostProcessors");
field.setAccessible(true);
- field.set(backendConnection, connectionPostProcessors);
+ field.set(connectionSession, connectionPostProcessors);
}
@Test
public void assertMultiThreadsGetConnection() throws SQLException, InterruptedException {
- MockConnectionUtil.setCachedConnections(backendConnection, "ds1", 10);
+ MockConnectionUtil.setCachedConnections(connectionSession, "ds1", 10);
when(backendDataSource.getConnections(anyString(), anyString(), eq(2), any())).thenReturn(MockConnectionUtil.mockNewConnections(2));
Thread thread1 = new Thread(this::assertOneThreadResult);
Thread thread2 = new Thread(this::assertOneThreadResult);
@@ -205,73 +205,73 @@ public final class BackendConnectionTest {
@SneakyThrows(SQLException.class)
private void assertOneThreadResult() {
- backendConnection.getTransactionStatus().setInTransaction(true);
- List<Connection> actualConnections = backendConnection.getConnections("ds1", 12, ConnectionMode.MEMORY_STRICTLY);
+ connectionSession.getTransactionStatus().setInTransaction(true);
+ List<Connection> actualConnections = connectionSession.getConnections("ds1", 12, ConnectionMode.MEMORY_STRICTLY);
assertThat(actualConnections.size(), is(12));
- assertThat(backendConnection.getConnectionSize(), is(12));
- assertTrue(backendConnection.getTransactionStatus().isInTransaction());
+ assertThat(connectionSession.getConnectionSize(), is(12));
+ assertTrue(connectionSession.getTransactionStatus().isInTransaction());
}
@Test(expected = ShardingSphereException.class)
public void assertFailedSwitchTransactionTypeWhileBegin() throws SQLException {
- BackendTransactionManager transactionManager = new BackendTransactionManager(backendConnection);
+ BackendTransactionManager transactionManager = new BackendTransactionManager(connectionSession);
transactionManager.begin();
- backendConnection.getTransactionStatus().setTransactionType(TransactionType.XA);
+ connectionSession.getTransactionStatus().setTransactionType(TransactionType.XA);
}
@Test(expected = ShardingSphereException.class)
public void assertFailedSwitchSchemaWhileBegin() throws SQLException {
- BackendTransactionManager transactionManager = new BackendTransactionManager(backendConnection);
+ BackendTransactionManager transactionManager = new BackendTransactionManager(connectionSession);
transactionManager.begin();
- backendConnection.setCurrentSchema("newSchema");
+ connectionSession.setCurrentSchema("newSchema");
}
@Test
public void assertIsNotSerialExecuteWhenNotInTransaction() {
- backendConnection.getTransactionStatus().setInTransaction(false);
- assertFalse(backendConnection.isSerialExecute());
+ connectionSession.getTransactionStatus().setInTransaction(false);
+ assertFalse(connectionSession.isSerialExecute());
}
@Test
public void assertIsNotSerialExecuteWhenInTransactionAndBaseTransactionType() {
- backendConnection.getTransactionStatus().setInTransaction(false);
- backendConnection.getTransactionStatus().setTransactionType(TransactionType.BASE);
- assertFalse(backendConnection.isSerialExecute());
+ connectionSession.getTransactionStatus().setInTransaction(false);
+ connectionSession.getTransactionStatus().setTransactionType(TransactionType.BASE);
+ assertFalse(connectionSession.isSerialExecute());
}
@Test
public void assertIsSerialExecuteWhenInTransactionAndLocalTransactionType() {
- backendConnection.getTransactionStatus().setTransactionType(TransactionType.LOCAL);
- backendConnection.getTransactionStatus().setInTransaction(true);
- assertTrue(backendConnection.isSerialExecute());
+ connectionSession.getTransactionStatus().setTransactionType(TransactionType.LOCAL);
+ connectionSession.getTransactionStatus().setInTransaction(true);
+ assertTrue(connectionSession.isSerialExecute());
}
@Test
public void assertIsSerialExecuteWhenInTransactionAndXaTransactionType() {
- backendConnection.getTransactionStatus().setTransactionType(TransactionType.XA);
- backendConnection.getTransactionStatus().setInTransaction(true);
- assertTrue(backendConnection.isSerialExecute());
+ connectionSession.getTransactionStatus().setTransactionType(TransactionType.XA);
+ connectionSession.getTransactionStatus().setInTransaction(true);
+ assertTrue(connectionSession.isSerialExecute());
}
@Test
public void assertSetFetchSizeAsExpected() throws InvocationTargetException, IllegalAccessException, NoSuchMethodException, SQLException {
Statement statement = mock(Statement.class);
- Method setFetchSizeMethod = backendConnection.getClass().getDeclaredMethod("setFetchSize", Statement.class);
+ Method setFetchSizeMethod = connectionSession.getClass().getDeclaredMethod("setFetchSize", Statement.class);
setFetchSizeMethod.setAccessible(true);
- setFetchSizeMethod.invoke(backendConnection, statement);
+ setFetchSizeMethod.invoke(connectionSession, statement);
verify(statement, times(1)).setFetchSize(Integer.MIN_VALUE);
}
@Test
public void assertCloseConnectionsCorrectlyWhenNotForceRollback() throws NoSuchFieldException, IllegalAccessException, SQLException {
- Field field = backendConnection.getClass().getDeclaredField("cachedConnections");
+ Field field = connectionSession.getClass().getDeclaredField("cachedConnections");
field.setAccessible(true);
- Multimap<String, Connection> cachedConnections = (Multimap<String, Connection>) field.get(backendConnection);
+ Multimap<String, Connection> cachedConnections = (Multimap<String, Connection>) field.get(connectionSession);
Connection connection = prepareCachedConnections();
cachedConnections.put("ignoredDataSourceName", connection);
ConnectionStatus connectionStatus = mock(ConnectionStatus.class);
prepareConnectionStatus(connectionStatus);
- backendConnection.closeConnections(false);
+ connectionSession.closeConnections(false);
verify(connection, times(1)).close();
assertTrue(cachedConnections.isEmpty());
verifyConnectionPostProcessorsEmpty();
@@ -281,9 +281,9 @@ public final class BackendConnectionTest {
public void assertCloseConnectionsCorrectlyWhenForceRollbackAndNotInTransaction() throws SQLException {
ConnectionStatus connectionStatus = mock(ConnectionStatus.class);
prepareConnectionStatus(connectionStatus);
- backendConnection.getTransactionStatus().setInTransaction(false);
+ connectionSession.getTransactionStatus().setInTransaction(false);
Connection connection = prepareCachedConnections();
- backendConnection.closeConnections(true);
+ connectionSession.closeConnections(true);
verify(connection, never()).rollback();
}
@@ -291,9 +291,9 @@ public final class BackendConnectionTest {
public void assertCloseConnectionsCorrectlyWhenForceRollbackAndInTransaction() throws SQLException {
ConnectionStatus connectionStatus = mock(ConnectionStatus.class);
prepareConnectionStatus(connectionStatus);
- backendConnection.getTransactionStatus().setInTransaction(true);
+ connectionSession.getTransactionStatus().setInTransaction(true);
Connection connection = prepareCachedConnections();
- backendConnection.closeConnections(true);
+ connectionSession.closeConnections(true);
verify(connection, times(1)).rollback();
}
@@ -304,7 +304,7 @@ public final class BackendConnectionTest {
Connection connection = prepareCachedConnections();
SQLException sqlException = new SQLException("");
doThrow(sqlException).when(connection).close();
- assertTrue(backendConnection.closeConnections(false).contains(sqlException));
+ assertTrue(connectionSession.closeConnections(false).contains(sqlException));
}
@Test
@@ -312,16 +312,16 @@ public final class BackendConnectionTest {
Connection connection = mock(Connection.class);
Statement statement = mock(Statement.class);
when(connection.createStatement()).thenReturn(statement);
- assertThat(backendConnection.createStorageResource(connection, ConnectionMode.MEMORY_STRICTLY, null), is(statement));
+ assertThat(connectionSession.createStorageResource(connection, ConnectionMode.MEMORY_STRICTLY, null), is(statement));
verify(connection, times(1)).createStatement();
}
@Test
public void assertGetConnectionsWithoutTransactions() throws SQLException {
- backendConnection.getTransactionStatus().setInTransaction(false);
+ connectionSession.getTransactionStatus().setInTransaction(false);
List<Connection> connections = MockConnectionUtil.mockNewConnections(1);
when(backendDataSource.getConnections(anyString(), anyString(), eq(1), any())).thenReturn(connections);
- List<Connection> fetchedConnections = backendConnection.getConnections("ds1", 1, null);
+ List<Connection> fetchedConnections = connectionSession.getConnections("ds1", 1, null);
assertThat(fetchedConnections.size(), is(1));
assertTrue(fetchedConnections.contains(connections.get(0)));
assertConnectionsCached("ds1", connections);
@@ -330,9 +330,9 @@ public final class BackendConnectionTest {
@SuppressWarnings("unchecked")
@SneakyThrows(ReflectiveOperationException.class)
private void assertConnectionsCached(final String dataSourceName, final Collection<Connection> connections) {
- Field field = backendConnection.getClass().getDeclaredField("cachedConnections");
+ Field field = connectionSession.getClass().getDeclaredField("cachedConnections");
field.setAccessible(true);
- Multimap<String, Connection> cachedConnections = (Multimap<String, Connection>) field.get(backendConnection);
+ Multimap<String, Connection> cachedConnections = (Multimap<String, Connection>) field.get(connectionSession);
assertTrue(cachedConnections.containsKey(dataSourceName));
assertArrayEquals(cachedConnections.get(dataSourceName).toArray(), connections.toArray());
}
@@ -340,9 +340,9 @@ public final class BackendConnectionTest {
@SuppressWarnings("unchecked")
@SneakyThrows(ReflectiveOperationException.class)
private Connection prepareCachedConnections() {
- Field field = backendConnection.getClass().getDeclaredField("cachedConnections");
+ Field field = connectionSession.getClass().getDeclaredField("cachedConnections");
field.setAccessible(true);
- Multimap<String, Connection> cachedConnections = (Multimap<String, Connection>) field.get(backendConnection);
+ Multimap<String, Connection> cachedConnections = (Multimap<String, Connection>) field.get(connectionSession);
Connection connection = mock(Connection.class);
cachedConnections.put("ignoredDataSourceName", connection);
return connection;
@@ -350,24 +350,24 @@ public final class BackendConnectionTest {
@SneakyThrows(ReflectiveOperationException.class)
private void prepareConnectionStatus(final ConnectionStatus connectionStatus) {
- Field field = backendConnection.getClass().getDeclaredField("connectionStatus");
+ Field field = connectionSession.getClass().getDeclaredField("connectionStatus");
field.setAccessible(true);
- field.set(backendConnection, connectionStatus);
+ field.set(connectionSession, connectionStatus);
}
@SuppressWarnings("unchecked")
@SneakyThrows(ReflectiveOperationException.class)
private void verifyConnectionPostProcessorsEmpty() {
- Field field = backendConnection.getClass().getDeclaredField("connectionPostProcessors");
+ Field field = connectionSession.getClass().getDeclaredField("connectionPostProcessors");
field.setAccessible(true);
- Collection<ConnectionPostProcessor> connectionPostProcessors = (Collection<ConnectionPostProcessor>) field.get(backendConnection);
+ Collection<ConnectionPostProcessor> connectionPostProcessors = (Collection<ConnectionPostProcessor>) field.get(connectionSession);
assertTrue(connectionPostProcessors.isEmpty());
}
@Test
public void assertAddDatabaseCommunicationEngine() {
DatabaseCommunicationEngine expectedEngine = mock(DatabaseCommunicationEngine.class);
- backendConnection.add(expectedEngine);
+ connectionSession.add(expectedEngine);
Collection<DatabaseCommunicationEngine> actual = getDatabaseCommunicationEngines();
assertThat(actual.size(), is(1));
assertThat(actual.iterator().next(), is(expectedEngine));
@@ -376,8 +376,8 @@ public final class BackendConnectionTest {
@Test
public void assertMarkDatabaseCommunicationEngineInUse() {
DatabaseCommunicationEngine expectedEngine = mock(DatabaseCommunicationEngine.class);
- backendConnection.add(expectedEngine);
- backendConnection.markResourceInUse(expectedEngine);
+ connectionSession.add(expectedEngine);
+ connectionSession.markResourceInUse(expectedEngine);
Collection<DatabaseCommunicationEngine> actual = getInUseDatabaseCommunicationEngines();
assertThat(actual.size(), is(1));
assertThat(actual.iterator().next(), is(expectedEngine));
@@ -388,7 +388,7 @@ public final class BackendConnectionTest {
DatabaseCommunicationEngine engine = mock(DatabaseCommunicationEngine.class);
Collection<DatabaseCommunicationEngine> actual = getInUseDatabaseCommunicationEngines();
actual.add(engine);
- backendConnection.unmarkResourceInUse(engine);
+ connectionSession.unmarkResourceInUse(engine);
assertTrue(actual.isEmpty());
}
@@ -403,13 +403,13 @@ public final class BackendConnectionTest {
databaseCommunicationEngines.add(engine);
databaseCommunicationEngines.add(inUseEngine);
inUseDatabaseCommunicationEngines.add(inUseEngine);
- Collection<SQLException> actual = backendConnection.closeDatabaseCommunicationEngines(false);
+ Collection<SQLException> actual = connectionSession.closeDatabaseCommunicationEngines(false);
assertThat(actual.size(), is(1));
assertThat(actual.iterator().next(), is(expectedException));
assertThat(inUseDatabaseCommunicationEngines.size(), is(1));
assertThat(databaseCommunicationEngines.size(), is(1));
verify(engine).close();
- backendConnection.closeDatabaseCommunicationEngines(true);
+ connectionSession.closeDatabaseCommunicationEngines(true);
verify(inUseEngine).close();
assertTrue(databaseCommunicationEngines.isEmpty());
assertTrue(inUseDatabaseCommunicationEngines.isEmpty());
@@ -418,16 +418,16 @@ public final class BackendConnectionTest {
@SuppressWarnings("unchecked")
@SneakyThrows
private Collection<DatabaseCommunicationEngine> getDatabaseCommunicationEngines() {
- Field field = BackendConnection.class.getDeclaredField("databaseCommunicationEngines");
+ Field field = JDBCConnectionSession.class.getDeclaredField("databaseCommunicationEngines");
field.setAccessible(true);
- return (Collection<DatabaseCommunicationEngine>) field.get(backendConnection);
+ return (Collection<DatabaseCommunicationEngine>) field.get(connectionSession);
}
@SuppressWarnings("unchecked")
@SneakyThrows
private Collection<DatabaseCommunicationEngine> getInUseDatabaseCommunicationEngines() {
- Field field = BackendConnection.class.getDeclaredField("inUseDatabaseCommunicationEngines");
+ Field field = JDBCConnectionSession.class.getDeclaredField("inUseDatabaseCommunicationEngines");
field.setAccessible(true);
- return (Collection<DatabaseCommunicationEngine>) field.get(backendConnection);
+ return (Collection<DatabaseCommunicationEngine>) field.get(connectionSession);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/MockConnectionUtil.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/MockConnectionUtil.java
index 04aca57..0e08bed 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/MockConnectionUtil.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/MockConnectionUtil.java
@@ -31,7 +31,7 @@ import java.util.List;
import static org.mockito.Mockito.mock;
/**
- * Mock backend connection utility.
+ * Mock JDBC connection session utility.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
final class MockConnectionUtil {
@@ -39,17 +39,17 @@ final class MockConnectionUtil {
/**
* Mock set cached connections.
*
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @param dataSourceName datasource name
* @param connectionSize connection size
*/
@SneakyThrows(ReflectiveOperationException.class)
- static void setCachedConnections(final BackendConnection backendConnection, final String dataSourceName, final int connectionSize) {
+ static void setCachedConnections(final JDBCConnectionSession connectionSession, final String dataSourceName, final int connectionSize) {
Multimap<String, Connection> cachedConnections = HashMultimap.create();
cachedConnections.putAll(dataSourceName, mockNewConnections(connectionSize));
- Field field = backendConnection.getClass().getDeclaredField("cachedConnections");
+ Field field = connectionSession.getClass().getDeclaredField("cachedConnections");
field.setAccessible(true);
- field.set(backendConnection, cachedConnections);
+ field.set(connectionSession, cachedConnections);
}
/**
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/BackendTransactionManagerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/BackendTransactionManagerTest.java
index 539e083..43854ec 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/BackendTransactionManagerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/BackendTransactionManagerTest.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction;
import lombok.SneakyThrows;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
import org.apache.shardingsphere.transaction.context.TransactionContexts;
@@ -45,7 +45,7 @@ import static org.mockito.Mockito.when;
public final class BackendTransactionManagerTest {
@Mock
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
@Mock
private TransactionStatus transactionStatus;
@@ -61,8 +61,8 @@ public final class BackendTransactionManagerTest {
@Before
public void setUp() {
setTransactionContexts();
- when(backendConnection.getSchemaName()).thenReturn("schema");
- when(backendConnection.getTransactionStatus()).thenReturn(transactionStatus);
+ when(connectionSession.getSchemaName()).thenReturn("schema");
+ when(connectionSession.getTransactionStatus()).thenReturn(transactionStatus);
}
@SneakyThrows(ReflectiveOperationException.class)
@@ -88,8 +88,8 @@ public final class BackendTransactionManagerTest {
newBackendTransactionManager(TransactionType.LOCAL, false);
backendTransactionManager.begin();
verify(transactionStatus).setInTransaction(true);
- verify(backendConnection).closeDatabaseCommunicationEngines(true);
- verify(backendConnection).closeConnections(false);
+ verify(connectionSession).closeDatabaseCommunicationEngines(true);
+ verify(connectionSession).closeConnections(false);
verify(localTransactionManager).begin();
}
@@ -98,7 +98,7 @@ public final class BackendTransactionManagerTest {
newBackendTransactionManager(TransactionType.XA, true);
backendTransactionManager.begin();
verify(transactionStatus, times(0)).setInTransaction(true);
- verify(backendConnection, times(0)).closeConnections(false);
+ verify(connectionSession, times(0)).closeConnections(false);
verify(shardingSphereTransactionManager).begin();
}
@@ -201,9 +201,9 @@ public final class BackendTransactionManagerTest {
}
private void newBackendTransactionManager(final TransactionType transactionType, final boolean inTransaction) {
- when(backendConnection.getTransactionStatus().getTransactionType()).thenReturn(transactionType);
+ when(connectionSession.getTransactionStatus().getTransactionType()).thenReturn(transactionType);
when(transactionStatus.isInTransaction()).thenReturn(inTransaction);
- backendTransactionManager = new BackendTransactionManager(backendConnection);
+ backendTransactionManager = new BackendTransactionManager(connectionSession);
setLocalTransactionManager();
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/LocalTransactionManagerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/LocalTransactionManagerTest.java
index ec54bb7..72aca10 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/LocalTransactionManagerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/LocalTransactionManagerTest.java
@@ -21,7 +21,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.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -40,7 +40,7 @@ import static org.mockito.Mockito.when;
public final class LocalTransactionManagerTest {
@Mock
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
@Mock
private TransactionStatus transactionStatus;
@@ -52,10 +52,10 @@ public final class LocalTransactionManagerTest {
@Before
public void setUp() throws SQLException {
- when(backendConnection.getTransactionStatus()).thenReturn(transactionStatus);
- when(backendConnection.getCachedConnections()).thenReturn(setCachedConnections());
+ when(connectionSession.getTransactionStatus()).thenReturn(transactionStatus);
+ when(connectionSession.getCachedConnections()).thenReturn(setCachedConnections());
when(transactionStatus.isInTransaction()).thenReturn(true);
- localTransactionManager = new LocalTransactionManager(backendConnection);
+ localTransactionManager = new LocalTransactionManager(connectionSession);
}
private Multimap<String, Connection> setCachedConnections() {
@@ -69,7 +69,7 @@ public final class LocalTransactionManagerTest {
@Test
public void assertBegin() {
localTransactionManager.begin();
- verify(backendConnection).getConnectionPostProcessors();
+ verify(connectionSession).getConnectionPostProcessors();
}
@Test
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactoryTest.java
index 3c27904..41a19be 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactoryTest.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.text.admin.DatabaseAdminQueryBackendHandler;
import org.apache.shardingsphere.proxy.backend.text.admin.DatabaseAdminUpdateBackendHandler;
@@ -64,12 +64,12 @@ public final class TextProtocolBackendHandlerFactoryTest {
private final DatabaseType databaseType = DatabaseTypeRegistry.getActualDatabaseType("MySQL");
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
@Before
public void setUp() {
- when(backendConnection.getTransactionStatus().getTransactionType()).thenReturn(TransactionType.LOCAL);
- when(backendConnection.getDefaultSchemaName()).thenReturn("schema");
+ when(connectionSession.getTransactionStatus().getTransactionType()).thenReturn(TransactionType.LOCAL);
+ when(connectionSession.getDefaultSchemaName()).thenReturn("schema");
MetaDataContexts metaDataContexts = mock(MetaDataContexts.class, RETURNS_DEEP_STUBS);
mockGlobalRuleMetaData(metaDataContexts);
ShardingSphereMetaData shardingSphereMetaData = mockShardingSphereMetaData();
@@ -105,126 +105,126 @@ public final class TextProtocolBackendHandlerFactoryTest {
@Test
public void assertNewInstanceWithCommonDistSQL() throws SQLException {
String sql = "set variable transaction_type=LOCAL";
- TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, connectionSession);
assertThat(actual, instanceOf(SetDistSQLBackendHandler.class));
sql = "show variable transaction_type";
- actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, connectionSession);
assertThat(actual, instanceOf(ShowDistSQLBackendHandler.class));
sql = "show all variables";
- actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, connectionSession);
assertThat(actual, instanceOf(ShowDistSQLBackendHandler.class));
sql = "set sharding hint database_value=1";
- actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, connectionSession);
assertThat(actual, instanceOf(HintDistSQLBackendHandler.class));
}
@Test
public void assertNewInstanceWithBegin() throws SQLException {
String sql = "BEGIN";
- TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, connectionSession);
assertThat(actual, instanceOf(TransactionBackendHandler.class));
}
@Test
public void assertNewInstanceWithStartTransaction() throws SQLException {
String sql = "START TRANSACTION";
- TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, connectionSession);
assertThat(actual, instanceOf(TransactionBackendHandler.class));
}
@Test
public void assertNewInstanceWithSetAutoCommitToOff() throws SQLException {
String sql = "SET AUTOCOMMIT=0";
- TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, connectionSession);
assertThat(actual, instanceOf(TransactionAutoCommitHandler.class));
}
@Test
public void assertNewInstanceWithScopeSetAutoCommitToOff() throws SQLException {
String sql = "SET @@SESSION.AUTOCOMMIT = OFF";
- TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, connectionSession);
assertThat(actual, instanceOf(TransactionAutoCommitHandler.class));
}
@Test
public void assertNewInstanceWithSetAutoCommitToOn() throws SQLException {
String sql = "SET AUTOCOMMIT=1";
- TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, connectionSession);
assertThat(actual, instanceOf(TransactionAutoCommitHandler.class));
}
@Test
public void assertNewInstanceWithScopeSetAutoCommitToOnForInTransaction() throws SQLException {
String sql = "SET @@SESSION.AUTOCOMMIT = ON";
- TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, connectionSession);
assertThat(actual, instanceOf(TransactionAutoCommitHandler.class));
}
@Test
public void assertNewInstanceWithUse() throws SQLException {
String sql = "use sharding_db";
- TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, connectionSession);
assertThat(actual, instanceOf(DatabaseAdminUpdateBackendHandler.class));
}
@Test
public void assertNewInstanceWithShowDatabase() throws SQLException {
String sql = "show databases";
- TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, connectionSession);
assertThat(actual, instanceOf(DatabaseAdminQueryBackendHandler.class));
}
@Test
public void assertNewInstanceWithSet() throws SQLException {
String sql = "set @num=1";
- TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, connectionSession);
assertThat(actual, instanceOf(BroadcastDatabaseBackendHandler.class));
}
@Test
public void assertNewInstanceWithShow() throws SQLException {
String sql = "SHOW VARIABLES LIKE '%x%'";
- TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, connectionSession);
assertThat(actual, instanceOf(UnicastDatabaseBackendHandler.class));
sql = "SHOW VARIABLES WHERE Variable_name ='language'";
- actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, connectionSession);
assertThat(actual, instanceOf(UnicastDatabaseBackendHandler.class));
sql = "SHOW CHARACTER SET";
- actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, connectionSession);
assertThat(actual, instanceOf(UnicastDatabaseBackendHandler.class));
sql = "SHOW COLLATION";
- actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, connectionSession);
assertThat(actual, instanceOf(UnicastDatabaseBackendHandler.class));
}
@Test
public void assertNewInstanceWithQuery() throws SQLException {
String sql = "select * from t_order limit 1";
- TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, connectionSession);
assertThat(actual, instanceOf(SchemaAssignedDatabaseBackendHandler.class));
sql = "select * from information_schema.schemata limit 1";
- actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, connectionSession);
assertThat(actual, instanceOf(DatabaseAdminQueryBackendHandler.class));
}
@Test
public void assertNewInstanceWithEmptyString() throws SQLException {
String sql = "";
- TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, connectionSession);
assertThat(actual, instanceOf(SkipBackendHandler.class));
}
@Test(expected = SQLParsingException.class)
public void assertNewInstanceWithErrorSQL() throws SQLException {
String sql = "SELECT";
- TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, connectionSession);
assertThat(actual, instanceOf(SkipBackendHandler.class));
}
@Test(expected = SQLParsingException.class)
public void assertNewInstanceWithErrorRDL() throws SQLException {
String sql = "CREATE SHARDING";
- TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, connectionSession);
assertThat(actual, instanceOf(SkipBackendHandler.class));
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseOperateBackendHandlerFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseOperateBackendHandlerFactoryTest.java
index f143022..fcc2774 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseOperateBackendHandlerFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseOperateBackendHandlerFactoryTest.java
@@ -26,7 +26,7 @@ import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerCon
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.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.exception.DBCreateExistsException;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
@@ -77,7 +77,7 @@ public final class DatabaseOperateBackendHandlerFactoryTest {
}
private void assertExecuteCreateDatabaseContext(final CreateDatabaseStatement sqlStatement) throws SQLException {
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getSchemaName()).thenReturn("schema");
sqlStatement.setDatabaseName("new_db");
setGovernanceMetaDataContexts(true);
@@ -96,7 +96,7 @@ public final class DatabaseOperateBackendHandlerFactoryTest {
}
private void assertExecuteDropDatabaseContext(final DropDatabaseStatement sqlStatement) throws SQLException {
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getSchemaName()).thenReturn("schema");
sqlStatement.setDatabaseName("schema");
setGovernanceMetaDataContexts(true);
@@ -115,7 +115,7 @@ public final class DatabaseOperateBackendHandlerFactoryTest {
}
public void assertExecuteCreateDatabaseContextWithException(final CreateDatabaseStatement sqlStatement) throws SQLException {
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getSchemaName()).thenReturn("schema");
sqlStatement.setDatabaseName("schema");
setGovernanceMetaDataContexts(true);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowConnectionIdExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowConnectionIdExecutorTest.java
index 660e4d2d..8d09eeb 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowConnectionIdExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowConnectionIdExecutorTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.proxy.backend.text.admin.mysql.executor;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
@@ -35,15 +35,15 @@ public final class ShowConnectionIdExecutorTest {
@Test
public void assertExecute() throws SQLException {
ShowConnectionIdExecutor executor = new ShowConnectionIdExecutor();
- executor.execute(mockBackendConnection());
+ executor.execute(mockConnectionSession());
assertThat(executor.getQueryResultMetaData().getColumnCount(), is(1));
while (executor.getMergedResult().next()) {
assertThat(executor.getMergedResult().getValue(1, Object.class), is(109));
}
}
- private BackendConnection mockBackendConnection() {
- BackendConnection result = mock(BackendConnection.class);
+ private ConnectionSession mockConnectionSession() {
+ ConnectionSession result = mock(ConnectionSession.class);
when(result.getConnectionId()).thenReturn(109);
return result;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowCreateDatabaseExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowCreateDatabaseExecutorTest.java
index 9dc6282..60f1434 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowCreateDatabaseExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowCreateDatabaseExecutorTest.java
@@ -20,15 +20,15 @@ package org.apache.shardingsphere.proxy.backend.text.admin.mysql.executor;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
-import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
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.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowCreateDatabaseStatement;
import org.junit.Before;
import org.junit.Test;
@@ -76,7 +76,7 @@ public final class ShowCreateDatabaseExecutorTest {
MySQLShowCreateDatabaseStatement statement = new MySQLShowCreateDatabaseStatement();
statement.setSchema("schema_0");
ShowCreateDatabaseExecutor showCreateDatabaseExecutor = new ShowCreateDatabaseExecutor(statement);
- showCreateDatabaseExecutor.execute(mockBackendConnection());
+ showCreateDatabaseExecutor.execute(mockConnectionSession());
assertThat(showCreateDatabaseExecutor.getQueryResultMetaData().getColumnCount(), is(2));
int count = 0;
while (showCreateDatabaseExecutor.getMergedResult().next()) {
@@ -85,8 +85,8 @@ public final class ShowCreateDatabaseExecutorTest {
}
}
- private BackendConnection mockBackendConnection() {
- BackendConnection result = mock(BackendConnection.class);
+ private ConnectionSession mockConnectionSession() {
+ ConnectionSession result = mock(ConnectionSession.class);
when(result.getGrantee()).thenReturn(new Grantee("root", ""));
when(result.getSchemaName()).thenReturn(String.format(SCHEMA_PATTERN, 0));
return result;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowCurrentUserExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowCurrentUserExecutorTest.java
index f9aad3a..c150bfb 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowCurrentUserExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowCurrentUserExecutorTest.java
@@ -20,15 +20,15 @@ package org.apache.shardingsphere.proxy.backend.text.admin.mysql.executor;
import org.apache.shardingsphere.authority.rule.AuthorityRule;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
import org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
-import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
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.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -75,15 +75,15 @@ public final class ShowCurrentUserExecutorTest {
@Test
public void assertExecute() throws SQLException {
ShowCurrentUserExecutor executor = new ShowCurrentUserExecutor();
- executor.execute(mockBackendConnection());
+ executor.execute(mockConnectionSession());
assertThat(executor.getQueryResultMetaData().getColumnCount(), is(1));
while (executor.getMergedResult().next()) {
assertThat(executor.getMergedResult().getValue(1, Object.class), is("root@%"));
}
}
- private BackendConnection mockBackendConnection() {
- BackendConnection result = mock(BackendConnection.class);
+ private ConnectionSession mockConnectionSession() {
+ ConnectionSession result = mock(ConnectionSession.class);
when(result.getGrantee()).thenReturn(grantee);
return result;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowDatabasesExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowDatabasesExecutorTest.java
index ae53d3f..c62f7d0 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowDatabasesExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowDatabasesExecutorTest.java
@@ -20,15 +20,15 @@ package org.apache.shardingsphere.proxy.backend.text.admin.mysql.executor;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
-import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
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.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dal.ShowFilterSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dal.ShowLikeSegment;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowDatabasesStatement;
@@ -82,7 +82,7 @@ public final class ShowDatabasesExecutorTest {
@Test
public void assertExecute() throws SQLException {
- showDatabasesExecutor.execute(mockBackendConnection());
+ showDatabasesExecutor.execute(mockConnectionSession());
assertThat(showDatabasesExecutor.getQueryResultMetaData().getColumnCount(), is(1));
int count = 0;
while (showDatabasesExecutor.getMergedResult().next()) {
@@ -99,7 +99,7 @@ public final class ShowDatabasesExecutorTest {
showFilterSegment.setLike(showLikeSegment);
showDatabasesStatement.setFilter(showFilterSegment);
showDatabasesExecutor = new ShowDatabasesExecutor(showDatabasesStatement);
- showDatabasesExecutor.execute(mockBackendConnection());
+ showDatabasesExecutor.execute(mockConnectionSession());
assertThat(showDatabasesExecutor.getQueryResultMetaData().getColumnCount(), is(1));
int count = 0;
while (showDatabasesExecutor.getMergedResult().next()) {
@@ -117,7 +117,7 @@ public final class ShowDatabasesExecutorTest {
showFilterSegment.setLike(showLikeSegment);
showDatabasesStatement.setFilter(showFilterSegment);
showDatabasesExecutor = new ShowDatabasesExecutor(showDatabasesStatement);
- showDatabasesExecutor.execute(mockBackendConnection());
+ showDatabasesExecutor.execute(mockConnectionSession());
assertThat(showDatabasesExecutor.getQueryResultMetaData().getColumnCount(), is(1));
int count = 0;
while (showDatabasesExecutor.getMergedResult().next()) {
@@ -135,7 +135,7 @@ public final class ShowDatabasesExecutorTest {
showFilterSegment.setLike(showLikeSegment);
showDatabasesStatement.setFilter(showFilterSegment);
showDatabasesExecutor = new ShowDatabasesExecutor(showDatabasesStatement);
- showDatabasesExecutor.execute(mockBackendConnection());
+ showDatabasesExecutor.execute(mockConnectionSession());
assertThat(showDatabasesExecutor.getQueryResultMetaData().getColumnCount(), is(1));
int count = 0;
while (showDatabasesExecutor.getMergedResult().next()) {
@@ -153,7 +153,7 @@ public final class ShowDatabasesExecutorTest {
showFilterSegment.setLike(showLikeSegment);
showDatabasesStatement.setFilter(showFilterSegment);
showDatabasesExecutor = new ShowDatabasesExecutor(showDatabasesStatement);
- showDatabasesExecutor.execute(mockBackendConnection());
+ showDatabasesExecutor.execute(mockConnectionSession());
assertThat(showDatabasesExecutor.getQueryResultMetaData().getColumnCount(), is(1));
int count = 0;
while (showDatabasesExecutor.getMergedResult().next()) {
@@ -163,8 +163,8 @@ public final class ShowDatabasesExecutorTest {
assertThat(count, is(0));
}
- private BackendConnection mockBackendConnection() {
- BackendConnection result = mock(BackendConnection.class);
+ private ConnectionSession mockConnectionSession() {
+ ConnectionSession result = mock(ConnectionSession.class);
when(result.getGrantee()).thenReturn(new Grantee("root", ""));
return result;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowFunctionStatusExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowFunctionStatusExecutorTest.java
index 3fdd6c3..8daa7d1 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowFunctionStatusExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowFunctionStatusExecutorTest.java
@@ -20,15 +20,15 @@ package org.apache.shardingsphere.proxy.backend.text.admin.mysql.executor;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
-import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
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.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowFunctionStatusStatement;
import org.junit.Before;
import org.junit.Test;
@@ -77,12 +77,12 @@ public final class ShowFunctionStatusExecutorTest {
@Test
public void assertExecute() throws SQLException {
- showFunctionStatusExecutor.execute(mockBackendConnection());
+ showFunctionStatusExecutor.execute(mockConnectionSession());
assertThat(showFunctionStatusExecutor.getQueryResultMetaData().getColumnCount(), is(11));
}
- private BackendConnection mockBackendConnection() {
- BackendConnection result = mock(BackendConnection.class);
+ private ConnectionSession mockConnectionSession() {
+ ConnectionSession result = mock(ConnectionSession.class);
when(result.getGrantee()).thenReturn(new Grantee("root", ""));
when(result.getSchemaName()).thenReturn(String.format(SCHEMA_PATTERN, 0));
return result;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowProcedureStatusExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowProcedureStatusExecutorTest.java
index f2f25f2..fdca4b6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowProcedureStatusExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowProcedureStatusExecutorTest.java
@@ -20,15 +20,15 @@ package org.apache.shardingsphere.proxy.backend.text.admin.mysql.executor;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
-import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
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.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowProcedureStatusStatement;
import org.junit.Before;
import org.junit.Test;
@@ -77,12 +77,12 @@ public final class ShowProcedureStatusExecutorTest {
@Test
public void assertExecute() throws SQLException {
- showProcedureStatusExecutor.execute(mockBackendConnection());
+ showProcedureStatusExecutor.execute(mockConnectionSession());
assertThat(showProcedureStatusExecutor.getQueryResultMetaData().getColumnCount(), is(11));
}
- private BackendConnection mockBackendConnection() {
- BackendConnection result = mock(BackendConnection.class);
+ private ConnectionSession mockConnectionSession() {
+ ConnectionSession result = mock(ConnectionSession.class);
when(result.getGrantee()).thenReturn(new Grantee("root", ""));
when(result.getSchemaName()).thenReturn(String.format(SCHEMA_PATTERN, 0));
return result;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowProcessListExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowProcessListExecutorTest.java
index ec20ca9..9d520fa 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowProcessListExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowProcessListExecutorTest.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.proxy.backend.text.admin.mysql.executor;
import io.netty.util.DefaultAttributeMap;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.transaction.core.TransactionType;
import org.junit.Before;
import org.junit.Test;
@@ -60,7 +60,7 @@ public final class ShowProcessListExecutorTest {
@Test
public void assertExecute() throws SQLException {
- showProcessListExecutor.execute(new BackendConnection(TransactionType.LOCAL, new DefaultAttributeMap()));
+ showProcessListExecutor.execute(new JDBCConnectionSession(TransactionType.LOCAL, new DefaultAttributeMap()));
assertThat(showProcessListExecutor.getQueryResultMetaData().getColumnCount(), is(8));
MergedResult mergedResult = showProcessListExecutor.getMergedResult();
while (mergedResult.next()) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesExecutorTest.java
index fc0ce07..4957fd6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesExecutorTest.java
@@ -20,15 +20,15 @@ package org.apache.shardingsphere.proxy.backend.text.admin.mysql.executor;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
-import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
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.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowTablesStatement;
import org.junit.Before;
import org.junit.Test;
@@ -77,15 +77,15 @@ public final class ShowTablesExecutorTest {
@Test
public void assertExecute() throws SQLException {
- showTablesExecutor.execute(mockBackendConnection());
+ showTablesExecutor.execute(mockConnectionSession());
assertThat(showTablesExecutor.getQueryResultMetaData().getColumnCount(), is(2));
while (showTablesExecutor.getMergedResult().next()) {
assertThat(showTablesExecutor.getMergedResult().getValue(1, Object.class), is(1));
}
}
- private BackendConnection mockBackendConnection() {
- BackendConnection result = mock(BackendConnection.class);
+ private ConnectionSession mockConnectionSession() {
+ ConnectionSession result = mock(ConnectionSession.class);
when(result.getGrantee()).thenReturn(new Grantee("root", ""));
when(result.getSchemaName()).thenReturn(String.format(SCHEMA_PATTERN, 0));
return result;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesStatusExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesStatusExecutorTest.java
index 5bddfeb..a17d83d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesStatusExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesStatusExecutorTest.java
@@ -20,15 +20,15 @@ package org.apache.shardingsphere.proxy.backend.text.admin.mysql.executor;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
-import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
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.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowTableStatusStatement;
import org.junit.Before;
import org.junit.Test;
@@ -81,7 +81,7 @@ public final class ShowTablesStatusExecutorTest {
@Test
public void assertExecute() throws SQLException {
- showTablesExecutor.execute(mockBackendConnection());
+ showTablesExecutor.execute(mockConnectionSession());
assertThat(showTablesExecutor.getQueryResultMetaData().getColumnCount(), is(1));
int count = 0;
while (showTablesExecutor.getMergedResult().next()) {
@@ -90,8 +90,8 @@ public final class ShowTablesStatusExecutorTest {
}
}
- private BackendConnection mockBackendConnection() {
- BackendConnection result = mock(BackendConnection.class);
+ private ConnectionSession mockConnectionSession() {
+ ConnectionSession result = mock(ConnectionSession.class);
when(result.getGrantee()).thenReturn(new Grantee("root", ""));
when(result.getSchemaName()).thenReturn(String.format(SCHEMA_PATTERN, 0));
return result;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowVersionExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowVersionExecutorTest.java
index fced813..e748644 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowVersionExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowVersionExecutorTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.backend.text.admin.mysql.executor;
import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLServerInfo;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
@@ -36,7 +36,7 @@ public final class ShowVersionExecutorTest {
public void assertExecute() throws SQLException {
MySQLServerInfo.setServerVersion("8.0.26");
ShowVersionExecutor executor = new ShowVersionExecutor();
- executor.execute(mock(BackendConnection.class));
+ executor.execute(mock(JDBCConnectionSession.class));
assertThat(executor.getQueryResultMetaData().getColumnCount(), is(1));
while (executor.getMergedResult().next()) {
assertThat(executor.getMergedResult().getValue(1, Object.class), is(MySQLServerInfo.getServerVersion()));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/UseDatabaseExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/UseDatabaseExecutorTest.java
index 632d5ff..58817dd 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/UseDatabaseExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/UseDatabaseExecutorTest.java
@@ -26,9 +26,9 @@ import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerCon
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.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.exception.UnknownDatabaseException;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLUseStatement;
import org.junit.Before;
import org.junit.Test;
@@ -53,7 +53,7 @@ public final class UseDatabaseExecutorTest {
private static final String SCHEMA_PATTERN = "schema_%s";
@Mock
- private BackendConnection backendConnection;
+ private ConnectionSession connectionSession;
@Before
public void setUp() throws NoSuchFieldException, IllegalAccessException {
@@ -81,8 +81,8 @@ public final class UseDatabaseExecutorTest {
MySQLUseStatement useStatement = mock(MySQLUseStatement.class);
when(useStatement.getSchema()).thenReturn(String.format(SCHEMA_PATTERN, 0));
UseDatabaseExecutor useSchemaBackendHandler = new UseDatabaseExecutor(useStatement);
- useSchemaBackendHandler.execute(backendConnection);
- verify(backendConnection).setCurrentSchema(anyString());
+ useSchemaBackendHandler.execute(connectionSession);
+ verify(connectionSession).setCurrentSchema(anyString());
}
@Test(expected = UnknownDatabaseException.class)
@@ -90,6 +90,6 @@ public final class UseDatabaseExecutorTest {
MySQLUseStatement useStatement = mock(MySQLUseStatement.class);
when(useStatement.getSchema()).thenReturn(String.format(SCHEMA_PATTERN, 10));
UseDatabaseExecutor useSchemaBackendHandler = new UseDatabaseExecutor(useStatement);
- useSchemaBackendHandler.execute(backendConnection);
+ useSchemaBackendHandler.execute(connectionSession);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/information/SelectInformationExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/information/SelectInformationExecutorTest.java
index 22b9319..2723767 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/information/SelectInformationExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/information/SelectInformationExecutorTest.java
@@ -34,7 +34,7 @@ import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
import org.apache.shardingsphere.parser.rule.builder.DefaultSQLParserRuleConfigurationBuilder;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.text.admin.executor.AbstractDatabaseMetadataExecutor.DefaultDatabaseMetadataExecutor;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
@@ -128,7 +128,7 @@ public final class SelectInformationExecutorTest {
metaDataMap.put("sharding_db", getMetaData());
metaDataMap.put("test", mock(ShardingSphereMetaData.class));
SelectInformationSchemataExecutor selectSchemataExecutor = new SelectInformationSchemataExecutor((SelectStatement) sqlStatement, sql);
- selectSchemataExecutor.execute(mock(BackendConnection.class));
+ selectSchemataExecutor.execute(mock(JDBCConnectionSession.class));
assertThat(selectSchemataExecutor.getQueryResultMetaData().getColumnCount(), is(mockResultSetMap.size()));
int count = 0;
while (selectSchemataExecutor.getMergedResult().next()) {
@@ -159,7 +159,7 @@ public final class SelectInformationExecutorTest {
Map<String, ShardingSphereMetaData> metaDataMap = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaDataMap();
metaDataMap.put("sharding_db", mock(ShardingSphereMetaData.class));
SelectInformationSchemataExecutor selectSchemataExecutor = new SelectInformationSchemataExecutor((SelectStatement) sqlStatement, sql);
- selectSchemataExecutor.execute(mock(BackendConnection.class));
+ selectSchemataExecutor.execute(mock(JDBCConnectionSession.class));
assertThat(selectSchemataExecutor.getQueryResultMetaData().getColumnCount(), is(mockResultSetMap.size()));
while (selectSchemataExecutor.getMergedResult().next()) {
assertThat(selectSchemataExecutor.getMergedResult().getValue(1, String.class), is("sharding_db"));
@@ -174,7 +174,7 @@ public final class SelectInformationExecutorTest {
final String sql = "SELECT SCHEMA_NAME, DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME, DEFAULT_ENCRYPTION FROM information_schema.SCHEMATA";
final SQLStatement sqlStatement = new ShardingSphereSQLParserEngine("MySQL", sqlParserRule).parse(sql, false);
SelectInformationSchemataExecutor selectSchemataExecutor = new SelectInformationSchemataExecutor((SelectStatement) sqlStatement, sql);
- selectSchemataExecutor.execute(mock(BackendConnection.class));
+ selectSchemataExecutor.execute(mock(JDBCConnectionSession.class));
assertThat(selectSchemataExecutor.getQueryResultMetaData().getColumnCount(), is(0));
}
@@ -189,7 +189,7 @@ public final class SelectInformationExecutorTest {
metaDataMap.put("demo_ds_0", getMetaData());
metaDataMap.put("test", mock(ShardingSphereMetaData.class));
DefaultDatabaseMetadataExecutor selectExecutor = new DefaultDatabaseMetadataExecutor(sql);
- selectExecutor.execute(mock(BackendConnection.class));
+ selectExecutor.execute(mock(JDBCConnectionSession.class));
assertThat(selectExecutor.getRows().get(0).get("sn"), is("demo_ds_0"));
assertThat(selectExecutor.getRows().get(0).get("DEFAULT_CHARACTER_SET_NAME"), is("utf8mb4"));
}
@@ -203,7 +203,7 @@ public final class SelectInformationExecutorTest {
Map<String, ShardingSphereMetaData> metaDataMap = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaDataMap();
metaDataMap.put("sharding_db", getMetaData());
DefaultDatabaseMetadataExecutor defaultSelectMetaDataExecutor = new DefaultDatabaseMetadataExecutor(sql);
- defaultSelectMetaDataExecutor.execute(mock(BackendConnection.class));
+ defaultSelectMetaDataExecutor.execute(mock(JDBCConnectionSession.class));
assertThat(defaultSelectMetaDataExecutor.getQueryResultMetaData().getColumnCount(), is(mockMap.size()));
while (defaultSelectMetaDataExecutor.getMergedResult().next()) {
assertThat(defaultSelectMetaDataExecutor.getMergedResult().getValue(1, String.class), is("0"));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/executor/SelectDatabaseExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/executor/SelectDatabaseExecutorTest.java
index ac9f0af..6831074 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/executor/SelectDatabaseExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/executor/SelectDatabaseExecutorTest.java
@@ -34,7 +34,7 @@ import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
import org.apache.shardingsphere.parser.rule.builder.DefaultSQLParserRuleConfigurationBuilder;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectStatement;
@@ -130,7 +130,7 @@ public final class SelectDatabaseExecutorTest {
metaDataMap.put("sharding_db", getMetaData());
metaDataMap.put("test", mock(ShardingSphereMetaData.class));
SelectDatabaseExecutor selectSchemataExecutor = new SelectDatabaseExecutor((SelectStatement) sqlStatement, sql);
- selectSchemataExecutor.execute(mock(BackendConnection.class));
+ selectSchemataExecutor.execute(mock(JDBCConnectionSession.class));
assertThat(selectSchemataExecutor.getQueryResultMetaData().getColumnCount(), is(mockResultSetMap.size()));
int count = 0;
while (selectSchemataExecutor.getMergedResult().next()) {
@@ -163,7 +163,7 @@ public final class SelectDatabaseExecutorTest {
Map<String, ShardingSphereMetaData> metaDataMap = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaDataMap();
metaDataMap.put("sharding_db", mock(ShardingSphereMetaData.class));
SelectDatabaseExecutor selectSchemataExecutor = new SelectDatabaseExecutor((SelectStatement) sqlStatement, sql);
- selectSchemataExecutor.execute(mock(BackendConnection.class));
+ selectSchemataExecutor.execute(mock(JDBCConnectionSession.class));
while (selectSchemataExecutor.getMergedResult().next()) {
assertThat(selectSchemataExecutor.getMergedResult().getValue(1, String.class), is("sharding_db"));
}
@@ -182,7 +182,7 @@ public final class SelectDatabaseExecutorTest {
Map<String, ShardingSphereMetaData> metaDataMap = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaDataMap();
metaDataMap.put("sharding_db", mock(ShardingSphereMetaData.class));
SelectDatabaseExecutor selectSchemataExecutor = new SelectDatabaseExecutor((SelectStatement) sqlStatement, sql);
- selectSchemataExecutor.execute(mock(BackendConnection.class));
+ selectSchemataExecutor.execute(mock(JDBCConnectionSession.class));
while (selectSchemataExecutor.getMergedResult().next()) {
assertThat(selectSchemataExecutor.getMergedResult().getValue(1, String.class), is(""));
assertThat(selectSchemataExecutor.getMergedResult().getValue(2, String.class), is("sharding_db"));
@@ -196,7 +196,7 @@ public final class SelectDatabaseExecutorTest {
final String sql = "SELECT d.oid, d.datname AS databasename, d.datacl, d.datistemplate FROM pg_database d LEFT JOIN pg_tablespace t ON d.dattablespace = t.oid;";
final SQLStatement sqlStatement = new ShardingSphereSQLParserEngine("MySQL", sqlParserRule).parse(sql, false);
SelectDatabaseExecutor selectSchemataExecutor = new SelectDatabaseExecutor((SelectStatement) sqlStatement, sql);
- selectSchemataExecutor.execute(mock(BackendConnection.class));
+ selectSchemataExecutor.execute(mock(JDBCConnectionSession.class));
assertThat(selectSchemataExecutor.getQueryResultMetaData().getColumnCount(), is(0));
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/executor/SelectTableExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/executor/SelectTableExecutorTest.java
index 2bdd089..0f34c86 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/executor/SelectTableExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/executor/SelectTableExecutorTest.java
@@ -32,7 +32,7 @@ import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerCon
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.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.junit.Before;
import org.junit.Test;
@@ -120,7 +120,7 @@ public final class SelectTableExecutorTest {
Map<String, ShardingSphereMetaData> metaDataMap = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaDataMap();
metaDataMap.put("sharding_db", getMetaData());
SelectTableExecutor selectSchemataExecutor = new SelectTableExecutor(sql);
- selectSchemataExecutor.execute(mock(BackendConnection.class));
+ selectSchemataExecutor.execute(mock(JDBCConnectionSession.class));
assertThat(selectSchemataExecutor.getQueryResultMetaData().getColumnCount(), is(mockResultSetMap.size()));
int count = 0;
while (selectSchemataExecutor.getMergedResult().next()) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/DatabaseBackendHandlerFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/DatabaseBackendHandlerFactoryTest.java
index f3a465c..0770fd4 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/DatabaseBackendHandlerFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/DatabaseBackendHandlerFactoryTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.backend.text.data;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.data.impl.BroadcastDatabaseBackendHandler;
import org.apache.shardingsphere.proxy.backend.text.data.impl.SchemaAssignedDatabaseBackendHandler;
import org.apache.shardingsphere.proxy.backend.text.data.impl.UnicastDatabaseBackendHandler;
@@ -41,7 +41,7 @@ public final class DatabaseBackendHandlerFactoryTest {
String sql = "SET a=1";
SQLStatementContext<SetStatement> context = mock(SQLStatementContext.class);
when(context.getSqlStatement()).thenReturn(mock(SetStatement.class));
- DatabaseBackendHandler actual = DatabaseBackendHandlerFactory.newInstance(context, sql, mock(BackendConnection.class));
+ DatabaseBackendHandler actual = DatabaseBackendHandlerFactory.newInstance(context, sql, mock(JDBCConnectionSession.class));
assertThat(actual, instanceOf(BroadcastDatabaseBackendHandler.class));
}
@@ -50,7 +50,7 @@ public final class DatabaseBackendHandlerFactoryTest {
String sql = "DESC tbl";
SQLStatementContext<DALStatement> context = mock(SQLStatementContext.class);
when(context.getSqlStatement()).thenReturn(mock(DALStatement.class));
- DatabaseBackendHandler actual = DatabaseBackendHandlerFactory.newInstance(context, sql, mock(BackendConnection.class));
+ DatabaseBackendHandler actual = DatabaseBackendHandlerFactory.newInstance(context, sql, mock(JDBCConnectionSession.class));
assertThat(actual, instanceOf(UnicastDatabaseBackendHandler.class));
}
@@ -59,7 +59,7 @@ public final class DatabaseBackendHandlerFactoryTest {
String sql = "SELECT 1";
SQLStatementContext<SelectStatement> context = mock(SQLStatementContext.class);
when(context.getSqlStatement()).thenReturn(mock(SelectStatement.class));
- DatabaseBackendHandler actual = DatabaseBackendHandlerFactory.newInstance(context, sql, mock(BackendConnection.class));
+ DatabaseBackendHandler actual = DatabaseBackendHandlerFactory.newInstance(context, sql, mock(JDBCConnectionSession.class));
assertThat(actual, instanceOf(UnicastDatabaseBackendHandler.class));
}
@@ -68,7 +68,7 @@ public final class DatabaseBackendHandlerFactoryTest {
String sql = "SELECT 1 FROM user WHERE id = 1";
SQLStatementContext<SQLStatement> context = mock(SQLStatementContext.class);
when(context.getSqlStatement()).thenReturn(mock(SQLStatement.class));
- DatabaseBackendHandler actual = DatabaseBackendHandlerFactory.newInstance(context, sql, mock(BackendConnection.class));
+ DatabaseBackendHandler actual = DatabaseBackendHandlerFactory.newInstance(context, sql, mock(JDBCConnectionSession.class));
assertThat(actual, instanceOf(SchemaAssignedDatabaseBackendHandler.class));
}
@@ -77,7 +77,7 @@ public final class DatabaseBackendHandlerFactoryTest {
String sql = "CREATE USER test IDENTIFIED BY '123456'";
SQLStatementContext<DCLStatement> context = mock(SQLStatementContext.class);
when(context.getSqlStatement()).thenReturn(mock(DCLStatement.class));
- DatabaseBackendHandler actual = DatabaseBackendHandlerFactory.newInstance(context, sql, mock(BackendConnection.class));
+ DatabaseBackendHandler actual = DatabaseBackendHandlerFactory.newInstance(context, sql, mock(JDBCConnectionSession.class));
assertThat(actual, instanceOf(BroadcastDatabaseBackendHandler.class));
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/BroadcastDatabaseBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/BroadcastDatabaseBackendHandlerTest.java
index 63b2e3e..7046ba1 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/BroadcastDatabaseBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/BroadcastDatabaseBackendHandlerTest.java
@@ -32,7 +32,7 @@ import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
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.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
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;
@@ -66,7 +66,7 @@ public final class BroadcastDatabaseBackendHandlerTest {
private static final String SCHEMA_PATTERN = "schema_%s";
@Mock
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
@Mock
private DatabaseCommunicationEngineFactory databaseCommunicationEngineFactory;
@@ -83,13 +83,13 @@ public final class BroadcastDatabaseBackendHandlerTest {
mock(ExecutorEngine.class), new ConfigurationProperties(new Properties()), mock(OptimizerContext.class));
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
contextManagerField.set(ProxyContext.getInstance(), contextManager);
- when(backendConnection.getSchemaName()).thenReturn(String.format(SCHEMA_PATTERN, 0));
+ when(connectionSession.getSchemaName()).thenReturn(String.format(SCHEMA_PATTERN, 0));
}
@Test
public void assertExecuteSuccess() throws SQLException {
mockDatabaseCommunicationEngine(new UpdateResponseHeader(mock(SQLStatement.class)));
- BroadcastDatabaseBackendHandler broadcastBackendHandler = new BroadcastDatabaseBackendHandler(mock(SQLStatementContext.class), "SET timeout = 1000", backendConnection);
+ BroadcastDatabaseBackendHandler broadcastBackendHandler = new BroadcastDatabaseBackendHandler(mock(SQLStatementContext.class), "SET timeout = 1000", connectionSession);
setBackendHandlerFactory(broadcastBackendHandler);
ResponseHeader actual = broadcastBackendHandler.execute();
assertThat(actual, instanceOf(UpdateResponseHeader.class));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/SchemaAssignedDatabaseBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/SchemaAssignedDatabaseBackendHandlerTest.java
index e9e3e2a..b8fa5ae 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/SchemaAssignedDatabaseBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/SchemaAssignedDatabaseBackendHandlerTest.java
@@ -30,7 +30,7 @@ import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
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.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
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;
@@ -67,7 +67,7 @@ public final class SchemaAssignedDatabaseBackendHandlerTest {
private SchemaAssignedDatabaseBackendHandler schemaAssignedDatabaseBackendHandler;
@Mock
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
@Mock
private DatabaseCommunicationEngineFactory databaseCommunicationEngineFactory;
@@ -84,9 +84,9 @@ public final class SchemaAssignedDatabaseBackendHandlerTest {
mock(ShardingSphereRuleMetaData.class), mock(ExecutorEngine.class), new ConfigurationProperties(new Properties()), mock(OptimizerContext.class));
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
contextManagerField.set(ProxyContext.getInstance(), contextManager);
- when(backendConnection.getSchemaName()).thenReturn(String.format(SCHEMA_PATTERN, 0));
+ when(connectionSession.getSchemaName()).thenReturn(String.format(SCHEMA_PATTERN, 0));
mockDatabaseCommunicationEngine(new UpdateResponseHeader(mock(SQLStatement.class)));
- schemaAssignedDatabaseBackendHandler = new SchemaAssignedDatabaseBackendHandler(mock(SQLStatementContext.class), EXECUTE_SQL, backendConnection);
+ schemaAssignedDatabaseBackendHandler = new SchemaAssignedDatabaseBackendHandler(mock(SQLStatementContext.class), EXECUTE_SQL, connectionSession);
setBackendHandlerFactory(schemaAssignedDatabaseBackendHandler);
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/UnicastDatabaseBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/UnicastDatabaseBackendHandlerTest.java
index 1182386..1fa234d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/UnicastDatabaseBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/UnicastDatabaseBackendHandlerTest.java
@@ -30,7 +30,7 @@ import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
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.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
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;
@@ -67,7 +67,7 @@ public final class UnicastDatabaseBackendHandlerTest {
private UnicastDatabaseBackendHandler unicastDatabaseBackendHandler;
@Mock
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
@Mock
private DatabaseCommunicationEngineFactory databaseCommunicationEngineFactory;
@@ -84,9 +84,9 @@ public final class UnicastDatabaseBackendHandlerTest {
mock(ShardingSphereRuleMetaData.class), mock(ExecutorEngine.class), new ConfigurationProperties(new Properties()), mock(OptimizerContext.class));
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
contextManagerField.set(ProxyContext.getInstance(), contextManager);
- when(backendConnection.getSchemaName()).thenReturn(String.format(SCHEMA_PATTERN, 0));
+ when(connectionSession.getSchemaName()).thenReturn(String.format(SCHEMA_PATTERN, 0));
mockDatabaseCommunicationEngine(new UpdateResponseHeader(mock(SQLStatement.class)));
- unicastDatabaseBackendHandler = new UnicastDatabaseBackendHandler(mock(SQLStatementContext.class), EXECUTE_SQL, backendConnection);
+ unicastDatabaseBackendHandler = new UnicastDatabaseBackendHandler(mock(SQLStatementContext.class), EXECUTE_SQL, connectionSession);
setBackendHandlerFactory(unicastDatabaseBackendHandler);
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/database/DropDatabaseBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/database/DropDatabaseBackendHandlerTest.java
index 08bee07..abafa29 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/database/DropDatabaseBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/database/DropDatabaseBackendHandlerTest.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.proxy.backend.text.database;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.exception.DBDropExistsException;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
@@ -46,7 +46,7 @@ import static org.mockito.Mockito.when;
public final class DropDatabaseBackendHandlerTest {
@Mock
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
@Mock
private DropDatabaseStatement sqlStatement;
@@ -61,7 +61,7 @@ public final class DropDatabaseBackendHandlerTest {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
ProxyContext.getInstance().init(contextManager);
- handler = new DropDatabaseBackendHandler(sqlStatement, backendConnection);
+ handler = new DropDatabaseBackendHandler(sqlStatement, connectionSession);
when(metaDataContexts.getAllSchemaNames()).thenReturn(Arrays.asList("test_db", "other_db"));
}
@@ -75,27 +75,27 @@ public final class DropDatabaseBackendHandlerTest {
public void assertExecuteDropWithoutCurrentDatabase() {
when(sqlStatement.getDatabaseName()).thenReturn("test_db");
ResponseHeader responseHeader = handler.execute();
- verify(backendConnection, times(0)).setCurrentSchema(null);
+ verify(connectionSession, times(0)).setCurrentSchema(null);
assertNotNull(responseHeader);
assertTrue(responseHeader instanceof UpdateResponseHeader);
}
@Test
public void assertExecuteDropCurrentDatabase() {
- when(backendConnection.getSchemaName()).thenReturn("test_db");
+ when(connectionSession.getSchemaName()).thenReturn("test_db");
when(sqlStatement.getDatabaseName()).thenReturn("test_db");
ResponseHeader responseHeader = handler.execute();
- verify(backendConnection).setCurrentSchema(null);
+ verify(connectionSession).setCurrentSchema(null);
assertNotNull(responseHeader);
assertTrue(responseHeader instanceof UpdateResponseHeader);
}
@Test
public void assertExecuteDropOtherDatabase() {
- when(backendConnection.getSchemaName()).thenReturn("test_db");
+ when(connectionSession.getSchemaName()).thenReturn("test_db");
when(sqlStatement.getDatabaseName()).thenReturn("other_db");
ResponseHeader responseHeader = handler.execute();
- verify(backendConnection, times(0)).setCurrentSchema(null);
+ verify(connectionSession, times(0)).setCurrentSchema(null);
assertNotNull(responseHeader);
assertTrue(responseHeader instanceof UpdateResponseHeader);
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactoryTest.java
index 46c79ad..736453d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactoryTest.java
@@ -33,7 +33,7 @@ import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerCon
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.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
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.QueryResponseHeader;
@@ -97,7 +97,7 @@ public final class DistSQLBackendHandlerFactoryTest {
@Test
public void assertExecuteDataSourcesContext() throws SQLException {
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getSchemaName()).thenReturn("schema");
setContextManager(true);
ResponseHeader response = RDLBackendHandlerFactory.newInstance(new MySQLDatabaseType(), mock(AddResourceStatement.class), connection).execute();
@@ -106,7 +106,7 @@ public final class DistSQLBackendHandlerFactoryTest {
@Test
public void assertExecuteShardingTableRuleContext() throws SQLException {
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getSchemaName()).thenReturn("schema");
setContextManager(true);
ShardingSphereMetaData metaData = ProxyContext.getInstance().getMetaData("schema");
@@ -117,7 +117,7 @@ public final class DistSQLBackendHandlerFactoryTest {
@Test
public void assertExecuteAddResourceContext() throws SQLException {
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getSchemaName()).thenReturn("schema");
setContextManager(true);
ResponseHeader response = RDLBackendHandlerFactory.newInstance(new MySQLDatabaseType(), mock(AddResourceStatement.class), connection).execute();
@@ -126,7 +126,7 @@ public final class DistSQLBackendHandlerFactoryTest {
@Test
public void assertExecuteAlterResourceContext() throws SQLException {
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getSchemaName()).thenReturn("schema");
setContextManager(true);
ResponseHeader response = RDLBackendHandlerFactory.newInstance(new MySQLDatabaseType(), mock(AlterResourceStatement.class), connection).execute();
@@ -135,7 +135,7 @@ public final class DistSQLBackendHandlerFactoryTest {
@Test
public void assertExecuteAlterShadowRuleContext() throws SQLException {
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getSchemaName()).thenReturn("schema");
setContextManager(true);
mockShardingSphereRuleMetaData();
@@ -145,7 +145,7 @@ public final class DistSQLBackendHandlerFactoryTest {
@Test
public void assertExecuteCreateShadowRuleContext() throws SQLException {
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getSchemaName()).thenReturn("schema");
setContextManager(true);
mockShardingSphereRuleMetaData();
@@ -155,7 +155,7 @@ public final class DistSQLBackendHandlerFactoryTest {
@Test
public void assertExecuteDropShadowRuleContext() throws SQLException {
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getSchemaName()).thenReturn("schema");
setContextManager(true);
mockShardingSphereRuleMetaData();
@@ -165,7 +165,7 @@ public final class DistSQLBackendHandlerFactoryTest {
@Test
public void assertExecuteAlterShadowAlgorithm() throws SQLException {
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getSchemaName()).thenReturn("schema");
setContextManager(true);
mockShardingSphereRuleMetaData();
@@ -175,7 +175,7 @@ public final class DistSQLBackendHandlerFactoryTest {
@Test
public void assertExecuteShowShadowRulesContext() throws SQLException {
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getSchemaName()).thenReturn("schema");
setContextManager(true);
mockShardingSphereRuleMetaData();
@@ -185,7 +185,7 @@ public final class DistSQLBackendHandlerFactoryTest {
@Test
public void assertExecuteShowShadowTableRulesContext() throws SQLException {
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getSchemaName()).thenReturn("schema");
setContextManager(true);
mockShardingSphereRuleMetaData();
@@ -195,7 +195,7 @@ public final class DistSQLBackendHandlerFactoryTest {
@Test
public void assertExecuteShowShadowAlgorithmsContext() throws SQLException {
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getSchemaName()).thenReturn("schema");
setContextManager(true);
mockShardingSphereRuleMetaData();
@@ -205,7 +205,7 @@ public final class DistSQLBackendHandlerFactoryTest {
@Test
public void assertExecuteDropShadowAlgorithmContext() throws SQLException {
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getSchemaName()).thenReturn("schema");
setContextManager(true);
mockShardingSphereRuleMetaData();
@@ -215,7 +215,7 @@ public final class DistSQLBackendHandlerFactoryTest {
@Test
public void assertExecuteDropResourceContext() throws SQLException {
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getSchemaName()).thenReturn("schema");
setContextManager(true);
ResponseHeader response = RDLBackendHandlerFactory.newInstance(new MySQLDatabaseType(), mock(DropResourceStatement.class), connection).execute();
@@ -224,7 +224,7 @@ public final class DistSQLBackendHandlerFactoryTest {
@Test(expected = RequiredRuleMissedException.class)
public void assertExecuteDropReadwriteSplittingRuleContext() throws SQLException {
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getSchemaName()).thenReturn("schema");
setContextManager(true);
ResponseHeader response = RDLBackendHandlerFactory.newInstance(new MySQLDatabaseType(), mock(DropReadwriteSplittingRuleStatement.class), connection).execute();
@@ -233,7 +233,7 @@ public final class DistSQLBackendHandlerFactoryTest {
@Test
public void assertExecuteCreateReadwriteSplittingRuleContext() throws SQLException {
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getSchemaName()).thenReturn("schema");
setContextManager(true);
ResponseHeader response = RDLBackendHandlerFactory.newInstance(new MySQLDatabaseType(), mock(CreateReadwriteSplittingRuleStatement.class), connection).execute();
@@ -242,7 +242,7 @@ public final class DistSQLBackendHandlerFactoryTest {
@Test(expected = RequiredRuleMissedException.class)
public void assertExecuteAlterReadwriteSplittingRuleContext() throws SQLException {
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getSchemaName()).thenReturn("schema");
setContextManager(true);
ResponseHeader response = RDLBackendHandlerFactory.newInstance(new MySQLDatabaseType(), mock(AlterReadwriteSplittingRuleStatement.class), connection).execute();
@@ -251,7 +251,7 @@ public final class DistSQLBackendHandlerFactoryTest {
@Test
public void assertExecuteShowResourceContext() throws SQLException {
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getSchemaName()).thenReturn("schema");
setContextManager(true);
ResponseHeader response = RQLBackendHandlerFactory.newInstance(mock(ShowResourcesStatement.class), connection).execute();
@@ -260,7 +260,7 @@ public final class DistSQLBackendHandlerFactoryTest {
@Test
public void assertExecuteShowScalingCheckAlgorithmsContext() throws SQLException {
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getSchemaName()).thenReturn("schema");
mockScalingContext();
ResponseHeader response = RALBackendHandlerFactory.newInstance(new MySQLDatabaseType(), mock(ShowScalingCheckAlgorithmsStatement.class), connection).execute();
@@ -269,7 +269,7 @@ public final class DistSQLBackendHandlerFactoryTest {
@Test
public void assertExecuteStopScalingSourceWritingContext() throws SQLException {
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getSchemaName()).thenReturn("schema");
mockScalingContext();
ResponseHeader response = RALBackendHandlerFactory.newInstance(new MySQLDatabaseType(), mock(StopScalingSourceWritingStatement.class), connection).execute();
@@ -279,7 +279,7 @@ public final class DistSQLBackendHandlerFactoryTest {
//TODO assertExecuteCheckoutScalingContext throw exception
@Test(expected = RuntimeException.class)
public void assertExecuteCheckoutScalingContext() throws SQLException {
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getSchemaName()).thenReturn("schema");
mockScalingContext();
ResponseHeader response = RALBackendHandlerFactory.newInstance(new MySQLDatabaseType(), mock(CheckoutScalingStatement.class), connection).execute();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/SetVariableBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/SetVariableBackendHandlerTest.java
index b7a92a2..a8e2727 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/SetVariableBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/SetVariableBackendHandlerTest.java
@@ -30,7 +30,7 @@ import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerCon
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.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
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;
@@ -60,7 +60,7 @@ public final class SetVariableBackendHandlerTest {
private static final String SCHEMA_PATTERN = "schema_%s";
- private final BackendConnection backendConnection = new BackendConnection(TransactionType.LOCAL, new DefaultAttributeMap());
+ private final JDBCConnectionSession connectionSession = new JDBCConnectionSession(TransactionType.LOCAL, new DefaultAttributeMap());
@Before
public void setUp() throws NoSuchFieldException, IllegalAccessException {
@@ -88,47 +88,47 @@ public final class SetVariableBackendHandlerTest {
@Test
public void assertSwitchTransactionTypeXA() throws SQLException {
- backendConnection.setCurrentSchema(String.format(SCHEMA_PATTERN, 0));
- SetDistSQLBackendHandler setDistSQLBackendHandler = new SetDistSQLBackendHandler(new SetVariableStatement("transaction_type", "XA"), backendConnection);
+ connectionSession.setCurrentSchema(String.format(SCHEMA_PATTERN, 0));
+ SetDistSQLBackendHandler setDistSQLBackendHandler = new SetDistSQLBackendHandler(new SetVariableStatement("transaction_type", "XA"), connectionSession);
ResponseHeader actual = setDistSQLBackendHandler.execute();
assertThat(actual, instanceOf(UpdateResponseHeader.class));
- assertThat(backendConnection.getTransactionStatus().getTransactionType(), is(TransactionType.XA));
+ assertThat(connectionSession.getTransactionStatus().getTransactionType(), is(TransactionType.XA));
}
@Test
public void assertSwitchTransactionTypeBASE() throws SQLException {
- backendConnection.setCurrentSchema(String.format(SCHEMA_PATTERN, 0));
- SetDistSQLBackendHandler setDistSQLBackendHandler = new SetDistSQLBackendHandler(new SetVariableStatement("transaction_type", "BASE"), backendConnection);
+ connectionSession.setCurrentSchema(String.format(SCHEMA_PATTERN, 0));
+ SetDistSQLBackendHandler setDistSQLBackendHandler = new SetDistSQLBackendHandler(new SetVariableStatement("transaction_type", "BASE"), connectionSession);
ResponseHeader actual = setDistSQLBackendHandler.execute();
assertThat(actual, instanceOf(UpdateResponseHeader.class));
- assertThat(backendConnection.getTransactionStatus().getTransactionType(), is(TransactionType.BASE));
+ assertThat(connectionSession.getTransactionStatus().getTransactionType(), is(TransactionType.BASE));
}
@Test
public void assertSwitchTransactionTypeLOCAL() throws SQLException {
- backendConnection.setCurrentSchema(String.format(SCHEMA_PATTERN, 0));
- SetDistSQLBackendHandler setDistSQLBackendHandler = new SetDistSQLBackendHandler(new SetVariableStatement("transaction_type", "LOCAL"), backendConnection);
+ connectionSession.setCurrentSchema(String.format(SCHEMA_PATTERN, 0));
+ SetDistSQLBackendHandler setDistSQLBackendHandler = new SetDistSQLBackendHandler(new SetVariableStatement("transaction_type", "LOCAL"), connectionSession);
ResponseHeader actual = setDistSQLBackendHandler.execute();
assertThat(actual, instanceOf(UpdateResponseHeader.class));
- assertThat(backendConnection.getTransactionStatus().getTransactionType(), is(TransactionType.LOCAL));
+ assertThat(connectionSession.getTransactionStatus().getTransactionType(), is(TransactionType.LOCAL));
}
@Test(expected = UnsupportedVariableException.class)
public void assertSwitchTransactionTypeFailed() throws SQLException {
- backendConnection.setCurrentSchema(String.format(SCHEMA_PATTERN, 0));
- new SetDistSQLBackendHandler(new SetVariableStatement("transaction_type", "XXX"), backendConnection).execute();
+ connectionSession.setCurrentSchema(String.format(SCHEMA_PATTERN, 0));
+ new SetDistSQLBackendHandler(new SetVariableStatement("transaction_type", "XXX"), connectionSession).execute();
}
@Test(expected = UnsupportedVariableException.class)
public void assertNotSupportedVariable() throws SQLException {
- new SetDistSQLBackendHandler(new SetVariableStatement("@@session", "XXX"), backendConnection).execute();
+ new SetDistSQLBackendHandler(new SetVariableStatement("@@session", "XXX"), connectionSession).execute();
}
@Test
public void assertSetAgentPluginsEnabledTrue() throws SQLException {
- backendConnection.setCurrentSchema(String.format(SCHEMA_PATTERN, 0));
- SetDistSQLBackendHandler setDistSQLBackendHandler = new SetDistSQLBackendHandler(new SetVariableStatement(VariableEnum.AGENT_PLUGINS_ENABLED.name(), Boolean.TRUE.toString()),
- backendConnection);
+ connectionSession.setCurrentSchema(String.format(SCHEMA_PATTERN, 0));
+ SetDistSQLBackendHandler setDistSQLBackendHandler = new SetDistSQLBackendHandler(new SetVariableStatement(VariableEnum.AGENT_PLUGINS_ENABLED.name(), Boolean.TRUE.toString()),
+ connectionSession);
ResponseHeader actual = setDistSQLBackendHandler.execute();
assertThat(actual, instanceOf(UpdateResponseHeader.class));
assertThat(SystemPropertyUtil.getSystemProperty(VariableEnum.AGENT_PLUGINS_ENABLED.name(), Boolean.FALSE.toString()), is(Boolean.TRUE.toString()));
@@ -136,8 +136,8 @@ public final class SetVariableBackendHandlerTest {
@Test
public void assertSetAgentPluginsEnabledFalse() throws SQLException {
- backendConnection.setCurrentSchema(String.format(SCHEMA_PATTERN, 0));
- SetDistSQLBackendHandler setDistSQLBackendHandler = new SetDistSQLBackendHandler(new SetVariableStatement(VariableEnum.AGENT_PLUGINS_ENABLED.name(), "FALSE"), backendConnection);
+ connectionSession.setCurrentSchema(String.format(SCHEMA_PATTERN, 0));
+ SetDistSQLBackendHandler setDistSQLBackendHandler = new SetDistSQLBackendHandler(new SetVariableStatement(VariableEnum.AGENT_PLUGINS_ENABLED.name(), "FALSE"), connectionSession);
ResponseHeader actual = setDistSQLBackendHandler.execute();
assertThat(actual, instanceOf(UpdateResponseHeader.class));
assertThat(SystemPropertyUtil.getSystemProperty(VariableEnum.AGENT_PLUGINS_ENABLED.name(), Boolean.FALSE.toString()), is(Boolean.FALSE.toString()));
@@ -145,8 +145,8 @@ public final class SetVariableBackendHandlerTest {
@Test
public void assertSetAgentPluginsEnabledFalseWithUnknownValue() throws SQLException {
- backendConnection.setCurrentSchema(String.format(SCHEMA_PATTERN, 0));
- SetDistSQLBackendHandler setDistSQLBackendHandler = new SetDistSQLBackendHandler(new SetVariableStatement(VariableEnum.AGENT_PLUGINS_ENABLED.name(), "xxx"), backendConnection);
+ connectionSession.setCurrentSchema(String.format(SCHEMA_PATTERN, 0));
+ SetDistSQLBackendHandler setDistSQLBackendHandler = new SetDistSQLBackendHandler(new SetVariableStatement(VariableEnum.AGENT_PLUGINS_ENABLED.name(), "xxx"), connectionSession);
ResponseHeader actual = setDistSQLBackendHandler.execute();
assertThat(actual, instanceOf(UpdateResponseHeader.class));
assertThat(SystemPropertyUtil.getSystemProperty(VariableEnum.AGENT_PLUGINS_ENABLED.name(), Boolean.FALSE.toString()), is(Boolean.FALSE.toString()));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/ShowAllVariablesBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/ShowAllVariablesBackendHandlerTest.java
index bd23ea7..8a20a85 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/ShowAllVariablesBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/ShowAllVariablesBackendHandlerTest.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowAl
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
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.QueryResponseHeader;
@@ -43,17 +43,17 @@ import static org.mockito.Mockito.when;
public final class ShowAllVariablesBackendHandlerTest {
- private final BackendConnection backendConnection = new BackendConnection(TransactionType.LOCAL, new DefaultAttributeMap());
+ private final JDBCConnectionSession connectionSession = new JDBCConnectionSession(TransactionType.LOCAL, new DefaultAttributeMap());
@Test
public void assertShowPropsVariable() throws SQLException {
- backendConnection.setCurrentSchema("schema");
+ connectionSession.setCurrentSchema("schema");
ContextManager contextManager = mock(ContextManager.class);
ProxyContext.getInstance().init(contextManager);
MetaDataContexts metaDataContexts = mock(MetaDataContexts.class);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
when(metaDataContexts.getProps()).thenReturn(new ConfigurationProperties(new Properties()));
- ShowDistSQLBackendHandler backendHandler = new ShowDistSQLBackendHandler(new ShowAllVariablesStatement(), backendConnection);
+ ShowDistSQLBackendHandler backendHandler = new ShowDistSQLBackendHandler(new ShowAllVariablesStatement(), connectionSession);
ResponseHeader actual = backendHandler.execute();
assertThat(actual, instanceOf(QueryResponseHeader.class));
assertThat(((QueryResponseHeader) actual).getQueryHeaders().size(), is(2));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/ShowVariableBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/ShowVariableBackendHandlerTest.java
index 11e235a..97aea16 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/ShowVariableBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/ShowVariableBackendHandlerTest.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowVa
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
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.QueryResponseHeader;
@@ -44,12 +44,12 @@ import static org.mockito.Mockito.when;
public final class ShowVariableBackendHandlerTest {
- private final BackendConnection backendConnection = new BackendConnection(TransactionType.LOCAL, new DefaultAttributeMap());
+ private final JDBCConnectionSession connectionSession = new JDBCConnectionSession(TransactionType.LOCAL, new DefaultAttributeMap());
@Test
public void assertShowTransactionType() throws SQLException {
- backendConnection.setCurrentSchema("schema");
- ShowDistSQLBackendHandler backendHandler = new ShowDistSQLBackendHandler(new ShowVariableStatement("transaction_type"), backendConnection);
+ connectionSession.setCurrentSchema("schema");
+ ShowDistSQLBackendHandler backendHandler = new ShowDistSQLBackendHandler(new ShowVariableStatement("transaction_type"), connectionSession);
ResponseHeader actual = backendHandler.execute();
assertThat(actual, instanceOf(QueryResponseHeader.class));
assertThat(((QueryResponseHeader) actual).getQueryHeaders().size(), is(1));
@@ -60,8 +60,8 @@ public final class ShowVariableBackendHandlerTest {
@Test
public void assertShowCachedConnections() throws SQLException {
- backendConnection.setCurrentSchema("schema");
- ShowDistSQLBackendHandler backendHandler = new ShowDistSQLBackendHandler(new ShowVariableStatement("cached_connections"), backendConnection);
+ connectionSession.setCurrentSchema("schema");
+ ShowDistSQLBackendHandler backendHandler = new ShowDistSQLBackendHandler(new ShowVariableStatement("cached_connections"), connectionSession);
ResponseHeader actual = backendHandler.execute();
assertThat(actual, instanceOf(QueryResponseHeader.class));
assertThat(((QueryResponseHeader) actual).getQueryHeaders().size(), is(1));
@@ -72,14 +72,14 @@ public final class ShowVariableBackendHandlerTest {
@Test(expected = UnsupportedVariableException.class)
public void assertShowCachedConnectionFailed() throws SQLException {
- backendConnection.setCurrentSchema("schema");
- new ShowDistSQLBackendHandler(new ShowVariableStatement("cached_connectionss"), backendConnection).execute();
+ connectionSession.setCurrentSchema("schema");
+ new ShowDistSQLBackendHandler(new ShowVariableStatement("cached_connectionss"), connectionSession).execute();
}
@Test
public void assertShowAgentPluginsEnabled() throws SQLException {
- backendConnection.setCurrentSchema("schema");
- ShowDistSQLBackendHandler backendHandler = new ShowDistSQLBackendHandler(new ShowVariableStatement(VariableEnum.AGENT_PLUGINS_ENABLED.name()), backendConnection);
+ connectionSession.setCurrentSchema("schema");
+ ShowDistSQLBackendHandler backendHandler = new ShowDistSQLBackendHandler(new ShowVariableStatement(VariableEnum.AGENT_PLUGINS_ENABLED.name()), connectionSession);
ResponseHeader actual = backendHandler.execute();
assertThat(actual, instanceOf(QueryResponseHeader.class));
assertThat(((QueryResponseHeader) actual).getQueryHeaders().size(), is(1));
@@ -90,7 +90,7 @@ public final class ShowVariableBackendHandlerTest {
@Test
public void assertShowPropsVariable() throws SQLException {
- backendConnection.setCurrentSchema("schema");
+ connectionSession.setCurrentSchema("schema");
ContextManager contextManager = mock(ContextManager.class);
ProxyContext.getInstance().init(contextManager);
MetaDataContexts metaDataContexts = mock(MetaDataContexts.class);
@@ -99,7 +99,7 @@ public final class ShowVariableBackendHandlerTest {
props.put("sql-show", "true");
ConfigurationProperties configurationProperties = new ConfigurationProperties(props);
when(metaDataContexts.getProps()).thenReturn(configurationProperties);
- ShowDistSQLBackendHandler backendHandler = new ShowDistSQLBackendHandler(new ShowVariableStatement("SQL_SHOW"), backendConnection);
+ ShowDistSQLBackendHandler backendHandler = new ShowDistSQLBackendHandler(new ShowVariableStatement("SQL_SHOW"), connectionSession);
ResponseHeader actual = backendHandler.execute();
assertThat(actual, instanceOf(QueryResponseHeader.class));
assertThat(((QueryResponseHeader) actual).getQueryHeaders().size(), is(1));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advance/ParseDistSQLBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advance/ParseDistSQLBackendHandlerTest.java
index aee999e..94d9bbc 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advance/ParseDistSQLBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advance/ParseDistSQLBackendHandlerTest.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
import org.apache.shardingsphere.parser.rule.builder.DefaultSQLParserRuleConfigurationBuilder;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.advanced.ParseDistSQLBackendHandler;
import org.apache.shardingsphere.sql.parser.exception.SQLParsingException;
@@ -63,7 +63,7 @@ public final class ParseDistSQLBackendHandlerTest {
public void assertGetRowData() {
String sql = "select * from t_order";
ParseStatement parseStatement = new ParseStatement(sql);
- ParseDistSQLBackendHandler parseDistSQLBackendHandler = new ParseDistSQLBackendHandler(new MySQLDatabaseType(), parseStatement, mock(BackendConnection.class));
+ ParseDistSQLBackendHandler parseDistSQLBackendHandler = new ParseDistSQLBackendHandler(new MySQLDatabaseType(), parseStatement, mock(JDBCConnectionSession.class));
parseDistSQLBackendHandler.execute();
SQLStatement statement = new ShardingSphereSQLParserEngine("MySQL", sqlParserRule).parse(sql, false);
assertThat(new LinkedList<>(parseDistSQLBackendHandler.getRowData()).getFirst(), is(new Gson().toJson(statement)));
@@ -73,7 +73,7 @@ public final class ParseDistSQLBackendHandlerTest {
public void assertExecute() {
String sql = "wrong sql";
ParseStatement parseStatement = new ParseStatement(sql);
- ParseDistSQLBackendHandler parseDistSQLBackendHandler = new ParseDistSQLBackendHandler(new MySQLDatabaseType(), parseStatement, mock(BackendConnection.class));
+ ParseDistSQLBackendHandler parseDistSQLBackendHandler = new ParseDistSQLBackendHandler(new MySQLDatabaseType(), parseStatement, mock(JDBCConnectionSession.class));
parseDistSQLBackendHandler.execute();
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/HintStatementExecutorFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/HintStatementExecutorFactoryTest.java
index f57d084..326c8f6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/HintStatementExecutorFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/HintStatementExecutorFactoryTest.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.HintDistSQLStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.hint.ClearHintStatement;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.executor.AddShardingHintDatabaseValueExecutor;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.executor.AddShardingHintTableValueExecutor;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.executor.ClearHintExecutor;
@@ -52,59 +52,59 @@ import static org.mockito.Mockito.mock;
public final class HintStatementExecutorFactoryTest {
@Mock
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
@Test
public void assertSetReadwriteSplittingHintSourceExecutor() throws SQLException {
HintDistSQLStatement sqlStatement = mock(SetReadwriteSplittingHintStatement.class);
- assertThat(HintStatementExecutorFactory.newInstance(sqlStatement, backendConnection), instanceOf(SetReadwriteSplittingHintExecutor.class));
+ assertThat(HintStatementExecutorFactory.newInstance(sqlStatement, connectionSession), instanceOf(SetReadwriteSplittingHintExecutor.class));
}
@Test
public void assertShowReadwriteSplittingHintSourceExecutor() throws SQLException {
HintDistSQLStatement sqlStatement = mock(ShowReadwriteSplittingHintStatusStatement.class);
- assertThat(HintStatementExecutorFactory.newInstance(sqlStatement, backendConnection), instanceOf(ShowReadwriteSplittingHintStatusExecutor.class));
+ assertThat(HintStatementExecutorFactory.newInstance(sqlStatement, connectionSession), instanceOf(ShowReadwriteSplittingHintStatusExecutor.class));
}
@Test
public void assertClearReadwriteSplittingHintSourceExecutor() throws SQLException {
HintDistSQLStatement sqlStatement = mock(ClearReadwriteSplittingHintStatement.class);
- assertThat(HintStatementExecutorFactory.newInstance(sqlStatement, backendConnection), instanceOf(ClearReadwriteSplittingHintExecutor.class));
+ assertThat(HintStatementExecutorFactory.newInstance(sqlStatement, connectionSession), instanceOf(ClearReadwriteSplittingHintExecutor.class));
}
@Test
public void assertClearHintExecutor() throws SQLException {
HintDistSQLStatement sqlStatement = mock(ClearHintStatement.class);
- assertThat(HintStatementExecutorFactory.newInstance(sqlStatement, backendConnection), instanceOf(ClearHintExecutor.class));
+ assertThat(HintStatementExecutorFactory.newInstance(sqlStatement, connectionSession), instanceOf(ClearHintExecutor.class));
}
@Test
public void assertSetShardingHintDatabaseValueExecutor() throws SQLException {
HintDistSQLStatement sqlStatement = mock(SetShardingHintDatabaseValueStatement.class);
- assertThat(HintStatementExecutorFactory.newInstance(sqlStatement, backendConnection), instanceOf(SetShardingHintDatabaseValueExecutor.class));
+ assertThat(HintStatementExecutorFactory.newInstance(sqlStatement, connectionSession), instanceOf(SetShardingHintDatabaseValueExecutor.class));
}
@Test
public void assertAddShardingHintDatabaseValueExecutor() throws SQLException {
HintDistSQLStatement sqlStatement = mock(AddShardingHintDatabaseValueStatement.class);
- assertThat(HintStatementExecutorFactory.newInstance(sqlStatement, backendConnection), instanceOf(AddShardingHintDatabaseValueExecutor.class));
+ assertThat(HintStatementExecutorFactory.newInstance(sqlStatement, connectionSession), instanceOf(AddShardingHintDatabaseValueExecutor.class));
}
@Test
public void assertAddShardingHintTableValueExecutor() throws SQLException {
HintDistSQLStatement sqlStatement = mock(AddShardingHintTableValueStatement.class);
- assertThat(HintStatementExecutorFactory.newInstance(sqlStatement, backendConnection), instanceOf(AddShardingHintTableValueExecutor.class));
+ assertThat(HintStatementExecutorFactory.newInstance(sqlStatement, connectionSession), instanceOf(AddShardingHintTableValueExecutor.class));
}
@Test
public void assertShowShardingHintStatusExecutor() throws SQLException {
HintDistSQLStatement sqlStatement = mock(ShowShardingHintStatusStatement.class);
- assertThat(HintStatementExecutorFactory.newInstance(sqlStatement, backendConnection), instanceOf(ShowShardingHintStatusExecutor.class));
+ assertThat(HintStatementExecutorFactory.newInstance(sqlStatement, connectionSession), instanceOf(ShowShardingHintStatusExecutor.class));
}
@Test
public void assertClearShardingValueHintExecutor() throws SQLException {
HintDistSQLStatement sqlStatement = mock(ClearShardingHintStatement.class);
- assertThat(HintStatementExecutorFactory.newInstance(sqlStatement, backendConnection), instanceOf(ClearShardingHintExecutor.class));
+ assertThat(HintStatementExecutorFactory.newInstance(sqlStatement, connectionSession), instanceOf(ClearShardingHintExecutor.class));
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/set/SetStatementExecutorFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/set/SetStatementExecutorFactoryTest.java
index af2c1e8..b3b825e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/set/SetStatementExecutorFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/set/SetStatementExecutorFactoryTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.set;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.SetDistSQLStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.set.SetInstanceStatusStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.set.SetVariableStatement;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.set.excutor.SetInstanceStatusExecutor;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.set.excutor.SetReadwriteSplittingStatusExecutor;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.set.excutor.SetVariableExecutor;
@@ -40,23 +40,23 @@ import static org.mockito.Mockito.mock;
public final class SetStatementExecutorFactoryTest {
@Mock
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
@Test
public void assertSetVariableExecutor() throws SQLException {
SetDistSQLStatement sqlStatement = mock(SetVariableStatement.class);
- assertThat(SetStatementExecutorFactory.newInstance(sqlStatement, backendConnection), instanceOf(SetVariableExecutor.class));
+ assertThat(SetStatementExecutorFactory.newInstance(sqlStatement, connectionSession), instanceOf(SetVariableExecutor.class));
}
@Test
public void assertSetReadwriteSplittingStatusExecutor() throws SQLException {
SetDistSQLStatement sqlStatement = mock(SetReadwriteSplittingStatusStatement.class);
- assertThat(SetStatementExecutorFactory.newInstance(sqlStatement, backendConnection), instanceOf(SetReadwriteSplittingStatusExecutor.class));
+ assertThat(SetStatementExecutorFactory.newInstance(sqlStatement, connectionSession), instanceOf(SetReadwriteSplittingStatusExecutor.class));
}
@Test
public void assertSetInstanceStatusExecutor() throws SQLException {
SetDistSQLStatement sqlStatement = mock(SetInstanceStatusStatement.class);
- assertThat(SetStatementExecutorFactory.newInstance(sqlStatement, backendConnection), instanceOf(SetInstanceStatusExecutor.class));
+ assertThat(SetStatementExecutorFactory.newInstance(sqlStatement, connectionSession), instanceOf(SetInstanceStatusExecutor.class));
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/set/executor/SetVariableExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/set/executor/SetVariableExecutorTest.java
index bbeb266..63f998e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/set/executor/SetVariableExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/set/executor/SetVariableExecutorTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.set.exec
import org.apache.shardingsphere.distsql.parser.statement.ral.common.set.SetVariableStatement;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.TransactionStatus;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.enums.VariableEnum;
@@ -41,7 +41,7 @@ public final class SetVariableExecutorTest {
@Test
public void assertExecuteWithTransactionType() {
SetVariableStatement statement = new SetVariableStatement("transaction_type", "local");
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
when(connection.getTransactionStatus()).thenReturn(new TransactionStatus(TransactionType.XA));
new SetVariableExecutor(statement, connection).execute();
assertThat(connection.getTransactionStatus().getTransactionType().name(), is(TransactionType.LOCAL.name()));
@@ -50,7 +50,7 @@ public final class SetVariableExecutorTest {
@Test
public void assertExecuteWithAgent() {
SetVariableStatement statement = new SetVariableStatement("AGENT_PLUGINS_ENABLED", "false");
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
new SetVariableExecutor(statement, connection).execute();
String actualValue = SystemPropertyUtil.getSystemProperty(VariableEnum.AGENT_PLUGINS_ENABLED.name(), "default");
assertThat(actualValue, is("false"));
@@ -63,7 +63,7 @@ public final class SetVariableExecutorTest {
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
ProxyContext.getInstance().init(contextManager);
SetVariableStatement statement = new SetVariableStatement("proxy_frontend_flush_threshold", "1024");
- BackendConnection connection = mock(BackendConnection.class);
+ JDBCConnectionSession connection = mock(JDBCConnectionSession.class);
new SetVariableExecutor(statement, connection).execute();
Object actualValue = contextManager.getMetaDataContexts().getProps().getProps().get("proxy-frontend-flush-threshold");
assertNotNull(actualValue);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AddResourceBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AddResourceBackendHandlerTest.java
index e226f56..3a8e1d6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AddResourceBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AddResourceBackendHandlerTest.java
@@ -27,7 +27,7 @@ import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
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;
@@ -59,7 +59,7 @@ public final class AddResourceBackendHandlerTest {
private AddResourceStatement addResourceStatement;
@Mock
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private MetaDataContexts metaDataContexts;
@@ -74,7 +74,7 @@ public final class AddResourceBackendHandlerTest {
@Before
public void setUp() throws Exception {
- addResourceBackendHandler = new AddResourceBackendHandler(new MySQLDatabaseType(), addResourceStatement, backendConnection);
+ addResourceBackendHandler = new AddResourceBackendHandler(new MySQLDatabaseType(), addResourceStatement, connectionSession);
Field field = addResourceBackendHandler.getClass().getDeclaredField("dataSourceConfigValidator");
field.setAccessible(true);
field.set(addResourceBackendHandler, dataSourceConfigurationValidator);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AlterResourceBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AlterResourceBackendHandlerTest.java
index 5e89259..394c551 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AlterResourceBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AlterResourceBackendHandlerTest.java
@@ -28,7 +28,7 @@ import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
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;
@@ -61,7 +61,7 @@ public final class AlterResourceBackendHandlerTest {
private AlterResourceStatement alterResourceStatement;
@Mock
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private MetaDataContexts metaDataContexts;
@@ -79,7 +79,7 @@ public final class AlterResourceBackendHandlerTest {
@Before
public void setUp() throws Exception {
- alterResourceBackendHandler = new AlterResourceBackendHandler(new MySQLDatabaseType(), alterResourceStatement, backendConnection);
+ alterResourceBackendHandler = new AlterResourceBackendHandler(new MySQLDatabaseType(), alterResourceStatement, connectionSession);
Field field = alterResourceBackendHandler.getClass().getDeclaredField("dataSourceConfigValidator");
field.setAccessible(true);
field.set(alterResourceBackendHandler, dataSourceConfigurationValidator);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/DropResourceBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/DropResourceBackendHandlerTest.java
index 76323d1..22cb314 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/DropResourceBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/DropResourceBackendHandlerTest.java
@@ -26,7 +26,7 @@ import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
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;
@@ -60,7 +60,7 @@ public final class DropResourceBackendHandlerTest {
private DropResourceStatement dropResourceStatement;
@Mock
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
@Mock
private ShardingSphereMetaData metaData;
@@ -94,7 +94,7 @@ public final class DropResourceBackendHandlerTest {
contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
ProxyContext.getInstance().init(contextManager);
- dropResourceBackendHandler = new DropResourceBackendHandler(dropResourceStatement, backendConnection);
+ dropResourceBackendHandler = new DropResourceBackendHandler(dropResourceStatement, connectionSession);
}
@Test
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RQLBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RQLBackendHandlerTest.java
index f8c2214..45b11e1 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RQLBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RQLBackendHandlerTest.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.infra.distsql.query.DistSQLResultSet;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
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.QueryResponseHeader;
@@ -63,7 +63,7 @@ public final class RQLBackendHandlerTest {
public void assertExecute() {
DistSQLResultSet resultSet = mock(DistSQLResultSet.class);
when(resultSet.getColumnNames()).thenReturn(Arrays.asList("foo", "bar"));
- RQLBackendHandler handler = new RQLBackendHandler(mock(RQLStatement.class), mock(BackendConnection.class), resultSet);
+ RQLBackendHandler handler = new RQLBackendHandler(mock(RQLStatement.class), mock(JDBCConnectionSession.class), resultSet);
ResponseHeader responseHeader = handler.execute("test", mock(RQLStatement.class));
assertThat(((QueryResponseHeader) responseHeader).getQueryHeaders().size(), is(2));
assertQueryHeader(((QueryResponseHeader) responseHeader).getQueryHeaders().get(0), "foo");
@@ -89,7 +89,7 @@ public final class RQLBackendHandlerTest {
public void assertGetRowData() {
DistSQLResultSet resultSet = mock(DistSQLResultSet.class);
when(resultSet.getRowData()).thenReturn(Arrays.asList("foo_value", "bar_value"));
- RQLBackendHandler handler = new RQLBackendHandler(mock(RQLStatement.class), mock(BackendConnection.class), resultSet);
+ RQLBackendHandler handler = new RQLBackendHandler(mock(RQLStatement.class), mock(JDBCConnectionSession.class), resultSet);
handler.execute("test", mock(RQLStatement.class));
Collection<Object> rowData = handler.getRowData();
assertThat(rowData.size(), is(2));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RuleDefinitionBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RuleDefinitionBackendHandlerTest.java
index 502cc46..2cba9ca 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RuleDefinitionBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RuleDefinitionBackendHandlerTest.java
@@ -21,7 +21,7 @@ import io.netty.util.DefaultAttributeMap;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionUpdater;
import org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
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;
@@ -59,10 +59,10 @@ public final class RuleDefinitionBackendHandlerTest {
@Test
public void assertExecute() throws SQLException {
- BackendConnection backendConnection = new BackendConnection(TransactionType.LOCAL, new DefaultAttributeMap());
- backendConnection.setCurrentSchema("test");
- ResponseHeader response = new RuleDefinitionBackendHandler<>(new CreateFixtureRuleStatement(), backendConnection).execute();
+ JDBCConnectionSession connectionSession = new JDBCConnectionSession(TransactionType.LOCAL, new DefaultAttributeMap());
+ connectionSession.setCurrentSchema("test");
+ ResponseHeader response = new RuleDefinitionBackendHandler<>(new CreateFixtureRuleStatement(), connectionSession).execute();
assertThat(response, instanceOf(UpdateResponseHeader.class));
- assertThat(backendConnection.getTransactionStatus().getTransactionType(), is(TransactionType.LOCAL));
+ assertThat(connectionSession.getTransactionStatus().getTransactionType(), is(TransactionType.LOCAL));
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionBackendHandlerFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionBackendHandlerFactoryTest.java
index 3cc12b6..91a35ba 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionBackendHandlerFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionBackendHandlerFactoryTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.backend.text.transaction;
import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.BackendTransactionManager;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
@@ -59,26 +59,26 @@ public final class TransactionBackendHandlerFactoryTest {
@Test
public void assertTransactionBackendHandlerReturnedWhenTCLStatementInstanceOfCommitStatement() {
- BackendConnection backendConnection = mock(BackendConnection.class, Answers.RETURNS_DEEP_STUBS);
+ JDBCConnectionSession connectionSession = mock(JDBCConnectionSession.class, Answers.RETURNS_DEEP_STUBS);
SQLStatementContext<CommitStatement> context = mock(SQLStatementContext.class);
when(context.getSqlStatement()).thenReturn(mock(CommitStatement.class));
- TextProtocolBackendHandler textProtocolBackendHandler = TransactionBackendHandlerFactory.newInstance(context, null, backendConnection);
+ TextProtocolBackendHandler textProtocolBackendHandler = TransactionBackendHandlerFactory.newInstance(context, null, connectionSession);
assertThat(textProtocolBackendHandler, instanceOf(TransactionBackendHandler.class));
TransactionBackendHandler transactionBackendHandler = (TransactionBackendHandler) textProtocolBackendHandler;
assertFieldOfInstance(transactionBackendHandler, "operationType", is(TransactionOperationType.COMMIT));
- assertFieldOfInstance(getBackendTransactionManager(transactionBackendHandler), "connection", is(backendConnection));
+ assertFieldOfInstance(getBackendTransactionManager(transactionBackendHandler), "connection", is(connectionSession));
}
@Test
public void assertTransactionBackendHandlerReturnedWhenTCLStatementInstanceOfRollbackStatement() {
- BackendConnection backendConnection = mock(BackendConnection.class, Answers.RETURNS_DEEP_STUBS);
+ JDBCConnectionSession connectionSession = mock(JDBCConnectionSession.class, Answers.RETURNS_DEEP_STUBS);
SQLStatementContext<RollbackStatement> context = mock(SQLStatementContext.class);
when(context.getSqlStatement()).thenReturn(mock(RollbackStatement.class));
- TextProtocolBackendHandler textProtocolBackendHandler = TransactionBackendHandlerFactory.newInstance(context, null, backendConnection);
+ TextProtocolBackendHandler textProtocolBackendHandler = TransactionBackendHandlerFactory.newInstance(context, null, connectionSession);
assertThat(textProtocolBackendHandler, instanceOf(TransactionBackendHandler.class));
TransactionBackendHandler transactionBackendHandler = (TransactionBackendHandler) textProtocolBackendHandler;
assertFieldOfInstance(transactionBackendHandler, "operationType", is(TransactionOperationType.ROLLBACK));
- assertFieldOfInstance(getBackendTransactionManager(transactionBackendHandler), "connection", is(backendConnection));
+ assertFieldOfInstance(getBackendTransactionManager(transactionBackendHandler), "connection", is(connectionSession));
}
@Test
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionBackendHandlerTest.java
index 4e86ef8..b523ad4 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionBackendHandlerTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.backend.text.transaction;
import io.netty.util.DefaultAttributeMap;
import lombok.SneakyThrows;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
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;
@@ -42,7 +42,7 @@ import static org.mockito.Mockito.when;
public final class TransactionBackendHandlerTest {
- private final BackendConnection backendConnection = new BackendConnection(TransactionType.LOCAL, new DefaultAttributeMap());
+ private final JDBCConnectionSession connectionSession = new JDBCConnectionSession(TransactionType.LOCAL, new DefaultAttributeMap());
@Before
@SneakyThrows(ReflectiveOperationException.class)
@@ -57,7 +57,7 @@ public final class TransactionBackendHandlerTest {
@Test
public void assertExecute() throws SQLException {
- TransactionBackendHandler transactionBackendHandler = new TransactionBackendHandler(mock(TCLStatement.class), TransactionOperationType.BEGIN, backendConnection);
+ TransactionBackendHandler transactionBackendHandler = new TransactionBackendHandler(mock(TCLStatement.class), TransactionOperationType.BEGIN, connectionSession);
ResponseHeader actual = transactionBackendHandler.execute();
assertThat(actual, instanceOf(UpdateResponseHeader.class));
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java
index 660aad9..8deca8c 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java
@@ -27,7 +27,7 @@ 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.communication.SQLStatementSchemaHolder;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.ConnectionStatus;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.BackendTransactionManager;
import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
@@ -49,7 +49,7 @@ public final class CommandExecutorTask implements Runnable {
private final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine;
- private final BackendConnection backendConnection;
+ private final JDBCConnectionSession connectionSession;
private final ChannelHandlerContext context;
@@ -65,16 +65,16 @@ public final class CommandExecutorTask implements Runnable {
public void run() {
boolean isNeedFlush = false;
try (PacketPayload payload = databaseProtocolFrontendEngine.getCodecEngine().createPacketPayload((ByteBuf) message, context.channel().attr(CommonConstants.CHARSET_ATTRIBUTE_KEY).get())) {
- ConnectionStatus connectionStatus = backendConnection.getConnectionStatus();
- if (!backendConnection.getTransactionStatus().isInConnectionHeldTransaction()) {
+ ConnectionStatus connectionStatus = connectionSession.getConnectionStatus();
+ if (!connectionSession.getTransactionStatus().isInConnectionHeldTransaction()) {
connectionStatus.waitUntilConnectionRelease();
connectionStatus.switchToUsing();
}
- if (!backendConnection.isAutoCommit() && !backendConnection.getTransactionStatus().isInTransaction()) {
- BackendTransactionManager transactionManager = new BackendTransactionManager(backendConnection);
+ if (!connectionSession.isAutoCommit() && !connectionSession.getTransactionStatus().isInTransaction()) {
+ BackendTransactionManager transactionManager = new BackendTransactionManager(connectionSession);
transactionManager.begin();
}
- isNeedFlush = executeCommand(context, payload, backendConnection);
+ isNeedFlush = executeCommand(context, payload, connectionSession);
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
@@ -83,10 +83,10 @@ public final class CommandExecutorTask implements Runnable {
// TODO optimize SQLStatementSchemaHolder
SQLStatementSchemaHolder.remove();
Collection<SQLException> exceptions = closeExecutionResources();
- if (!backendConnection.getTransactionStatus().isInConnectionHeldTransaction()) {
- exceptions.addAll(backendConnection.closeDatabaseCommunicationEngines(true));
- exceptions.addAll(backendConnection.closeConnections(false));
- backendConnection.getConnectionStatus().switchToReleased();
+ if (!connectionSession.getTransactionStatus().isInConnectionHeldTransaction()) {
+ exceptions.addAll(connectionSession.closeDatabaseCommunicationEngines(true));
+ exceptions.addAll(connectionSession.closeConnections(false));
+ connectionSession.getConnectionStatus().switchToReleased();
}
if (isNeedFlush) {
context.flush();
@@ -95,11 +95,11 @@ public final class CommandExecutorTask implements Runnable {
}
}
- private boolean executeCommand(final ChannelHandlerContext context, final PacketPayload payload, final BackendConnection backendConnection) throws SQLException {
+ private boolean executeCommand(final ChannelHandlerContext context, final PacketPayload payload, final JDBCConnectionSession connectionSession) throws SQLException {
CommandExecuteEngine commandExecuteEngine = databaseProtocolFrontendEngine.getCommandExecuteEngine();
CommandPacketType type = commandExecuteEngine.getCommandPacketType(payload);
- CommandPacket commandPacket = commandExecuteEngine.getCommandPacket(payload, type, backendConnection);
- CommandExecutor commandExecutor = commandExecuteEngine.getCommandExecutor(type, commandPacket, backendConnection);
+ CommandPacket commandPacket = commandExecuteEngine.getCommandPacket(payload, type, connectionSession);
+ CommandExecutor commandExecutor = commandExecuteEngine.getCommandExecutor(type, commandPacket, connectionSession);
try {
Collection<DatabasePacket<?>> responsePackets = commandExecutor.execute();
if (responsePackets.isEmpty()) {
@@ -107,7 +107,7 @@ public final class CommandExecutorTask implements Runnable {
}
responsePackets.forEach(context::write);
if (commandExecutor instanceof QueryCommandExecutor) {
- return commandExecuteEngine.writeQueryData(context, backendConnection, (QueryCommandExecutor) commandExecutor, responsePackets.size());
+ return commandExecuteEngine.writeQueryData(context, connectionSession, (QueryCommandExecutor) commandExecutor, responsePackets.size());
}
} finally {
commandExecutor.close();
@@ -119,16 +119,16 @@ public final class CommandExecutorTask implements Runnable {
if (!ExpectedExceptions.isExpected(cause.getClass())) {
log.error("Exception occur: ", cause);
}
- context.write(databaseProtocolFrontendEngine.getCommandExecuteEngine().getErrorPacket(cause, backendConnection));
- Optional<DatabasePacket<?>> databasePacket = databaseProtocolFrontendEngine.getCommandExecuteEngine().getOtherPacket(backendConnection);
+ context.write(databaseProtocolFrontendEngine.getCommandExecuteEngine().getErrorPacket(cause, connectionSession));
+ Optional<DatabasePacket<?>> databasePacket = databaseProtocolFrontendEngine.getCommandExecuteEngine().getOtherPacket(connectionSession);
databasePacket.ifPresent(context::write);
context.flush();
}
private Collection<SQLException> closeExecutionResources() {
Collection<SQLException> result = new LinkedList<>();
- result.addAll(backendConnection.closeDatabaseCommunicationEngines(false));
- result.addAll(backendConnection.closeFederationExecutor());
+ result.addAll(connectionSession.closeDatabaseCommunicationEngines(false));
+ result.addAll(connectionSession.closeFederationExecutor());
return result;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/executor/ConnectionThreadExecutorGroup.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/executor/ConnectionThreadExecutorGroup.java
index af93e52..4731bc7 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/executor/ConnectionThreadExecutorGroup.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/executor/ConnectionThreadExecutorGroup.java
@@ -31,7 +31,7 @@ import java.util.concurrent.TimeUnit;
* Connection thread executor group.
*
* <p>
- * Manage the thread for each backend connection invoking.
+ * Manage the thread for each connection session invoking.
* This ensure XA transaction framework processed by current thread id.
* </p>
*/
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandler.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandler.java
index 9808bb0..af0d23f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandler.java
@@ -25,7 +25,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.db.protocol.CommonConstants;
import org.apache.shardingsphere.db.protocol.payload.PacketPayload;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.frontend.authentication.AuthenticationResult;
import org.apache.shardingsphere.proxy.frontend.executor.ConnectionThreadExecutorGroup;
@@ -44,13 +44,13 @@ public final class FrontendChannelInboundHandler extends ChannelInboundHandlerAd
private final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine;
- private final BackendConnection backendConnection;
+ private final JDBCConnectionSession connectionSession;
private volatile boolean authenticated;
public FrontendChannelInboundHandler(final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine, final Channel channel) {
this.databaseProtocolFrontendEngine = databaseProtocolFrontendEngine;
- backendConnection = new BackendConnection(getTransactionRule().getDefaultType(), channel);
+ connectionSession = new JDBCConnectionSession(getTransactionRule().getDefaultType(), channel);
}
private TransactionRule getTransactionRule() {
@@ -63,7 +63,7 @@ public final class FrontendChannelInboundHandler extends ChannelInboundHandlerAd
public void channelActive(final ChannelHandlerContext context) {
int connectionId = databaseProtocolFrontendEngine.getAuthenticationEngine().handshake(context);
ConnectionThreadExecutorGroup.getInstance().register(connectionId);
- backendConnection.setConnectionId(connectionId);
+ connectionSession.setConnectionId(connectionId);
}
@Override
@@ -72,22 +72,22 @@ public final class FrontendChannelInboundHandler extends ChannelInboundHandlerAd
authenticated = authenticate(context, (ByteBuf) message);
return;
}
- ProxyStateContext.execute(context, message, databaseProtocolFrontendEngine, backendConnection);
+ ProxyStateContext.execute(context, message, databaseProtocolFrontendEngine, connectionSession);
}
private boolean authenticate(final ChannelHandlerContext context, final ByteBuf message) {
try (PacketPayload payload = databaseProtocolFrontendEngine.getCodecEngine().createPacketPayload(message, context.channel().attr(CommonConstants.CHARSET_ATTRIBUTE_KEY).get())) {
AuthenticationResult authResult = databaseProtocolFrontendEngine.getAuthenticationEngine().authenticate(context, payload);
if (authResult.isFinished()) {
- backendConnection.setGrantee(new Grantee(authResult.getUsername(), authResult.getHostname()));
- backendConnection.setCurrentSchema(authResult.getDatabase());
+ connectionSession.setGrantee(new Grantee(authResult.getUsername(), authResult.getHostname()));
+ connectionSession.setCurrentSchema(authResult.getDatabase());
}
return authResult.isFinished();
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
log.error("Exception occur: ", ex);
- context.writeAndFlush(databaseProtocolFrontendEngine.getCommandExecuteEngine().getErrorPacket(ex, backendConnection));
+ context.writeAndFlush(databaseProtocolFrontendEngine.getCommandExecuteEngine().getErrorPacket(ex, connectionSession));
context.close();
}
return false;
@@ -100,17 +100,17 @@ public final class FrontendChannelInboundHandler extends ChannelInboundHandlerAd
}
private void closeAllResources() {
- ConnectionThreadExecutorGroup.getInstance().unregisterAndAwaitTermination(backendConnection.getConnectionId());
- backendConnection.closeDatabaseCommunicationEngines(true);
- backendConnection.closeConnections(true);
- backendConnection.closeFederationExecutor();
- databaseProtocolFrontendEngine.release(backendConnection);
+ ConnectionThreadExecutorGroup.getInstance().unregisterAndAwaitTermination(connectionSession.getConnectionId());
+ connectionSession.closeDatabaseCommunicationEngines(true);
+ connectionSession.closeConnections(true);
+ connectionSession.closeFederationExecutor();
+ databaseProtocolFrontendEngine.release(connectionSession);
}
@Override
public void channelWritabilityChanged(final ChannelHandlerContext context) {
if (context.channel().isWritable()) {
- backendConnection.getResourceLock().doNotify();
+ connectionSession.getResourceLock().doNotify();
}
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/ProxyState.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/ProxyState.java
index e6fe0f1..9cbd4db 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/ProxyState.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/ProxyState.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.frontend.state;
import io.netty.channel.ChannelHandlerContext;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine;
/**
@@ -32,7 +32,7 @@ public interface ProxyState {
* @param context channel handler context
* @param message message
* @param databaseProtocolFrontendEngine database protocol frontend engine
- * @param backendConnection backend connection
+ * @param connectionSession connection session
*/
- void execute(ChannelHandlerContext context, Object message, DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine, BackendConnection backendConnection);
+ void execute(ChannelHandlerContext context, Object message, DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine, JDBCConnectionSession connectionSession);
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/ProxyStateContext.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/ProxyStateContext.java
index 238c602..846bc91 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/ProxyStateContext.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/ProxyStateContext.java
@@ -21,7 +21,7 @@ import io.netty.channel.ChannelHandlerContext;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.infra.state.StateType;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine;
import org.apache.shardingsphere.proxy.frontend.state.impl.CircuitBreakProxyState;
@@ -51,10 +51,10 @@ public final class ProxyStateContext {
* @param context channel handler context
* @param message message
* @param databaseProtocolFrontendEngine database protocol frontend engine
- * @param backendConnection backend connection
+ * @param connectionSession connection session
*/
public static void execute(final ChannelHandlerContext context, final Object message,
- final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine, final BackendConnection backendConnection) {
- STATES.get(ProxyContext.getInstance().getStateContext().getCurrentState()).execute(context, message, databaseProtocolFrontendEngine, backendConnection);
+ final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine, final JDBCConnectionSession connectionSession) {
+ STATES.get(ProxyContext.getInstance().getStateContext().getCurrentState()).execute(context, message, databaseProtocolFrontendEngine, connectionSession);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/CircuitBreakProxyState.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/CircuitBreakProxyState.java
index 62249be..0a69bf5 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/CircuitBreakProxyState.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/CircuitBreakProxyState.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.proxy.frontend.state.impl;
import io.netty.channel.ChannelHandlerContext;
import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.exception.CircuitBreakException;
import org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine;
import org.apache.shardingsphere.proxy.frontend.state.ProxyState;
@@ -32,9 +32,9 @@ import java.util.Optional;
public final class CircuitBreakProxyState implements ProxyState {
@Override
- public void execute(final ChannelHandlerContext context, final Object message, final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine, final BackendConnection backendConnection) {
- context.writeAndFlush(databaseProtocolFrontendEngine.getCommandExecuteEngine().getErrorPacket(new CircuitBreakException(), backendConnection));
- Optional<DatabasePacket<?>> databasePacket = databaseProtocolFrontendEngine.getCommandExecuteEngine().getOtherPacket(backendConnection);
+ public void execute(final ChannelHandlerContext context, final Object message, final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine, final JDBCConnectionSession connectionSession) {
+ context.writeAndFlush(databaseProtocolFrontendEngine.getCommandExecuteEngine().getErrorPacket(new CircuitBreakException(), connectionSession));
+ Optional<DatabasePacket<?>> databasePacket = databaseProtocolFrontendEngine.getCommandExecuteEngine().getOtherPacket(connectionSession);
databasePacket.ifPresent(context::writeAndFlush);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/LockProxyState.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/LockProxyState.java
index 727a62c..f7c1c2e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/LockProxyState.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/LockProxyState.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.frontend.state.impl;
import io.netty.channel.ChannelHandlerContext;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine;
import org.apache.shardingsphere.proxy.frontend.state.ProxyState;
@@ -28,7 +28,7 @@ import org.apache.shardingsphere.proxy.frontend.state.ProxyState;
public final class LockProxyState implements ProxyState {
@Override
- public void execute(final ChannelHandlerContext context, final Object message, final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine, final BackendConnection backendConnection) {
+ public void execute(final ChannelHandlerContext context, final Object message, final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine, final JDBCConnectionSession connectionSession) {
throw new UnsupportedOperationException("LockProxyState");
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyState.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyState.java
index ee7f999..17d92d8 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyState.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyState.java
@@ -19,8 +19,9 @@ package org.apache.shardingsphere.proxy.frontend.state.impl;
import io.netty.channel.ChannelHandlerContext;
import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
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;
@@ -36,30 +37,30 @@ import java.util.concurrent.ExecutorService;
public final class OKProxyState implements ProxyState {
@Override
- public void execute(final ChannelHandlerContext context, final Object message, final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine, final BackendConnection backendConnection) {
- CommandExecutorTask commandExecutorTask = new CommandExecutorTask(databaseProtocolFrontendEngine, backendConnection, context, message);
- ExecutorService executorService = determineSuitableExecutorService(context, databaseProtocolFrontendEngine, backendConnection);
+ public void execute(final ChannelHandlerContext context, final Object message, final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine, final JDBCConnectionSession connectionSession) {
+ CommandExecutorTask commandExecutorTask = new CommandExecutorTask(databaseProtocolFrontendEngine, connectionSession, context, message);
+ ExecutorService executorService = determineSuitableExecutorService(context, databaseProtocolFrontendEngine, connectionSession);
executorService.execute(commandExecutorTask);
}
private ExecutorService determineSuitableExecutorService(final ChannelHandlerContext context, final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine,
- final BackendConnection backendConnection) {
+ final ConnectionSession connectionSession) {
ExecutorService result;
- if (requireOccupyThreadForConnection(backendConnection)) {
- result = ConnectionThreadExecutorGroup.getInstance().get(backendConnection.getConnectionId());
+ if (requireOccupyThreadForConnection(connectionSession)) {
+ result = ConnectionThreadExecutorGroup.getInstance().get(connectionSession.getConnectionId());
} else if (isPreferNettyEventLoop()) {
result = context.executor();
} else if (databaseProtocolFrontendEngine.getFrontendContext().isRequiredSameThreadForConnection()) {
- result = ConnectionThreadExecutorGroup.getInstance().get(backendConnection.getConnectionId());
+ result = ConnectionThreadExecutorGroup.getInstance().get(connectionSession.getConnectionId());
} else {
result = UserExecutorGroup.getInstance().getExecutorService();
}
return result;
}
- private boolean requireOccupyThreadForConnection(final BackendConnection backendConnection) {
+ private boolean requireOccupyThreadForConnection(final ConnectionSession connectionSession) {
return ProxyContext.getInstance().getContextManager().getMetaDataContexts().getProps().<Boolean>getValue(ConfigurationPropertyKey.PROXY_HINT_ENABLED)
- || TransactionType.isDistributedTransaction(backendConnection.getTransactionStatus().getTransactionType());
+ || TransactionType.isDistributedTransaction(connectionSession.getTransactionStatus().getTransactionType());
}
private boolean isPreferNettyEventLoop() {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTaskTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTaskTest.java
index b5029d1..6dedc4a 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTaskTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTaskTest.java
@@ -24,7 +24,7 @@ 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.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.ConnectionStatus;
import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
import org.apache.shardingsphere.proxy.frontend.command.executor.QueryCommandExecutor;
@@ -61,7 +61,7 @@ public final class CommandExecutorTaskTest {
private PacketPayload payload;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private ChannelHandlerContext handlerContext;
@@ -92,45 +92,45 @@ public final class CommandExecutorTaskTest {
@Before
public void setup() {
- when(backendConnection.closeDatabaseCommunicationEngines(anyBoolean())).thenReturn(Collections.emptyList());
- when(backendConnection.isAutoCommit()).thenReturn(true);
+ when(connectionSession.closeDatabaseCommunicationEngines(anyBoolean())).thenReturn(Collections.emptyList());
+ when(connectionSession.isAutoCommit()).thenReturn(true);
when(handlerContext.channel().attr(CommonConstants.CHARSET_ATTRIBUTE_KEY).get()).thenReturn(StandardCharsets.UTF_8);
}
@Test
public void assertRunNeedFlushByFalse() throws SQLException {
when(queryCommandExecutor.execute()).thenReturn(Collections.emptyList());
- when(engine.getCommandExecuteEngine().getCommandPacket(payload, commandPacketType, backendConnection)).thenReturn(commandPacket);
- when(engine.getCommandExecuteEngine().getCommandExecutor(commandPacketType, commandPacket, backendConnection)).thenReturn(queryCommandExecutor);
+ when(engine.getCommandExecuteEngine().getCommandPacket(payload, commandPacketType, connectionSession)).thenReturn(commandPacket);
+ when(engine.getCommandExecuteEngine().getCommandExecutor(commandPacketType, commandPacket, connectionSession)).thenReturn(queryCommandExecutor);
when(engine.getCommandExecuteEngine().getCommandPacketType(payload)).thenReturn(commandPacketType);
- when(backendConnection.getConnectionStatus()).thenReturn(connectionStatus);
+ when(connectionSession.getConnectionStatus()).thenReturn(connectionStatus);
when(engine.getCodecEngine().createPacketPayload(message, StandardCharsets.UTF_8)).thenReturn(payload);
- when(backendConnection.closeConnections(false)).thenReturn(Collections.emptyList());
- when(backendConnection.closeFederationExecutor()).thenReturn(Collections.emptyList());
- CommandExecutorTask actual = new CommandExecutorTask(engine, backendConnection, handlerContext, message);
+ when(connectionSession.closeConnections(false)).thenReturn(Collections.emptyList());
+ when(connectionSession.closeFederationExecutor()).thenReturn(Collections.emptyList());
+ CommandExecutorTask actual = new CommandExecutorTask(engine, connectionSession, handlerContext, message);
actual.run();
verify(queryCommandExecutor).close();
- verify(backendConnection).closeDatabaseCommunicationEngines(true);
+ verify(connectionSession).closeDatabaseCommunicationEngines(true);
}
@Test
public void assertRunNeedFlushByTrue() throws SQLException {
when(queryCommandExecutor.execute()).thenReturn(Collections.singletonList(databasePacket));
- when(engine.getCommandExecuteEngine().getCommandPacket(payload, commandPacketType, backendConnection)).thenReturn(commandPacket);
- when(engine.getCommandExecuteEngine().getCommandExecutor(commandPacketType, commandPacket, backendConnection)).thenReturn(queryCommandExecutor);
+ when(engine.getCommandExecuteEngine().getCommandPacket(payload, commandPacketType, connectionSession)).thenReturn(commandPacket);
+ when(engine.getCommandExecuteEngine().getCommandExecutor(commandPacketType, commandPacket, connectionSession)).thenReturn(queryCommandExecutor);
when(engine.getCommandExecuteEngine().getCommandPacketType(payload)).thenReturn(commandPacketType);
- when(engine.getCommandExecuteEngine().writeQueryData(any(ChannelHandlerContext.class), any(BackendConnection.class), any(QueryCommandExecutor.class), anyInt())).thenReturn(true);
- when(backendConnection.getConnectionStatus()).thenReturn(connectionStatus);
+ when(engine.getCommandExecuteEngine().writeQueryData(any(ChannelHandlerContext.class), any(JDBCConnectionSession.class), any(QueryCommandExecutor.class), anyInt())).thenReturn(true);
+ when(connectionSession.getConnectionStatus()).thenReturn(connectionStatus);
when(engine.getCodecEngine().createPacketPayload(message, StandardCharsets.UTF_8)).thenReturn(payload);
- when(backendConnection.closeConnections(false)).thenReturn(Collections.emptyList());
- when(backendConnection.closeFederationExecutor()).thenReturn(Collections.emptyList());
- CommandExecutorTask actual = new CommandExecutorTask(engine, backendConnection, handlerContext, message);
+ when(connectionSession.closeConnections(false)).thenReturn(Collections.emptyList());
+ when(connectionSession.closeFederationExecutor()).thenReturn(Collections.emptyList());
+ CommandExecutorTask actual = new CommandExecutorTask(engine, connectionSession, handlerContext, message);
actual.run();
verify(handlerContext).write(databasePacket);
verify(handlerContext).flush();
- verify(engine.getCommandExecuteEngine()).writeQueryData(handlerContext, backendConnection, queryCommandExecutor, 1);
+ verify(engine.getCommandExecuteEngine()).writeQueryData(handlerContext, connectionSession, queryCommandExecutor, 1);
verify(queryCommandExecutor).close();
- verify(backendConnection).closeDatabaseCommunicationEngines(true);
+ verify(connectionSession).closeDatabaseCommunicationEngines(true);
}
@Test
@@ -138,35 +138,35 @@ public final class CommandExecutorTaskTest {
when(frontendContext.isFlushForPerCommandPacket()).thenReturn(true);
when(engine.getFrontendContext()).thenReturn(frontendContext);
when(commandExecutor.execute()).thenReturn(Collections.singletonList(databasePacket));
- when(engine.getCommandExecuteEngine().getCommandPacket(payload, commandPacketType, backendConnection)).thenReturn(commandPacket);
- when(engine.getCommandExecuteEngine().getCommandExecutor(commandPacketType, commandPacket, backendConnection)).thenReturn(commandExecutor);
+ when(engine.getCommandExecuteEngine().getCommandPacket(payload, commandPacketType, connectionSession)).thenReturn(commandPacket);
+ when(engine.getCommandExecuteEngine().getCommandExecutor(commandPacketType, commandPacket, connectionSession)).thenReturn(commandExecutor);
when(engine.getCommandExecuteEngine().getCommandPacketType(payload)).thenReturn(commandPacketType);
- when(backendConnection.getConnectionStatus()).thenReturn(connectionStatus);
+ when(connectionSession.getConnectionStatus()).thenReturn(connectionStatus);
when(engine.getCodecEngine().createPacketPayload(message, StandardCharsets.UTF_8)).thenReturn(payload);
- when(backendConnection.closeConnections(false)).thenReturn(Collections.emptyList());
- when(backendConnection.closeFederationExecutor()).thenReturn(Collections.emptyList());
- CommandExecutorTask actual = new CommandExecutorTask(engine, backendConnection, handlerContext, message);
+ when(connectionSession.closeConnections(false)).thenReturn(Collections.emptyList());
+ when(connectionSession.closeFederationExecutor()).thenReturn(Collections.emptyList());
+ CommandExecutorTask actual = new CommandExecutorTask(engine, connectionSession, handlerContext, message);
actual.run();
verify(handlerContext).write(databasePacket);
verify(handlerContext).flush();
verify(commandExecutor).close();
- verify(backendConnection).closeDatabaseCommunicationEngines(true);
+ verify(connectionSession).closeDatabaseCommunicationEngines(true);
}
@Test
public void assertRunWithError() {
RuntimeException mockException = new RuntimeException("mock");
- when(backendConnection.getConnectionStatus()).thenReturn(connectionStatus);
- doThrow(mockException).when(backendConnection).isAutoCommit();
+ when(connectionSession.getConnectionStatus()).thenReturn(connectionStatus);
+ doThrow(mockException).when(connectionSession).isAutoCommit();
when(engine.getCodecEngine().createPacketPayload(message, StandardCharsets.UTF_8)).thenReturn(payload);
- when(engine.getCommandExecuteEngine().getErrorPacket(mockException, backendConnection)).thenReturn(databasePacket);
- when(engine.getCommandExecuteEngine().getOtherPacket(backendConnection)).thenReturn(Optional.of(databasePacket));
- when(backendConnection.closeConnections(false)).thenReturn(Collections.emptyList());
- when(backendConnection.closeFederationExecutor()).thenReturn(Collections.emptyList());
- CommandExecutorTask actual = new CommandExecutorTask(engine, backendConnection, handlerContext, message);
+ when(engine.getCommandExecuteEngine().getErrorPacket(mockException, connectionSession)).thenReturn(databasePacket);
+ when(engine.getCommandExecuteEngine().getOtherPacket(connectionSession)).thenReturn(Optional.of(databasePacket));
+ when(connectionSession.closeConnections(false)).thenReturn(Collections.emptyList());
+ when(connectionSession.closeFederationExecutor()).thenReturn(Collections.emptyList());
+ CommandExecutorTask actual = new CommandExecutorTask(engine, connectionSession, handlerContext, message);
actual.run();
verify(handlerContext, times(2)).write(databasePacket);
verify(handlerContext).flush();
- verify(backendConnection).closeDatabaseCommunicationEngines(true);
+ verify(connectionSession).closeDatabaseCommunicationEngines(true);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/fixture/DatabaseProtocolFrontendEngineFixture.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/fixture/DatabaseProtocolFrontendEngineFixture.java
index 0135361..0c54100 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/fixture/DatabaseProtocolFrontendEngineFixture.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/fixture/DatabaseProtocolFrontendEngineFixture.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.frontend.fixture;
import org.apache.shardingsphere.db.protocol.codec.DatabasePacketCodecEngine;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.context.FrontendContext;
import org.apache.shardingsphere.proxy.frontend.authentication.AuthenticationEngine;
import org.apache.shardingsphere.proxy.frontend.command.CommandExecuteEngine;
@@ -52,6 +52,6 @@ public final class DatabaseProtocolFrontendEngineFixture implements DatabaseProt
}
@Override
- public void release(final BackendConnection backendConnection) {
+ public void release(final ConnectionSession connectionSession) {
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyStateTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyStateTest.java
index d0cb8f3..c68d095 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyStateTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyStateTest.java
@@ -22,7 +22,7 @@ import io.netty.util.concurrent.EventExecutor;
import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask;
import org.apache.shardingsphere.proxy.frontend.executor.ConnectionThreadExecutorGroup;
@@ -59,7 +59,7 @@ public final class OKProxyStateTest {
private DatabaseProtocolFrontendEngine frontendEngine;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private BackendConnection connection;
+ private JDBCConnectionSession connection;
@BeforeClass
public static void setupGlobal() {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngine.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngine.java
index ddb2098..ee2d8a2 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngine.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngine.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.db.protocol.codec.DatabasePacketCodecEngine;
import org.apache.shardingsphere.db.protocol.mysql.codec.MySQLPacketCodecEngine;
import org.apache.shardingsphere.db.protocol.mysql.packet.MySQLPacket;
import org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary.MySQLPreparedStatementRegistry;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+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;
@@ -45,8 +45,8 @@ public final class MySQLFrontendEngine implements DatabaseProtocolFrontendEngine
private final DatabasePacketCodecEngine<MySQLPacket> codecEngine = new MySQLPacketCodecEngine();
@Override
- public void release(final BackendConnection backendConnection) {
- MySQLPreparedStatementRegistry.getInstance().unregisterConnection(backendConnection.getConnectionId());
+ public void release(final ConnectionSession connectionSession) {
+ MySQLPreparedStatementRegistry.getInstance().unregisterConnection(connectionSession.getConnectionId());
}
@Override
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecuteEngine.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecuteEngine.java
index 69a0555..e9bba13 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecuteEngine.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecuteEngine.java
@@ -29,8 +29,9 @@ 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.infra.config.properties.ConfigurationPropertyKey;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.CommandExecuteEngine;
import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
import org.apache.shardingsphere.proxy.frontend.command.executor.QueryCommandExecutor;
@@ -51,17 +52,17 @@ public final class MySQLCommandExecuteEngine implements CommandExecuteEngine {
}
@Override
- public MySQLCommandPacket getCommandPacket(final PacketPayload payload, final CommandPacketType type, final BackendConnection backendConnection) throws SQLException {
- return MySQLCommandPacketFactory.newInstance((MySQLCommandPacketType) type, (MySQLPacketPayload) payload, backendConnection.getConnectionId());
+ public MySQLCommandPacket getCommandPacket(final PacketPayload payload, final CommandPacketType type, final ConnectionSession connectionSession) throws SQLException {
+ return MySQLCommandPacketFactory.newInstance((MySQLCommandPacketType) type, (MySQLPacketPayload) payload, connectionSession.getConnectionId());
}
@Override
- public CommandExecutor getCommandExecutor(final CommandPacketType type, final CommandPacket packet, final BackendConnection backendConnection) throws SQLException {
- return MySQLCommandExecutorFactory.newInstance((MySQLCommandPacketType) type, packet, backendConnection);
+ public CommandExecutor getCommandExecutor(final CommandPacketType type, final CommandPacket packet, final JDBCConnectionSession connectionSession) throws SQLException {
+ return MySQLCommandExecutorFactory.newInstance((MySQLCommandPacketType) type, packet, connectionSession);
}
@Override
- public DatabasePacket<?> getErrorPacket(final Exception cause, final BackendConnection backendConnection) {
+ public DatabasePacket<?> getErrorPacket(final Exception cause, final ConnectionSession connectionSession) {
return MySQLErrPacketFactory.newInstance(cause);
}
@@ -71,13 +72,13 @@ public final class MySQLCommandExecuteEngine implements CommandExecuteEngine {
}
@Override
- public Optional<DatabasePacket<?>> getOtherPacket(final BackendConnection backendConnection) {
+ public Optional<DatabasePacket<?>> getOtherPacket(final ConnectionSession connectionSession) {
return Optional.empty();
}
@Override
public boolean writeQueryData(final ChannelHandlerContext context,
- final BackendConnection backendConnection, final QueryCommandExecutor queryCommandExecutor, final int headerPackagesCount) throws SQLException {
+ final JDBCConnectionSession connectionSession, final QueryCommandExecutor queryCommandExecutor, final int headerPackagesCount) throws SQLException {
if (ResponseType.QUERY != queryCommandExecutor.getResponseType() || !context.channel().isActive()) {
return true;
}
@@ -88,7 +89,7 @@ public final class MySQLCommandExecuteEngine implements CommandExecuteEngine {
count++;
while (!context.channel().isWritable() && context.channel().isActive()) {
context.flush();
- backendConnection.getResourceLock().doAwait();
+ connectionSession.getResourceLock().doAwait();
}
DatabasePacket<?> dataValue = queryCommandExecutor.getQueryRowPacket();
context.write(dataValue);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactory.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactory.java
index aebadb9..d612328 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactory.java
@@ -29,7 +29,7 @@ import org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary.r
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.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
import org.apache.shardingsphere.proxy.frontend.mysql.command.admin.initdb.MySQLComInitDbExecutor;
import org.apache.shardingsphere.proxy.frontend.mysql.command.admin.ping.MySQLComPingExecutor;
@@ -56,31 +56,31 @@ public final class MySQLCommandExecutorFactory {
*
* @param commandPacketType command packet type for MySQL
* @param commandPacket command packet for MySQL
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @return command executor
* @throws SQLException SQL exception
*/
- public static CommandExecutor newInstance(final MySQLCommandPacketType commandPacketType, final CommandPacket commandPacket, final BackendConnection backendConnection) throws SQLException {
+ public static CommandExecutor newInstance(final MySQLCommandPacketType commandPacketType, final CommandPacket commandPacket, final JDBCConnectionSession connectionSession) throws SQLException {
log.debug("Execute packet type: {}, value: {}", commandPacketType, commandPacket);
switch (commandPacketType) {
case COM_QUIT:
return new MySQLComQuitExecutor();
case COM_INIT_DB:
- return new MySQLComInitDbExecutor((MySQLComInitDbPacket) commandPacket, backendConnection);
+ return new MySQLComInitDbExecutor((MySQLComInitDbPacket) commandPacket, connectionSession);
case COM_FIELD_LIST:
- return new MySQLComFieldListPacketExecutor((MySQLComFieldListPacket) commandPacket, backendConnection);
+ return new MySQLComFieldListPacketExecutor((MySQLComFieldListPacket) commandPacket, connectionSession);
case COM_QUERY:
- return new MySQLComQueryPacketExecutor((MySQLComQueryPacket) commandPacket, backendConnection);
+ return new MySQLComQueryPacketExecutor((MySQLComQueryPacket) commandPacket, connectionSession);
case COM_PING:
return new MySQLComPingExecutor();
case COM_STMT_PREPARE:
- return new MySQLComStmtPrepareExecutor((MySQLComStmtPreparePacket) commandPacket, backendConnection);
+ return new MySQLComStmtPrepareExecutor((MySQLComStmtPreparePacket) commandPacket, connectionSession);
case COM_STMT_EXECUTE:
- return new MySQLComStmtExecuteExecutor((MySQLComStmtExecutePacket) commandPacket, backendConnection);
+ return new MySQLComStmtExecuteExecutor((MySQLComStmtExecutePacket) commandPacket, connectionSession);
case COM_STMT_RESET:
return new MySQLComStmtResetExecutor((MySQLComStmtResetPacket) commandPacket);
case COM_STMT_CLOSE:
- return new MySQLComStmtCloseExecutor((MySQLComStmtClosePacket) commandPacket, backendConnection.getConnectionId());
+ return new MySQLComStmtCloseExecutor((MySQLComStmtClosePacket) commandPacket, connectionSession.getConnectionId());
default:
return new MySQLUnsupportedCommandExecutor(commandPacketType);
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/initdb/MySQLComInitDbExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/initdb/MySQLComInitDbExecutor.java
index e4e9af9..416b224 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/initdb/MySQLComInitDbExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/initdb/MySQLComInitDbExecutor.java
@@ -23,9 +23,9 @@ import org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLOKPacket;
import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
import org.apache.shardingsphere.infra.executor.check.SQLCheckEngine;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.exception.UnknownDatabaseException;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
import org.apache.shardingsphere.sql.parser.sql.common.util.SQLUtil;
@@ -41,13 +41,13 @@ public final class MySQLComInitDbExecutor implements CommandExecutor {
private final MySQLComInitDbPacket packet;
- private final BackendConnection backendConnection;
+ private final ConnectionSession connectionSession;
@Override
public Collection<DatabasePacket<?>> execute() {
String schemaName = SQLUtil.getExactlyValue(packet.getSchema());
- if (ProxyContext.getInstance().schemaExists(schemaName) && SQLCheckEngine.check(schemaName, getRules(schemaName), backendConnection.getGrantee())) {
- backendConnection.setCurrentSchema(packet.getSchema());
+ if (ProxyContext.getInstance().schemaExists(schemaName) && SQLCheckEngine.check(schemaName, getRules(schemaName), connectionSession.getGrantee())) {
+ connectionSession.setCurrentSchema(packet.getSchema());
return Collections.singletonList(new MySQLOKPacket(1));
}
throw new UnknownDatabaseException(packet.getSchema());
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutor.java
index d8d4b0d..69d6ddd 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutor.java
@@ -38,7 +38,7 @@ import org.apache.shardingsphere.parser.rule.SQLParserRule;
import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngineFactory;
import org.apache.shardingsphere.proxy.backend.communication.SQLStatementSchemaHolder;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
import org.apache.shardingsphere.proxy.backend.response.data.impl.BinaryQueryResponseCell;
@@ -76,30 +76,30 @@ public final class MySQLComStmtExecuteExecutor implements QueryCommandExecutor {
private int currentSequenceId;
- public MySQLComStmtExecuteExecutor(final MySQLComStmtExecutePacket packet, final BackendConnection backendConnection) throws SQLException {
- String schemaName = backendConnection.getSchemaName();
+ public MySQLComStmtExecuteExecutor(final MySQLComStmtExecutePacket packet, final JDBCConnectionSession connectionSession) throws SQLException {
+ String schemaName = connectionSession.getSchemaName();
MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
Optional<SQLParserRule> sqlParserRule = metaDataContexts.getGlobalRuleMetaData().findSingleRule(SQLParserRule.class);
ShardingSphereSQLParserEngine sqlStatementParserEngine = new ShardingSphereSQLParserEngine(DatabaseTypeRegistry.getTrunkDatabaseTypeName(
metaDataContexts.getMetaData(schemaName).getResource().getDatabaseType()), sqlParserRule.orElse(null));
SQLStatement sqlStatement = sqlStatementParserEngine.parse(packet.getSql(), true);
SQLStatementContext<?> sqlStatementContext = SQLStatementContextFactory.newInstance(metaDataContexts.getMetaDataMap(), packet.getParameters(),
- sqlStatement, backendConnection.getDefaultSchemaName());
+ sqlStatement, connectionSession.getDefaultSchemaName());
// TODO optimize SQLStatementSchemaHolder
if (sqlStatementContext instanceof TableAvailable) {
((TableAvailable) sqlStatementContext).getTablesContext().getSchemaName().ifPresent(SQLStatementSchemaHolder::set);
}
- SQLCheckEngine.check(sqlStatement, Collections.emptyList(), getRules(schemaName), schemaName, metaDataContexts.getMetaDataMap(), backendConnection.getGrantee());
- characterSet = backendConnection.getAttributeMap().attr(MySQLConstants.MYSQL_CHARACTER_SET_ATTRIBUTE_KEY).get().getId();
+ SQLCheckEngine.check(sqlStatement, Collections.emptyList(), getRules(schemaName), schemaName, metaDataContexts.getMetaDataMap(), connectionSession.getGrantee());
+ characterSet = connectionSession.getAttributeMap().attr(MySQLConstants.MYSQL_CHARACTER_SET_ATTRIBUTE_KEY).get().getId();
// TODO Refactor the following branch
if (sqlStatement instanceof TCLStatement) {
databaseCommunicationEngine = null;
textProtocolBackendHandler =
- TextProtocolBackendHandlerFactory.newInstance(DatabaseTypeRegistry.getActualDatabaseType("MySQL"), packet.getSql(), backendConnection);
+ TextProtocolBackendHandlerFactory.newInstance(DatabaseTypeRegistry.getActualDatabaseType("MySQL"), packet.getSql(), connectionSession);
return;
}
textProtocolBackendHandler = null;
- databaseCommunicationEngine = DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(sqlStatementContext, packet.getSql(), packet.getParameters(), backendConnection);
+ databaseCommunicationEngine = DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(sqlStatementContext, packet.getSql(), packet.getParameters(), connectionSession);
}
private static Collection<ShardingSphereRule> getRules(final String schemaName) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutor.java
index 963c8c0..2159391 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutor.java
@@ -32,8 +32,8 @@ import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.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;
import org.apache.shardingsphere.proxy.frontend.exception.UnsupportedPreparedStatementException;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
@@ -51,23 +51,23 @@ public final class MySQLComStmtPrepareExecutor implements CommandExecutor {
private final MySQLComStmtPreparePacket packet;
- private final BackendConnection backendConnection;
+ private final ConnectionSession connectionSession;
private final int characterSet;
private int currentSequenceId;
- public MySQLComStmtPrepareExecutor(final MySQLComStmtPreparePacket packet, final BackendConnection backendConnection) {
+ public MySQLComStmtPrepareExecutor(final MySQLComStmtPreparePacket packet, final ConnectionSession connectionSession) {
this.packet = packet;
- this.backendConnection = backendConnection;
- characterSet = backendConnection.getAttributeMap().attr(MySQLConstants.MYSQL_CHARACTER_SET_ATTRIBUTE_KEY).get().getId();
+ this.connectionSession = connectionSession;
+ characterSet = connectionSession.getAttributeMap().attr(MySQLConstants.MYSQL_CHARACTER_SET_ATTRIBUTE_KEY).get().getId();
}
@Override
public Collection<DatabasePacket<?>> execute() {
MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
ShardingSphereSQLParserEngine sqlStatementParserEngine = new ShardingSphereSQLParserEngine(DatabaseTypeRegistry.getTrunkDatabaseTypeName(
- metaDataContexts.getMetaData(backendConnection.getSchemaName()).getResource().getDatabaseType()),
+ metaDataContexts.getMetaData(connectionSession.getSchemaName()).getResource().getDatabaseType()),
metaDataContexts.getGlobalRuleMetaData().findSingleRule(SQLParserRule.class).orElse(null));
SQLStatement sqlStatement = sqlStatementParserEngine.parse(packet.getSql(), true);
if (!MySQLComStmtPrepareChecker.isStatementAllowed(sqlStatement)) {
@@ -75,14 +75,14 @@ public final class MySQLComStmtPrepareExecutor implements CommandExecutor {
}
int parameterCount = sqlStatement.getParameterCount();
int projectionCount = getProjectionCount(sqlStatement);
- int statementId = MySQLPreparedStatementRegistry.getInstance().getConnectionPreparedStatements(backendConnection.getConnectionId()).prepareStatement(packet.getSql(), parameterCount);
+ int statementId = MySQLPreparedStatementRegistry.getInstance().getConnectionPreparedStatements(connectionSession.getConnectionId()).prepareStatement(packet.getSql(), parameterCount);
return createPackets(statementId, projectionCount, parameterCount);
}
private int getProjectionCount(final SQLStatement sqlStatement) {
if (sqlStatement instanceof SelectStatement) {
Map<String, ShardingSphereMetaData> metaDataMap = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaDataMap();
- String schemaName = backendConnection.getSchemaName();
+ String schemaName = connectionSession.getSchemaName();
SelectStatementContext sqlStatementContext = (SelectStatementContext) SQLStatementContextFactory.newInstance(metaDataMap, Collections.emptyList(), sqlStatement, schemaName);
return sqlStatementContext.getProjectionsContext().getExpandProjections().size();
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/fieldlist/MySQLComFieldListPacketExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/fieldlist/MySQLComFieldListPacketExecutor.java
index a407a9d..6517bed 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/fieldlist/MySQLComFieldListPacketExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/fieldlist/MySQLComFieldListPacketExecutor.java
@@ -31,7 +31,7 @@ import org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
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.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
@@ -59,9 +59,9 @@ public final class MySQLComFieldListPacketExecutor implements CommandExecutor {
private int currentSequenceId;
- public MySQLComFieldListPacketExecutor(final MySQLComFieldListPacket packet, final BackendConnection backendConnection) {
+ public MySQLComFieldListPacketExecutor(final MySQLComFieldListPacket packet, final JDBCConnectionSession connectionSession) {
this.packet = packet;
- schemaName = backendConnection.getDefaultSchemaName();
+ schemaName = connectionSession.getDefaultSchemaName();
String sql = String.format(SQL, packet.getTable(), schemaName);
MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
Optional<SQLParserRule> sqlParserRule = metaDataContexts.getGlobalRuleMetaData().findSingleRule(SQLParserRule.class);
@@ -69,8 +69,8 @@ public final class MySQLComFieldListPacketExecutor implements CommandExecutor {
DatabaseTypeRegistry.getTrunkDatabaseTypeName(metaDataContexts.getMetaData(schemaName).getResource().getDatabaseType()), sqlParserRule.orElse(null));
SQLStatement sqlStatement = sqlStatementParserEngine.parse(sql, false);
SQLStatementContext<?> sqlStatementContext = SQLStatementContextFactory.newInstance(metaDataContexts.getMetaDataMap(), Collections.emptyList(), sqlStatement, schemaName);
- databaseCommunicationEngine = DatabaseCommunicationEngineFactory.getInstance().newTextProtocolInstance(sqlStatementContext, sql, backendConnection);
- characterSet = backendConnection.getAttributeMap().attr(MySQLConstants.MYSQL_CHARACTER_SET_ATTRIBUTE_KEY).get().getId();
+ databaseCommunicationEngine = DatabaseCommunicationEngineFactory.getInstance().newTextProtocolInstance(sqlStatementContext, sql, connectionSession);
+ characterSet = connectionSession.getAttributeMap().attr(MySQLConstants.MYSQL_CHARACTER_SET_ATTRIBUTE_KEY).get().getId();
}
@Override
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutor.java
index 316e9e9..8c86224 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutor.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.db.protocol.mysql.packet.command.query.text.MyS
import org.apache.shardingsphere.db.protocol.mysql.packet.command.query.text.query.MySQLComQueryPacket;
import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
@@ -51,9 +51,9 @@ public final class MySQLComQueryPacketExecutor implements QueryCommandExecutor {
private int currentSequenceId;
- public MySQLComQueryPacketExecutor(final MySQLComQueryPacket packet, final BackendConnection backendConnection) throws SQLException {
- textProtocolBackendHandler = TextProtocolBackendHandlerFactory.newInstance(DatabaseTypeRegistry.getActualDatabaseType("MySQL"), packet.getSql(), backendConnection);
- characterSet = backendConnection.getAttributeMap().attr(MySQLConstants.MYSQL_CHARACTER_SET_ATTRIBUTE_KEY).get().getId();
+ public MySQLComQueryPacketExecutor(final MySQLComQueryPacket packet, final JDBCConnectionSession connectionSession) throws SQLException {
+ textProtocolBackendHandler = TextProtocolBackendHandlerFactory.newInstance(DatabaseTypeRegistry.getActualDatabaseType("MySQL"), packet.getSql(), connectionSession);
+ characterSet = connectionSession.getAttributeMap().attr(MySQLConstants.MYSQL_CHARACTER_SET_ATTRIBUTE_KEY).get().getId();
}
@Override
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactoryTest.java
index d06bb6e..83ec3c8 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactoryTest.java
@@ -39,7 +39,7 @@ import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
import org.apache.shardingsphere.parser.rule.builder.DefaultSQLParserRuleConfigurationBuilder;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.frontend.mysql.command.admin.initdb.MySQLComInitDbExecutor;
import org.apache.shardingsphere.proxy.frontend.mysql.command.admin.ping.MySQLComPingExecutor;
@@ -77,13 +77,13 @@ public final class MySQLCommandExecutorFactoryTest {
private final SQLParserRule sqlParserRule = new SQLParserRule(new DefaultSQLParserRuleConfigurationBuilder().build());
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
@Before
public void setUp() throws ReflectiveOperationException {
- when(backendConnection.getSchemaName()).thenReturn("logic_db");
- when(backendConnection.getDefaultSchemaName()).thenReturn("logic_db");
- when(backendConnection.getAttributeMap().attr(MySQLConstants.MYSQL_CHARACTER_SET_ATTRIBUTE_KEY).get()).thenReturn(MySQLCharacterSet.UTF8MB4_GENERAL_CI);
+ when(connectionSession.getSchemaName()).thenReturn("logic_db");
+ when(connectionSession.getDefaultSchemaName()).thenReturn("logic_db");
+ when(connectionSession.getAttributeMap().attr(MySQLConstants.MYSQL_CHARACTER_SET_ATTRIBUTE_KEY).get()).thenReturn(MySQLCharacterSet.UTF8MB4_GENERAL_CI);
Field contextManagerField = ProxyContext.getInstance().getClass().getDeclaredField("contextManager");
contextManagerField.setAccessible(true);
ShardingSphereMetaData metaData = mockShardingSphereMetaData();
@@ -105,61 +105,61 @@ public final class MySQLCommandExecutorFactoryTest {
@Test
public void assertNewInstanceWithComQuit() throws SQLException {
- assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_QUIT, mock(CommandPacket.class), backendConnection), instanceOf(MySQLComQuitExecutor.class));
+ assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_QUIT, mock(CommandPacket.class), connectionSession), instanceOf(MySQLComQuitExecutor.class));
}
@Test
public void assertNewInstanceWithComInitDb() throws SQLException {
- assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_INIT_DB, mock(MySQLComInitDbPacket.class), backendConnection), instanceOf(MySQLComInitDbExecutor.class));
+ assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_INIT_DB, mock(MySQLComInitDbPacket.class), connectionSession), instanceOf(MySQLComInitDbExecutor.class));
}
@Test
public void assertNewInstanceWithComFieldList() throws SQLException {
MySQLComFieldListPacket packet = mock(MySQLComFieldListPacket.class);
when(packet.getTable()).thenReturn("test");
- assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_FIELD_LIST, packet, backendConnection), instanceOf(MySQLComFieldListPacketExecutor.class));
+ assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_FIELD_LIST, packet, connectionSession), instanceOf(MySQLComFieldListPacketExecutor.class));
}
@Test
public void assertNewInstanceWithComQuery() throws SQLException {
MySQLComQueryPacket packet = mock(MySQLComQueryPacket.class);
when(packet.getSql()).thenReturn("");
- assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_QUERY, packet, backendConnection), instanceOf(MySQLComQueryPacketExecutor.class));
+ assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_QUERY, packet, connectionSession), instanceOf(MySQLComQueryPacketExecutor.class));
}
@Test
public void assertNewInstanceWithComPing() throws SQLException {
- assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_PING, mock(CommandPacket.class), backendConnection), instanceOf(MySQLComPingExecutor.class));
+ assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_PING, mock(CommandPacket.class), connectionSession), instanceOf(MySQLComPingExecutor.class));
}
@Test
public void assertNewInstanceWithComStmtPrepare() throws SQLException {
assertThat(MySQLCommandExecutorFactory.newInstance(
- MySQLCommandPacketType.COM_STMT_PREPARE, mock(MySQLComStmtPreparePacket.class), backendConnection), instanceOf(MySQLComStmtPrepareExecutor.class));
+ MySQLCommandPacketType.COM_STMT_PREPARE, mock(MySQLComStmtPreparePacket.class), connectionSession), instanceOf(MySQLComStmtPrepareExecutor.class));
}
@Test
public void assertNewInstanceWithComStmtExecute() throws SQLException {
MySQLComStmtExecutePacket packet = mock(MySQLComStmtExecutePacket.class);
when(packet.getSql()).thenReturn("SELECT 1");
- assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_STMT_EXECUTE, packet, backendConnection), instanceOf(MySQLComStmtExecuteExecutor.class));
+ assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_STMT_EXECUTE, packet, connectionSession), instanceOf(MySQLComStmtExecuteExecutor.class));
}
@Test
public void assertNewInstanceWithComStmtReset() throws SQLException {
assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_STMT_RESET,
- mock(MySQLComStmtResetPacket.class), backendConnection), instanceOf(MySQLComStmtResetExecutor.class));
+ mock(MySQLComStmtResetPacket.class), connectionSession), instanceOf(MySQLComStmtResetExecutor.class));
}
@Test
public void assertNewInstanceWithComStmtClose() throws SQLException {
assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_STMT_CLOSE,
- mock(MySQLComStmtClosePacket.class), backendConnection), instanceOf(MySQLComStmtCloseExecutor.class));
+ mock(MySQLComStmtClosePacket.class), connectionSession), instanceOf(MySQLComStmtCloseExecutor.class));
}
@Test
public void assertNewInstanceWithUnsupportedCommand() throws SQLException {
assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_REFRESH,
- mock(CommandPacket.class), backendConnection), instanceOf(MySQLUnsupportedCommandExecutor.class));
+ mock(CommandPacket.class), connectionSession), instanceOf(MySQLUnsupportedCommandExecutor.class));
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java
index 1681b49..c06416b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java
@@ -32,7 +32,7 @@ import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
import org.apache.shardingsphere.parser.rule.builder.DefaultSQLParserRuleConfigurationBuilder;
import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
@@ -71,7 +71,7 @@ public final class MySQLComStmtExecuteExecutorTest {
private DatabaseCommunicationEngine databaseCommunicationEngine;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
@Before
public void setUp() throws ReflectiveOperationException {
@@ -84,7 +84,7 @@ public final class MySQLComStmtExecuteExecutorTest {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
contextManagerField.set(ProxyContext.getInstance(), contextManager);
- when(backendConnection.getAttributeMap().attr(MySQLConstants.MYSQL_CHARACTER_SET_ATTRIBUTE_KEY).get()).thenReturn(MySQLCharacterSet.UTF8MB4_GENERAL_CI);
+ when(connectionSession.getAttributeMap().attr(MySQLConstants.MYSQL_CHARACTER_SET_ATTRIBUTE_KEY).get()).thenReturn(MySQLCharacterSet.UTF8MB4_GENERAL_CI);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findSingleRule(SQLParserRule.class)).thenReturn(Optional.of(sqlParserRule));
}
@@ -97,11 +97,11 @@ public final class MySQLComStmtExecuteExecutorTest {
@Test
public void assertIsQueryResponse() throws NoSuchFieldException, SQLException {
- when(backendConnection.getSchemaName()).thenReturn("logic_db");
- when(backendConnection.getDefaultSchemaName()).thenReturn("logic_db");
+ when(connectionSession.getSchemaName()).thenReturn("logic_db");
+ when(connectionSession.getDefaultSchemaName()).thenReturn("logic_db");
MySQLComStmtExecutePacket packet = mock(MySQLComStmtExecutePacket.class);
when(packet.getSql()).thenReturn("SELECT 1");
- MySQLComStmtExecuteExecutor mysqlComStmtExecuteExecutor = new MySQLComStmtExecuteExecutor(packet, backendConnection);
+ MySQLComStmtExecuteExecutor mysqlComStmtExecuteExecutor = new MySQLComStmtExecuteExecutor(packet, connectionSession);
FieldSetter.setField(mysqlComStmtExecuteExecutor, MySQLComStmtExecuteExecutor.class.getDeclaredField("databaseCommunicationEngine"), databaseCommunicationEngine);
when(databaseCommunicationEngine.execute()).thenReturn(new QueryResponseHeader(Collections.singletonList(mock(QueryHeader.class))));
mysqlComStmtExecuteExecutor.execute();
@@ -110,11 +110,11 @@ public final class MySQLComStmtExecuteExecutorTest {
@Test
public void assertIsUpdateResponse() throws NoSuchFieldException, SQLException {
- when(backendConnection.getSchemaName()).thenReturn("logic_db");
- when(backendConnection.getDefaultSchemaName()).thenReturn("logic_db");
+ when(connectionSession.getSchemaName()).thenReturn("logic_db");
+ when(connectionSession.getDefaultSchemaName()).thenReturn("logic_db");
MySQLComStmtExecutePacket packet = mock(MySQLComStmtExecutePacket.class);
when(packet.getSql()).thenReturn("SELECT 1");
- MySQLComStmtExecuteExecutor mysqlComStmtExecuteExecutor = new MySQLComStmtExecuteExecutor(packet, backendConnection);
+ MySQLComStmtExecuteExecutor mysqlComStmtExecuteExecutor = new MySQLComStmtExecuteExecutor(packet, connectionSession);
FieldSetter.setField(mysqlComStmtExecuteExecutor, MySQLComStmtExecuteExecutor.class.getDeclaredField("databaseCommunicationEngine"), databaseCommunicationEngine);
when(databaseCommunicationEngine.execute()).thenReturn(new UpdateResponseHeader(mock(SQLStatement.class)));
mysqlComStmtExecuteExecutor.execute();
@@ -123,11 +123,11 @@ public final class MySQLComStmtExecuteExecutorTest {
@Test
public void assertExecutePreparedCommit() throws SQLException, NoSuchFieldException {
- when(backendConnection.getSchemaName()).thenReturn("logic_db");
- when(backendConnection.getDefaultSchemaName()).thenReturn("logic_db");
+ when(connectionSession.getSchemaName()).thenReturn("logic_db");
+ when(connectionSession.getDefaultSchemaName()).thenReturn("logic_db");
MySQLComStmtExecutePacket packet = mock(MySQLComStmtExecutePacket.class);
when(packet.getSql()).thenReturn("commit");
- MySQLComStmtExecuteExecutor mysqlComStmtExecuteExecutor = new MySQLComStmtExecuteExecutor(packet, backendConnection);
+ MySQLComStmtExecuteExecutor mysqlComStmtExecuteExecutor = new MySQLComStmtExecuteExecutor(packet, connectionSession);
TextProtocolBackendHandler textProtocolBackendHandler = mock(TextProtocolBackendHandler.class);
FieldSetter.setField(mysqlComStmtExecuteExecutor, MySQLComStmtExecuteExecutor.class.getDeclaredField("textProtocolBackendHandler"), textProtocolBackendHandler);
when(textProtocolBackendHandler.execute()).thenReturn(new UpdateResponseHeader(mock(CommitStatement.class)));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutorTest.java
index a821e5d..2f81eb5 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutorTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query;
import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLCharacterSet;
import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLConstants;
import org.apache.shardingsphere.db.protocol.mysql.packet.command.query.text.query.MySQLComQueryPacket;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
@@ -53,17 +53,17 @@ public final class MySQLComQueryPacketExecutorTest {
private MySQLComQueryPacket packet;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
@Before
public void setUp() {
when(packet.getSql()).thenReturn("");
- when(backendConnection.getAttributeMap().attr(MySQLConstants.MYSQL_CHARACTER_SET_ATTRIBUTE_KEY).get()).thenReturn(MySQLCharacterSet.UTF8MB4_GENERAL_CI);
+ when(connectionSession.getAttributeMap().attr(MySQLConstants.MYSQL_CHARACTER_SET_ATTRIBUTE_KEY).get()).thenReturn(MySQLCharacterSet.UTF8MB4_GENERAL_CI);
}
@Test
public void assertIsQueryResponse() throws SQLException, NoSuchFieldException {
- MySQLComQueryPacketExecutor mysqlComQueryPacketExecutor = new MySQLComQueryPacketExecutor(packet, backendConnection);
+ MySQLComQueryPacketExecutor mysqlComQueryPacketExecutor = new MySQLComQueryPacketExecutor(packet, connectionSession);
FieldSetter.setField(mysqlComQueryPacketExecutor, MySQLComQueryPacketExecutor.class.getDeclaredField("textProtocolBackendHandler"), textProtocolBackendHandler);
when(textProtocolBackendHandler.execute()).thenReturn(new QueryResponseHeader(Collections.singletonList(mock(QueryHeader.class))));
mysqlComQueryPacketExecutor.execute();
@@ -72,7 +72,7 @@ public final class MySQLComQueryPacketExecutorTest {
@Test
public void assertIsUpdateResponse() throws SQLException, NoSuchFieldException {
- MySQLComQueryPacketExecutor mysqlComQueryPacketExecutor = new MySQLComQueryPacketExecutor(packet, backendConnection);
+ MySQLComQueryPacketExecutor mysqlComQueryPacketExecutor = new MySQLComQueryPacketExecutor(packet, connectionSession);
FieldSetter.setField(mysqlComQueryPacketExecutor, MySQLComQueryPacketExecutor.class.getDeclaredField("textProtocolBackendHandler"), textProtocolBackendHandler);
when(textProtocolBackendHandler.execute()).thenReturn(new UpdateResponseHeader(mock(SQLStatement.class)));
mysqlComQueryPacketExecutor.execute();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/OpenGaussFrontendEngine.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/OpenGaussFrontendEngine.java
index 3f4ff40..b55bad2 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/OpenGaussFrontendEngine.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/OpenGaussFrontendEngine.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.proxy.frontend.opengauss;
import lombok.Getter;
import org.apache.shardingsphere.db.protocol.codec.DatabasePacketCodecEngine;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.authentication.AuthenticationEngine;
import org.apache.shardingsphere.proxy.frontend.context.FrontendContext;
import org.apache.shardingsphere.proxy.frontend.opengauss.command.OpenGaussCommandExecuteEngine;
@@ -52,8 +52,8 @@ public final class OpenGaussFrontendEngine implements DatabaseProtocolFrontendEn
}
@Override
- public void release(final BackendConnection backendConnection) {
- postgreSQLFrontendEngine.release(backendConnection);
+ public void release(final ConnectionSession connectionSession) {
+ postgreSQLFrontendEngine.release(connectionSession);
}
@Override
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/OpenGaussCommandExecuteEngine.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/OpenGaussCommandExecuteEngine.java
index e497693..2cdfa8b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/OpenGaussCommandExecuteEngine.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/OpenGaussCommandExecuteEngine.java
@@ -25,7 +25,8 @@ 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.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.CommandExecuteEngine;
import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
import org.apache.shardingsphere.proxy.frontend.command.executor.QueryCommandExecutor;
@@ -50,19 +51,19 @@ public final class OpenGaussCommandExecuteEngine implements CommandExecuteEngine
}
@Override
- public CommandPacket getCommandPacket(final PacketPayload payload, final CommandPacketType type, final BackendConnection backendConnection) {
- return OpenGaussCommandPacketFactory.newInstance(type, (PostgreSQLPacketPayload) payload, backendConnection.getConnectionId());
+ public CommandPacket getCommandPacket(final PacketPayload payload, final CommandPacketType type, final ConnectionSession connectionSession) {
+ return OpenGaussCommandPacketFactory.newInstance(type, (PostgreSQLPacketPayload) payload, connectionSession.getConnectionId());
}
@Override
- public CommandExecutor getCommandExecutor(final CommandPacketType type, final CommandPacket packet, final BackendConnection backendConnection) throws SQLException {
- PostgreSQLConnectionContext connectionContext = PostgreSQLConnectionContextRegistry.getInstance().get(backendConnection.getConnectionId());
- return OpenGaussCommandExecutorFactory.newInstance(type, packet, backendConnection, connectionContext);
+ public CommandExecutor getCommandExecutor(final CommandPacketType type, final CommandPacket packet, final JDBCConnectionSession connectionSession) throws SQLException {
+ PostgreSQLConnectionContext connectionContext = PostgreSQLConnectionContextRegistry.getInstance().get(connectionSession.getConnectionId());
+ return OpenGaussCommandExecutorFactory.newInstance(type, packet, connectionSession, connectionContext);
}
@Override
- public DatabasePacket<?> getErrorPacket(final Exception cause, final BackendConnection backendConnection) {
- PostgreSQLConnectionContextRegistry.getInstance().get(backendConnection.getConnectionId()).getPendingExecutors().clear();
+ public DatabasePacket<?> getErrorPacket(final Exception cause, final ConnectionSession connectionSession) {
+ PostgreSQLConnectionContextRegistry.getInstance().get(connectionSession.getConnectionId()).getPendingExecutors().clear();
return OpenGaussErrorPacketFactory.newInstance(cause);
}
@@ -72,13 +73,13 @@ public final class OpenGaussCommandExecuteEngine implements CommandExecuteEngine
}
@Override
- public Optional<DatabasePacket<?>> getOtherPacket(final BackendConnection backendConnection) {
- return postgreSQLCommandExecuteEngine.getOtherPacket(backendConnection);
+ public Optional<DatabasePacket<?>> getOtherPacket(final ConnectionSession connectionSession) {
+ return postgreSQLCommandExecuteEngine.getOtherPacket(connectionSession);
}
@Override
public boolean writeQueryData(final ChannelHandlerContext context,
- final BackendConnection backendConnection, final QueryCommandExecutor queryCommandExecutor, final int headerPackagesCount) throws SQLException {
- return postgreSQLCommandExecuteEngine.writeQueryData(context, backendConnection, queryCommandExecutor, headerPackagesCount);
+ final JDBCConnectionSession connectionSession, final QueryCommandExecutor queryCommandExecutor, final int headerPackagesCount) throws SQLException {
+ return postgreSQLCommandExecuteEngine.writeQueryData(context, connectionSession, queryCommandExecutor, headerPackagesCount);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/OpenGaussCommandExecutorFactory.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/OpenGaussCommandExecutorFactory.java
index 2a3ab85..4f904fb 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/OpenGaussCommandExecutorFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/OpenGaussCommandExecutorFactory.java
@@ -26,7 +26,7 @@ import org.apache.shardingsphere.db.protocol.packet.CommandPacket;
import org.apache.shardingsphere.db.protocol.packet.CommandPacketType;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.PostgreSQLCommandPacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.PostgreSQLCommandPacketType;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
import org.apache.shardingsphere.proxy.frontend.opengauss.command.query.extended.bind.OpenGaussComBatchBindExecutor;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLCommandExecutorFactory;
@@ -46,14 +46,14 @@ public final class OpenGaussCommandExecutorFactory {
*
* @param commandPacketType command packet type for PostgreSQL/openGauss
* @param commandPacket command packet for PostgreSQL/openGauss
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @param connectionContext PostgreSQL connection context
* @return command executor
* @throws SQLException SQL exception
*/
public static CommandExecutor newInstance(final CommandPacketType commandPacketType, final CommandPacket commandPacket,
- final BackendConnection backendConnection, final PostgreSQLConnectionContext connectionContext) throws SQLException {
- return commandPacketType == OpenGaussCommandPacketType.BATCH_BIND_COMMAND ? new OpenGaussComBatchBindExecutor((OpenGaussComBatchBindPacket) commandPacket, backendConnection)
- : PostgreSQLCommandExecutorFactory.newInstance((PostgreSQLCommandPacketType) commandPacketType, (PostgreSQLCommandPacket) commandPacket, backendConnection, connectionContext);
+ final JDBCConnectionSession connectionSession, final PostgreSQLConnectionContext connectionContext) throws SQLException {
+ return commandPacketType == OpenGaussCommandPacketType.BATCH_BIND_COMMAND ? new OpenGaussComBatchBindExecutor((OpenGaussComBatchBindPacket) commandPacket, connectionSession)
+ : PostgreSQLCommandExecutorFactory.newInstance((PostgreSQLCommandPacketType) commandPacketType, (PostgreSQLCommandPacket) commandPacket, connectionSession, connectionContext);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutor.java
index b295965..ef40f6b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutor.java
@@ -32,7 +32,7 @@ import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
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.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
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;
@@ -56,7 +56,7 @@ public final class OpenGaussComBatchBindExecutor implements QueryCommandExecutor
private final OpenGaussComBatchBindPacket packet;
- private final BackendConnection backendConnection;
+ private final JDBCConnectionSession connectionSession;
private SQLStatement sqlStatement;
@@ -66,7 +66,7 @@ public final class OpenGaussComBatchBindExecutor implements QueryCommandExecutor
@Override
public Collection<DatabasePacket<?>> execute() throws SQLException {
- sqlStatement = parseSql(packet.getSql(), backendConnection.getSchemaName());
+ sqlStatement = parseSql(packet.getSql(), connectionSession.getSchemaName());
while (packet.hasNextParameters()) {
List<Object> parameters = packet.readOneGroupOfParameters();
DatabaseCommunicationEngine databaseCommunicationEngine = newEngine(parameters);
@@ -76,19 +76,19 @@ public final class OpenGaussComBatchBindExecutor implements QueryCommandExecutor
updateCount += ((UpdateResponseHeader) responseHeader).getUpdateCount();
}
} finally {
- backendConnection.closeDatabaseCommunicationEngines(false);
+ connectionSession.closeDatabaseCommunicationEngines(false);
}
}
return Collections.singletonList(new PostgreSQLBindCompletePacket());
}
private DatabaseCommunicationEngine newEngine(final List<Object> parameter) {
- return DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(getSqlStatementContext(parameter), packet.getSql(), parameter, backendConnection);
+ return DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(getSqlStatementContext(parameter), packet.getSql(), parameter, connectionSession);
}
private SQLStatementContext<?> getSqlStatementContext(final List<Object> parameters) {
Map<String, ShardingSphereMetaData> metaDataMap = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaDataMap();
- return SQLStatementContextFactory.newInstance(metaDataMap, parameters, sqlStatement, backendConnection.getDefaultSchemaName());
+ return SQLStatementContextFactory.newInstance(metaDataMap, parameters, sqlStatement, connectionSession.getDefaultSchemaName());
}
private SQLStatement parseSql(final String sql, final String schemaName) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/OpenGaussFrontendEngineTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/OpenGaussFrontendEngineTest.java
index 16285e7..4a2cab3 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/OpenGaussFrontendEngineTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/OpenGaussFrontendEngineTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.frontend.opengauss;
import lombok.SneakyThrows;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.opengauss.command.OpenGaussCommandExecuteEngine;
import org.apache.shardingsphere.proxy.frontend.postgresql.PostgreSQLFrontendEngine;
import org.junit.Before;
@@ -85,7 +85,7 @@ public final class OpenGaussFrontendEngineTest {
@Test
public void assertRelease() {
- BackendConnection connection = mock(BackendConnection.class);
+ ConnectionSession connection = mock(ConnectionSession.class);
openGaussFrontendEngine.release(connection);
verify(mockPostgreSQLFrontendEngine).release(connection);
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/PostgreSQLFrontendEngine.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/PostgreSQLFrontendEngine.java
index c56e9f1..fd0723d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/PostgreSQLFrontendEngine.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/PostgreSQLFrontendEngine.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.db.protocol.codec.DatabasePacketCodecEngine;
import org.apache.shardingsphere.db.protocol.postgresql.codec.PostgreSQLPacketCodecEngine;
import org.apache.shardingsphere.db.protocol.postgresql.packet.PostgreSQLPacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.PostgreSQLPreparedStatementRegistry;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+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;
@@ -46,9 +46,9 @@ public final class PostgreSQLFrontendEngine implements DatabaseProtocolFrontendE
private final DatabasePacketCodecEngine<PostgreSQLPacket> codecEngine = new PostgreSQLPacketCodecEngine();
@Override
- public void release(final BackendConnection backendConnection) {
- PostgreSQLPreparedStatementRegistry.getInstance().unregister(backendConnection.getConnectionId());
- PostgreSQLConnectionContextRegistry.getInstance().remove(backendConnection.getConnectionId());
+ public void release(final ConnectionSession connectionSession) {
+ PostgreSQLPreparedStatementRegistry.getInstance().unregister(connectionSession.getConnectionId());
+ PostgreSQLConnectionContextRegistry.getInstance().remove(connectionSession.getConnectionId());
}
@Override
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngine.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngine.java
index 396c371..009b326 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngine.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngine.java
@@ -31,8 +31,9 @@ import org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQ
import org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQLReadyForQueryPacket;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.CommandExecuteEngine;
import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
import org.apache.shardingsphere.proxy.frontend.command.executor.QueryCommandExecutor;
@@ -57,24 +58,24 @@ public final class PostgreSQLCommandExecuteEngine implements CommandExecuteEngin
}
@Override
- public PostgreSQLCommandPacket getCommandPacket(final PacketPayload payload, final CommandPacketType type, final BackendConnection backendConnection) {
- PostgreSQLConnectionContext connectionContext = PostgreSQLConnectionContextRegistry.getInstance().get(backendConnection.getConnectionId());
+ public PostgreSQLCommandPacket getCommandPacket(final PacketPayload payload, final CommandPacketType type, final ConnectionSession connectionSession) {
+ PostgreSQLConnectionContext connectionContext = PostgreSQLConnectionContextRegistry.getInstance().get(connectionSession.getConnectionId());
connectionContext.setCurrentPacketType((PostgreSQLCommandPacketType) type);
- return PostgreSQLCommandPacketFactory.newInstance((PostgreSQLCommandPacketType) type, (PostgreSQLPacketPayload) payload, backendConnection.getConnectionId());
+ return PostgreSQLCommandPacketFactory.newInstance((PostgreSQLCommandPacketType) type, (PostgreSQLPacketPayload) payload, connectionSession.getConnectionId());
}
@Override
- public CommandExecutor getCommandExecutor(final CommandPacketType type, final CommandPacket packet, final BackendConnection backendConnection) throws SQLException {
- PostgreSQLConnectionContext connectionContext = PostgreSQLConnectionContextRegistry.getInstance().get(backendConnection.getConnectionId());
+ public CommandExecutor getCommandExecutor(final CommandPacketType type, final CommandPacket packet, final JDBCConnectionSession connectionSession) throws SQLException {
+ PostgreSQLConnectionContext connectionContext = PostgreSQLConnectionContextRegistry.getInstance().get(connectionSession.getConnectionId());
if (connectionContext.isErrorOccurred() && PostgreSQLCommandPacketType.isExtendedProtocolPacketType((PostgreSQLCommandPacketType) type) && PostgreSQLCommandPacketType.SYNC_COMMAND != type) {
return Collections::emptyList;
}
- return PostgreSQLCommandExecutorFactory.newInstance((PostgreSQLCommandPacketType) type, (PostgreSQLCommandPacket) packet, backendConnection, connectionContext);
+ return PostgreSQLCommandExecutorFactory.newInstance((PostgreSQLCommandPacketType) type, (PostgreSQLCommandPacket) packet, connectionSession, connectionContext);
}
@Override
- public DatabasePacket<?> getErrorPacket(final Exception cause, final BackendConnection backendConnection) {
- PostgreSQLConnectionContext connectionContext = PostgreSQLConnectionContextRegistry.getInstance().get(backendConnection.getConnectionId());
+ public DatabasePacket<?> getErrorPacket(final Exception cause, final ConnectionSession connectionSession) {
+ PostgreSQLConnectionContext connectionContext = PostgreSQLConnectionContextRegistry.getInstance().get(connectionSession.getConnectionId());
if (PostgreSQLCommandPacketType.isExtendedProtocolPacketType(connectionContext.getCurrentPacketType())) {
connectionContext.setErrorOccurred(true);
connectionContext.getPendingExecutors().clear();
@@ -88,15 +89,15 @@ public final class PostgreSQLCommandExecuteEngine implements CommandExecuteEngin
}
@Override
- public Optional<DatabasePacket<?>> getOtherPacket(final BackendConnection backendConnection) {
- PostgreSQLConnectionContext connectionContext = PostgreSQLConnectionContextRegistry.getInstance().get(backendConnection.getConnectionId());
+ public Optional<DatabasePacket<?>> getOtherPacket(final ConnectionSession connectionSession) {
+ PostgreSQLConnectionContext connectionContext = PostgreSQLConnectionContextRegistry.getInstance().get(connectionSession.getConnectionId());
return PostgreSQLCommandPacketType.isExtendedProtocolPacketType(connectionContext.getCurrentPacketType()) ? Optional.empty()
- : Optional.of(new PostgreSQLReadyForQueryPacket(backendConnection.getTransactionStatus().isInTransaction()));
+ : Optional.of(new PostgreSQLReadyForQueryPacket(connectionSession.getTransactionStatus().isInTransaction()));
}
@Override
public boolean writeQueryData(final ChannelHandlerContext context,
- final BackendConnection backendConnection, final QueryCommandExecutor queryCommandExecutor, final int headerPackagesCount) throws SQLException {
+ final JDBCConnectionSession connectionSession, final QueryCommandExecutor queryCommandExecutor, final int headerPackagesCount) throws SQLException {
if (queryCommandExecutor instanceof PostgreSQLComSyncExecutor) {
return true;
}
@@ -105,26 +106,26 @@ public final class PostgreSQLCommandExecuteEngine implements CommandExecuteEngin
return true;
}
if (queryCommandExecutor instanceof PostgreSQLComQueryExecutor) {
- return processSimpleQuery(context, backendConnection, (PostgreSQLComQueryExecutor) queryCommandExecutor);
+ return processSimpleQuery(context, connectionSession, (PostgreSQLComQueryExecutor) queryCommandExecutor);
}
- writeDataPackets(context, backendConnection, queryCommandExecutor);
+ writeDataPackets(context, connectionSession, queryCommandExecutor);
return false;
}
- private boolean processSimpleQuery(final ChannelHandlerContext context, final BackendConnection backendConnection, final PostgreSQLComQueryExecutor queryExecutor) throws SQLException {
+ private boolean processSimpleQuery(final ChannelHandlerContext context, final JDBCConnectionSession connectionSession, final PostgreSQLComQueryExecutor queryExecutor) throws SQLException {
if (ResponseType.UPDATE == queryExecutor.getResponseType()) {
- context.write(new PostgreSQLReadyForQueryPacket(backendConnection.getTransactionStatus().isInTransaction()));
+ context.write(new PostgreSQLReadyForQueryPacket(connectionSession.getTransactionStatus().isInTransaction()));
return true;
}
- long dataRows = writeDataPackets(context, backendConnection, queryExecutor);
+ long dataRows = writeDataPackets(context, connectionSession, queryExecutor);
if (ResponseType.QUERY == queryExecutor.getResponseType()) {
context.write(new PostgreSQLCommandCompletePacket(PostgreSQLCommand.SELECT.name(), dataRows));
}
- context.write(new PostgreSQLReadyForQueryPacket(backendConnection.getTransactionStatus().isInTransaction()));
+ context.write(new PostgreSQLReadyForQueryPacket(connectionSession.getTransactionStatus().isInTransaction()));
return true;
}
- private long writeDataPackets(final ChannelHandlerContext context, final BackendConnection backendConnection, final QueryCommandExecutor queryCommandExecutor) throws SQLException {
+ private long writeDataPackets(final ChannelHandlerContext context, final JDBCConnectionSession connectionSession, final QueryCommandExecutor queryCommandExecutor) throws SQLException {
long dataRows = 0;
int flushCount = 0;
int proxyFrontendFlushThreshold = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getProps().<Integer>getValue(ConfigurationPropertyKey.PROXY_FRONTEND_FLUSH_THRESHOLD);
@@ -132,7 +133,7 @@ public final class PostgreSQLCommandExecuteEngine implements CommandExecuteEngin
flushCount++;
while (!context.channel().isWritable() && context.channel().isActive()) {
context.flush();
- backendConnection.getResourceLock().doAwait();
+ connectionSession.getResourceLock().doAwait();
}
DatabasePacket<?> resultValue = queryCommandExecutor.getQueryRowPacket();
context.write(resultValue);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactory.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactory.java
index 9c6968b..412e04c 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactory.java
@@ -28,7 +28,7 @@ import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.ext
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.execute.PostgreSQLComExecutePacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.parse.PostgreSQLComParsePacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.simple.PostgreSQLComQueryPacket;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.generic.PostgreSQLComTerminationExecutor;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.generic.PostgreSQLUnsupportedCommandExecutor;
@@ -55,21 +55,21 @@ public final class PostgreSQLCommandExecutorFactory {
*
* @param commandPacketType command packet type for PostgreSQL
* @param commandPacket command packet for PostgreSQL
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @param connectionContext PostgreSQL connection context
* @return command executor
* @throws SQLException SQL exception
*/
public static CommandExecutor newInstance(final PostgreSQLCommandPacketType commandPacketType, final PostgreSQLCommandPacket commandPacket,
- final BackendConnection backendConnection, final PostgreSQLConnectionContext connectionContext) throws SQLException {
+ final JDBCConnectionSession connectionSession, final PostgreSQLConnectionContext connectionContext) throws SQLException {
log.debug("Execute packet type: {}, value: {}", commandPacketType, commandPacket);
switch (commandPacketType) {
case SIMPLE_QUERY:
- return new PostgreSQLComQueryExecutor(connectionContext, (PostgreSQLComQueryPacket) commandPacket, backendConnection);
+ return new PostgreSQLComQueryExecutor(connectionContext, (PostgreSQLComQueryPacket) commandPacket, connectionSession);
case PARSE_COMMAND:
- return new PostgreSQLComParseExecutor((PostgreSQLComParsePacket) commandPacket, backendConnection);
+ return new PostgreSQLComParseExecutor((PostgreSQLComParsePacket) commandPacket, connectionSession);
case BIND_COMMAND:
- connectionContext.getPendingExecutors().add(new PostgreSQLComBindExecutor(connectionContext, (PostgreSQLComBindPacket) commandPacket, backendConnection));
+ connectionContext.getPendingExecutors().add(new PostgreSQLComBindExecutor(connectionContext, (PostgreSQLComBindPacket) commandPacket, connectionSession));
break;
case DESCRIBE_COMMAND:
connectionContext.getPendingExecutors().add(new PostgreSQLComDescribeExecutor(connectionContext, (PostgreSQLComDescribePacket) commandPacket));
@@ -77,9 +77,9 @@ public final class PostgreSQLCommandExecutorFactory {
case EXECUTE_COMMAND:
return new PostgreSQLComExecuteExecutor(connectionContext, (PostgreSQLComExecutePacket) commandPacket);
case SYNC_COMMAND:
- return new PostgreSQLComSyncExecutor(connectionContext, backendConnection);
+ return new PostgreSQLComSyncExecutor(connectionContext, connectionSession);
case CLOSE_COMMAND:
- connectionContext.getPendingExecutors().add(new PostgreSQLComCloseExecutor(connectionContext, (PostgreSQLComClosePacket) commandPacket, backendConnection));
+ connectionContext.getPendingExecutors().add(new PostgreSQLComCloseExecutor(connectionContext, (PostgreSQLComClosePacket) commandPacket, connectionSession));
break;
case TERMINATE:
return new PostgreSQLComTerminationExecutor();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLConnectionContext.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLConnectionContext.java
index 3e4e7ce..514d42e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLConnectionContext.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLConnectionContext.java
@@ -23,7 +23,7 @@ import lombok.Setter;
import org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLValueFormat;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.PostgreSQLCommandPacketType;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.PostgreSQLPreparedStatement;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.PostgreSQLPortal;
@@ -57,13 +57,13 @@ public final class PostgreSQLConnectionContext {
* @param preparedStatement prepared statement
* @param parameters bind parameters
* @param resultFormats result formats
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @return a new portal
* @throws SQLException SQL exception
*/
public PostgreSQLPortal createPortal(final String portal, final PostgreSQLPreparedStatement preparedStatement, final List<Object> parameters, final List<PostgreSQLValueFormat> resultFormats,
- final BackendConnection backendConnection) throws SQLException {
- PostgreSQLPortal result = new PostgreSQLPortal(preparedStatement, parameters, resultFormats, backendConnection);
+ final JDBCConnectionSession connectionSession) throws SQLException {
+ PostgreSQLPortal result = new PostgreSQLPortal(preparedStatement, parameters, resultFormats, connectionSession);
portals.put(portal, result);
return result;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLConnectionContextRegistry.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLConnectionContextRegistry.java
index 81f06a2..4c0ac5a 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLConnectionContextRegistry.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLConnectionContextRegistry.java
@@ -45,7 +45,7 @@ public final class PostgreSQLConnectionContextRegistry {
/**
* Get PostgreSQL connection context.
*
- * @param connectionId backend connection id
+ * @param connectionId connection id
* @return PostgreSQL connection context
*/
public PostgreSQLConnectionContext get(final int connectionId) {
@@ -55,7 +55,7 @@ public final class PostgreSQLConnectionContextRegistry {
/**
* Remove PostgreSQL connection context.
*
- * @param connectionId backend connection id
+ * @param connectionId connection id
* @return Removed PostgreSQL connection context
*/
public PostgreSQLConnectionContext remove(final int connectionId) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLPortal.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLPortal.java
index 221fb67..3d2f3bd 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLPortal.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLPortal.java
@@ -33,7 +33,7 @@ import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
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.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseCell;
import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
@@ -68,25 +68,25 @@ public final class PostgreSQLPortal {
private final TextProtocolBackendHandler textProtocolBackendHandler;
- private final BackendConnection backendConnection;
+ private final JDBCConnectionSession connectionSession;
private ResponseHeader responseHeader;
public PostgreSQLPortal(final PostgreSQLPreparedStatement preparedStatement, final List<Object> parameters, final List<PostgreSQLValueFormat> resultFormats,
- final BackendConnection backendConnection) throws SQLException {
+ final JDBCConnectionSession connectionSession) throws SQLException {
this.sqlStatement = preparedStatement.getSqlStatement();
this.resultFormats = resultFormats;
- this.backendConnection = backendConnection;
+ this.connectionSession = connectionSession;
if (sqlStatement instanceof TCLStatement || sqlStatement instanceof EmptyStatement || sqlStatement instanceof DistSQLStatement) {
databaseCommunicationEngine = null;
textProtocolBackendHandler =
- TextProtocolBackendHandlerFactory.newInstance(DatabaseTypeRegistry.getActualDatabaseType("PostgreSQL"), preparedStatement.getSql(), backendConnection);
+ TextProtocolBackendHandlerFactory.newInstance(DatabaseTypeRegistry.getActualDatabaseType("PostgreSQL"), preparedStatement.getSql(), connectionSession);
return;
}
SQLStatementContext<?> sqlStatementContext = SQLStatementContextFactory.newInstance(
- ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaDataMap(), parameters, sqlStatement, backendConnection.getDefaultSchemaName());
+ ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaDataMap(), parameters, sqlStatement, connectionSession.getDefaultSchemaName());
databaseCommunicationEngine = DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(sqlStatementContext,
- preparedStatement.getSql(), parameters, backendConnection);
+ preparedStatement.getSql(), parameters, connectionSession);
textProtocolBackendHandler = null;
}
@@ -181,7 +181,7 @@ public final class PostgreSQLPortal {
* Suspend the portal.
*/
public void suspend() {
- backendConnection.markResourceInUse(databaseCommunicationEngine);
+ connectionSession.markResourceInUse(databaseCommunicationEngine);
}
/**
@@ -191,7 +191,7 @@ public final class PostgreSQLPortal {
*/
public void close() throws SQLException {
if (null != databaseCommunicationEngine) {
- backendConnection.unmarkResourceInUse(databaseCommunicationEngine);
+ connectionSession.unmarkResourceInUse(databaseCommunicationEngine);
}
if (null != textProtocolBackendHandler) {
textProtocolBackendHandler.close();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutor.java
index a138528..feefa71 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutor.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.ext
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.PostgreSQLPreparedStatementRegistry;
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.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLConnectionContext;
@@ -41,12 +41,12 @@ public final class PostgreSQLComBindExecutor implements CommandExecutor {
private final PostgreSQLComBindPacket packet;
- private final BackendConnection backendConnection;
+ private final JDBCConnectionSession connectionSession;
@Override
public Collection<DatabasePacket<?>> execute() throws SQLException {
- PostgreSQLPreparedStatement preparedStatement = PostgreSQLPreparedStatementRegistry.getInstance().get(backendConnection.getConnectionId(), packet.getStatementId());
- connectionContext.createPortal(packet.getPortal(), preparedStatement, packet.getParameters(), packet.getResultFormats(), backendConnection).execute();
+ PostgreSQLPreparedStatement preparedStatement = PostgreSQLPreparedStatementRegistry.getInstance().get(connectionSession.getConnectionId(), packet.getStatementId());
+ connectionContext.createPortal(packet.getPortal(), preparedStatement, packet.getParameters(), packet.getResultFormats(), connectionSession).execute();
return Collections.singletonList(new PostgreSQLBindCompletePacket());
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutor.java
index 5e6bff6..3e4b3e3 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutor.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.PostgreSQLPreparedStatementRegistry;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.close.PostgreSQLCloseCompletePacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.close.PostgreSQLComClosePacket;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.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.PostgreSQLConnectionContext;
@@ -40,13 +40,13 @@ public final class PostgreSQLComCloseExecutor implements CommandExecutor {
private final PostgreSQLComClosePacket packet;
- private final BackendConnection backendConnection;
+ private final ConnectionSession connectionSession;
@Override
public Collection<DatabasePacket<?>> execute() throws SQLException {
switch (packet.getType()) {
case PREPARED_STATEMENT:
- PostgreSQLPreparedStatementRegistry.getInstance().unregister(backendConnection.getConnectionId(), packet.getName());
+ PostgreSQLPreparedStatementRegistry.getInstance().unregister(connectionSession.getConnectionId(), packet.getName());
break;
case PORTAL:
closePortal();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutor.java
index 0fc7949..abdb4dd 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutor.java
@@ -25,8 +25,8 @@ import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.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;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.EmptyStatement;
@@ -39,10 +39,10 @@ import java.util.Collections;
*/
public final class PostgreSQLComParseExecutor implements CommandExecutor {
- public PostgreSQLComParseExecutor(final PostgreSQLComParsePacket packet, final BackendConnection backendConnection) {
- String schemaName = backendConnection.getSchemaName();
+ public PostgreSQLComParseExecutor(final PostgreSQLComParsePacket packet, final ConnectionSession connectionSession) {
+ String schemaName = connectionSession.getSchemaName();
SQLStatement sqlStatement = parseSql(packet.getSql(), schemaName);
- PostgreSQLPreparedStatementRegistry.getInstance().register(backendConnection.getConnectionId(), packet.getStatementId(), packet.getSql(), sqlStatement, packet.getColumnTypes());
+ PostgreSQLPreparedStatementRegistry.getInstance().register(connectionSession.getConnectionId(), packet.getStatementId(), packet.getSql(), sqlStatement, packet.getColumnTypes());
}
private SQLStatement parseSql(final String sql, final String schemaName) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/sync/PostgreSQLComSyncExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/sync/PostgreSQLComSyncExecutor.java
index bb057c7..45db022 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/sync/PostgreSQLComSyncExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/sync/PostgreSQLComSyncExecutor.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extend
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQLReadyForQueryPacket;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.executor.QueryCommandExecutor;
import org.apache.shardingsphere.proxy.frontend.command.executor.ResponseType;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLConnectionContext;
@@ -37,12 +37,12 @@ public final class PostgreSQLComSyncExecutor implements QueryCommandExecutor {
private final PostgreSQLConnectionContext connectionContext;
- private final BackendConnection backendConnection;
+ private final ConnectionSession connectionSession;
@Override
public Collection<DatabasePacket<?>> execute() {
connectionContext.clearContext();
- return Collections.singleton(new PostgreSQLReadyForQueryPacket(backendConnection.getTransactionStatus().isInTransaction()));
+ return Collections.singleton(new PostgreSQLReadyForQueryPacket(connectionSession.getTransactionStatus().isInTransaction()));
}
@Override
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutor.java
index 5737d13..069e814 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutor.java
@@ -27,7 +27,7 @@ import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.sim
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLDataRowPacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQLCommandCompletePacket;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
@@ -61,9 +61,9 @@ public final class PostgreSQLComQueryExecutor implements QueryCommandExecutor {
private volatile ResponseType responseType;
public PostgreSQLComQueryExecutor(final PostgreSQLConnectionContext connectionContext, final PostgreSQLComQueryPacket comQueryPacket,
- final BackendConnection backendConnection) throws SQLException {
+ final JDBCConnectionSession connectionSession) throws SQLException {
this.connectionContext = connectionContext;
- textProtocolBackendHandler = TextProtocolBackendHandlerFactory.newInstance(DatabaseTypeRegistry.getActualDatabaseType("PostgreSQL"), comQueryPacket.getSql(), backendConnection);
+ textProtocolBackendHandler = TextProtocolBackendHandlerFactory.newInstance(DatabaseTypeRegistry.getActualDatabaseType("PostgreSQL"), comQueryPacket.getSql(), connectionSession);
}
@Override
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/PostgreSQLFrontendEngineTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/PostgreSQLFrontendEngineTest.java
index ccbbb4f..79c9add 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/PostgreSQLFrontendEngineTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/PostgreSQLFrontendEngineTest.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.proxy.frontend.postgresql;
import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.executor.ConnectionThreadExecutorGroup;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLConnectionContext;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLConnectionContextRegistry;
@@ -45,14 +45,14 @@ public final class PostgreSQLFrontendEngineTest {
@Test
public void assertRelease() {
- BackendConnection backendConnection = mock(BackendConnection.class, RETURNS_DEEP_STUBS);
+ ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
int connectionId = 1;
- when(backendConnection.getConnectionId()).thenReturn(connectionId);
+ when(connectionSession.getConnectionId()).thenReturn(connectionId);
PostgreSQLConnectionContextRegistry.getInstance().get(connectionId);
PostgreSQLFrontendEngine frontendEngine = new PostgreSQLFrontendEngine();
ConnectionThreadExecutorGroup.getInstance().register(connectionId);
ConnectionThreadExecutorGroup.getInstance().unregisterAndAwaitTermination(connectionId);
- frontendEngine.release(backendConnection);
+ frontendEngine.release(connectionSession);
assertTrue(getConnectionContexts().isEmpty());
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngineTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngineTest.java
index 2c29ae0..0d81572 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngineTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngineTest.java
@@ -22,7 +22,7 @@ import io.netty.channel.ChannelHandlerContext;
import org.apache.shardingsphere.db.protocol.postgresql.packet.PostgreSQLPacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQLCommandCompletePacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQLReadyForQueryPacket;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.ResourceLock;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.TransactionStatus;
import org.apache.shardingsphere.proxy.frontend.command.executor.QueryCommandExecutor;
@@ -63,12 +63,12 @@ public final class PostgreSQLCommandExecuteEngineTest {
private QueryCommandExecutor queryCommandExecutor;
@Mock
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
@Before
public void setUp() {
when(channelHandlerContext.channel()).thenReturn(channel);
- when(backendConnection.getTransactionStatus()).thenReturn(new TransactionStatus(TransactionType.LOCAL));
+ when(connectionSession.getTransactionStatus()).thenReturn(new TransactionStatus(TransactionType.LOCAL));
}
@Test
@@ -76,7 +76,7 @@ public final class PostgreSQLCommandExecuteEngineTest {
PostgreSQLComQueryExecutor comQueryExecutor = mock(PostgreSQLComQueryExecutor.class);
when(comQueryExecutor.getResponseType()).thenReturn(ResponseType.UPDATE);
PostgreSQLCommandExecuteEngine commandExecuteEngine = new PostgreSQLCommandExecuteEngine();
- boolean actual = commandExecuteEngine.writeQueryData(channelHandlerContext, backendConnection, comQueryExecutor, 0);
+ boolean actual = commandExecuteEngine.writeQueryData(channelHandlerContext, connectionSession, comQueryExecutor, 0);
assertTrue(actual);
verify(channelHandlerContext).write(any(PostgreSQLReadyForQueryPacket.class));
}
@@ -85,14 +85,14 @@ public final class PostgreSQLCommandExecuteEngineTest {
public void assertWriteQueryDataWithUpdate() throws SQLException {
PostgreSQLCommandExecuteEngine commandExecuteEngine = new PostgreSQLCommandExecuteEngine();
when(queryCommandExecutor.getResponseType()).thenReturn(ResponseType.UPDATE);
- boolean actual = commandExecuteEngine.writeQueryData(channelHandlerContext, backendConnection, queryCommandExecutor, 0);
+ boolean actual = commandExecuteEngine.writeQueryData(channelHandlerContext, connectionSession, queryCommandExecutor, 0);
assertFalse(actual);
}
@Test
public void assertWriteQueryDataWithComSync() throws SQLException {
PostgreSQLCommandExecuteEngine commandExecuteEngine = new PostgreSQLCommandExecuteEngine();
- boolean actual = commandExecuteEngine.writeQueryData(channelHandlerContext, backendConnection, new PostgreSQLComSyncExecutor(connectionContext, backendConnection), 0);
+ boolean actual = commandExecuteEngine.writeQueryData(channelHandlerContext, connectionSession, new PostgreSQLComSyncExecutor(connectionContext, connectionSession), 0);
assertTrue(actual);
verify(channelHandlerContext, never()).write(any(Object.class));
}
@@ -102,7 +102,7 @@ public final class PostgreSQLCommandExecuteEngineTest {
PostgreSQLCommandExecuteEngine commandExecuteEngine = new PostgreSQLCommandExecuteEngine();
when(queryCommandExecutor.getResponseType()).thenReturn(ResponseType.QUERY);
when(channel.isActive()).thenReturn(false);
- boolean actual = commandExecuteEngine.writeQueryData(channelHandlerContext, backendConnection, queryCommandExecutor, 0);
+ boolean actual = commandExecuteEngine.writeQueryData(channelHandlerContext, connectionSession, queryCommandExecutor, 0);
assertTrue(actual);
verify(channelHandlerContext).write(isA(PostgreSQLCommandCompletePacket.class));
}
@@ -115,11 +115,11 @@ public final class PostgreSQLCommandExecuteEngineTest {
when(queryCommandExecutor.next()).thenReturn(true, false);
when(channel.isWritable()).thenReturn(false, true);
ResourceLock resourceLock = mock(ResourceLock.class);
- when(backendConnection.getResourceLock()).thenReturn(resourceLock);
+ when(connectionSession.getResourceLock()).thenReturn(resourceLock);
PostgreSQLPacket packet = mock(PostgreSQLPacket.class);
when(queryCommandExecutor.getQueryRowPacket()).thenReturn(packet);
PostgreSQLCommandExecuteEngine commandExecuteEngine = new PostgreSQLCommandExecuteEngine();
- boolean actual = commandExecuteEngine.writeQueryData(channelHandlerContext, backendConnection, queryCommandExecutor, 0);
+ boolean actual = commandExecuteEngine.writeQueryData(channelHandlerContext, connectionSession, queryCommandExecutor, 0);
assertTrue(actual);
verify(resourceLock).doAwait();
verify(channelHandlerContext).write(packet);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactoryTest.java
index fec7565..d978b71 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactoryTest.java
@@ -27,7 +27,7 @@ import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.ext
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.execute.PostgreSQLComExecutePacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.parse.PostgreSQLComParsePacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.simple.PostgreSQLComQueryPacket;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.generic.PostgreSQLComTerminationExecutor;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.bind.PostgreSQLComBindExecutor;
@@ -61,7 +61,7 @@ import static org.mockito.Mockito.when;
public final class PostgreSQLCommandExecutorFactoryTest {
@Mock
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
@Mock
private PostgreSQLConnectionContext connectionContext;
@@ -70,7 +70,7 @@ public final class PostgreSQLCommandExecutorFactoryTest {
public void setup() {
PostgreSQLPreparedStatementRegistry.getInstance().register(1);
PostgreSQLPreparedStatementRegistry.getInstance().register(1, "2", "", new EmptyStatement(), Collections.emptyList());
- when(backendConnection.getConnectionId()).thenReturn(1);
+ when(connectionSession.getConnectionId()).thenReturn(1);
}
@Test
@@ -78,9 +78,9 @@ public final class PostgreSQLCommandExecutorFactoryTest {
PostgreSQLConnectionContext connectionContext = mock(PostgreSQLConnectionContext.class);
Collection<CommandExecutor> pendingCommandExecutors = new LinkedList<>();
when(connectionContext.getPendingExecutors()).thenReturn(pendingCommandExecutors);
- PostgreSQLCommandExecutorFactory.newInstance(PostgreSQLCommandPacketType.CLOSE_COMMAND, mock(PostgreSQLComClosePacket.class), backendConnection, connectionContext);
- PostgreSQLCommandExecutorFactory.newInstance(PostgreSQLCommandPacketType.BIND_COMMAND, mock(PostgreSQLComBindPacket.class), backendConnection, connectionContext);
- PostgreSQLCommandExecutorFactory.newInstance(PostgreSQLCommandPacketType.DESCRIBE_COMMAND, null, backendConnection, connectionContext);
+ PostgreSQLCommandExecutorFactory.newInstance(PostgreSQLCommandPacketType.CLOSE_COMMAND, mock(PostgreSQLComClosePacket.class), connectionSession, connectionContext);
+ PostgreSQLCommandExecutorFactory.newInstance(PostgreSQLCommandPacketType.BIND_COMMAND, mock(PostgreSQLComBindPacket.class), connectionSession, connectionContext);
+ PostgreSQLCommandExecutorFactory.newInstance(PostgreSQLCommandPacketType.DESCRIBE_COMMAND, null, connectionSession, connectionContext);
assertThat(pendingCommandExecutors.size(), is(3));
Iterator<CommandExecutor> commandExecutorIterator = pendingCommandExecutors.iterator();
assertThat(commandExecutorIterator.next(), instanceOf(PostgreSQLComCloseExecutor.class));
@@ -90,7 +90,7 @@ public final class PostgreSQLCommandExecutorFactoryTest {
@Test
public void assertNewInstance() throws SQLException {
- when(backendConnection.getSchemaName()).thenReturn("schema");
+ when(connectionSession.getSchemaName()).thenReturn("schema");
Collection<InputOutput> inputOutputs = Arrays.asList(
new InputOutput(PostgreSQLCommandPacketType.SIMPLE_QUERY, PostgreSQLComQueryPacket.class, PostgreSQLComQueryExecutor.class),
new InputOutput(PostgreSQLCommandPacketType.PARSE_COMMAND, PostgreSQLComParsePacket.class, PostgreSQLComParseExecutor.class),
@@ -104,7 +104,7 @@ public final class PostgreSQLCommandExecutorFactoryTest {
commandPacketClass = PostgreSQLCommandPacket.class;
}
PostgreSQLCommandPacket packet = preparePacket(commandPacketClass);
- CommandExecutor actual = PostgreSQLCommandExecutorFactory.newInstance(inputOutput.getCommandPacketType(), packet, backendConnection, connectionContext);
+ CommandExecutor actual = PostgreSQLCommandExecutorFactory.newInstance(inputOutput.getCommandPacketType(), packet, connectionSession, connectionContext);
assertThat(actual, instanceOf(inputOutput.getResultClass()));
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLConnectionContextTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLConnectionContextTest.java
index 7d44aed..528476b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLConnectionContextTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLConnectionContextTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.frontend.postgresql.command;
import lombok.SneakyThrows;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.PostgreSQLCommandPacketType;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.PostgreSQLPreparedStatement;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.PostgreSQLPortal;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.EmptyStatement;
import org.junit.Test;
@@ -48,7 +48,7 @@ public final class PostgreSQLConnectionContextTest {
PostgreSQLPreparedStatement statement = mock(PostgreSQLPreparedStatement.class);
when(statement.getSql()).thenReturn("");
when(statement.getSqlStatement()).thenReturn(new EmptyStatement());
- PostgreSQLPortal actual = context.createPortal("P_1", statement, Collections.emptyList(), Collections.emptyList(), mock(BackendConnection.class));
+ PostgreSQLPortal actual = context.createPortal("P_1", statement, Collections.emptyList(), Collections.emptyList(), mock(JDBCConnectionSession.class));
assertThat(actual, is(getPortals(context).get("P_1")));
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLPortalTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLPortalTest.java
index 0d931ab..d302b18 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLPortalTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLPortalTest.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.Pos
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.PostgreSQLPreparedStatement;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLDataRowPacket;
import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
import org.apache.shardingsphere.proxy.backend.response.data.impl.BinaryQueryResponseCell;
import org.apache.shardingsphere.proxy.backend.response.data.impl.TextQueryResponseCell;
@@ -67,7 +67,7 @@ public final class PostgreSQLPortalTest {
private TextProtocolBackendHandler textProtocolBackendHandler;
@Mock
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
private PostgreSQLPortal portal;
@@ -77,7 +77,7 @@ public final class PostgreSQLPortalTest {
when(preparedStatement.getSql()).thenReturn("");
when(preparedStatement.getSqlStatement()).thenReturn(new EmptyStatement());
List<PostgreSQLValueFormat> resultFormats = new ArrayList<>(Arrays.asList(PostgreSQLValueFormat.TEXT, PostgreSQLValueFormat.BINARY));
- portal = new PostgreSQLPortal(preparedStatement, Collections.emptyList(), resultFormats, backendConnection);
+ portal = new PostgreSQLPortal(preparedStatement, Collections.emptyList(), resultFormats, connectionSession);
}
@Test
@@ -164,7 +164,7 @@ public final class PostgreSQLPortalTest {
setDatabaseCommunicationEngine(databaseCommunicationEngine);
setTextProtocolBackendHandler(null);
portal.suspend();
- verify(backendConnection).markResourceInUse(databaseCommunicationEngine);
+ verify(connectionSession).markResourceInUse(databaseCommunicationEngine);
}
@Test
@@ -172,7 +172,7 @@ public final class PostgreSQLPortalTest {
setDatabaseCommunicationEngine(databaseCommunicationEngine);
setTextProtocolBackendHandler(textProtocolBackendHandler);
portal.close();
- verify(backendConnection).unmarkResourceInUse(databaseCommunicationEngine);
+ verify(connectionSession).unmarkResourceInUse(databaseCommunicationEngine);
verify(textProtocolBackendHandler).close();
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutorTest.java
index c4564f9..3a92de7 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutorTest.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.ext
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.PostgreSQLPreparedStatementRegistry;
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.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLConnectionContext;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.PostgreSQLPortal;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.EmptyStatement;
@@ -60,7 +60,7 @@ public final class PostgreSQLComBindExecutorTest {
private PostgreSQLComBindPacket bindPacket;
@Mock
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
@Before
@SuppressWarnings("unchecked")
@@ -71,13 +71,13 @@ public final class PostgreSQLComBindExecutorTest {
when(bindPacket.getPortal()).thenReturn("C_1");
when(bindPacket.getParameters()).thenReturn(Collections.emptyList());
when(bindPacket.getResultFormats()).thenReturn(Collections.emptyList());
- when(backendConnection.getConnectionId()).thenReturn(1);
- when(connectionContext.createPortal(anyString(), any(PostgreSQLPreparedStatement.class), any(List.class), any(List.class), eq(backendConnection))).thenReturn(portal);
+ when(connectionSession.getConnectionId()).thenReturn(1);
+ when(connectionContext.createPortal(anyString(), any(PostgreSQLPreparedStatement.class), any(List.class), any(List.class), eq(connectionSession))).thenReturn(portal);
}
@Test
public void assertExecuteEmptyBindPacket() throws SQLException {
- PostgreSQLComBindExecutor executor = new PostgreSQLComBindExecutor(connectionContext, bindPacket, backendConnection);
+ PostgreSQLComBindExecutor executor = new PostgreSQLComBindExecutor(connectionContext, bindPacket, connectionSession);
Collection<DatabasePacket<?>> actual = executor.execute();
assertThat(actual.size(), is(1));
assertThat(actual.iterator().next(), is(instanceOf(PostgreSQLBindCompletePacket.class)));
@@ -86,7 +86,7 @@ public final class PostgreSQLComBindExecutorTest {
@Test
public void assertExecuteBindPacketWithQuerySQLAndReturnEmptyResult() throws SQLException {
- PostgreSQLComBindExecutor executor = new PostgreSQLComBindExecutor(connectionContext, bindPacket, backendConnection);
+ PostgreSQLComBindExecutor executor = new PostgreSQLComBindExecutor(connectionContext, bindPacket, connectionSession);
Collection<DatabasePacket<?>> actual = executor.execute();
assertThat(actual.size(), is(1));
assertThat(actual.iterator().next(), is(instanceOf(PostgreSQLBindCompletePacket.class)));
@@ -95,7 +95,7 @@ public final class PostgreSQLComBindExecutorTest {
@Test
public void assertExecuteBindPacketWithQuerySQL() throws SQLException {
- PostgreSQLComBindExecutor executor = new PostgreSQLComBindExecutor(connectionContext, bindPacket, backendConnection);
+ PostgreSQLComBindExecutor executor = new PostgreSQLComBindExecutor(connectionContext, bindPacket, connectionSession);
Collection<DatabasePacket<?>> actual = executor.execute();
assertThat(actual.size(), is(1));
Iterator<DatabasePacket<?>> actualPackets = actual.iterator();
@@ -105,7 +105,7 @@ public final class PostgreSQLComBindExecutorTest {
@Test
public void assertExecuteBindPacketWithUpdateSQL() throws SQLException {
- PostgreSQLComBindExecutor executor = new PostgreSQLComBindExecutor(connectionContext, bindPacket, backendConnection);
+ PostgreSQLComBindExecutor executor = new PostgreSQLComBindExecutor(connectionContext, bindPacket, connectionSession);
Collection<DatabasePacket<?>> actual = executor.execute();
assertThat(actual.size(), is(1));
assertThat(actual.iterator().next(), is(instanceOf(PostgreSQLBindCompletePacket.class)));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutorTest.java
index 3084984..d12e8b7 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutorTest.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.PostgreSQLPreparedStatementRegistry;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.close.PostgreSQLCloseCompletePacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.close.PostgreSQLComClosePacket;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLConnectionContext;
import org.junit.Before;
import org.junit.Test;
@@ -48,19 +48,19 @@ public final class PostgreSQLComCloseExecutorTest {
private PostgreSQLComClosePacket packet;
@Mock
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
@Before
public void setup() {
PostgreSQLPreparedStatementRegistry.getInstance().register(1);
- when(backendConnection.getConnectionId()).thenReturn(1);
+ when(connectionSession.getConnectionId()).thenReturn(1);
}
@Test
public void assertExecuteClosePreparedStatement() throws SQLException {
when(packet.getType()).thenReturn(PostgreSQLComClosePacket.Type.PREPARED_STATEMENT);
when(packet.getName()).thenReturn("S_1");
- PostgreSQLComCloseExecutor closeExecutor = new PostgreSQLComCloseExecutor(connectionContext, packet, backendConnection);
+ PostgreSQLComCloseExecutor closeExecutor = new PostgreSQLComCloseExecutor(connectionContext, packet, connectionSession);
Collection<DatabasePacket<?>> actual = closeExecutor.execute();
assertThat(actual.size(), is(1));
assertThat(actual.iterator().next(), is(instanceOf(PostgreSQLCloseCompletePacket.class)));
@@ -71,7 +71,7 @@ public final class PostgreSQLComCloseExecutorTest {
when(packet.getType()).thenReturn(PostgreSQLComClosePacket.Type.PORTAL);
String portalName = "C_1";
when(packet.getName()).thenReturn(portalName);
- PostgreSQLComCloseExecutor closeExecutor = new PostgreSQLComCloseExecutor(connectionContext, packet, backendConnection);
+ PostgreSQLComCloseExecutor closeExecutor = new PostgreSQLComCloseExecutor(connectionContext, packet, connectionSession);
Collection<DatabasePacket<?>> actual = closeExecutor.execute();
assertThat(actual.size(), is(1));
assertThat(actual.iterator().next(), is(instanceOf(PostgreSQLCloseCompletePacket.class)));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java
index 510fdf8..165fc32 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java
@@ -31,8 +31,8 @@ import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
import org.apache.shardingsphere.parser.rule.builder.DefaultSQLParserRuleConfigurationBuilder;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.EmptyStatement;
import org.junit.Before;
import org.junit.Test;
@@ -61,20 +61,20 @@ public final class PostgreSQLComParseExecutorTest {
private PostgreSQLComParsePacket parsePacket;
@Mock
- private BackendConnection backendConnection;
+ private ConnectionSession connectionSession;
@Before
public void setup() {
PostgreSQLPreparedStatementRegistry.getInstance().register(1);
PostgreSQLPreparedStatementRegistry.getInstance().register(1, "2", "", new EmptyStatement(), Collections.emptyList());
- when(backendConnection.getConnectionId()).thenReturn(1);
+ when(connectionSession.getConnectionId()).thenReturn(1);
}
@Test
public void assertNewInstance() throws NoSuchFieldException, IllegalAccessException {
when(parsePacket.getSql()).thenReturn("SELECT 1");
when(parsePacket.getStatementId()).thenReturn("2");
- when(backendConnection.getSchemaName()).thenReturn("schema");
+ when(connectionSession.getSchemaName()).thenReturn("schema");
Field contextManagerField = ProxyContext.getInstance().getClass().getDeclaredField("contextManager");
contextManagerField.setAccessible(true);
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
@@ -83,7 +83,7 @@ public final class PostgreSQLComParseExecutorTest {
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
contextManagerField.set(ProxyContext.getInstance(), contextManager);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findSingleRule(SQLParserRule.class)).thenReturn(Optional.of(sqlParserRule));
- PostgreSQLComParseExecutor actual = new PostgreSQLComParseExecutor(parsePacket, backendConnection);
+ PostgreSQLComParseExecutor actual = new PostgreSQLComParseExecutor(parsePacket, connectionSession);
assertThat(actual.execute().iterator().next(), instanceOf(PostgreSQLParseCompletePacket.class));
}
@@ -97,7 +97,7 @@ public final class PostgreSQLComParseExecutorTest {
public void assertGetSqlWithNull() {
when(parsePacket.getStatementId()).thenReturn("");
when(parsePacket.getSql()).thenReturn("");
- PostgreSQLComParseExecutor actual = new PostgreSQLComParseExecutor(parsePacket, backendConnection);
+ PostgreSQLComParseExecutor actual = new PostgreSQLComParseExecutor(parsePacket, connectionSession);
assertThat(actual.execute().iterator().next(), instanceOf(PostgreSQLParseCompletePacket.class));
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/sync/PostgreSQLComSyncExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/sync/PostgreSQLComSyncExecutorTest.java
index 60b06d0..219e93c 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/sync/PostgreSQLComSyncExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/sync/PostgreSQLComSyncExecutorTest.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extend
import lombok.SneakyThrows;
import org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQLReadyForQueryPacket;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.TransactionStatus;
import org.apache.shardingsphere.proxy.frontend.command.executor.ResponseType;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLConnectionContext;
@@ -44,26 +44,26 @@ public final class PostgreSQLComSyncExecutorTest {
private PostgreSQLConnectionContext connectionContext;
@Mock
- private BackendConnection backendConnection;
+ private JDBCConnectionSession connectionSession;
@Test
public void assertNewInstance() {
- when(backendConnection.getTransactionStatus()).thenReturn(new TransactionStatus(TransactionType.LOCAL));
- PostgreSQLComSyncExecutor actual = new PostgreSQLComSyncExecutor(connectionContext, backendConnection);
+ when(connectionSession.getTransactionStatus()).thenReturn(new TransactionStatus(TransactionType.LOCAL));
+ PostgreSQLComSyncExecutor actual = new PostgreSQLComSyncExecutor(connectionContext, connectionSession);
assertThat(actual.execute().iterator().next(), is(instanceOf(PostgreSQLReadyForQueryPacket.class)));
}
@Test(expected = UnsupportedOperationException.class)
@SneakyThrows(SQLException.class)
public void assertNextFalse() {
- PostgreSQLComSyncExecutor actual = new PostgreSQLComSyncExecutor(connectionContext, backendConnection);
+ PostgreSQLComSyncExecutor actual = new PostgreSQLComSyncExecutor(connectionContext, connectionSession);
assertFalse(actual.next());
actual.getQueryRowPacket();
}
@Test
public void assertResponseType() {
- ResponseType actual = new PostgreSQLComSyncExecutor(connectionContext, backendConnection).getResponseType();
+ ResponseType actual = new PostgreSQLComSyncExecutor(connectionContext, connectionSession).getResponseType();
assertThat(actual, is(ResponseType.UPDATE));
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutorTest.java
index b73ff15..aa469d6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutorTest.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.Pos
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.simple.PostgreSQLComQueryPacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLDataRowPacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQLCommandCompletePacket;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
@@ -67,9 +67,9 @@ public final class PostgreSQLComQueryExecutorTest {
@Before
public void setUp() throws SQLException {
PostgreSQLComQueryPacket queryPacket = mock(PostgreSQLComQueryPacket.class);
- BackendConnection backendConnection = mock(BackendConnection.class);
+ JDBCConnectionSession connectionSession = mock(JDBCConnectionSession.class);
when(queryPacket.getSql()).thenReturn("");
- queryExecutor = new PostgreSQLComQueryExecutor(connectionContext, queryPacket, backendConnection);
+ queryExecutor = new PostgreSQLComQueryExecutor(connectionContext, queryPacket, connectionSession);
setMockFieldIntoExecutor(queryExecutor);
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-spi/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecuteEngine.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-spi/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecuteEngine.java
index 81d494a..e9ed058 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-spi/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecuteEngine.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-spi/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecuteEngine.java
@@ -22,7 +22,8 @@ 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.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCConnectionSession;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
import org.apache.shardingsphere.proxy.frontend.command.executor.QueryCommandExecutor;
@@ -47,31 +48,31 @@ public interface CommandExecuteEngine {
*
* @param payload packet payload
* @param type command packet type
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @return command packet
* @throws SQLException SQL exception
*/
- CommandPacket getCommandPacket(PacketPayload payload, CommandPacketType type, BackendConnection backendConnection) throws SQLException;
+ CommandPacket getCommandPacket(PacketPayload payload, CommandPacketType type, ConnectionSession connectionSession) throws SQLException;
/**
* Get command executor.
*
* @param type command packet type
* @param packet command packet
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @return command executor
* @throws SQLException SQL exception
*/
- CommandExecutor getCommandExecutor(CommandPacketType type, CommandPacket packet, BackendConnection backendConnection) throws SQLException;
+ CommandExecutor getCommandExecutor(CommandPacketType type, CommandPacket packet, JDBCConnectionSession connectionSession) throws SQLException;
/**
* Get error packet.
*
* @param cause cause of error
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @return error packet
*/
- DatabasePacket<?> getErrorPacket(Exception cause, BackendConnection backendConnection);
+ DatabasePacket<?> getErrorPacket(Exception cause, ConnectionSession connectionSession);
/**
* Get error packet.
@@ -84,20 +85,20 @@ public interface CommandExecuteEngine {
/**
* Get other packet.
*
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @return other packet
*/
- Optional<DatabasePacket<?>> getOtherPacket(BackendConnection backendConnection);
+ Optional<DatabasePacket<?>> getOtherPacket(ConnectionSession connectionSession);
/**
* Write query data.
*
* @param context channel handler context
- * @param backendConnection backend connection
+ * @param connectionSession connection session
* @param queryCommandExecutor query command executor
* @param headerPackagesCount count of header packages
* @return is need flush
* @throws SQLException SQL exception
*/
- boolean writeQueryData(ChannelHandlerContext context, BackendConnection backendConnection, QueryCommandExecutor queryCommandExecutor, int headerPackagesCount) throws SQLException;
+ boolean writeQueryData(ChannelHandlerContext context, JDBCConnectionSession connectionSession, QueryCommandExecutor queryCommandExecutor, int headerPackagesCount) throws SQLException;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-spi/src/main/java/org/apache/shardingsphere/proxy/frontend/spi/DatabaseProtocolFrontendEngine.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-spi/src/main/java/org/apache/shardingsphere/proxy/frontend/spi/DatabaseProtocolFrontendEngine.java
index 2831961..d3d95cd 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-spi/src/main/java/org/apache/shardingsphere/proxy/frontend/spi/DatabaseProtocolFrontendEngine.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-spi/src/main/java/org/apache/shardingsphere/proxy/frontend/spi/DatabaseProtocolFrontendEngine.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.frontend.spi;
import org.apache.shardingsphere.db.protocol.codec.DatabasePacketCodecEngine;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.context.FrontendContext;
import org.apache.shardingsphere.proxy.frontend.authentication.AuthenticationEngine;
import org.apache.shardingsphere.proxy.frontend.command.CommandExecuteEngine;
@@ -60,7 +60,7 @@ public interface DatabaseProtocolFrontendEngine extends DatabaseTypeAwareSPI {
/**
* Release resource.
*
- * @param backendConnection backend connection
+ * @param connectionSession connection session
*/
- void release(BackendConnection backendConnection);
+ void release(ConnectionSession connectionSession);
}