28
28
import io .netty .channel .ChannelInitializer ;
29
29
import io .netty .channel .ChannelOption ;
30
30
import io .netty .channel .EventLoopGroup ;
31
+ import io .netty .channel .epoll .EpollDomainSocketChannel ;
31
32
import io .netty .channel .group .ChannelGroup ;
32
33
import io .netty .channel .socket .nio .NioSocketChannel ;
33
34
import java .net .SocketAddress ;
34
35
import java .util .concurrent .ScheduledExecutorService ;
35
36
import javax .net .ssl .SSLContext ;
36
37
import javax .net .ssl .SSLParameters ;
38
+ import org .apache .commons .lang3 .StringUtils ;
39
+
37
40
38
41
/**
39
42
* Factory class to produce {@link AsyncPool}<{@link Channel}> for Http Channels
@@ -53,7 +56,9 @@ public class HttpChannelPoolFactory implements ChannelPoolFactory
53
56
private final ScheduledExecutorService _scheduler ;
54
57
private final AsyncPoolImpl .Strategy _strategy ;
55
58
private int _channelPoolWaiterTimeout ;
59
+ private final String _udsAddress ;
56
60
61
+ @ Deprecated
57
62
public HttpChannelPoolFactory (
58
63
ScheduledExecutorService scheduler ,
59
64
EventLoopGroup eventLoopGroup ,
@@ -76,7 +81,36 @@ public HttpChannelPoolFactory(
76
81
int connectTimeout ,
77
82
int sslHandShakeTimeout )
78
83
{
79
- ChannelInitializer <NioSocketChannel > initializer = new HttpChannelInitializer (sslContext , sslParameters ,
84
+ this ( scheduler , eventLoopGroup , channelGroup , strategy , sslContext , sslParameters , maxPoolSize ,
85
+ minPoolSize , maxPoolWaiterSize , maxInitialLineLength , maxHeaderSize , maxChunkSize ,
86
+ maxConcurrentConnectionInitializations , idleTimeout , maxContentLength , tcpNoDelay , enableSSLSessionResumption ,
87
+ channelPoolWaiterTimeout , connectTimeout , sslHandShakeTimeout , null );
88
+ }
89
+
90
+ public HttpChannelPoolFactory (
91
+ ScheduledExecutorService scheduler ,
92
+ EventLoopGroup eventLoopGroup ,
93
+ ChannelGroup channelGroup ,
94
+ AsyncPoolImpl .Strategy strategy ,
95
+ SSLContext sslContext ,
96
+ SSLParameters sslParameters ,
97
+ int maxPoolSize ,
98
+ int minPoolSize ,
99
+ int maxPoolWaiterSize ,
100
+ int maxInitialLineLength ,
101
+ int maxHeaderSize ,
102
+ int maxChunkSize ,
103
+ int maxConcurrentConnectionInitializations ,
104
+ long idleTimeout ,
105
+ long maxContentLength ,
106
+ boolean tcpNoDelay ,
107
+ boolean enableSSLSessionResumption ,
108
+ int channelPoolWaiterTimeout ,
109
+ int connectTimeout ,
110
+ int sslHandShakeTimeout ,
111
+ String udsAddress )
112
+ {
113
+ ChannelInitializer <Channel > initializer = new HttpChannelInitializer (sslContext , sslParameters ,
80
114
maxInitialLineLength , maxHeaderSize , maxChunkSize , maxContentLength , enableSSLSessionResumption , sslHandShakeTimeout );
81
115
82
116
_scheduler = scheduler ;
@@ -89,9 +123,22 @@ public HttpChannelPoolFactory(
89
123
_idleTimeout = idleTimeout ;
90
124
_tcpNoDelay = tcpNoDelay ;
91
125
_channelPoolWaiterTimeout = channelPoolWaiterTimeout ;
126
+ _udsAddress = udsAddress ;
92
127
93
- _bootstrap = new Bootstrap ().group (eventLoopGroup ).channel (NioSocketChannel .class ).
94
- option (ChannelOption .CONNECT_TIMEOUT_MILLIS , connectTimeout ).handler (initializer );
128
+ if (!StringUtils .isEmpty (_udsAddress )) {
129
+ _bootstrap = new Bootstrap ()
130
+ .group (eventLoopGroup )
131
+ .channel (EpollDomainSocketChannel .class )
132
+ .option (ChannelOption .CONNECT_TIMEOUT_MILLIS , connectTimeout )
133
+ .handler (initializer );
134
+ }
135
+ else {
136
+ _bootstrap = new Bootstrap ()
137
+ .group (eventLoopGroup )
138
+ .channel (NioSocketChannel .class )
139
+ .option (ChannelOption .CONNECT_TIMEOUT_MILLIS , connectTimeout )
140
+ .handler (initializer );
141
+ }
95
142
}
96
143
97
144
@ Override
0 commit comments