Skip to content

Commit b707758

Browse files
authored
Merge branch 'master' into swarm
2 parents aba519c + 8463994 commit b707758

File tree

3 files changed

+57
-6
lines changed

3 files changed

+57
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ Change Log
22
===
33
## (dev) 3.1.0 (reserverd for swarm features)
44

5+
6+
## 3.0.12
7+
- Make NettyDockerCmdExecFactory has compatibility both Linux and OSX automatically
8+
- Fix double encoding for netty.
9+
- filter config.json before unmarshalling (creds/auth)
10+
511
## 3.0.11
612
- Add labels and attachable properties to network.
713
- Set default socket timeout for RequestConfig.

pom.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<groupId>com.github.docker-java</groupId>
1111
<artifactId>docker-java</artifactId>
1212
<packaging>jar</packaging>
13-
<version>3.0.12-SNAPSHOT</version>
13+
<version>3.1.0-SNAPSHOT</version>
1414

1515
<name>docker-java</name>
1616
<url>https://github.com/docker-java/docker-java</url>
@@ -73,7 +73,7 @@
7373
<!-- test dependencies -->
7474
<logback.version>1.1.7</logback.version>
7575
<testng.version>6.9.10</testng.version>
76-
<netty.version>4.1.3.Final</netty.version>
76+
<netty.version>4.1.11.Final</netty.version>
7777
<hamcrest.library.version>1.3</hamcrest.library.version>
7878
<hamcrest.jpa-matchers>1.8</hamcrest.jpa-matchers>
7979
<lambdaj.version>2.3.3</lambdaj.version>
@@ -258,6 +258,12 @@
258258
<version>${netty.version}</version>
259259
<classifier>linux-x86_64</classifier>
260260
</dependency>
261+
<dependency>
262+
<groupId>io.netty</groupId>
263+
<artifactId>netty-transport-native-kqueue</artifactId>
264+
<version>${netty.version}</version>
265+
<classifier>osx-x86_64</classifier>
266+
</dependency>
261267
<dependency>
262268
<groupId>junit</groupId>
263269
<artifactId>junit</artifactId>

src/main/java/com/github/dockerjava/netty/NettyDockerCmdExecFactory.java

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
package com.github.dockerjava.netty;
22

3+
import static com.google.common.base.Preconditions.checkNotNull;
4+
5+
import java.io.IOException;
6+
import java.net.InetAddress;
7+
import java.net.InetSocketAddress;
8+
import java.net.SocketAddress;
9+
import java.security.Security;
10+
11+
import javax.net.ssl.SSLEngine;
12+
import javax.net.ssl.SSLParameters;
13+
14+
import org.apache.commons.lang.SystemUtils;
15+
import org.bouncycastle.jce.provider.BouncyCastleProvider;
16+
317
import com.github.dockerjava.api.command.AttachContainerCmd;
418
import com.github.dockerjava.api.command.AuthCmd;
519
import com.github.dockerjava.api.command.BuildImageCmd;
@@ -142,6 +156,8 @@
142156
import io.netty.channel.EventLoopGroup;
143157
import io.netty.channel.epoll.EpollDomainSocketChannel;
144158
import io.netty.channel.epoll.EpollEventLoopGroup;
159+
import io.netty.channel.kqueue.KQueueDomainSocketChannel;
160+
import io.netty.channel.kqueue.KQueueEventLoopGroup;
145161
import io.netty.channel.nio.NioEventLoopGroup;
146162
import io.netty.channel.socket.DuplexChannel;
147163
import io.netty.channel.socket.SocketChannel;
@@ -249,6 +265,15 @@ private interface NettyInitializer {
249265
private class UnixDomainSocketInitializer implements NettyInitializer {
250266
@Override
251267
public EventLoopGroup init(Bootstrap bootstrap, DockerClientConfig dockerClientConfig) {
268+
if (SystemUtils.IS_OS_LINUX) {
269+
return epollGroup();
270+
} else if (SystemUtils.IS_OS_MAC_OSX) {
271+
return kqueueGroup();
272+
}
273+
throw new RuntimeException("Unspported OS");
274+
}
275+
276+
public EventLoopGroup epollGroup() {
252277
EventLoopGroup epollEventLoopGroup = new EpollEventLoopGroup(0, new DefaultThreadFactory(threadPrefix));
253278

254279
ChannelFactory<EpollDomainSocketChannel> factory = new ChannelFactory<EpollDomainSocketChannel>() {
@@ -258,14 +283,28 @@ public EpollDomainSocketChannel newChannel() {
258283
}
259284
};
260285

261-
bootstrap.group(epollEventLoopGroup).channelFactory(factory)
262-
.handler(new ChannelInitializer<UnixChannel>() {
286+
bootstrap.group(epollEventLoopGroup).channelFactory(factory).handler(new ChannelInitializer<UnixChannel>() {
287+
@Override
288+
protected void initChannel(final UnixChannel channel) throws Exception {
289+
channel.pipeline().addLast(new HttpClientCodec());
290+
}
291+
});
292+
return epollEventLoopGroup;
293+
}
294+
295+
public EventLoopGroup kqueueGroup() {
296+
EventLoopGroup nioEventLoopGroup = new KQueueEventLoopGroup(0, new DefaultThreadFactory(threadPrefix));
297+
298+
bootstrap.group(nioEventLoopGroup).channel(KQueueDomainSocketChannel.class)
299+
.handler(new ChannelInitializer<KQueueDomainSocketChannel>() {
263300
@Override
264-
protected void initChannel(final UnixChannel channel) throws Exception {
301+
protected void initChannel(final KQueueDomainSocketChannel channel) throws Exception {
302+
channel.pipeline().addLast(new LoggingHandler(getClass()));
265303
channel.pipeline().addLast(new HttpClientCodec());
266304
}
267305
});
268-
return epollEventLoopGroup;
306+
307+
return nioEventLoopGroup;
269308
}
270309

271310
@Override

0 commit comments

Comments
 (0)