Add ServerBootstrap.group() that takes a single group
This commit is contained in:
parent
d298707198
commit
d3a2835503
|
@ -49,7 +49,7 @@ public class LocalEcho {
|
||||||
// Note that we can use any event loop to ensure certain local channels
|
// Note that we can use any event loop to ensure certain local channels
|
||||||
// are handled by the same event loop thread which drives a certain socket channel
|
// are handled by the same event loop thread which drives a certain socket channel
|
||||||
// to reduce the communication latency between socket channels and local channels.
|
// to reduce the communication latency between socket channels and local channels.
|
||||||
sb.group(new LocalEventLoopGroup(), new LocalEventLoopGroup())
|
sb.group(new LocalEventLoopGroup())
|
||||||
.channel(new LocalServerChannel())
|
.channel(new LocalServerChannel())
|
||||||
.localAddress(addr)
|
.localAddress(addr)
|
||||||
.handler(new ChannelInitializer<LocalServerChannel>() {
|
.handler(new ChannelInitializer<LocalServerChannel>() {
|
||||||
|
@ -67,7 +67,7 @@ public class LocalEcho {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cb.group(new NioEventLoopGroup())
|
cb.group(new NioEventLoopGroup()) // NIO event loops are also OK
|
||||||
.channel(new LocalChannel())
|
.channel(new LocalChannel())
|
||||||
.remoteAddress(addr)
|
.remoteAddress(addr)
|
||||||
.handler(new ChannelInitializer<LocalChannel>() {
|
.handler(new ChannelInitializer<LocalChannel>() {
|
||||||
|
|
|
@ -56,7 +56,7 @@ final class SocketTestPermutation {
|
||||||
public ServerBootstrap newInstance() {
|
public ServerBootstrap newInstance() {
|
||||||
AioEventLoopGroup loop = new AioEventLoopGroup();
|
AioEventLoopGroup loop = new AioEventLoopGroup();
|
||||||
return new ServerBootstrap().
|
return new ServerBootstrap().
|
||||||
group(loop, loop).
|
group(loop).
|
||||||
channel(new AioServerSocketChannel(loop));
|
channel(new AioServerSocketChannel(loop));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -63,6 +63,18 @@ public class ServerBootstrap {
|
||||||
private ChannelHandler childHandler;
|
private ChannelHandler childHandler;
|
||||||
private SocketAddress localAddress;
|
private SocketAddress localAddress;
|
||||||
|
|
||||||
|
public ServerBootstrap group(EventLoopGroup group) {
|
||||||
|
if (group == null) {
|
||||||
|
throw new NullPointerException("group");
|
||||||
|
}
|
||||||
|
if (parentGroup != null) {
|
||||||
|
throw new IllegalStateException("parentGroup set already");
|
||||||
|
}
|
||||||
|
parentGroup = group;
|
||||||
|
childGroup = group;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public ServerBootstrap group(EventLoopGroup parentGroup, EventLoopGroup childGroup) {
|
public ServerBootstrap group(EventLoopGroup parentGroup, EventLoopGroup childGroup) {
|
||||||
if (parentGroup == null) {
|
if (parentGroup == null) {
|
||||||
throw new NullPointerException("parentGroup");
|
throw new NullPointerException("parentGroup");
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class LocalChannelRegistryTest {
|
||||||
.remoteAddress(addr)
|
.remoteAddress(addr)
|
||||||
.handler(new TestHandler());
|
.handler(new TestHandler());
|
||||||
|
|
||||||
sb.group(new LocalEventLoopGroup(), new LocalEventLoopGroup())
|
sb.group(new LocalEventLoopGroup())
|
||||||
.channel(new LocalServerChannel())
|
.channel(new LocalServerChannel())
|
||||||
.localAddress(addr)
|
.localAddress(addr)
|
||||||
.childHandler(new ChannelInitializer<LocalChannel>() {
|
.childHandler(new ChannelInitializer<LocalChannel>() {
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class LocalTransportThreadModelTest {
|
||||||
public static void init() {
|
public static void init() {
|
||||||
// Configure a test server
|
// Configure a test server
|
||||||
sb = new ServerBootstrap();
|
sb = new ServerBootstrap();
|
||||||
sb.group(new LocalEventLoopGroup(), new LocalEventLoopGroup())
|
sb.group(new LocalEventLoopGroup())
|
||||||
.channel(new LocalServerChannel())
|
.channel(new LocalServerChannel())
|
||||||
.localAddress(LocalAddress.ANY)
|
.localAddress(LocalAddress.ANY)
|
||||||
.childHandler(new ChannelInitializer<LocalChannel>() {
|
.childHandler(new ChannelInitializer<LocalChannel>() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user