提交 721227d7 编写于 作者: T terrymanu

for #1898, ResultPacket => QueryData

上级 6a2bc8a3
......@@ -18,7 +18,7 @@
package org.apache.shardingsphere.shardingproxy.backend.communication;
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.query.ResultPacket;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import java.sql.SQLException;
......@@ -45,10 +45,10 @@ public interface DatabaseCommunicationEngine {
boolean next() throws SQLException;
/**
* Get result value.
* Get query data.
*
* @return result packet
* @return query data
* @throws SQLException SQL exception
*/
ResultPacket getResultValue() throws SQLException;
QueryData getQueryData() throws SQLException;
}
......@@ -38,9 +38,9 @@ import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.execut
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.FailureResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.SuccessResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryHeader;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryHeaderResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.query.ResultPacket;
import org.apache.shardingsphere.shardingproxy.runtime.GlobalRegistry;
import org.apache.shardingsphere.shardingproxy.runtime.schema.LogicSchema;
import org.apache.shardingsphere.shardingproxy.runtime.schema.ShardingSchema;
......@@ -152,14 +152,14 @@ public final class JDBCDatabaseCommunicationEngine implements DatabaseCommunicat
}
@Override
public ResultPacket getResultValue() throws SQLException {
public QueryData getQueryData() throws SQLException {
List<QueryHeader> queryHeaders = ((ExecuteQueryResponse) executeResponse).getQueryHeaders();
int columnCount = queryHeaders.size();
List<Object> row = new ArrayList<>(columnCount);
for (int columnIndex = 1; columnIndex <= columnCount; columnIndex++) {
row.add(mergedResult.getValue(columnIndex, Object.class));
}
return new ResultPacket(++currentSequenceId, row, columnCount, getColumnTypes(queryHeaders));
return new QueryData(++currentSequenceId, row, columnCount, getColumnTypes(queryHeaders));
}
private List<Integer> getColumnTypes(final List<QueryHeader> queryHeaders) {
......
......@@ -23,13 +23,13 @@ import lombok.RequiredArgsConstructor;
import java.util.List;
/**
* Result packet.
* Query data.
*
* @author zhangliang
*/
@RequiredArgsConstructor
@Getter
public final class ResultPacket {
public final class QueryData {
private final int sequenceId;
......
......@@ -17,7 +17,7 @@
package org.apache.shardingsphere.shardingproxy.backend.text;
import org.apache.shardingsphere.shardingproxy.backend.result.query.ResultPacket;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.CommandResponsePackets;
import java.sql.SQLException;
......@@ -45,10 +45,10 @@ public interface TextProtocolBackendHandler {
boolean next() throws SQLException;
/**
* Get result value.
* Get query data.
*
* @return result packet
* @return query data
* @throws SQLException SQL exception
*/
ResultPacket getResultValue() throws SQLException;
QueryData getQueryData() throws SQLException;
}
......@@ -20,7 +20,7 @@ package org.apache.shardingsphere.shardingproxy.backend.text.admin;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.shardingproxy.backend.communication.DatabaseCommunicationEngineFactory;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.query.ResultPacket;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.shardingproxy.runtime.GlobalRegistry;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.DatabasePacket;
......@@ -66,7 +66,7 @@ public final class BroadcastBackendHandler implements TextProtocolBackendHandler
}
@Override
public ResultPacket getResultValue() {
public QueryData getQueryData() {
return null;
}
}
......@@ -17,7 +17,7 @@
package org.apache.shardingsphere.shardingproxy.backend.text.admin;
import org.apache.shardingsphere.shardingproxy.backend.result.query.ResultPacket;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.CommandResponsePackets;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.generic.DatabaseSuccessPacket;
......@@ -40,7 +40,7 @@ public final class GUICompatibilityBackendHandler implements TextProtocolBackend
}
@Override
public ResultPacket getResultValue() {
public QueryData getQueryData() {
return null;
}
}
......@@ -19,7 +19,7 @@ package org.apache.shardingsphere.shardingproxy.backend.text.admin;
import org.apache.shardingsphere.core.merger.MergedResult;
import org.apache.shardingsphere.core.merger.dal.show.ShowDatabasesMergedResult;
import org.apache.shardingsphere.shardingproxy.backend.result.query.ResultPacket;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.shardingproxy.runtime.GlobalRegistry;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.CommandResponsePackets;
......@@ -58,7 +58,7 @@ public final class ShowDatabasesBackendHandler implements TextProtocolBackendHan
}
@Override
public ResultPacket getResultValue() throws SQLException {
return new ResultPacket(++currentSequenceId, Collections.singletonList(mergedResult.getValue(1, Object.class)), 1, Collections.singletonList(Types.VARCHAR));
public QueryData getQueryData() throws SQLException {
return new QueryData(++currentSequenceId, Collections.singletonList(mergedResult.getValue(1, Object.class)), 1, Collections.singletonList(Types.VARCHAR));
}
}
......@@ -22,9 +22,9 @@ import org.apache.shardingsphere.shardingproxy.backend.communication.DatabaseCom
import org.apache.shardingsphere.shardingproxy.backend.communication.DatabaseCommunicationEngineFactory;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryHeader;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryHeaderResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.query.ResultPacket;
import org.apache.shardingsphere.shardingproxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.shardingproxy.runtime.GlobalRegistry;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.CommandResponsePackets;
......@@ -74,7 +74,7 @@ public final class UnicastBackendHandler implements TextProtocolBackendHandler {
}
@Override
public ResultPacket getResultValue() throws SQLException {
return databaseCommunicationEngine.getResultValue();
public QueryData getQueryData() throws SQLException {
return databaseCommunicationEngine.getQueryData();
}
}
......@@ -21,7 +21,7 @@ import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.core.parsing.parser.dialect.mysql.statement.UseStatement;
import org.apache.shardingsphere.core.util.SQLUtil;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.query.ResultPacket;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.shardingproxy.runtime.GlobalRegistry;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.CommandResponsePackets;
......@@ -60,7 +60,7 @@ public final class UseDatabaseBackendHandler implements TextProtocolBackendHandl
}
@Override
public ResultPacket getResultValue() {
public QueryData getQueryData() {
return null;
}
}
......@@ -22,9 +22,9 @@ import org.apache.shardingsphere.shardingproxy.backend.communication.DatabaseCom
import org.apache.shardingsphere.shardingproxy.backend.communication.DatabaseCommunicationEngineFactory;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryHeader;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryHeaderResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.query.ResultPacket;
import org.apache.shardingsphere.shardingproxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.CommandResponsePackets;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.query.DataHeaderPacket;
......@@ -78,7 +78,7 @@ public final class QueryBackendHandler implements TextProtocolBackendHandler {
}
@Override
public ResultPacket getResultValue() throws SQLException {
return databaseCommunicationEngine.getResultValue();
public QueryData getQueryData() throws SQLException {
return databaseCommunicationEngine.getQueryData();
}
}
......@@ -19,7 +19,7 @@ package org.apache.shardingsphere.shardingproxy.backend.text.sctl.set;
import com.google.common.base.Optional;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.query.ResultPacket;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.CommandResponsePackets;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.generic.DatabaseFailurePacket;
......@@ -68,7 +68,7 @@ public final class ShardingCTLSetBackendHandler implements TextProtocolBackendHa
}
@Override
public ResultPacket getResultValue() {
public QueryData getQueryData() {
return null;
}
}
......@@ -21,7 +21,7 @@ import com.google.common.base.Optional;
import org.apache.shardingsphere.core.merger.MergedResult;
import org.apache.shardingsphere.core.merger.dal.show.ShowShardingCTLMergedResult;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.query.ResultPacket;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.CommandResponsePackets;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.query.DataHeaderPacket;
......@@ -91,7 +91,7 @@ public final class ShardingCTLShowBackendHandler implements TextProtocolBackendH
}
@Override
public ResultPacket getResultValue() throws SQLException {
return new ResultPacket(++currentSequenceId, Collections.singletonList(mergedResult.getValue(1, Object.class)), 1, Collections.singletonList(Types.VARCHAR));
public QueryData getQueryData() throws SQLException {
return new QueryData(++currentSequenceId, Collections.singletonList(mergedResult.getValue(1, Object.class)), 1, Collections.singletonList(Types.VARCHAR));
}
}
......@@ -17,7 +17,7 @@
package org.apache.shardingsphere.shardingproxy.backend.text.transaction;
import org.apache.shardingsphere.shardingproxy.backend.result.query.ResultPacket;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.CommandResponsePackets;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.generic.DatabaseSuccessPacket;
......@@ -40,7 +40,7 @@ public final class SkipBackendHandler implements TextProtocolBackendHandler {
}
@Override
public ResultPacket getResultValue() {
public QueryData getQueryData() {
return null;
}
}
......@@ -19,7 +19,7 @@ package org.apache.shardingsphere.shardingproxy.backend.text.transaction;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendTransactionManager;
import org.apache.shardingsphere.shardingproxy.backend.result.query.ResultPacket;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.CommandResponsePackets;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.generic.DatabaseSuccessPacket;
......@@ -75,7 +75,7 @@ public final class TransactionBackendHandler implements TextProtocolBackendHandl
}
@Override
public ResultPacket getResultValue() {
public QueryData getQueryData() {
return null;
}
}
......@@ -133,7 +133,7 @@ public final class MySQLCommandExecutor implements Runnable {
}
}
}
DatabasePacket resultValue = mysqlQueryCommandPacket.getResultValue();
DatabasePacket resultValue = mysqlQueryCommandPacket.getQueryData();
currentSequenceId = resultValue.getSequenceId();
context.write(resultValue);
if (proxyFrontendFlushThreshold == count) {
......
......@@ -126,7 +126,7 @@ public final class PostgreSQLCommandExecutor implements Runnable {
}
}
}
DatabasePacket resultValue = queryCommandPacket.getResultValue();
DatabasePacket resultValue = queryCommandPacket.getQueryData();
context.write(resultValue);
if (proxyFrontendFlushThreshold == count) {
context.flush();
......
......@@ -39,10 +39,10 @@ public interface MySQLQueryCommandPacket extends MySQLCommandPacket {
boolean next() throws SQLException;
/**
* Get result value.
* Get query data.
*
* @return database packet of result value
* @return database packet of query data
* @throws SQLException SQL exception
*/
DatabasePacket getResultValue() throws SQLException;
DatabasePacket getQueryData() throws SQLException;
}
......@@ -24,7 +24,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.shardingproxy.backend.communication.DatabaseCommunicationEngine;
import org.apache.shardingsphere.shardingproxy.backend.communication.DatabaseCommunicationEngineFactory;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.query.ResultPacket;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.runtime.GlobalRegistry;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.DatabasePacket;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.CommandResponsePackets;
......@@ -149,14 +149,14 @@ public final class MySQLQueryComStmtExecutePacket implements MySQLQueryCommandPa
}
@Override
public DatabasePacket getResultValue() throws SQLException {
ResultPacket resultPacket = databaseCommunicationEngine.getResultValue();
int columnCount = resultPacket.getColumnCount();
List<Integer> jdbcColumnTypes = resultPacket.getColumnTypes();
public DatabasePacket getQueryData() throws SQLException {
QueryData queryData = databaseCommunicationEngine.getQueryData();
int columnCount = queryData.getColumnCount();
List<Integer> jdbcColumnTypes = queryData.getColumnTypes();
List<MySQLColumnType> mySQLColumnTypes = new ArrayList<>(128);
for (int i = 0; i < columnCount; i++) {
mySQLColumnTypes.add(MySQLColumnType.valueOfJDBCType(jdbcColumnTypes.get(i)));
}
return new MySQLBinaryResultSetRowPacket(resultPacket.getSequenceId(), columnCount, resultPacket.getData(), mySQLColumnTypes);
return new MySQLBinaryResultSetRowPacket(queryData.getSequenceId(), columnCount, queryData.getData(), mySQLColumnTypes);
}
}
......@@ -85,7 +85,7 @@ public final class MySQLComFieldListPacket implements MySQLCommandPacket {
CommandResponsePackets result = new CommandResponsePackets();
int currentSequenceId = 0;
while (databaseCommunicationEngine.next()) {
String columnName = databaseCommunicationEngine.getResultValue().getData().get(0).toString();
String columnName = databaseCommunicationEngine.getQueryData().getData().get(0).toString();
result.getPackets().add(new MySQLColumnDefinition41Packet(++currentSequenceId, schemaName, table, table, columnName, columnName, 100, MySQLColumnType.MYSQL_TYPE_VARCHAR, 0));
}
result.getPackets().add(new MySQLEofPacket(++currentSequenceId));
......
......@@ -21,7 +21,7 @@ import com.google.common.base.Optional;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.query.ResultPacket;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.shardingproxy.backend.text.TextProtocolBackendHandlerFactory;
import org.apache.shardingsphere.shardingproxy.runtime.GlobalRegistry;
......@@ -85,8 +85,8 @@ public final class MySQLComPacketQuery implements MySQLQueryCommandPacket {
}
@Override
public DatabasePacket getResultValue() throws SQLException {
ResultPacket resultPacket = textProtocolBackendHandler.getResultValue();
return new MySQLTextResultSetRowPacket(resultPacket.getSequenceId(), resultPacket.getData());
public DatabasePacket getQueryData() throws SQLException {
QueryData queryData = textProtocolBackendHandler.getQueryData();
return new MySQLTextResultSetRowPacket(queryData.getSequenceId(), queryData.getData());
}
}
......@@ -38,10 +38,10 @@ public interface PostgreSQLQueryCommandPacket extends PostgreSQLCommandPacket {
boolean next() throws SQLException;
/**
* Get result value.
* Get query data.
*
* @return database packet of result value
* @throws SQLException SQL exception
*/
DatabasePacket getResultValue() throws SQLException;
DatabasePacket getQueryData() throws SQLException;
}
......@@ -23,7 +23,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.shardingproxy.backend.communication.DatabaseCommunicationEngine;
import org.apache.shardingsphere.shardingproxy.backend.communication.DatabaseCommunicationEngineFactory;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.query.ResultPacket;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.runtime.GlobalRegistry;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.DatabasePacket;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.CommandResponsePackets;
......@@ -123,15 +123,15 @@ public final class PostgreSQLComBindPacket implements PostgreSQLQueryCommandPack
}
@Override
public DatabasePacket getResultValue() throws SQLException {
ResultPacket resultPacket = databaseCommunicationEngine.getResultValue();
int columnCount = resultPacket.getColumnCount();
List<Integer> jdbcColumnTypes = resultPacket.getColumnTypes();
public DatabasePacket getQueryData() throws SQLException {
QueryData queryData = databaseCommunicationEngine.getQueryData();
int columnCount = queryData.getColumnCount();
List<Integer> jdbcColumnTypes = queryData.getColumnTypes();
List<PostgreSQLColumnType> columnTypes = new ArrayList<>(128);
for (int i = 0; i < columnCount; i++) {
columnTypes.add(PostgreSQLColumnType.valueOfJDBCType(jdbcColumnTypes.get(i)));
}
return new PostgreSQLBinaryResultSetRowPacket(resultPacket.getColumnCount(), resultPacket.getData(), columnTypes);
return new PostgreSQLBinaryResultSetRowPacket(queryData.getColumnCount(), queryData.getData(), columnTypes);
}
@Override
......
......@@ -21,7 +21,6 @@ import com.google.common.base.Optional;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.query.ResultPacket;
import org.apache.shardingsphere.shardingproxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.shardingproxy.backend.text.TextProtocolBackendHandlerFactory;
import org.apache.shardingsphere.shardingproxy.runtime.GlobalRegistry;
......@@ -72,9 +71,8 @@ public final class PostgreSQLComQueryPacket implements PostgreSQLQueryCommandPac
}
@Override
public DatabasePacket getResultValue() throws SQLException {
ResultPacket resultPacket = textProtocolBackendHandler.getResultValue();
return new PostgreSQLDataRowPacket(resultPacket.getData());
public DatabasePacket getQueryData() throws SQLException {
return new PostgreSQLDataRowPacket(textProtocolBackendHandler.getQueryData().getData());
}
@Override
......
......@@ -8,51 +8,51 @@
#
######################################################################################################
#
#schemaName: sharding_db
#
#dataSources:
# ds_0:
# url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false
# username: root
# password:
# connectionTimeoutMilliseconds: 30000
# idleTimeoutMilliseconds: 60000
# maxLifetimeMilliseconds: 1800000
# maxPoolSize: 50
# ds_1:
# url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false
# username: root
# password:
# connectionTimeoutMilliseconds: 30000
# idleTimeoutMilliseconds: 60000
# maxLifetimeMilliseconds: 1800000
# maxPoolSize: 50
#
#shardingRule:
# tables:
# t_order:
# actualDataNodes: ds_${0..1}.t_order_${0..1}
# tableStrategy:
# inline:
# shardingColumn: order_id
# algorithmExpression: t_order_${order_id % 2}
# keyGenerator:
# type: SNOWFLAKE
# column: order_id
# t_order_item:
# actualDataNodes: ds_${0..1}.t_order_item_${0..1}
# tableStrategy:
# inline:
# shardingColumn: order_id
# algorithmExpression: t_order_item_${order_id % 2}
# keyGenerator:
# type: SNOWFLAKE
# column: order_item_id
# bindingTables:
# - t_order,t_order_item
# defaultDatabaseStrategy:
# inline:
# shardingColumn: user_id
# algorithmExpression: ds_${user_id % 2}
# defaultTableStrategy:
# none:
schemaName: sharding_db
dataSources:
ds_0:
url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false
username: root
password:
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
ds_1:
url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false
username: root
password:
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
shardingRule:
tables:
t_order:
actualDataNodes: ds_${0..1}.t_order_${0..1}
tableStrategy:
inline:
shardingColumn: order_id
algorithmExpression: t_order_${order_id % 2}
keyGenerator:
type: SNOWFLAKE
column: order_id
t_order_item:
actualDataNodes: ds_${0..1}.t_order_item_${0..1}
tableStrategy:
inline:
shardingColumn: order_id
algorithmExpression: t_order_item_${order_id % 2}
keyGenerator:
type: SNOWFLAKE
column: order_item_id
bindingTables:
- t_order,t_order_item
defaultDatabaseStrategy:
inline:
shardingColumn: user_id
algorithmExpression: ds_${user_id % 2}
defaultTableStrategy:
none:
......@@ -11,18 +11,18 @@
# serverLists: localhost:2181
# namespace: orchestration
#
#authentication:
# username: root
# password: root
#
#props:
# max.connections.size.per.query: 1
# acceptor.size: 16 # The default value is available processors count * 2.
# executor.size: 16 # Infinite by default.
# proxy.frontend.flush.threshold: 128 # The default value is 128.
# # LOCAL: Proxy will run with LOCAL transaction.
# # XA: Proxy will run with XA transaction.
# # BASE: Proxy will run with B.A.S.E transaction.
# proxy.transaction.type: LOCAL
# proxy.opentracing.enabled: false
# sql.show: false
authentication:
username: root
password: root
props:
max.connections.size.per.query: 1
acceptor.size: 16 # The default value is available processors count * 2.
executor.size: 16 # Infinite by default.
proxy.frontend.flush.threshold: 128 # The default value is 128.
# LOCAL: Proxy will run with LOCAL transaction.
# XA: Proxy will run with XA transaction.
# BASE: Proxy will run with B.A.S.E transaction.
proxy.transaction.type: LOCAL
proxy.opentracing.enabled: false
sql.show: false
......@@ -18,7 +18,7 @@
package org.apache.shardingsphere.shardingproxy.backend.text.admin;
import org.apache.shardingsphere.shardingproxy.backend.MockGlobalRegistryUtil;
import org.apache.shardingsphere.shardingproxy.backend.result.query.ResultPacket;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.CommandResponsePackets;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.query.QueryResponsePackets;
import org.junit.Before;
......@@ -56,12 +56,12 @@ public final class ShowDatabasesBackendHandlerTest {
showDatabasesBackendHandler.execute();
int sequenceId = 4;
while (showDatabasesBackendHandler.next()) {
ResultPacket resultPacket = showDatabasesBackendHandler.getResultValue();
assertThat(resultPacket.getColumnCount(), is(1));
assertThat(resultPacket.getColumnTypes().size(), is(1));
assertThat(resultPacket.getColumnTypes().iterator().next(), is(Types.VARCHAR));
assertThat(resultPacket.getSequenceId(), is(sequenceId));
assertThat(resultPacket.getData().size(), is(1));
QueryData queryData = showDatabasesBackendHandler.getQueryData();
assertThat(queryData.getColumnCount(), is(1));
assertThat(queryData.getColumnTypes().size(), is(1));
assertThat(queryData.getColumnTypes().iterator().next(), is(Types.VARCHAR));
assertThat(queryData.getSequenceId(), is(sequenceId));
assertThat(queryData.getData().size(), is(1));
++sequenceId;
}
}
......
......@@ -18,7 +18,7 @@
package org.apache.shardingsphere.shardingproxy.backend.text.sctl.show;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.query.ResultPacket;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.CommandResponsePackets;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.query.DataHeaderPacket;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.query.QueryResponsePackets;
......@@ -47,8 +47,8 @@ public final class ShardingCTLShowBackendHandlerTest {
assertThat(actual.getHeadPacket(), instanceOf(DataHeaderPacket.class));
assertThat(actual.getPackets().size(), is(1));
backendHandler.next();
ResultPacket resultPacket = backendHandler.getResultValue();
assertThat(resultPacket.getData().iterator().next(), CoreMatchers.<Object>is("LOCAL"));
QueryData queryData = backendHandler.getQueryData();
assertThat(queryData.getData().iterator().next(), CoreMatchers.<Object>is("LOCAL"));
}
@Test
......@@ -60,8 +60,8 @@ public final class ShardingCTLShowBackendHandlerTest {
assertThat(actual.getHeadPacket(), instanceOf(DataHeaderPacket.class));
assertThat(actual.getPackets().size(), is(1));
backendHandler.next();
ResultPacket resultPacket = backendHandler.getResultValue();
assertThat(resultPacket.getData().iterator().next(), CoreMatchers.<Object>is(0));
QueryData queryData = backendHandler.getQueryData();
assertThat(queryData.getData().iterator().next(), CoreMatchers.<Object>is(0));
}
@Test
......
......@@ -22,7 +22,7 @@ import lombok.SneakyThrows;
import org.apache.shardingsphere.shardingproxy.backend.communication.DatabaseCommunicationEngine;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.query.ResultPacket;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.DatabasePacket;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.CommandResponsePackets;
import org.apache.shardingsphere.shardingproxy.transport.mysql.packet.MySQLPacketPayload;
......@@ -86,13 +86,13 @@ public final class MySQLComStmtExecutePacketTest {
when(payload.readInt1()).thenReturn(0, 1);
when(databaseCommunicationEngine.execute()).thenReturn(mock(BackendResponse.class));
when(databaseCommunicationEngine.next()).thenReturn(true, false);
when(databaseCommunicationEngine.getResultValue()).thenReturn(new ResultPacket(2, Collections.<Object>singletonList(99999L), 1, Collections.singletonList(Types.BIGINT)));
when(databaseCommunicationEngine.getQueryData()).thenReturn(new QueryData(2, Collections.<Object>singletonList(99999L), 1, Collections.singletonList(Types.BIGINT)));
MySQLQueryComStmtExecutePacket packet = new MySQLQueryComStmtExecutePacket(1, payload, backendConnection);
setBackendHandler(packet, databaseCommunicationEngine);
Optional<CommandResponsePackets> actualCommandResponsePackets = packet.execute();
assertTrue(actualCommandResponsePackets.isPresent());
assertTrue(packet.next());
DatabasePacket actualResultValue = packet.getResultValue();
DatabasePacket actualResultValue = packet.getQueryData();
assertThat(actualResultValue.getSequenceId(), is(2));
assertThat(((MySQLBinaryResultSetRowPacket) actualResultValue).getData(), is(Collections.<Object>singletonList(99999L)));
assertFalse(packet.next());
......
......@@ -25,7 +25,7 @@ import org.apache.shardingsphere.shardingproxy.backend.communication.DatabaseCom
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.FailureResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.query.ResultPacket;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.runtime.GlobalRegistry;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.DatabasePacket;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.CommandResponsePackets;
......@@ -99,7 +99,7 @@ public final class MySQLComFieldListPacketTest {
when(payload.readStringNul()).thenReturn("tbl");
when(payload.readStringEOF()).thenReturn("-");
when(databaseCommunicationEngine.next()).thenReturn(true, false);
when(databaseCommunicationEngine.getResultValue()).thenReturn(new ResultPacket(1, Collections.<Object>singletonList("id"), 1, Collections.singletonList(Types.VARCHAR)));
when(databaseCommunicationEngine.getQueryData()).thenReturn(new QueryData(1, Collections.<Object>singletonList("id"), 1, Collections.singletonList(Types.VARCHAR)));
BackendResponse backendResponse = mock(BackendResponse.class);
when(backendResponse.getPackets()).thenReturn(Collections.<DatabasePacket>singletonList(new MySQLFieldCountPacket(1, 1)));
when(databaseCommunicationEngine.execute()).thenReturn(backendResponse);
......
......@@ -22,7 +22,7 @@ import lombok.SneakyThrows;
import org.apache.shardingsphere.core.constant.ShardingConstant;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.ConnectionStatus;
import org.apache.shardingsphere.shardingproxy.backend.result.query.ResultPacket;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.shardingproxy.runtime.GlobalRegistry;
import org.apache.shardingsphere.shardingproxy.runtime.schema.ShardingSchema;
......@@ -108,8 +108,8 @@ public final class MySQLComQueryPacketTest {
assertThat(actual.get().getPackets().size(), is(1));
assertThat(actual.get().getPackets().iterator().next(), is((DatabasePacket) expectedMySQLFieldCountPacket));
assertTrue(packet.next());
assertThat(packet.getResultValue().getSequenceId(), is(2));
assertThat(((MySQLTextResultSetRowPacket) packet.getResultValue()).getData(), is(Collections.<Object>singletonList(99999L)));
assertThat(packet.getQueryData().getSequenceId(), is(2));
assertThat(((MySQLTextResultSetRowPacket) packet.getQueryData()).getData(), is(Collections.<Object>singletonList(99999L)));
assertFalse(packet.next());
}
......@@ -117,10 +117,10 @@ public final class MySQLComQueryPacketTest {
private void setBackendHandler(final MySQLComPacketQuery packet, final MySQLFieldCountPacket expectedMySQLFieldCountPacket) {
TextProtocolBackendHandler textProtocolBackendHandler = mock(TextProtocolBackendHandler.class);
when(textProtocolBackendHandler.next()).thenReturn(true, false);
when(textProtocolBackendHandler.getResultValue()).thenReturn(new ResultPacket(1, Collections.<Object>singletonList("id"), 1, Collections.singletonList(Types.VARCHAR)));
when(textProtocolBackendHandler.getQueryData()).thenReturn(new QueryData(1, Collections.<Object>singletonList("id"), 1, Collections.singletonList(Types.VARCHAR)));
when(textProtocolBackendHandler.execute()).thenReturn(new CommandResponsePackets(expectedMySQLFieldCountPacket));
when(textProtocolBackendHandler.next()).thenReturn(true, false);
when(textProtocolBackendHandler.getResultValue()).thenReturn(new ResultPacket(2, Collections.<Object>singletonList(99999L), 1, Collections.singletonList(Types.BIGINT)));
when(textProtocolBackendHandler.getQueryData()).thenReturn(new QueryData(2, Collections.<Object>singletonList(99999L), 1, Collections.singletonList(Types.BIGINT)));
Field field = MySQLComPacketQuery.class.getDeclaredField("textProtocolBackendHandler");
field.setAccessible(true);
field.set(packet, textProtocolBackendHandler);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册