Revert "Using native transport (epoll) with netty"
This reverts commit f22f2043. - It did not run inside karaf Change-Id: Ieab6684bbde1029ad53337e9a4ee03623c2e6ab7
Showing
1 changed file
with
6 additions
and
20 deletions
| ... | @@ -16,11 +16,7 @@ import io.netty.channel.ChannelHandlerContext; | ... | @@ -16,11 +16,7 @@ import io.netty.channel.ChannelHandlerContext; |
| 16 | import io.netty.channel.ChannelInitializer; | 16 | import io.netty.channel.ChannelInitializer; |
| 17 | import io.netty.channel.ChannelOption; | 17 | import io.netty.channel.ChannelOption; |
| 18 | import io.netty.channel.EventLoopGroup; | 18 | import io.netty.channel.EventLoopGroup; |
| 19 | -import io.netty.channel.ServerChannel; | ||
| 20 | import io.netty.channel.SimpleChannelInboundHandler; | 19 | import io.netty.channel.SimpleChannelInboundHandler; |
| 21 | -import io.netty.channel.epoll.EpollEventLoopGroup; | ||
| 22 | -import io.netty.channel.epoll.EpollServerSocketChannel; | ||
| 23 | -import io.netty.channel.epoll.EpollSocketChannel; | ||
| 24 | import io.netty.channel.nio.NioEventLoopGroup; | 20 | import io.netty.channel.nio.NioEventLoopGroup; |
| 25 | import io.netty.channel.socket.SocketChannel; | 21 | import io.netty.channel.socket.SocketChannel; |
| 26 | import io.netty.channel.socket.nio.NioServerSocketChannel; | 22 | import io.netty.channel.socket.nio.NioServerSocketChannel; |
| ... | @@ -44,10 +40,9 @@ public class NettyMessagingService implements MessagingService { | ... | @@ -44,10 +40,9 @@ public class NettyMessagingService implements MessagingService { |
| 44 | 40 | ||
| 45 | private final int port; | 41 | private final int port; |
| 46 | private final Endpoint localEp; | 42 | private final Endpoint localEp; |
| 47 | - private EventLoopGroup bossGroup; | 43 | + private final EventLoopGroup bossGroup = new NioEventLoopGroup(); |
| 48 | private EventLoopGroup workerGroup; | 44 | private EventLoopGroup workerGroup; |
| 49 | - private Class<? extends Channel> clientChannelClass; | 45 | + private Class<? extends Channel> channelClass; |
| 50 | - private Class<? extends ServerChannel> serverChannelClass; | ||
| 51 | private final ConcurrentMap<String, MessageHandler> handlers = new ConcurrentHashMap<>(); | 46 | private final ConcurrentMap<String, MessageHandler> handlers = new ConcurrentHashMap<>(); |
| 52 | private final Cache<Long, AsyncResponse> responseFutures = CacheBuilder.newBuilder() | 47 | private final Cache<Long, AsyncResponse> responseFutures = CacheBuilder.newBuilder() |
| 53 | .maximumSize(100000) | 48 | .maximumSize(100000) |
| ... | @@ -60,17 +55,8 @@ public class NettyMessagingService implements MessagingService { | ... | @@ -60,17 +55,8 @@ public class NettyMessagingService implements MessagingService { |
| 60 | 55 | ||
| 61 | // TODO: make this configurable. | 56 | // TODO: make this configurable. |
| 62 | private void initEventLoopGroup() { | 57 | private void initEventLoopGroup() { |
| 63 | - try { | 58 | + workerGroup = new NioEventLoopGroup(); |
| 64 | - bossGroup = new EpollEventLoopGroup(); | 59 | + channelClass = NioSocketChannel.class; |
| 65 | - workerGroup = new EpollEventLoopGroup(); | ||
| 66 | - clientChannelClass = EpollSocketChannel.class; | ||
| 67 | - serverChannelClass = EpollServerSocketChannel.class; | ||
| 68 | - } catch (Throwable th) { | ||
| 69 | - bossGroup = new NioEventLoopGroup(); | ||
| 70 | - workerGroup = new NioEventLoopGroup(); | ||
| 71 | - serverChannelClass = NioServerSocketChannel.class; | ||
| 72 | - clientChannelClass = NioSocketChannel.class; | ||
| 73 | - } | ||
| 74 | } | 60 | } |
| 75 | 61 | ||
| 76 | public NettyMessagingService() { | 62 | public NettyMessagingService() { |
| ... | @@ -164,7 +150,7 @@ public class NettyMessagingService implements MessagingService { | ... | @@ -164,7 +150,7 @@ public class NettyMessagingService implements MessagingService { |
| 164 | // TODO: Need JVM options to configure PooledByteBufAllocator. | 150 | // TODO: Need JVM options to configure PooledByteBufAllocator. |
| 165 | b.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); | 151 | b.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); |
| 166 | b.group(bossGroup, workerGroup) | 152 | b.group(bossGroup, workerGroup) |
| 167 | - .channel(serverChannelClass) | 153 | + .channel(NioServerSocketChannel.class) |
| 168 | .childHandler(new OnosCommunicationChannelInitializer()) | 154 | .childHandler(new OnosCommunicationChannelInitializer()) |
| 169 | .option(ChannelOption.SO_BACKLOG, 128) | 155 | .option(ChannelOption.SO_BACKLOG, 128) |
| 170 | .childOption(ChannelOption.SO_KEEPALIVE, true); | 156 | .childOption(ChannelOption.SO_KEEPALIVE, true); |
| ... | @@ -195,7 +181,7 @@ public class NettyMessagingService implements MessagingService { | ... | @@ -195,7 +181,7 @@ public class NettyMessagingService implements MessagingService { |
| 195 | bootstrap.group(workerGroup); | 181 | bootstrap.group(workerGroup); |
| 196 | // TODO: Make this faster: | 182 | // TODO: Make this faster: |
| 197 | // http://normanmaurer.me/presentations/2014-facebook-eng-netty/slides.html#37.0 | 183 | // http://normanmaurer.me/presentations/2014-facebook-eng-netty/slides.html#37.0 |
| 198 | - bootstrap.channel(clientChannelClass); | 184 | + bootstrap.channel(channelClass); |
| 199 | bootstrap.option(ChannelOption.SO_KEEPALIVE, true); | 185 | bootstrap.option(ChannelOption.SO_KEEPALIVE, true); |
| 200 | bootstrap.handler(new OnosCommunicationChannelInitializer()); | 186 | bootstrap.handler(new OnosCommunicationChannelInitializer()); |
| 201 | // Start the client. | 187 | // Start the client. | ... | ... |
-
Please register or login to post a comment