This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 0b0c5f9d38f Refactor ConnectionContext (#24783)
0b0c5f9d38f is described below
commit 0b0c5f9d38f57a07a9d92ad39d909dc37e3bc908
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Mar 23 19:37:12 2023 +0800
Refactor ConnectionContext (#24783)
* Refactor LoadBalanceAlgorithm
* Refactor ConnectionContext
---
.../route/impl/ReadwriteSplittingDataSourceRouter.java | 2 +-
.../sharding/merge/ddl/fetch/FetchStreamMergedResult.java | 14 +++++++-------
.../sharding/rewrite/token/pojo/FetchDirectionToken.java | 2 +-
.../sharding/merge/ddl/ShardingDDLResultMergerTest.java | 2 +-
.../merge/ddl/fetch/FetchStreamMergedResultTest.java | 2 +-
.../shardingsphere/infra/context/ConnectionContext.java | 10 +++++-----
.../sql/execute/engine/driver/jdbc/JDBCExecutor.java | 2 +-
.../infra/executor/sql/execute/engine/raw/RawExecutor.java | 2 +-
.../driver/jdbc/core/connection/ConnectionManager.java | 6 +++---
.../jdbc/core/connection/ShardingSphereConnection.java | 4 ++--
.../core/statement/ShardingSpherePreparedStatement.java | 2 +-
.../jdbc/core/statement/ShardingSphereStatement.java | 4 ++--
.../jdbc/core/connection/ShardingSphereConnectionTest.java | 14 +++++++-------
.../proxy/backend/connector/BackendConnection.java | 2 +-
.../proxy/backend/connector/DatabaseConnector.java | 6 +++---
.../proxy/backend/connector/ProxySQLExecutor.java | 2 +-
.../jdbc/transaction/BackendTransactionManager.java | 2 +-
.../backend/handler/distsql/rul/sql/PreviewHandler.java | 2 +-
.../backend/handler/transaction/TransactionXAHandler.java | 2 +-
.../jdbc/transaction/BackendTransactionManagerTest.java | 2 +-
.../test/it/rewrite/engine/SQLRewriterIT.java | 2 +-
21 files changed, 43 insertions(+), 43 deletions(-)
diff --git
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/route/impl/ReadwriteSplittingDataSourceRouter.java
b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/route/impl/ReadwriteSplittingDataSourceRouter.java
index 429d466c34d..4c051688072 100644
---
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/route/impl/ReadwriteSplittingDataSourceRouter.java
+++
b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/route/impl/ReadwriteSplittingDataSourceRouter.java
@@ -49,7 +49,7 @@ public final class ReadwriteSplittingDataSourceRouter {
return rule.getWriteDataSource();
}
return rule.getLoadBalancer().getDataSource(rule.getName(),
rule.getWriteDataSource(), rule.getEnabledReplicaDataSources(),
- connectionContext.getTransactionConnectionContext());
+ connectionContext.getTransactionContext());
}
private boolean isPrimaryRoute(final SQLStatementContext<?>
sqlStatementContext) {
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/merge/ddl/fetch/FetchStreamMergedResult.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/merge/ddl/fetch/FetchStreamMergedResult.java
index fbf73cdb80c..a74173edcd7 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/merge/ddl/fetch/FetchStreamMergedResult.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/merge/ddl/fetch/FetchStreamMergedResult.java
@@ -97,8 +97,8 @@ public final class FetchStreamMergedResult extends
StreamMergedResult {
private List<FetchOrderByValueGroup> getFetchOrderByValueGroups(final
List<QueryResult> queryResults, final SelectStatementContext
selectStatementContext,
final
ShardingSphereSchema schema, final String cursorName, final ConnectionContext
connectionContext) throws SQLException {
- long actualFetchCount = Math.max(fetchCount -
connectionContext.getCursorConnectionContext().getMinGroupRowCounts().getOrDefault(cursorName,
0L), 0);
- List<FetchGroup> fetchGroups =
connectionContext.getCursorConnectionContext().getOrderByValueGroups().computeIfAbsent(cursorName,
key -> createFetchOrderByValueGroups(queryResults.size()));
+ long actualFetchCount = Math.max(fetchCount -
connectionContext.getCursorContext().getMinGroupRowCounts().getOrDefault(cursorName,
0L), 0);
+ List<FetchGroup> fetchGroups =
connectionContext.getCursorContext().getOrderByValueGroups().computeIfAbsent(cursorName,
key -> createFetchOrderByValueGroups(queryResults.size()));
List<FetchOrderByValueGroup> result = new
ArrayList<>(fetchGroups.size());
for (FetchGroup each : fetchGroups) {
result.add((FetchOrderByValueGroup) each);
@@ -107,7 +107,7 @@ public final class FetchStreamMergedResult extends
StreamMergedResult {
if (actualFetchCount <= 0 &&
!DirectionType.isAllDirectionType(directionType)) {
return result;
}
- if
(connectionContext.getCursorConnectionContext().getExecutedAllDirections().containsKey(cursorName))
{
+ if
(connectionContext.getCursorContext().getExecutedAllDirections().containsKey(cursorName))
{
result.forEach(each -> each.getOrderByValues().clear());
return result;
}
@@ -155,20 +155,20 @@ public final class FetchStreamMergedResult extends
StreamMergedResult {
private void setMinResultSetRowCount(final String cursorName, final
ConnectionContext connectionContext) {
Collection<Long> rowCounts = new LinkedList<>();
- List<FetchGroup> fetchOrderByValueGroups =
connectionContext.getCursorConnectionContext().getOrderByValueGroups().getOrDefault(cursorName,
new LinkedList<>());
+ List<FetchGroup> fetchOrderByValueGroups =
connectionContext.getCursorContext().getOrderByValueGroups().getOrDefault(cursorName,
new LinkedList<>());
for (FetchGroup each : fetchOrderByValueGroups) {
rowCounts.add(getGroupRowCount((FetchOrderByValueGroup) each));
}
long minResultSetRowCount =
DirectionType.isAllDirectionType(directionType) ? 0 :
Collections.min(rowCounts) - fetchCount;
-
connectionContext.getCursorConnectionContext().getMinGroupRowCounts().put(cursorName,
Math.max(minResultSetRowCount, 0L));
+
connectionContext.getCursorContext().getMinGroupRowCounts().put(cursorName,
Math.max(minResultSetRowCount, 0L));
}
private void handleExecutedAllDirections(final ConnectionContext
connectionContext, final String cursorName) {
- if
(connectionContext.getCursorConnectionContext().getExecutedAllDirections().containsKey(cursorName))
{
+ if
(connectionContext.getCursorContext().getExecutedAllDirections().containsKey(cursorName))
{
isExecutedAllDirection = true;
}
if (DirectionType.isAllDirectionType(directionType)) {
-
connectionContext.getCursorConnectionContext().getExecutedAllDirections().put(cursorName,
true);
+
connectionContext.getCursorContext().getExecutedAllDirections().put(cursorName,
true);
}
}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/FetchDirectionToken.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/FetchDirectionToken.java
index 9f373af3e27..3f75999ada2 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/FetchDirectionToken.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/FetchDirectionToken.java
@@ -51,7 +51,7 @@ public final class FetchDirectionToken extends SQLToken
implements Substitutable
@Override
public String toString() {
- long actualFetchCount = Math.max(fetchCount -
connectionContext.getCursorConnectionContext().getMinGroupRowCounts().getOrDefault(cursorName,
0L), 0);
+ long actualFetchCount = Math.max(fetchCount -
connectionContext.getCursorContext().getMinGroupRowCounts().getOrDefault(cursorName,
0L), 0);
if (DirectionType.isForwardCountDirectionType(directionType)) {
return " FORWARD " + actualFetchCount + " ";
}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/ShardingDDLResultMergerTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/ShardingDDLResultMergerTest.java
index 38ead93fbc0..a7cf188aabf 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/ShardingDDLResultMergerTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/ShardingDDLResultMergerTest.java
@@ -68,7 +68,7 @@ public final class ShardingDDLResultMergerTest {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
when(database.getSchema(DefaultDatabase.LOGIC_NAME)).thenReturn(mock(ShardingSphereSchema.class));
ConnectionContext connectionContext = mock(ConnectionContext.class);
- when(connectionContext.getCursorConnectionContext()).thenReturn(new
CursorConnectionContext());
+ when(connectionContext.getCursorContext()).thenReturn(new
CursorConnectionContext());
assertThat(merger.merge(createMultiQueryResults(),
createFetchStatementContext(database), mock(ShardingSphereDatabase.class),
connectionContext),
instanceOf(FetchStreamMergedResult.class));
}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/fetch/FetchStreamMergedResultTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/fetch/FetchStreamMergedResultTest.java
index 79f200baef7..dca5c65ef6e 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/fetch/FetchStreamMergedResultTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/fetch/FetchStreamMergedResultTest.java
@@ -75,7 +75,7 @@ public final class FetchStreamMergedResultTest {
database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn(DefaultDatabase.LOGIC_NAME);
connectionContext = mock(ConnectionContext.class);
- when(connectionContext.getCursorConnectionContext()).thenReturn(new
CursorConnectionContext());
+ when(connectionContext.getCursorContext()).thenReturn(new
CursorConnectionContext());
}
private OpenGaussFetchStatement createFetchStatement(final boolean
containsAllDirectionType) {
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/context/ConnectionContext.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/context/ConnectionContext.java
index 94eb7559743..29d3f55dddd 100644
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/context/ConnectionContext.java
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/context/ConnectionContext.java
@@ -36,9 +36,9 @@ import java.util.Optional;
@Getter
public final class ConnectionContext implements AutoCloseable {
- private final CursorConnectionContext cursorConnectionContext = new
CursorConnectionContext();
+ private final CursorConnectionContext cursorContext = new
CursorConnectionContext();
- private final TransactionConnectionContext transactionConnectionContext =
new TransactionConnectionContext();
+ private final TransactionConnectionContext transactionContext = new
TransactionConnectionContext();
@Getter(AccessLevel.NONE)
private final PreferredDataSourceProvider preferredDataSourceProvider;
@@ -47,7 +47,7 @@ public final class ConnectionContext implements AutoCloseable
{
private String trafficInstanceId;
public ConnectionContext() {
- preferredDataSourceProvider = Collections::emptySet;
+ this(Collections::emptySet);
}
/**
@@ -86,13 +86,13 @@ public final class ConnectionContext implements
AutoCloseable {
* Clear cursor connection context.
*/
public void clearCursorConnectionContext() {
- cursorConnectionContext.close();
+ cursorContext.close();
}
/**
* Clear transaction connection context.
*/
public void clearTransactionConnectionContext() {
- transactionConnectionContext.close();
+ transactionContext.close();
}
}
diff --git
a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/driver/jdbc/JDBCExecutor.java
b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/driver/jdbc/JDBCExecutor.java
index a0d9e876657..0681cc855c0 100644
---
a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/driver/jdbc/JDBCExecutor.java
+++
b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/driver/jdbc/JDBCExecutor.java
@@ -64,7 +64,7 @@ public final class JDBCExecutor {
public <T> List<T> execute(final ExecutionGroupContext<JDBCExecutionUnit>
executionGroupContext,
final JDBCExecutorCallback<T> firstCallback,
final JDBCExecutorCallback<T> callback) throws SQLException {
try {
- return executorEngine.execute(executionGroupContext,
firstCallback, callback,
connectionContext.getTransactionConnectionContext().isInTransaction());
+ return executorEngine.execute(executionGroupContext,
firstCallback, callback,
connectionContext.getTransactionContext().isInTransaction());
} catch (final SQLException ex) {
SQLExecutorExceptionHandler.handleException(ex);
return Collections.emptyList();
diff --git
a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/raw/RawExecutor.java
b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/raw/RawExecutor.java
index 174c549ae0b..57e9454c29a 100644
---
a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/raw/RawExecutor.java
+++
b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/raw/RawExecutor.java
@@ -69,7 +69,7 @@ public final class RawExecutor {
private <T> List<T> execute(final
ExecutionGroupContext<RawSQLExecutionUnit> executionGroupContext,
final RawSQLExecutorCallback firstCallback,
final RawSQLExecutorCallback callback) throws SQLException {
try {
- return (List<T>) executorEngine.execute(executionGroupContext,
firstCallback, callback,
connectionContext.getTransactionConnectionContext().isInTransaction());
+ return (List<T>) executorEngine.execute(executionGroupContext,
firstCallback, callback,
connectionContext.getTransactionContext().isInTransaction());
} catch (final SQLException ex) {
SQLExecutorExceptionHandler.handleException(ex);
return Collections.emptyList();
diff --git
a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManager.java
b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManager.java
index ac8721586ef..913159af6a4 100644
---
a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManager.java
+++
b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManager.java
@@ -331,15 +331,15 @@ public final class ConnectionManager implements
ExecutorJDBCConnectionManager, A
@SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
private List<Connection> createConnections(final String dataSourceName,
final DataSource dataSource, final int connectionSize, final ConnectionMode
connectionMode) throws SQLException {
if (1 == connectionSize) {
- Connection connection = createConnection(dataSourceName,
dataSource, connectionContext.getTransactionConnectionContext());
+ Connection connection = createConnection(dataSourceName,
dataSource, connectionContext.getTransactionContext());
methodInvocationRecorder.replay(connection);
return Collections.singletonList(connection);
}
if (ConnectionMode.CONNECTION_STRICTLY == connectionMode) {
- return createConnections(dataSourceName, dataSource,
connectionSize, connectionContext.getTransactionConnectionContext());
+ return createConnections(dataSourceName, dataSource,
connectionSize, connectionContext.getTransactionContext());
}
synchronized (dataSource) {
- return createConnections(dataSourceName, dataSource,
connectionSize, connectionContext.getTransactionConnectionContext());
+ return createConnections(dataSourceName, dataSource,
connectionSize, connectionContext.getTransactionContext());
}
}
diff --git
a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
index d09f97d7bf8..ca4bcd2573c 100644
---
a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
+++
b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
@@ -145,7 +145,7 @@ public final class ShardingSphereConnection extends
AbstractConnectionAdapter {
private void processLocalTransaction() throws SQLException {
connectionManager.setAutoCommit(autoCommit);
if (!autoCommit) {
-
getConnectionContext().getTransactionConnectionContext().setInTransaction(true);
+
getConnectionContext().getTransactionContext().setInTransaction(true);
}
}
@@ -154,7 +154,7 @@ public final class ShardingSphereConnection extends
AbstractConnectionAdapter {
case BEGIN:
connectionManager.close();
connectionManager.getConnectionTransaction().begin();
-
getConnectionContext().getTransactionConnectionContext().setInTransaction(true);
+
getConnectionContext().getTransactionContext().setInTransaction(true);
break;
case COMMIT:
connectionManager.getConnectionTransaction().commit();
diff --git
a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
index 555aeae6e37..33b3e6dfe0f 100644
---
a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
+++
b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
@@ -437,7 +437,7 @@ public final class ShardingSpherePreparedStatement extends
AbstractPreparedState
private boolean isNeedImplicitCommitTransaction(final ExecutionContext
executionContext) {
ConnectionTransaction connectionTransaction =
connection.getConnectionManager().getConnectionTransaction();
- boolean isInTransaction =
connection.getConnectionManager().getConnectionContext().getTransactionConnectionContext().isInTransaction();
+ boolean isInTransaction =
connection.getConnectionManager().getConnectionContext().getTransactionContext().isInTransaction();
SQLStatement sqlStatement =
executionContext.getSqlStatementContext().getSqlStatement();
return
TransactionType.isDistributedTransaction(connectionTransaction.getTransactionType())
&& !isInTransaction && sqlStatement instanceof DMLStatement
&& !(sqlStatement instanceof SelectStatement) &&
executionContext.getExecutionUnits().size() > 1;
diff --git
a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
index 855a5b107b3..4f75f26066d 100644
---
a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
+++
b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
@@ -484,7 +484,7 @@ public final class ShardingSphereStatement extends
AbstractStatementAdapter {
}
private void checkSameDatabaseNameInTransaction(final
SQLStatementContext<?> sqlStatementContext, final String
connectionDatabaseName) {
- if
(!connection.getConnectionManager().getConnectionContext().getTransactionConnectionContext().isInTransaction())
{
+ if
(!connection.getConnectionManager().getConnectionContext().getTransactionContext().isInTransaction())
{
return;
}
if (sqlStatementContext instanceof TableAvailable) {
@@ -558,7 +558,7 @@ public final class ShardingSphereStatement extends
AbstractStatementAdapter {
private boolean isNeedImplicitCommitTransaction(final ExecutionContext
executionContext) {
ConnectionTransaction connectionTransaction =
connection.getConnectionManager().getConnectionTransaction();
- boolean isInTransaction =
connection.getConnectionManager().getConnectionContext().getTransactionConnectionContext().isInTransaction();
+ boolean isInTransaction =
connection.getConnectionManager().getConnectionContext().getTransactionContext().isInTransaction();
SQLStatement sqlStatement =
executionContext.getSqlStatementContext().getSqlStatement();
return
TransactionType.isDistributedTransaction(connectionTransaction.getTransactionType())
&& !isInTransaction && sqlStatement instanceof DMLStatement
&& !(sqlStatement instanceof SelectStatement) &&
executionContext.getExecutionUnits().size() > 1;
diff --git
a/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnectionTest.java
b/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnectionTest.java
index 97081bd89ac..a6d8b4a3c50 100644
---
a/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnectionTest.java
+++
b/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnectionTest.java
@@ -117,10 +117,10 @@ public final class ShardingSphereConnectionTest {
connection.getConnectionManager().getConnections("ds", 1,
ConnectionMode.MEMORY_STRICTLY);
connection.setAutoCommit(false);
assertFalse(connection.getAutoCommit());
-
assertTrue(connection.getConnectionManager().getConnectionContext().getTransactionConnectionContext().isInTransaction());
+
assertTrue(connection.getConnectionManager().getConnectionContext().getTransactionContext().isInTransaction());
verify(physicalConnection).setAutoCommit(false);
connection.commit();
-
assertFalse(connection.getConnectionManager().getConnectionContext().getTransactionConnectionContext().isInTransaction());
+
assertFalse(connection.getConnectionManager().getConnectionContext().getTransactionContext().isInTransaction());
verify(physicalConnection).commit();
}
@@ -130,12 +130,12 @@ public final class ShardingSphereConnectionTest {
when(connectionTransaction.getDistributedTransactionOperationType(false)).thenReturn(DistributedTransactionOperationType.BEGIN);
ConnectionManager connectionManager =
mockConnectionManager(connectionTransaction);
connection.setAutoCommit(false);
-
assertTrue(connectionManager.getConnectionContext().getTransactionConnectionContext().isInTransaction());
+
assertTrue(connectionManager.getConnectionContext().getTransactionContext().isInTransaction());
assertFalse(connection.getAutoCommit());
-
assertTrue(connection.getConnectionManager().getConnectionContext().getTransactionConnectionContext().isInTransaction());
+
assertTrue(connection.getConnectionManager().getConnectionContext().getTransactionContext().isInTransaction());
verify(connectionTransaction).begin();
connection.commit();
-
assertFalse(connection.getConnectionManager().getConnectionContext().getTransactionConnectionContext().isInTransaction());
+
assertFalse(connection.getConnectionManager().getConnectionContext().getTransactionContext().isInTransaction());
verify(connectionManager).commit();
}
@@ -157,10 +157,10 @@ public final class ShardingSphereConnectionTest {
final ConnectionManager connectionManager =
mockConnectionManager(connectionTransaction);
connection.setAutoCommit(false);
assertFalse(connection.getAutoCommit());
-
assertTrue(connection.getConnectionManager().getConnectionContext().getTransactionConnectionContext().isInTransaction());
+
assertTrue(connection.getConnectionManager().getConnectionContext().getTransactionContext().isInTransaction());
verify(connectionTransaction).begin();
connection.rollback();
-
assertFalse(connection.getConnectionManager().getConnectionContext().getTransactionConnectionContext().isInTransaction());
+
assertFalse(connection.getConnectionManager().getConnectionContext().getTransactionContext().isInTransaction());
verify(connectionManager).rollback();
}
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/BackendConnection.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/BackendConnection.java
index e25ae72f5f8..2449423d8bb 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/BackendConnection.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/BackendConnection.java
@@ -100,7 +100,7 @@ public final class BackendConnection implements
ExecutorJDBCConnectionManager {
private void executeTransactionHooksAfterCreateConnections(final
List<Connection> result) throws SQLException {
if (connectionSession.getTransactionStatus().isInTransaction()) {
for (TransactionHook each : transactionHooks) {
- each.afterCreateConnections(result,
connectionSession.getConnectionContext().getTransactionConnectionContext());
+ each.afterCreateConnections(result,
connectionSession.getConnectionContext().getTransactionContext());
}
}
}
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/DatabaseConnector.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/DatabaseConnector.java
index 145e632e108..df7287600da 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/DatabaseConnector.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/DatabaseConnector.java
@@ -302,15 +302,15 @@ public final class DatabaseConnector implements
DatabaseBackendHandler {
private void prepareCursorStatementContext(final CursorAvailable
statementContext, final ConnectionSession connectionSession, final String
cursorName) {
if (statementContext instanceof CursorStatementContext) {
-
connectionSession.getConnectionContext().getCursorConnectionContext().getCursorDefinitions().put(cursorName,
(CursorStatementContext) statementContext);
+
connectionSession.getConnectionContext().getCursorContext().getCursorDefinitions().put(cursorName,
(CursorStatementContext) statementContext);
}
if (statementContext instanceof CursorDefinitionAware) {
- CursorStatementContext cursorStatementContext =
(CursorStatementContext)
connectionSession.getConnectionContext().getCursorConnectionContext().getCursorDefinitions().get(cursorName);
+ CursorStatementContext cursorStatementContext =
(CursorStatementContext)
connectionSession.getConnectionContext().getCursorContext().getCursorDefinitions().get(cursorName);
Preconditions.checkArgument(null != cursorStatementContext,
"Cursor %s does not exist.", cursorName);
((CursorDefinitionAware)
statementContext).setUpCursorDefinition(cursorStatementContext);
}
if (statementContext instanceof CloseStatementContext) {
-
connectionSession.getConnectionContext().getCursorConnectionContext().removeCursorName(cursorName);
+
connectionSession.getConnectionContext().getCursorContext().removeCursorName(cursorName);
}
}
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/ProxySQLExecutor.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/ProxySQLExecutor.java
index ac9c4ce626b..a117cc5f4e7 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/ProxySQLExecutor.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/ProxySQLExecutor.java
@@ -205,7 +205,7 @@ public final class ProxySQLExecutor {
}
private TransactionConnectionContext getTransactionContext(final
ConnectionSession connectionSession) {
- return
connectionSession.getBackendConnection().getConnectionSession().getConnectionContext().getTransactionConnectionContext();
+ return
connectionSession.getBackendConnection().getConnectionSession().getConnectionContext().getTransactionContext();
}
private List<ExecuteResult> getSaneExecuteResults(final ExecutionContext
executionContext, final SQLException originalException) throws SQLException {
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/transaction/BackendTransactionManager.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/transaction/BackendTransactionManager.java
index ebd10f731f9..d837f943e36 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/transaction/BackendTransactionManager.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/transaction/BackendTransactionManager.java
@@ -130,7 +130,7 @@ public final class BackendTransactionManager implements
TransactionManager {
}
private TransactionConnectionContext getTransactionContext() {
- return
connection.getConnectionSession().getConnectionContext().getTransactionConnectionContext();
+ return
connection.getConnectionSession().getConnectionContext().getTransactionContext();
}
@Override
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/sql/PreviewHandler.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/sql/PreviewHandler.java
index 4b57b70881f..3d4ce15c959 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/sql/PreviewHandler.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/sql/PreviewHandler.java
@@ -119,7 +119,7 @@ public final class PreviewHandler extends
SQLRULBackendHandler<PreviewStatement>
return;
}
String cursorName = ((CursorAvailable)
sqlStatementContext).getCursorName().get().getIdentifier().getValue().toLowerCase();
- CursorStatementContext cursorStatementContext =
(CursorStatementContext)
getConnectionSession().getConnectionContext().getCursorConnectionContext().getCursorDefinitions().get(cursorName);
+ CursorStatementContext cursorStatementContext =
(CursorStatementContext)
getConnectionSession().getConnectionContext().getCursorContext().getCursorDefinitions().get(cursorName);
Preconditions.checkArgument(null != cursorStatementContext, "Cursor %s
does not exist.", cursorName);
((CursorDefinitionAware)
sqlStatementContext).setUpCursorDefinition(cursorStatementContext);
}
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/transaction/TransactionXAHandler.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/transaction/TransactionXAHandler.java
index 67a535017f6..8bd35b6a91f 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/transaction/TransactionXAHandler.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/transaction/TransactionXAHandler.java
@@ -76,7 +76,7 @@ public final class TransactionXAHandler implements
ProxyBackendHandler {
*/
ShardingSpherePreconditions.checkState(!connectionSession.getTransactionStatus().isInTransaction(),
XATransactionNestedBeginException::new);
ResponseHeader header = backendHandler.execute();
-
connectionSession.getConnectionContext().getTransactionConnectionContext().setInTransaction(true);
+
connectionSession.getConnectionContext().getTransactionContext().setInTransaction(true);
return header;
case "END":
case "PREPARE":
diff --git
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/transaction/BackendTransactionManagerTest.java
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/transaction/BackendTransactionManagerTest.java
index 3b9d09dad8d..cc9a74df883 100644
---
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/transaction/BackendTransactionManagerTest.java
+++
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/transaction/BackendTransactionManagerTest.java
@@ -78,7 +78,7 @@ public final class BackendTransactionManagerTest {
ConnectionContext connectionContext = mock(ConnectionContext.class);
when(connectionSession.getConnectionContext()).thenReturn(connectionContext);
TransactionConnectionContext context = new
TransactionConnectionContext();
-
when(connectionContext.getTransactionConnectionContext()).thenReturn(context);
+ when(connectionContext.getTransactionContext()).thenReturn(context);
}
@Test
diff --git
a/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/engine/SQLRewriterIT.java
b/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/engine/SQLRewriterIT.java
index 939d7b18c52..cc044769eec 100644
---
a/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/engine/SQLRewriterIT.java
+++
b/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/engine/SQLRewriterIT.java
@@ -140,7 +140,7 @@ public abstract class SQLRewriterIT {
RouteContext routeContext = new SQLRouteEngine(databaseRules,
props).route(new ConnectionContext(), queryContext,
mock(ShardingSphereRuleMetaData.class), database);
SQLRewriteEntry sqlRewriteEntry = new SQLRewriteEntry(database, new
ShardingSphereRuleMetaData(Collections.singleton(new SQLTranslatorRule(new
SQLTranslatorRuleConfiguration()))), props);
ConnectionContext connectionContext = mock(ConnectionContext.class);
- when(connectionContext.getCursorConnectionContext()).thenReturn(new
CursorConnectionContext());
+ when(connectionContext.getCursorContext()).thenReturn(new
CursorConnectionContext());
SQLRewriteResult sqlRewriteResult =
sqlRewriteEntry.rewrite(testParams.getInputSQL(),
testParams.getInputParameters(), sqlStatementContext, routeContext,
connectionContext);
return sqlRewriteResult instanceof GenericSQLRewriteResult
? Collections.singleton(((GenericSQLRewriteResult)
sqlRewriteResult).getSqlRewriteUnit())