54
54
import io .micrometer .core .instrument .Tag ;
55
55
import io .micrometer .core .instrument .Tags ;
56
56
import io .micrometer .core .instrument .composite .CompositeMeterRegistry ;
57
+ import io .netty .bootstrap .Bootstrap ;
57
58
import io .netty .buffer .ByteBufAllocator ;
58
59
import io .netty .buffer .ByteBufAllocatorMetric ;
59
60
import io .netty .buffer .ByteBufAllocatorMetricProvider ;
60
61
import io .netty .channel .EventLoopGroup ;
62
+ import io .netty .channel .epoll .EpollEventLoopGroup ;
63
+ import io .netty .channel .epoll .EpollSocketChannel ;
61
64
import io .netty .channel .nio .NioEventLoopGroup ;
62
65
import io .netty .handler .ssl .SslContextBuilder ;
63
66
import io .netty .handler .ssl .SslHandler ;
@@ -441,6 +444,12 @@ public void setMaxSegmentSize(ByteCapacity in) {
441
444
converter = Utils .ByteCapacityTypeConverter .class )
442
445
private ByteCapacity requestedMaxFrameSize ;
443
446
447
+ @ CommandLine .Option (
448
+ names = {"--native-epoll" , "-ne" },
449
+ description = "use Netty's native epoll transport (Linux x86-64 only)" ,
450
+ defaultValue = "false" )
451
+ private boolean nativeEpoll ;
452
+
444
453
private MetricsCollector metricsCollector ;
445
454
private PerformanceMetrics performanceMetrics ;
446
455
private List <Monitoring > monitorings ;
@@ -664,7 +673,14 @@ public Integer call() throws Exception {
664
673
}
665
674
}
666
675
667
- this .eventLoopGroup = new NioEventLoopGroup ();
676
+ java .util .function .Consumer <Bootstrap > bootstrapCustomizer ;
677
+ if (this .nativeEpoll ) {
678
+ this .eventLoopGroup = new EpollEventLoopGroup ();
679
+ bootstrapCustomizer = b -> b .channel (EpollSocketChannel .class );
680
+ } else {
681
+ this .eventLoopGroup = new NioEventLoopGroup ();
682
+ bootstrapCustomizer = b -> {};
683
+ }
668
684
669
685
EnvironmentBuilder environmentBuilder =
670
686
Environment .builder ()
@@ -676,6 +692,7 @@ public Integer call() throws Exception {
676
692
.netty ()
677
693
.byteBufAllocator (byteBufAllocator )
678
694
.eventLoopGroup (eventLoopGroup )
695
+ .bootstrapCustomizer (bootstrapCustomizer )
679
696
.environmentBuilder ()
680
697
.codec (codec )
681
698
.maxProducersByConnection (this .producersByConnection )
0 commit comments