|
106 | 106 | import com.github.dockerjava.netty.exec.RenameContainerCmdExec; |
107 | 107 |
|
108 | 108 | import io.netty.bootstrap.Bootstrap; |
| 109 | +import io.netty.channel.Channel; |
| 110 | +import io.netty.channel.ChannelFactory; |
109 | 111 | import io.netty.channel.ChannelInitializer; |
110 | 112 | import io.netty.channel.EventLoopGroup; |
111 | 113 | import io.netty.channel.epoll.EpollDomainSocketChannel; |
|
131 | 133 | import java.net.InetAddress; |
132 | 134 | import java.net.InetSocketAddress; |
133 | 135 | import java.net.SocketAddress; |
| 136 | +import java.nio.channels.SelectionKey; |
| 137 | +import java.nio.channels.Selector; |
134 | 138 | import java.security.Security; |
135 | 139 |
|
| 140 | +import jnr.enxio.channels.NativeSelectorProvider; |
| 141 | +import jnr.unixsocket.UnixServerSocketChannel; |
| 142 | +import jnr.unixsocket.UnixSocketAddress; |
| 143 | +import jnr.unixsocket.UnixSocketChannel; |
136 | 144 | import static com.google.common.base.Preconditions.checkNotNull; |
137 | 145 |
|
138 | 146 | /** |
@@ -216,17 +224,32 @@ private interface NettyInitializer { |
216 | 224 | } |
217 | 225 |
|
218 | 226 | private class UnixDomainSocketInitializer implements NettyInitializer { |
| 227 | + |
| 228 | + final java.io.File path = new java.io.File("/var/run/docker.sock"); |
| 229 | + |
219 | 230 | @Override |
220 | 231 | public EventLoopGroup init(Bootstrap bootstrap, DockerClientConfig dockerClientConfig) { |
221 | | - EventLoopGroup epollEventLoopGroup = new EpollEventLoopGroup(0, new DefaultThreadFactory(threadPrefix)); |
222 | | - bootstrap.group(epollEventLoopGroup).channel(EpollDomainSocketChannel.class) |
223 | | - .handler(new ChannelInitializer<UnixChannel>() { |
| 232 | + |
| 233 | + EventLoopGroup nioEventLoopGroup = new NioEventLoopGroup(0, new DefaultThreadFactory(threadPrefix), NativeSelectorProvider.getInstance()); |
| 234 | + |
| 235 | + ChannelFactory<NioSocketChannel> factory = new ChannelFactory<NioSocketChannel>() { |
| 236 | + |
| 237 | + @Override |
| 238 | + public NioSocketChannel newChannel() { |
| 239 | + unisockets.SocketChannel socketChannel = unisockets.SocketChannel.open(path); |
| 240 | + return new NioSocketChannel(socketChannel); |
| 241 | + } |
| 242 | + }; |
| 243 | + |
| 244 | + bootstrap.group(nioEventLoopGroup).channelFactory(factory) |
| 245 | + .handler(new ChannelInitializer<SocketChannel>() { |
224 | 246 | @Override |
225 | | - protected void initChannel(final UnixChannel channel) throws Exception { |
| 247 | + protected void initChannel(final SocketChannel channel) throws Exception { |
226 | 248 | channel.pipeline().addLast(new HttpClientCodec()); |
227 | 249 | } |
228 | 250 | }); |
229 | | - return epollEventLoopGroup; |
| 251 | + |
| 252 | + return nioEventLoopGroup; |
230 | 253 | } |
231 | 254 |
|
232 | 255 | @Override |
|
0 commit comments