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 c8c613a71ff Refactor code style for ShardingSphereProxy (#25281)
c8c613a71ff is described below

commit c8c613a71ff4c3c7d6e165e96d6918b1a0c7c6c1
Author: 吴伟杰 <[email protected]>
AuthorDate: Sun Apr 23 10:09:49 2023 +0800

    Refactor code style for ShardingSphereProxy (#25281)
---
 .../proxy/frontend/ShardingSphereProxy.java        | 23 +++++++++-------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git 
a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/ShardingSphereProxy.java
 
b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/ShardingSphereProxy.java
index 8e2fe6e7722..5622e84cc22 100644
--- 
a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/ShardingSphereProxy.java
+++ 
b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/ShardingSphereProxy.java
@@ -50,15 +50,21 @@ import java.util.List;
 @Slf4j
 public final class ShardingSphereProxy {
     
-    private EventLoopGroup bossGroup;
+    private final EventLoopGroup bossGroup;
     
-    private EventLoopGroup workerGroup;
+    private final EventLoopGroup workerGroup;
     
     public ShardingSphereProxy() {
-        createEventLoopGroup();
+        bossGroup = Epoll.isAvailable() ? new EpollEventLoopGroup(1) : new 
NioEventLoopGroup(1);
+        workerGroup = getWorkerGroup();
         Runtime.getRuntime().addShutdownHook(new Thread(this::close));
     }
     
+    private EventLoopGroup getWorkerGroup() {
+        int workerThreads = 
ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps().<Integer>getValue(ConfigurationPropertyKey.PROXY_FRONTEND_EXECUTOR_SIZE);
+        return Epoll.isAvailable() ? new EpollEventLoopGroup(workerThreads) : 
new NioEventLoopGroup(workerThreads);
+    }
+    
     /**
      * Start ShardingSphere-Proxy.
      *
@@ -91,7 +97,6 @@ public final class ShardingSphereProxy {
                 log.info("The listening address for DomainSocket is {}", 
socketPath);
             } else {
                 log.error("DomainSocket failed to start:{}", 
futureParams.cause().getMessage());
-                futureParams.cause().printStackTrace();
             }
         });
     }
@@ -119,16 +124,6 @@ public final class ShardingSphereProxy {
         }
     }
     
-    private void createEventLoopGroup() {
-        bossGroup = Epoll.isAvailable() ? new EpollEventLoopGroup(1) : new 
NioEventLoopGroup(1);
-        workerGroup = getWorkerGroup();
-    }
-    
-    private EventLoopGroup getWorkerGroup() {
-        int workerThreads = 
ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps().<Integer>getValue(ConfigurationPropertyKey.PROXY_FRONTEND_EXECUTOR_SIZE);
-        return Epoll.isAvailable() ? new EpollEventLoopGroup(workerThreads) : 
new NioEventLoopGroup(workerThreads);
-    }
-    
     private void initServerBootstrap(final ServerBootstrap bootstrap) {
         Integer backLog = 
ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps().<Integer>getValue(ConfigurationPropertyKey.PROXY_NETTY_BACKLOG);
         bootstrap.group(bossGroup, workerGroup)

Reply via email to