[ 
https://issues.apache.org/jira/browse/QPIDJMS-553?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17502385#comment-17502385
 ] 

ASF GitHub Bot commented on QPIDJMS-553:
----------------------------------------

franz1981 commented on a change in pull request #45:
URL: https://github.com/apache/qpid-jms/pull/45#discussion_r820861231



##########
File path: 
qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/netty/NettyEventLoopGroupFactory.java
##########
@@ -0,0 +1,288 @@
+/*
+ * 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.qpid.jms.transports.netty;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.util.concurrent.Future;
+import org.apache.qpid.jms.transports.TransportOptions;
+import org.apache.qpid.jms.util.QpidJMSThreadFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class NettyEventLoopGroupFactory {
+
+   private NettyEventLoopGroupFactory() {
+
+   }
+
+   public interface Ref<T> extends AutoCloseable {
+
+      T ref();
+
+      @Override
+      void close();
+   }
+
+   public interface EventLoopGroupRef extends Ref<EventLoopGroup> {
+
+      EventLoopType type();
+   }
+
+   private static final Logger LOG = 
LoggerFactory.getLogger(NettyEventLoopGroupFactory.class);
+   private static final AtomicLong SHARED_EVENT_LOOP_GROUP_INSTANCE_SEQUENCE = 
new AtomicLong(0);
+   private static final int SHUTDOWN_TIMEOUT = 50;
+
+   public enum EventLoopType {
+      EPOLL, KQUEUE, NIO;
+
+      static EventLoopType valueOf(final TransportOptions transportOptions) {
+         final boolean useKQueue = KQueueSupport.isAvailable(transportOptions);
+         final boolean useEpoll = EpollSupport.isAvailable(transportOptions);
+         if (useKQueue) {
+            return KQUEUE;
+         }
+         if (useEpoll) {
+            return EPOLL;
+         }
+         return NIO;
+      }
+   }
+
+   private static QpidJMSThreadFactory createSharedQpidJMSThreadFactory(final 
EventLoopType type, final int threads) {
+      return new QpidJMSThreadFactory("SharedNettyEventLoopGroup " + type + 
":( threads = " + threads + " - id = " + 
SHARED_EVENT_LOOP_GROUP_INSTANCE_SEQUENCE.incrementAndGet() + ")", true);

Review comment:
       uh sorry, I'll fix this now




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


> Shared Netty event loop group
> -----------------------------
>
>                 Key: QPIDJMS-553
>                 URL: https://issues.apache.org/jira/browse/QPIDJMS-553
>             Project: Qpid JMS
>          Issue Type: New Feature
>            Reporter: Francesco Nigro
>            Priority: Major
>
> One of the most interesting feature of Netty while using KQueue/NIO/Epoll in 
> non-blocking mode is to be able to handle many connections with few threads; 
> this is going to be critical and even more important with the upcoming 
> IO_URING support, where the time spent on the Netty event loop to handle 
> network syscalls will be further reduced, allowing syscall batching across 
> different connections.
> Having the chance to handle many client connections with few Netty threads is 
> already beneficial in constrained environments (containers with few cores) in 
> order to reduce the native and heap memory usage.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

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

Reply via email to