infearOnTheWay commented on a change in pull request #2603: Add nio support for 
mysql protocol implementation
URL: https://github.com/apache/incubator-doris/pull/2603#discussion_r361951114
 
 

 ##########
 File path: fe/src/main/java/org/apache/doris/mysql/nio/ReadListener.java
 ##########
 @@ -0,0 +1,66 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.doris.mysql.nio;
+
+import org.apache.doris.qe.ConnectContext;
+import org.apache.doris.qe.ConnectProcessor;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.xnio.ChannelListener;
+import org.xnio.XnioIoThread;
+import org.xnio.conduits.ConduitStreamSourceChannel;
+
+/**
+ * Created by infear on 2019/12/20.
+ */
+public class ReadListener implements 
ChannelListener<ConduitStreamSourceChannel> {
+    private final Logger LOG = LogManager.getLogger(this.getClass());
+    private NConnectContext ctx;
+    private ConnectProcessor connectProcessor;
+
+    public ReadListener(NConnectContext nConnectContext, ConnectProcessor 
connectProcessor) {
+        this.ctx = nConnectContext;
+        this.connectProcessor = connectProcessor;
+    }
+
+    @Override
+    public void handleEvent(ConduitStreamSourceChannel channel) {
+        // suspend must be call sync in current thread (the IO-Thread notify 
the read event),
+        // otherwise multi handler(task thread) would be waked up by once 
query.
+        XnioIoThread.requireCurrentThread();
+        ctx.suspendAcceptQuery();
+        // start async query handle in task thread.
+        channel.getWorker().execute(() -> {
 
 Review comment:
   @lingbin @imay 
   After discussion with @imay, according to the case in doris, it woud be 
better to use a cahceThreadPool instead of fixed-size(16) thread pool mentioned 
above. I would optimize this part and also try to make users be able to inject 
customized thread pool. It should be more flexible.
   Thanks for your advice!
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to