You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2022/06/09 09:28:00 UTC
[shardingsphere] branch master updated: Remove HandlerParameter.databaseType (#18262)
This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new bb03a529357 Remove HandlerParameter.databaseType (#18262)
bb03a529357 is described below
commit bb03a52935725cf323c7134004910aa788164eef
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu Jun 9 17:27:47 2022 +0800
Remove HandlerParameter.databaseType (#18262)
* Remove HandlerParameter.databaseType
* Remove HandlerParameter.databaseType
* Remove HandlerParameter.databaseType
* Remove HandlerParameter.databaseType
---
.../parser/segment/EncryptColumnSegment.java | 2 +-
.../text/distsql/ral/RALBackendHandler.java | 25 +++++++++-------------
.../text/distsql/ral/RALBackendHandlerFactory.java | 2 +-
.../ral/advanced/ParseDistSQLBackendHandler.java | 9 +++-----
.../advance/ParseDistSQLBackendHandlerTest.java | 5 ++---
.../common/queryable/CountInstanceRulesTest.java | 4 ++--
.../ExportDatabaseConfigurationHandlerTest.java | 7 +-----
.../queryable/ShowAuthorityRuleHandlerTest.java | 2 +-
.../queryable/ShowInstanceModeHandlerTest.java | 2 +-
.../queryable/ShowSQLParserRuleHandlerTest.java | 2 +-
.../queryable/ShowTableMetadataHandlerTest.java | 7 +-----
.../queryable/ShowTrafficRulesHandlerTest.java | 2 +-
.../queryable/ShowTransactionRuleHandlerTest.java | 2 +-
.../queryable/ShowVariableBackendHandlerTest.java | 18 ++++++----------
.../common/updatable/AlterInstanceHandlerTest.java | 6 +++---
.../updatable/AlterSQLParserRuleHandlerTest.java | 4 ++--
.../updatable/AlterTrafficRuleHandlerTest.java | 8 +++----
.../updatable/CreateTrafficRuleHandlerTest.java | 8 +++----
.../updatable/DropTrafficRuleHandlerTest.java | 12 +++++------
.../ImportDatabaseConfigurationHandlerTest.java | 3 +--
.../updatable/SetVariableBackendHandlerTest.java | 20 +++++++----------
.../common/updatable/SetVariableExecutorTest.java | 3 +--
22 files changed, 61 insertions(+), 92 deletions(-)
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-statement/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/segment/EncryptColumnSegment.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-statement/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/segment/EncryptColumnSegment.java
index 2aaeccdbe03..e1b8d380fdf 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-statement/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/segment/EncryptColumnSegment.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-statement/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/segment/EncryptColumnSegment.java
@@ -56,7 +56,7 @@ public final class EncryptColumnSegment implements ASTNode {
this(name, cipherColumn, plainColumn, assistedQueryColumn, encryptor, null);
}
- public EncryptColumnSegment(final String name, final String cipherColumn, final String plainColumn, final String assistedQueryColumn, final String dataType, final String cipherDataType,
+ public EncryptColumnSegment(final String name, final String cipherColumn, final String plainColumn, final String assistedQueryColumn, final String dataType, final String cipherDataType,
final String plainDataType, final String assistedQueryDataType, final AlgorithmSegment encryptor) {
this(name, cipherColumn, plainColumn, assistedQueryColumn, dataType, cipherDataType, plainDataType, assistedQueryDataType, encryptor, null);
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandler.java
index 8da45842f17..6034c074fcb 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandler.java
@@ -20,9 +20,7 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.ral;
import com.google.common.base.Preconditions;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import lombok.experimental.Accessors;
import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
@@ -39,15 +37,6 @@ public abstract class RALBackendHandler<E extends RALStatement, R extends RALBac
private E sqlStatement;
- @Override
- public final ResponseHeader execute() throws SQLException {
- Preconditions.checkArgument(null != sqlStatement, "sql statement cannot be empty.");
- ContextManager contextManager = ProxyContext.getInstance().getContextManager();
- return handle(contextManager, sqlStatement);
- }
-
- protected abstract ResponseHeader handle(ContextManager contextManager, E sqlStatement) throws SQLException;
-
/**
* Method to initialize handler, this method needs to be rewritten when the handler has properties other than sql statement.
*
@@ -59,15 +48,21 @@ public abstract class RALBackendHandler<E extends RALStatement, R extends RALBac
return (R) this;
}
- @Getter
- @Accessors(chain = true)
+ @Override
+ public final ResponseHeader execute() throws SQLException {
+ Preconditions.checkNotNull(sqlStatement, "sql statement cannot be empty.");
+ ContextManager contextManager = ProxyContext.getInstance().getContextManager();
+ return handle(contextManager, sqlStatement);
+ }
+
+ protected abstract ResponseHeader handle(ContextManager contextManager, E sqlStatement) throws SQLException;
+
@RequiredArgsConstructor
+ @Getter
public static class HandlerParameter<E extends RALStatement> {
private final E statement;
- private final DatabaseType databaseType;
-
private final ConnectionSession connectionSession;
}
}
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 e6547484a2b..27e7e44a2b2 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
@@ -166,7 +166,7 @@ public final class RALBackendHandlerFactory {
if (sqlStatement instanceof UpdatableScalingRALStatement) {
return new UpdatableScalingRALBackendHandler((UpdatableScalingRALStatement) sqlStatement);
}
- return getHandler(sqlStatement, new HandlerParameter(sqlStatement, databaseType, connectionSession));
+ return getHandler(sqlStatement, new HandlerParameter(sqlStatement, connectionSession));
}
private static RALBackendHandler newInstance(final Class<? extends RALBackendHandler> clazz) {
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 8023d5cbb78..0eb00f3f326 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
@@ -45,13 +45,10 @@ public final class ParseDistSQLBackendHandler extends QueryableRALBackendHandler
private static final String PARSED_STATEMENT_DETAIL = "parsed_statement_detail";
- private DatabaseType databaseType;
-
private ConnectionSession connectionSession;
@Override
public ParseDistSQLBackendHandler init(final HandlerParameter<ParseStatement> parameter) {
- databaseType = parameter.getDatabaseType();
connectionSession = parameter.getConnectionSession();
return super.init(parameter);
}
@@ -67,17 +64,17 @@ public final class ParseDistSQLBackendHandler extends QueryableRALBackendHandler
Preconditions.checkState(sqlParserRule.isPresent());
SQLStatement parsedSqlStatement;
try {
- parsedSqlStatement = sqlParserRule.get().getSQLParserEngine(getStorageType(databaseType, connectionSession).getType()).parse(getSqlStatement().getSql(), false);
+ parsedSqlStatement = sqlParserRule.get().getSQLParserEngine(getStorageType(connectionSession).getType()).parse(getSqlStatement().getSql(), false);
} catch (SQLParsingException ex) {
throw new SQLParsingException("You have a syntax error in your parsed statement");
}
return Collections.singleton(Arrays.asList(parsedSqlStatement.getClass().getSimpleName(), new Gson().toJson(parsedSqlStatement)));
}
- private static DatabaseType getStorageType(final DatabaseType defaultDatabaseType, final ConnectionSession connectionSession) {
+ private static DatabaseType getStorageType(final ConnectionSession connectionSession) {
String databaseName = connectionSession.getDatabaseName();
return Strings.isNullOrEmpty(databaseName) || !ProxyContext.getInstance().databaseExists(databaseName)
- ? defaultDatabaseType
+ ? connectionSession.getDatabaseType()
: ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabases().get(databaseName).getResource().getDatabaseType();
}
}
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 414fb19770f..8a81e22b22c 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
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.ral.advance;
import com.google.gson.Gson;
import org.apache.shardingsphere.distsql.parser.statement.ral.advanced.ParseStatement;
-import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
import org.apache.shardingsphere.parser.rule.builder.DefaultSQLParserRuleConfigurationBuilder;
@@ -64,7 +63,7 @@ public final class ParseDistSQLBackendHandlerTest extends ProxyContextRestorer {
public void assertGetRowData() throws SQLException {
String sql = "select * from t_order";
ParseStatement parseStatement = new ParseStatement(sql);
- ParseDistSQLBackendHandler parseDistSQLBackendHandler = new ParseDistSQLBackendHandler().init(new HandlerParameter<>(parseStatement, new MySQLDatabaseType(), mock(ConnectionSession.class)));
+ ParseDistSQLBackendHandler parseDistSQLBackendHandler = new ParseDistSQLBackendHandler().init(new HandlerParameter<>(parseStatement, mock(ConnectionSession.class)));
parseDistSQLBackendHandler.execute();
parseDistSQLBackendHandler.next();
SQLStatement statement = sqlParserRule.getSQLParserEngine("MySQL").parse(sql, false);
@@ -76,7 +75,7 @@ public final class ParseDistSQLBackendHandlerTest extends ProxyContextRestorer {
public void assertExecute() throws SQLException {
String sql = "wrong sql";
ParseStatement parseStatement = new ParseStatement(sql);
- ParseDistSQLBackendHandler parseDistSQLBackendHandler = new ParseDistSQLBackendHandler().init(new HandlerParameter<>(parseStatement, new MySQLDatabaseType(), mock(ConnectionSession.class)));
+ ParseDistSQLBackendHandler parseDistSQLBackendHandler = new ParseDistSQLBackendHandler().init(new HandlerParameter<>(parseStatement, mock(ConnectionSession.class)));
parseDistSQLBackendHandler.execute();
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/CountInstanceRulesTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/CountInstanceRulesTest.java
index 6e025a0fb1b..8e70cbeae60 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/CountInstanceRulesTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/CountInstanceRulesTest.java
@@ -119,7 +119,7 @@ public final class CountInstanceRulesTest extends ProxyContextRestorer {
@Test
public void assertGetRowData() throws SQLException {
- CountInstanceRulesHandler handler = new CountInstanceRulesHandler().init(new RALBackendHandler.HandlerParameter<>(new CountInstanceRulesStatement(), null, null));
+ CountInstanceRulesHandler handler = new CountInstanceRulesHandler().init(new RALBackendHandler.HandlerParameter<>(new CountInstanceRulesStatement(), null));
handler.execute();
handler.next();
Collection<Object> actual = handler.getRowData();
@@ -166,7 +166,7 @@ public final class CountInstanceRulesTest extends ProxyContextRestorer {
@Test
public void assertGetRowDataWithoutConfiguration() throws SQLException {
- CountInstanceRulesHandler handler = new CountInstanceRulesHandler().init(new RALBackendHandler.HandlerParameter<>(new CountInstanceRulesStatement(), null, null));
+ CountInstanceRulesHandler handler = new CountInstanceRulesHandler().init(new RALBackendHandler.HandlerParameter<>(new CountInstanceRulesStatement(), null));
when(database1.getRuleMetaData().getConfigurations()).thenReturn(Collections.emptyList());
when(database2.getRuleMetaData().getConfigurations()).thenReturn(Collections.emptyList());
handler.execute();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ExportDatabaseConfigurationHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ExportDatabaseConfigurationHandlerTest.java
index 792bd87e4b8..032e60e9dc9 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ExportDatabaseConfigurationHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ExportDatabaseConfigurationHandlerTest.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.queryabl
import com.zaxxer.hikari.HikariDataSource;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.queryable.ExportDatabaseConfigurationStatement;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
-import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereColumn;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereIndex;
@@ -71,7 +70,7 @@ public final class ExportDatabaseConfigurationHandlerTest extends ProxyContextRe
@Test
public void assertExportDatabaseExecutor() throws SQLException {
- ExportDatabaseConfigurationHandler handler = new ExportDatabaseConfigurationHandler().init(createParameter(createSQLStatement(), mock(ConnectionSession.class)));
+ ExportDatabaseConfigurationHandler handler = new ExportDatabaseConfigurationHandler().init(new HandlerParameter<>(createSQLStatement(), mock(ConnectionSession.class)));
handler.execute();
handler.next();
Collection<Object> data = new ArrayList<>(handler.getRowData());
@@ -132,8 +131,4 @@ public final class ExportDatabaseConfigurationHandlerTest extends ProxyContextRe
private ExportDatabaseConfigurationStatement createSQLStatement() {
return new ExportDatabaseConfigurationStatement(new DatabaseSegment(0, 0, new IdentifierValue("sharding_db")), null);
}
-
- private HandlerParameter<ExportDatabaseConfigurationStatement> createParameter(final ExportDatabaseConfigurationStatement statement, final ConnectionSession connectionSession) {
- return new HandlerParameter<>(statement, new MySQLDatabaseType(), connectionSession);
- }
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowAuthorityRuleHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowAuthorityRuleHandlerTest.java
index aba69fca459..e6223e42b29 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowAuthorityRuleHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowAuthorityRuleHandlerTest.java
@@ -42,7 +42,7 @@ import static org.mockito.Mockito.when;
public final class ShowAuthorityRuleHandlerTest extends ProxyContextRestorer {
- private final ShowAuthorityRuleHandler handler = new ShowAuthorityRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new ShowAuthorityRuleStatement(), null, null));
+ private final ShowAuthorityRuleHandler handler = new ShowAuthorityRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new ShowAuthorityRuleStatement(), null));
@Test
public void assertAuthorityRule() throws SQLException {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandlerTest.java
index fcf57c737bc..4dd9b60042d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandlerTest.java
@@ -45,7 +45,7 @@ public final class ShowInstanceModeHandlerTest extends ProxyContextRestorer {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
InstanceContext instanceContext = createInstanceContext();
when(contextManager.getInstanceContext()).thenReturn(instanceContext);
- ShowInstanceModeHandler handler = new ShowInstanceModeHandler().init(new RALBackendHandler.HandlerParameter<>(new ShowInstanceModeStatement(), null, null));
+ ShowInstanceModeHandler handler = new ShowInstanceModeHandler().init(new RALBackendHandler.HandlerParameter<>(new ShowInstanceModeStatement(), null));
ProxyContext.init(contextManager);
handler.execute();
handler.next();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowSQLParserRuleHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowSQLParserRuleHandlerTest.java
index 84e342f5e4a..b6acb615e31 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowSQLParserRuleHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowSQLParserRuleHandlerTest.java
@@ -46,7 +46,7 @@ public final class ShowSQLParserRuleHandlerTest extends ProxyContextRestorer {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(getGlobalRuleMetaData());
ProxyContext.init(contextManager);
- ShowSQLParserRuleHandler handler = new ShowSQLParserRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new ShowSQLParserRuleStatement(), null, null));
+ ShowSQLParserRuleHandler handler = new ShowSQLParserRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new ShowSQLParserRuleStatement(), null));
handler.execute();
handler.next();
List<Object> data = new ArrayList<>(handler.getRowData());
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTableMetadataHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTableMetadataHandlerTest.java
index ec2737d06b0..4816a22ddac 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTableMetadataHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTableMetadataHandlerTest.java
@@ -18,7 +18,6 @@
package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.queryable;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.queryable.ShowTableMetadataStatement;
-import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereColumn;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereIndex;
@@ -58,7 +57,7 @@ public final class ShowTableMetadataHandlerTest extends ProxyContextRestorer {
ProxyContext.init(contextManager);
ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
when(connectionSession.getDatabaseName()).thenReturn("db_name");
- ShowTableMetadataHandler handler = new ShowTableMetadataHandler().init(getParameter(createSqlStatement(), connectionSession));
+ ShowTableMetadataHandler handler = new ShowTableMetadataHandler().init(new HandlerParameter<>(createSqlStatement(), connectionSession));
handler.execute();
handler.next();
List<Object> data = new ArrayList<>(handler.getRowData());
@@ -87,8 +86,4 @@ public final class ShowTableMetadataHandlerTest extends ProxyContextRestorer {
private ShowTableMetadataStatement createSqlStatement() {
return new ShowTableMetadataStatement(Collections.singleton("t_order"), new DatabaseSegment(0, 0, new IdentifierValue("db_name")));
}
-
- private HandlerParameter<ShowTableMetadataStatement> getParameter(final ShowTableMetadataStatement statement, final ConnectionSession connectionSession) {
- return new HandlerParameter<>(statement, new MySQLDatabaseType(), connectionSession);
- }
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTrafficRulesHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTrafficRulesHandlerTest.java
index d807757d6e6..7a44c5a5a61 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTrafficRulesHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTrafficRulesHandlerTest.java
@@ -49,7 +49,7 @@ public class ShowTrafficRulesHandlerTest extends ProxyContextRestorer {
public void assertExecutor() throws SQLException {
ShowTrafficRulesStatement showTrafficRuleStatement = new ShowTrafficRulesStatement();
showTrafficRuleStatement.setRuleName("rule_name_1");
- ShowTrafficRulesHandler handler = new ShowTrafficRulesHandler().init(new RALBackendHandler.HandlerParameter<>(showTrafficRuleStatement, null, null));
+ ShowTrafficRulesHandler handler = new ShowTrafficRulesHandler().init(new RALBackendHandler.HandlerParameter<>(showTrafficRuleStatement, null));
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findRuleConfigurations(any())).thenReturn(createTrafficRule());
ProxyContext.init(contextManager);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTransactionRuleHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTransactionRuleHandlerTest.java
index 01aa2e9d34a..499d0d3a8e2 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTransactionRuleHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTransactionRuleHandlerTest.java
@@ -41,7 +41,7 @@ import static org.mockito.Mockito.when;
public final class ShowTransactionRuleHandlerTest extends ProxyContextRestorer {
- private final ShowTransactionRuleHandler handler = new ShowTransactionRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new ShowTransactionRuleStatement(), null, null));
+ private final ShowTransactionRuleHandler handler = new ShowTransactionRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new ShowTransactionRuleStatement(), null));
@Test
public void assertExecutorWithXA() throws SQLException {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowVariableBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowVariableBackendHandlerTest.java
index 27c61782d0f..36adca234e7 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowVariableBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowVariableBackendHandlerTest.java
@@ -63,8 +63,7 @@ public final class ShowVariableBackendHandlerTest extends ProxyContextRestorer {
@Test
public void assertShowTransactionType() throws SQLException {
connectionSession.setCurrentDatabase("db");
- ShowVariableHandler backendHandler = new ShowVariableHandler()
- .init(new HandlerParameter<>(new ShowVariableStatement("transaction_type"), new MySQLDatabaseType(), connectionSession));
+ ShowVariableHandler backendHandler = new ShowVariableHandler().init(new HandlerParameter<>(new ShowVariableStatement("transaction_type"), connectionSession));
ResponseHeader actual = backendHandler.execute();
assertThat(actual, instanceOf(QueryResponseHeader.class));
assertThat(((QueryResponseHeader) actual).getQueryHeaders().size(), is(2));
@@ -77,8 +76,7 @@ public final class ShowVariableBackendHandlerTest extends ProxyContextRestorer {
@Test
public void assertShowCachedConnections() throws SQLException {
connectionSession.setCurrentDatabase("db");
- ShowVariableHandler backendHandler = new ShowVariableHandler()
- .init(new HandlerParameter<>(new ShowVariableStatement("cached_connections"), new MySQLDatabaseType(), connectionSession));
+ ShowVariableHandler backendHandler = new ShowVariableHandler().init(new HandlerParameter<>(new ShowVariableStatement("cached_connections"), connectionSession));
ResponseHeader actual = backendHandler.execute();
assertThat(actual, instanceOf(QueryResponseHeader.class));
assertThat(((QueryResponseHeader) actual).getQueryHeaders().size(), is(2));
@@ -91,8 +89,7 @@ public final class ShowVariableBackendHandlerTest extends ProxyContextRestorer {
@Test(expected = UnsupportedVariableException.class)
public void assertShowCachedConnectionFailed() throws SQLException {
connectionSession.setCurrentDatabase("db");
- ShowVariableHandler backendHandler = new ShowVariableHandler()
- .init(new HandlerParameter<>(new ShowVariableStatement("cached_connectionss"), new MySQLDatabaseType(), connectionSession));
+ ShowVariableHandler backendHandler = new ShowVariableHandler().init(new HandlerParameter<>(new ShowVariableStatement("cached_connectionss"), connectionSession));
backendHandler.execute();
}
@@ -100,8 +97,7 @@ public final class ShowVariableBackendHandlerTest extends ProxyContextRestorer {
public void assertShowAgentPluginsEnabled() throws SQLException {
SystemPropertyUtil.setSystemProperty(VariableEnum.AGENT_PLUGINS_ENABLED.name(), Boolean.TRUE.toString());
connectionSession.setCurrentDatabase("db");
- ShowVariableHandler backendHandler = new ShowVariableHandler()
- .init(new HandlerParameter<>(new ShowVariableStatement(VariableEnum.AGENT_PLUGINS_ENABLED.name()), new MySQLDatabaseType(), connectionSession));
+ ShowVariableHandler backendHandler = new ShowVariableHandler().init(new HandlerParameter<>(new ShowVariableStatement(VariableEnum.AGENT_PLUGINS_ENABLED.name()), connectionSession));
ResponseHeader actual = backendHandler.execute();
assertThat(actual, instanceOf(QueryResponseHeader.class));
assertThat(((QueryResponseHeader) actual).getQueryHeaders().size(), is(2));
@@ -121,8 +117,7 @@ public final class ShowVariableBackendHandlerTest extends ProxyContextRestorer {
Properties props = new Properties();
props.put("sql-show", Boolean.TRUE.toString());
when(metaDataContexts.getMetaData().getProps()).thenReturn(new ConfigurationProperties(props));
- ShowVariableHandler backendHandler = new ShowVariableHandler()
- .init(new HandlerParameter<>(new ShowVariableStatement("SQL_SHOW"), new MySQLDatabaseType(), connectionSession));
+ ShowVariableHandler backendHandler = new ShowVariableHandler().init(new HandlerParameter<>(new ShowVariableStatement("SQL_SHOW"), connectionSession));
ResponseHeader actual = backendHandler.execute();
assertThat(actual, instanceOf(QueryResponseHeader.class));
assertThat(((QueryResponseHeader) actual).getQueryHeaders().size(), is(2));
@@ -140,8 +135,7 @@ public final class ShowVariableBackendHandlerTest extends ProxyContextRestorer {
MetaDataContexts metaDataContexts = mock(MetaDataContexts.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
when(metaDataContexts.getMetaData().getProps()).thenReturn(new ConfigurationProperties(new Properties()));
- ShowVariableHandler backendHandler = new ShowVariableHandler()
- .init(new HandlerParameter<>(new ShowVariableStatement(), new MySQLDatabaseType(), connectionSession));
+ ShowVariableHandler backendHandler = new ShowVariableHandler().init(new HandlerParameter<>(new ShowVariableStatement(), 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/common/updatable/AlterInstanceHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterInstanceHandlerTest.java
index 06721e13850..8baf2bd31b7 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterInstanceHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterInstanceHandlerTest.java
@@ -40,7 +40,7 @@ public final class AlterInstanceHandlerTest extends ProxyContextRestorer {
String instanceId = "instance_id";
String key = "key_1";
String value = "value_1";
- new AlterInstanceHandler().init(new RALBackendHandler.HandlerParameter<>(getSQLStatement(instanceId, key, value), null, null)).execute();
+ new AlterInstanceHandler().init(new RALBackendHandler.HandlerParameter<>(getSQLStatement(instanceId, key, value), null)).execute();
}
@Test(expected = UnsupportedOperationException.class)
@@ -51,7 +51,7 @@ public final class AlterInstanceHandlerTest extends ProxyContextRestorer {
String instanceId = "instance_id";
String key = "xa_recovery_nodes";
String value = "value_1";
- new AlterInstanceHandler().init(new RALBackendHandler.HandlerParameter<>(getSQLStatement(instanceId, key, value), null, null)).execute();
+ new AlterInstanceHandler().init(new RALBackendHandler.HandlerParameter<>(getSQLStatement(instanceId, key, value), null)).execute();
}
@Test(expected = UnsupportedOperationException.class)
@@ -63,7 +63,7 @@ public final class AlterInstanceHandlerTest extends ProxyContextRestorer {
String instanceId = "instance_id";
String key = "xa_recovery_nodes";
String value = "value_1";
- new AlterInstanceHandler().init(new RALBackendHandler.HandlerParameter<>(getSQLStatement(instanceId, key, value), null, null)).execute();
+ new AlterInstanceHandler().init(new RALBackendHandler.HandlerParameter<>(getSQLStatement(instanceId, key, value), null)).execute();
}
private AlterInstanceStatement getSQLStatement(final String instanceId, final String key, final String value) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterSQLParserRuleHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterSQLParserRuleHandlerTest.java
index 003b186427f..2cd8e17d693 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterSQLParserRuleHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterSQLParserRuleHandlerTest.java
@@ -48,7 +48,7 @@ public final class AlterSQLParserRuleHandlerTest extends ProxyContextRestorer {
when(contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findRuleConfigurations(SQLParserRuleConfiguration.class)).thenReturn(Collections.emptyList());
when(contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getConfigurations()).thenReturn(new LinkedList<>());
ProxyContext.init(contextManager);
- new AlterSQLParserRuleHandler().init(new RALBackendHandler.HandlerParameter<>(createSQLStatement(), null, null)).execute();
+ new AlterSQLParserRuleHandler().init(new RALBackendHandler.HandlerParameter<>(createSQLStatement(), null)).execute();
SQLParserRuleConfiguration actual = (SQLParserRuleConfiguration) contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getConfigurations().iterator().next();
assertTrue(actual.isSqlCommentParseEnabled());
assertThat(actual.getSqlStatementCache().getInitialCapacity(), is(1000));
@@ -66,7 +66,7 @@ public final class AlterSQLParserRuleHandlerTest extends ProxyContextRestorer {
.getMetaData().getGlobalRuleMetaData().findRuleConfigurations(SQLParserRuleConfiguration.class)).thenReturn(Collections.singleton(sqlParserRuleConfig));
when(contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getConfigurations()).thenReturn(globalRuleConfigs);
ProxyContext.init(contextManager);
- new AlterSQLParserRuleHandler().init(new RALBackendHandler.HandlerParameter<>(createSQLStatement(), null, null)).execute();
+ new AlterSQLParserRuleHandler().init(new RALBackendHandler.HandlerParameter<>(createSQLStatement(), null)).execute();
SQLParserRuleConfiguration actual = (SQLParserRuleConfiguration) contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getConfigurations().iterator().next();
assertTrue(actual.isSqlCommentParseEnabled());
assertThat(actual.getSqlStatementCache().getInitialCapacity(), is(1000));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandlerTest.java
index dab602959d8..d86458cb46a 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandlerTest.java
@@ -53,7 +53,7 @@ public final class AlterTrafficRuleHandlerTest extends ProxyContextRestorer {
ProxyContext.init(contextManager);
TrafficRuleSegment trafficRuleSegment = new TrafficRuleSegment("input_rule_name", Arrays.asList("olap", "order_by"),
new AlgorithmSegment("invalid", new Properties()), new AlgorithmSegment("invalid", new Properties()));
- new AlterTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(getSQLStatement(trafficRuleSegment), null, null)).execute();
+ new AlterTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(getSQLStatement(trafficRuleSegment), null)).execute();
}
@Test(expected = InvalidAlgorithmConfigurationException.class)
@@ -63,7 +63,7 @@ public final class AlterTrafficRuleHandlerTest extends ProxyContextRestorer {
ProxyContext.init(contextManager);
TrafficRuleSegment trafficRuleSegment = new TrafficRuleSegment("rule_name_1", Arrays.asList("olap", "order_by"),
new AlgorithmSegment("invalid", new Properties()), new AlgorithmSegment("invalid", new Properties()));
- new AlterTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(getSQLStatement(trafficRuleSegment), null, null)).execute();
+ new AlterTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(getSQLStatement(trafficRuleSegment), null)).execute();
}
@Test(expected = RequiredRuleMissedException.class)
@@ -73,7 +73,7 @@ public final class AlterTrafficRuleHandlerTest extends ProxyContextRestorer {
ProxyContext.init(contextManager);
TrafficRuleSegment trafficRuleSegment = new TrafficRuleSegment("rule_name_3", Arrays.asList("olap", "order_by"),
new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()), new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()));
- new AlterTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(getSQLStatement(trafficRuleSegment), null, null)).execute();
+ new AlterTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(getSQLStatement(trafficRuleSegment), null)).execute();
}
@Test
@@ -85,7 +85,7 @@ public final class AlterTrafficRuleHandlerTest extends ProxyContextRestorer {
new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()), new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()));
TrafficRuleSegment trafficRuleSegment2 = new TrafficRuleSegment("rule_name_2", Collections.emptyList(),
new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()), null);
- new AlterTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(getSQLStatement(trafficRuleSegment1, trafficRuleSegment2), null, null)).execute();
+ new AlterTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(getSQLStatement(trafficRuleSegment1, trafficRuleSegment2), null)).execute();
}
private Collection<RuleConfiguration> createTrafficRule() {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandlerTest.java
index baccc2a56d1..bdd0f9d6608 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandlerTest.java
@@ -51,7 +51,7 @@ public final class CreateTrafficRuleHandlerTest extends ProxyContextRestorer {
ProxyContext.init(contextManager);
TrafficRuleSegment trafficRuleSegment = new TrafficRuleSegment("input_rule_name", Arrays.asList("olap", "order_by"),
new AlgorithmSegment("invalid", new Properties()), new AlgorithmSegment("invalid", new Properties()));
- new CreateTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new CreateTrafficRuleStatement(Collections.singletonList(trafficRuleSegment)), null, null)).execute();
+ new CreateTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new CreateTrafficRuleStatement(Collections.singletonList(trafficRuleSegment)), null)).execute();
}
@Test(expected = InvalidAlgorithmConfigurationException.class)
@@ -61,7 +61,7 @@ public final class CreateTrafficRuleHandlerTest extends ProxyContextRestorer {
ProxyContext.init(contextManager);
TrafficRuleSegment trafficRuleSegment = new TrafficRuleSegment("input_rule_name", Arrays.asList("olap", "order_by"),
new AlgorithmSegment("invalid", new Properties()), new AlgorithmSegment("invalid", new Properties()));
- new CreateTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new CreateTrafficRuleStatement(Collections.singletonList(trafficRuleSegment)), null, null)).execute();
+ new CreateTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new CreateTrafficRuleStatement(Collections.singletonList(trafficRuleSegment)), null)).execute();
}
@Test(expected = DuplicateRuleException.class)
@@ -71,7 +71,7 @@ public final class CreateTrafficRuleHandlerTest extends ProxyContextRestorer {
ProxyContext.init(contextManager);
TrafficRuleSegment trafficRuleSegment = new TrafficRuleSegment("rule_name_1", Arrays.asList("olap", "order_by"),
new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()), new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()));
- new CreateTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new CreateTrafficRuleStatement(Collections.singletonList(trafficRuleSegment)), null, null)).execute();
+ new CreateTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new CreateTrafficRuleStatement(Collections.singletonList(trafficRuleSegment)), null)).execute();
}
@Test
@@ -83,7 +83,7 @@ public final class CreateTrafficRuleHandlerTest extends ProxyContextRestorer {
new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()), new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()));
TrafficRuleSegment trafficRuleSegment2 = new TrafficRuleSegment("rule_name_4", Collections.emptyList(),
new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()), null);
- new CreateTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new CreateTrafficRuleStatement(Arrays.asList(trafficRuleSegment1, trafficRuleSegment2)), null, null)).execute();
+ new CreateTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new CreateTrafficRuleStatement(Arrays.asList(trafficRuleSegment1, trafficRuleSegment2)), null)).execute();
}
private RuleConfiguration createTrafficRuleConfiguration() {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/DropTrafficRuleHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/DropTrafficRuleHandlerTest.java
index e6a604b402b..d30e70d61fa 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/DropTrafficRuleHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/DropTrafficRuleHandlerTest.java
@@ -53,7 +53,7 @@ public final class DropTrafficRuleHandlerTest extends ProxyContextRestorer {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findRuleConfigurations(any())).thenReturn(new LinkedList<>());
ProxyContext.init(contextManager);
- new DropTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new DropTrafficRuleStatement(Collections.singletonList("rule_name"), false), null, null)).execute();
+ new DropTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new DropTrafficRuleStatement(Collections.singletonList("rule_name"), false), null)).execute();
}
@Test
@@ -61,7 +61,7 @@ public final class DropTrafficRuleHandlerTest extends ProxyContextRestorer {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findRuleConfigurations(any())).thenReturn(new LinkedList<>());
ProxyContext.init(contextManager);
- new DropTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new DropTrafficRuleStatement(Collections.singletonList("rule_name"), true), null, null)).execute();
+ new DropTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new DropTrafficRuleStatement(Collections.singletonList("rule_name"), true), null)).execute();
}
@Test(expected = RequiredRuleMissedException.class)
@@ -69,7 +69,7 @@ public final class DropTrafficRuleHandlerTest extends ProxyContextRestorer {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findRuleConfigurations(any())).thenReturn(Collections.singleton(createTrafficRuleConfiguration()));
ProxyContext.init(contextManager);
- new DropTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new DropTrafficRuleStatement(Collections.singletonList("rule_name"), false), null, null)).execute();
+ new DropTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new DropTrafficRuleStatement(Collections.singletonList("rule_name"), false), null)).execute();
}
@Test
@@ -77,7 +77,7 @@ public final class DropTrafficRuleHandlerTest extends ProxyContextRestorer {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRuleConfiguration(any())).thenReturn(Optional.of(createTrafficRuleConfiguration()));
ProxyContext.init(contextManager);
- new DropTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new DropTrafficRuleStatement(Collections.singletonList("rule_name_1"), false), null, null)).execute();
+ new DropTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new DropTrafficRuleStatement(Collections.singletonList("rule_name_1"), false), null)).execute();
Optional<TrafficRuleConfiguration> ruleConfig = contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRuleConfiguration(TrafficRuleConfiguration.class);
assertTrue(ruleConfig.isPresent());
assertThat(ruleConfig.get().getTrafficStrategies().size(), is(1));
@@ -93,7 +93,7 @@ public final class DropTrafficRuleHandlerTest extends ProxyContextRestorer {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRuleConfiguration(any())).thenReturn(Optional.of(createTrafficRuleConfiguration()));
ProxyContext.init(contextManager);
- new DropTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new DropTrafficRuleStatement(Collections.singletonList("rule_name_1"), false), null, null)).execute();
+ new DropTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new DropTrafficRuleStatement(Collections.singletonList("rule_name_1"), false), null)).execute();
Optional<TrafficRuleConfiguration> ruleConfig = contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRuleConfiguration(TrafficRuleConfiguration.class);
assertTrue(ruleConfig.isPresent());
assertThat(ruleConfig.get().getTrafficStrategies().size(), is(1));
@@ -109,7 +109,7 @@ public final class DropTrafficRuleHandlerTest extends ProxyContextRestorer {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRuleConfiguration(any())).thenReturn(Optional.of(createTrafficRuleConfiguration()));
ProxyContext.init(contextManager);
- new DropTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new DropTrafficRuleStatement(Collections.singletonList("rule_name_3"), true), null, null)).execute();
+ new DropTrafficRuleHandler().init(new RALBackendHandler.HandlerParameter<>(new DropTrafficRuleStatement(Collections.singletonList("rule_name_3"), true), null)).execute();
Optional<TrafficRuleConfiguration> ruleConfig = contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRuleConfiguration(TrafficRuleConfiguration.class);
assertTrue(ruleConfig.isPresent());
assertThat(ruleConfig.get().getTrafficStrategies().size(), is(2));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/ImportDatabaseConfigurationHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/ImportDatabaseConfigurationHandlerTest.java
index 7fed3ee78fd..015cd45cc3c 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/ImportDatabaseConfigurationHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/ImportDatabaseConfigurationHandlerTest.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.updatabl
import org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.ImportDatabaseConfigurationStatement;
import org.apache.shardingsphere.infra.database.DefaultDatabase;
-import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.datasource.props.DataSourcePropertiesValidator;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereColumn;
@@ -158,6 +157,6 @@ public final class ImportDatabaseConfigurationHandlerTest extends ProxyContextRe
private RALBackendHandler.HandlerParameter<ImportDatabaseConfigurationStatement> getParameter(final String importFilePath, final ConnectionSession connectionSession) {
ImportDatabaseConfigurationStatement statement = new ImportDatabaseConfigurationStatement(
Objects.requireNonNull(ImportDatabaseConfigurationHandlerTest.class.getResource(importFilePath)).getPath());
- return new RALBackendHandler.HandlerParameter<>(statement, new MySQLDatabaseType(), connectionSession);
+ return new RALBackendHandler.HandlerParameter<>(statement, connectionSession);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetVariableBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetVariableBackendHandlerTest.java
index f85be58284e..cde1a405b30 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetVariableBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetVariableBackendHandlerTest.java
@@ -95,7 +95,7 @@ public final class SetVariableBackendHandlerTest extends ProxyContextRestorer {
@Test
public void assertSwitchTransactionTypeXA() throws SQLException {
connectionSession.setCurrentDatabase(String.format(DATABASE_PATTERN, 0));
- ResponseHeader actual = new SetVariableHandler().init(getParameter(new SetVariableStatement("transaction_type", "XA"), connectionSession)).execute();
+ ResponseHeader actual = new SetVariableHandler().init(new HandlerParameter<>(new SetVariableStatement("transaction_type", "XA"), connectionSession)).execute();
assertThat(actual, instanceOf(UpdateResponseHeader.class));
assertThat(connectionSession.getTransactionStatus().getTransactionType(), is(TransactionType.XA));
}
@@ -103,7 +103,7 @@ public final class SetVariableBackendHandlerTest extends ProxyContextRestorer {
@Test
public void assertSwitchTransactionTypeBASE() throws SQLException {
connectionSession.setCurrentDatabase(String.format(DATABASE_PATTERN, 0));
- ResponseHeader actual = new SetVariableHandler().init(getParameter(new SetVariableStatement("transaction_type", "BASE"), connectionSession)).execute();
+ ResponseHeader actual = new SetVariableHandler().init(new HandlerParameter<>(new SetVariableStatement("transaction_type", "BASE"), connectionSession)).execute();
assertThat(actual, instanceOf(UpdateResponseHeader.class));
assertThat(connectionSession.getTransactionStatus().getTransactionType(), is(TransactionType.BASE));
}
@@ -111,7 +111,7 @@ public final class SetVariableBackendHandlerTest extends ProxyContextRestorer {
@Test
public void assertSwitchTransactionTypeLOCAL() throws SQLException {
connectionSession.setCurrentDatabase(String.format(DATABASE_PATTERN, 0));
- ResponseHeader actual = new SetVariableHandler().init(getParameter(new SetVariableStatement("transaction_type", "LOCAL"), connectionSession)).execute();
+ ResponseHeader actual = new SetVariableHandler().init(new HandlerParameter<>(new SetVariableStatement("transaction_type", "LOCAL"), connectionSession)).execute();
assertThat(actual, instanceOf(UpdateResponseHeader.class));
assertThat(connectionSession.getTransactionStatus().getTransactionType(), is(TransactionType.LOCAL));
}
@@ -119,18 +119,18 @@ public final class SetVariableBackendHandlerTest extends ProxyContextRestorer {
@Test(expected = UnsupportedVariableException.class)
public void assertSwitchTransactionTypeFailed() throws SQLException {
connectionSession.setCurrentDatabase(String.format(DATABASE_PATTERN, 0));
- new SetVariableHandler().init(getParameter(new SetVariableStatement("transaction_type", "XXX"), connectionSession)).execute();
+ new SetVariableHandler().init(new HandlerParameter<>(new SetVariableStatement("transaction_type", "XXX"), connectionSession)).execute();
}
@Test(expected = UnsupportedVariableException.class)
public void assertNotSupportedVariable() throws SQLException {
- new SetVariableHandler().init(getParameter(new SetVariableStatement("@@session", "XXX"), connectionSession)).execute();
+ new SetVariableHandler().init(new HandlerParameter<>(new SetVariableStatement("@@session", "XXX"), connectionSession)).execute();
}
@Test
public void assertSetAgentPluginsEnabledTrue() throws SQLException {
connectionSession.setCurrentDatabase(String.format(DATABASE_PATTERN, 0));
- ResponseHeader actual = new SetVariableHandler().init(getParameter(new SetVariableStatement(VariableEnum.AGENT_PLUGINS_ENABLED.name(), Boolean.TRUE.toString()), null)).execute();
+ ResponseHeader actual = new SetVariableHandler().init(new HandlerParameter<>(new SetVariableStatement(VariableEnum.AGENT_PLUGINS_ENABLED.name(), Boolean.TRUE.toString()), null)).execute();
assertThat(actual, instanceOf(UpdateResponseHeader.class));
assertThat(SystemPropertyUtil.getSystemProperty(VariableEnum.AGENT_PLUGINS_ENABLED.name(), Boolean.FALSE.toString()), is(Boolean.TRUE.toString()));
}
@@ -138,7 +138,7 @@ public final class SetVariableBackendHandlerTest extends ProxyContextRestorer {
@Test
public void assertSetAgentPluginsEnabledFalse() throws SQLException {
connectionSession.setCurrentDatabase(String.format(DATABASE_PATTERN, 0));
- ResponseHeader actual = new SetVariableHandler().init(getParameter(new SetVariableStatement(VariableEnum.AGENT_PLUGINS_ENABLED.name(), Boolean.FALSE.toString()), null)).execute();
+ ResponseHeader actual = new SetVariableHandler().init(new HandlerParameter<>(new SetVariableStatement(VariableEnum.AGENT_PLUGINS_ENABLED.name(), Boolean.FALSE.toString()), null)).execute();
assertThat(actual, instanceOf(UpdateResponseHeader.class));
assertThat(SystemPropertyUtil.getSystemProperty(VariableEnum.AGENT_PLUGINS_ENABLED.name(), Boolean.FALSE.toString()), is(Boolean.FALSE.toString()));
}
@@ -146,12 +146,8 @@ public final class SetVariableBackendHandlerTest extends ProxyContextRestorer {
@Test
public void assertSetAgentPluginsEnabledFalseWithUnknownValue() throws SQLException {
connectionSession.setCurrentDatabase(String.format(DATABASE_PATTERN, 0));
- ResponseHeader actual = new SetVariableHandler().init(getParameter(new SetVariableStatement(VariableEnum.AGENT_PLUGINS_ENABLED.name(), "xxx"), connectionSession)).execute();
+ ResponseHeader actual = new SetVariableHandler().init(new HandlerParameter<>(new SetVariableStatement(VariableEnum.AGENT_PLUGINS_ENABLED.name(), "xxx"), connectionSession)).execute();
assertThat(actual, instanceOf(UpdateResponseHeader.class));
assertThat(SystemPropertyUtil.getSystemProperty(VariableEnum.AGENT_PLUGINS_ENABLED.name(), Boolean.FALSE.toString()), is(Boolean.FALSE.toString()));
}
-
- private HandlerParameter<SetVariableStatement> getParameter(final SetVariableStatement statement, final ConnectionSession connectionSession) {
- return new HandlerParameter<>(statement, new MySQLDatabaseType(), connectionSession);
- }
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetVariableExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetVariableExecutorTest.java
index 3c2d0653e5e..0151206b52a 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetVariableExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetVariableExecutorTest.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.updatabl
import org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.SetVariableStatement;
import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
-import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -75,6 +74,6 @@ public final class SetVariableExecutorTest extends ProxyContextRestorer {
}
private HandlerParameter<SetVariableStatement> getParameter(final SetVariableStatement statement, final ConnectionSession connectionSession) {
- return new HandlerParameter<>(statement, new MySQLDatabaseType(), connectionSession);
+ return new HandlerParameter<>(statement, connectionSession);
}
}