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 2021/10/29 09:09:55 UTC
[shardingsphere] branch master updated: Revise #12863 for code
style (#13350)
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 5174a71 Revise #12863 for code style (#13350)
5174a71 is described below
commit 5174a713df477627f80fe9310583c97f40bc5e64
Author: 吴伟杰 <wu...@apache.org>
AuthorDate: Fri Oct 29 17:09:18 2021 +0800
Revise #12863 for code style (#13350)
* Revise #12863 for code style
* Fix checkstyle
---
.../proxy/frontend/state/impl/OKProxyState.java | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyState.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyState.java
index 52efc97..ee7f999 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyState.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyState.java
@@ -38,17 +38,23 @@ public final class OKProxyState implements ProxyState {
@Override
public void execute(final ChannelHandlerContext context, final Object message, final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine, final BackendConnection backendConnection) {
CommandExecutorTask commandExecutorTask = new CommandExecutorTask(databaseProtocolFrontendEngine, backendConnection, context, message);
- ExecutorService executorService;
+ ExecutorService executorService = determineSuitableExecutorService(context, databaseProtocolFrontendEngine, backendConnection);
+ executorService.execute(commandExecutorTask);
+ }
+
+ private ExecutorService determineSuitableExecutorService(final ChannelHandlerContext context, final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine,
+ final BackendConnection backendConnection) {
+ ExecutorService result;
if (requireOccupyThreadForConnection(backendConnection)) {
- executorService = ConnectionThreadExecutorGroup.getInstance().get(backendConnection.getConnectionId());
+ result = ConnectionThreadExecutorGroup.getInstance().get(backendConnection.getConnectionId());
} else if (isPreferNettyEventLoop()) {
- executorService = context.executor();
+ result = context.executor();
} else if (databaseProtocolFrontendEngine.getFrontendContext().isRequiredSameThreadForConnection()) {
- executorService = ConnectionThreadExecutorGroup.getInstance().get(backendConnection.getConnectionId());
+ result = ConnectionThreadExecutorGroup.getInstance().get(backendConnection.getConnectionId());
} else {
- executorService = UserExecutorGroup.getInstance().getExecutorService();
+ result = UserExecutorGroup.getInstance().getExecutorService();
}
- executorService.execute(commandExecutorTask);
+ return result;
}
private boolean requireOccupyThreadForConnection(final BackendConnection backendConnection) {