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 2022/06/09 11:19:32 UTC
[shardingsphere] branch master updated: Refactor RALBackendHandlerFactory (#18268)
This is an automated email from the ASF dual-hosted git repository.
zhaojinchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new c7c605db90f Refactor RALBackendHandlerFactory (#18268)
c7c605db90f is described below
commit c7c605db90f51024a431a05ef378b157d83d20b8
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu Jun 9 19:19:25 2022 +0800
Refactor RALBackendHandlerFactory (#18268)
---
.../proxy/backend/text/TextProtocolBackendHandlerFactory.java | 2 +-
.../proxy/backend/text/distsql/DistSQLBackendHandlerFactory.java | 8 +++-----
.../proxy/backend/text/distsql/ral/RALBackendHandlerFactory.java | 4 +---
.../backend/text/distsql/DistSQLBackendHandlerFactoryTest.java | 6 +++---
4 files changed, 8 insertions(+), 12 deletions(-)
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 4f97aa9a78b..143f0ccf2e5 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
@@ -99,7 +99,7 @@ public final class TextProtocolBackendHandlerFactory {
if (connectionSession.getTransactionStatus().isInTransaction() && !(sqlStatement instanceof RQLStatement || sqlStatement instanceof QueryableRALStatement)) {
throw new UnsupportedOperationException("Non-query dist sql is not supported within a transaction");
}
- return DistSQLBackendHandlerFactory.newInstance(databaseType, (DistSQLStatement) sqlStatement, connectionSession);
+ return DistSQLBackendHandlerFactory.newInstance((DistSQLStatement) sqlStatement, connectionSession);
}
handleAutoCommit(sqlStatement, connectionSession);
SQLStatementContext<?> sqlStatementContext = SQLStatementContextFactory.newInstance(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabases(),
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 4c25355bd95..3150afccfd7 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
@@ -27,7 +27,6 @@ import org.apache.shardingsphere.distsql.parser.statement.ral.scaling.QueryableS
import org.apache.shardingsphere.distsql.parser.statement.ral.scaling.UpdatableScalingRALStatement;
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.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.exception.DatabaseLockedException;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
@@ -47,13 +46,12 @@ public final class DistSQLBackendHandlerFactory {
/**
* Create new instance of DistSQL backend handler.
*
- * @param databaseType database type
* @param sqlStatement dist SQL statement
* @param connectionSession connection session
* @return text protocol backend handler
* @throws SQLException SQL exception
*/
- public static TextProtocolBackendHandler newInstance(final DatabaseType databaseType, final DistSQLStatement sqlStatement, final ConnectionSession connectionSession) throws SQLException {
+ public static TextProtocolBackendHandler newInstance(final DistSQLStatement sqlStatement, final ConnectionSession connectionSession) throws SQLException {
if (sqlStatement instanceof RQLStatement) {
return RQLBackendHandlerFactory.newInstance((RQLStatement) sqlStatement, connectionSession);
}
@@ -64,10 +62,10 @@ public final class DistSQLBackendHandlerFactory {
if (sqlStatement instanceof RALStatement) {
if (sqlStatement instanceof CommonDistSQLStatement || sqlStatement instanceof QueryableRALStatement || sqlStatement instanceof QueryableScalingRALStatement
|| sqlStatement instanceof UpdatableScalingRALStatement) {
- return RALBackendHandlerFactory.newInstance(databaseType, (RALStatement) sqlStatement, connectionSession);
+ return RALBackendHandlerFactory.newInstance((RALStatement) sqlStatement, connectionSession);
}
checkLockedDatabase(connectionSession);
- return RALBackendHandlerFactory.newInstance(databaseType, (RALStatement) sqlStatement, connectionSession);
+ return RALBackendHandlerFactory.newInstance((RALStatement) 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/RALBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandlerFactory.java
index 27e7e44a2b2..a9a107c67b5 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
@@ -51,7 +51,6 @@ import org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.S
import org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.UnlabelInstanceStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.scaling.QueryableScalingRALStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.scaling.UpdatableScalingRALStatement;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.RALBackendHandler.HandlerParameter;
@@ -150,13 +149,12 @@ public final class RALBackendHandlerFactory {
/**
* Create new instance of RAL backend handler.
*
- * @param databaseType database type
* @param sqlStatement RAL statement
* @param connectionSession connection session
* @return created instance
* @throws SQLException SQL exception
*/
- public static TextProtocolBackendHandler newInstance(final DatabaseType databaseType, final RALStatement sqlStatement, final ConnectionSession connectionSession) throws SQLException {
+ public static TextProtocolBackendHandler newInstance(final RALStatement sqlStatement, final ConnectionSession connectionSession) throws SQLException {
if (sqlStatement instanceof HintDistSQLStatement) {
return new HintDistSQLBackendHandler((HintDistSQLStatement) sqlStatement, connectionSession);
}
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 4fbf2e7de56..2bcb2ef6fdc 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
@@ -241,7 +241,7 @@ public final class DistSQLBackendHandlerFactoryTest extends ProxyContextRestorer
@Test
public void assertExecuteShowScalingCheckAlgorithmsContext() throws SQLException {
mockScalingContext();
- ResponseHeader response = RALBackendHandlerFactory.newInstance(new MySQLDatabaseType(), mock(ShowScalingCheckAlgorithmsStatement.class), connectionSession).execute();
+ ResponseHeader response = RALBackendHandlerFactory.newInstance(mock(ShowScalingCheckAlgorithmsStatement.class), connectionSession).execute();
assertThat(response, instanceOf(QueryResponseHeader.class));
}
@@ -250,7 +250,7 @@ public final class DistSQLBackendHandlerFactoryTest extends ProxyContextRestorer
@Test
public void assertExecuteStopScalingSourceWritingContext() throws SQLException {
mockScalingContext();
- ResponseHeader response = RALBackendHandlerFactory.newInstance(new MySQLDatabaseType(), mock(StopScalingSourceWritingStatement.class), connectionSession).execute();
+ ResponseHeader response = RALBackendHandlerFactory.newInstance(mock(StopScalingSourceWritingStatement.class), connectionSession).execute();
assertThat(response, instanceOf(UpdateResponseHeader.class));
}
@@ -258,7 +258,7 @@ public final class DistSQLBackendHandlerFactoryTest extends ProxyContextRestorer
@Test
public void assertExecuteCheckoutScalingContext() throws SQLException {
mockScalingContext();
- ResponseHeader response = RALBackendHandlerFactory.newInstance(new MySQLDatabaseType(), mock(ApplyScalingStatement.class), connectionSession).execute();
+ ResponseHeader response = RALBackendHandlerFactory.newInstance(mock(ApplyScalingStatement.class), connectionSession).execute();
assertThat(response, instanceOf(UpdateResponseHeader.class));
}