Thomas Vachuska | 24c849c | 2014-10-27 09:53:05 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 19 | package org.onlab.netty; |
| 20 | |
| 21 | import java.io.IOException; |
| 22 | import java.net.UnknownHostException; |
| 23 | import java.util.concurrent.ConcurrentHashMap; |
| 24 | import java.util.concurrent.ConcurrentMap; |
| 25 | import java.util.concurrent.TimeUnit; |
Madan Jampani | 24f9efb | 2014-10-24 18:56:23 -0700 | [diff] [blame] | 26 | import java.util.concurrent.atomic.AtomicLong; |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 27 | |
| 28 | import io.netty.bootstrap.Bootstrap; |
| 29 | import io.netty.bootstrap.ServerBootstrap; |
| 30 | import io.netty.buffer.PooledByteBufAllocator; |
| 31 | import io.netty.channel.Channel; |
| 32 | import io.netty.channel.ChannelFuture; |
Madan Jampani | ddf7622 | 2014-10-04 23:48:44 -0700 | [diff] [blame] | 33 | import io.netty.channel.ChannelHandler; |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 34 | import io.netty.channel.ChannelHandlerContext; |
| 35 | import io.netty.channel.ChannelInitializer; |
| 36 | import io.netty.channel.ChannelOption; |
| 37 | import io.netty.channel.EventLoopGroup; |
Madan Jampani | 824a7c1 | 2014-10-21 09:46:15 -0700 | [diff] [blame] | 38 | import io.netty.channel.ServerChannel; |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 39 | import io.netty.channel.SimpleChannelInboundHandler; |
Madan Jampani | 824a7c1 | 2014-10-21 09:46:15 -0700 | [diff] [blame] | 40 | import io.netty.channel.epoll.EpollEventLoopGroup; |
| 41 | import io.netty.channel.epoll.EpollServerSocketChannel; |
| 42 | import io.netty.channel.epoll.EpollSocketChannel; |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 43 | import io.netty.channel.nio.NioEventLoopGroup; |
| 44 | import io.netty.channel.socket.SocketChannel; |
| 45 | import io.netty.channel.socket.nio.NioServerSocketChannel; |
| 46 | import io.netty.channel.socket.nio.NioSocketChannel; |
| 47 | |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 48 | import org.apache.commons.pool.KeyedPoolableObjectFactory; |
| 49 | import org.apache.commons.pool.impl.GenericKeyedObjectPool; |
| 50 | import org.slf4j.Logger; |
| 51 | import org.slf4j.LoggerFactory; |
| 52 | |
| 53 | import com.google.common.cache.Cache; |
| 54 | import com.google.common.cache.CacheBuilder; |
Madan Jampani | 24f9efb | 2014-10-24 18:56:23 -0700 | [diff] [blame] | 55 | import com.google.common.util.concurrent.ListenableFuture; |
| 56 | import com.google.common.util.concurrent.SettableFuture; |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 57 | |
| 58 | /** |
| 59 | * A Netty based implementation of MessagingService. |
| 60 | */ |
| 61 | public class NettyMessagingService implements MessagingService { |
| 62 | |
| 63 | private final Logger log = LoggerFactory.getLogger(getClass()); |
| 64 | |
Madan Jampani | ddf7622 | 2014-10-04 23:48:44 -0700 | [diff] [blame] | 65 | private final Endpoint localEp; |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 66 | private final ConcurrentMap<String, MessageHandler> handlers = new ConcurrentHashMap<>(); |
Madan Jampani | 24f9efb | 2014-10-24 18:56:23 -0700 | [diff] [blame] | 67 | private final AtomicLong messageIdGenerator = new AtomicLong(0); |
| 68 | private final Cache<Long, SettableFuture<byte[]>> responseFutures = CacheBuilder.newBuilder() |
Madan Jampani | ddf7622 | 2014-10-04 23:48:44 -0700 | [diff] [blame] | 69 | .maximumSize(100000) |
Madan Jampani | ddf7622 | 2014-10-04 23:48:44 -0700 | [diff] [blame] | 70 | // TODO: Once the entry expires, notify blocking threads (if any). |
| 71 | .expireAfterWrite(10, TimeUnit.MINUTES) |
| 72 | .build(); |
| 73 | private final GenericKeyedObjectPool<Endpoint, Channel> channels |
| 74 | = new GenericKeyedObjectPool<Endpoint, Channel>(new OnosCommunicationChannelFactory()); |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 75 | |
Madan Jampani | 824a7c1 | 2014-10-21 09:46:15 -0700 | [diff] [blame] | 76 | private EventLoopGroup serverGroup; |
| 77 | private EventLoopGroup clientGroup; |
| 78 | private Class<? extends ServerChannel> serverChannelClass; |
| 79 | private Class<? extends Channel> clientChannelClass; |
| 80 | |
Madan Jampani | 5e83f33 | 2014-10-20 15:35:09 -0700 | [diff] [blame] | 81 | private void initEventLoopGroup() { |
Madan Jampani | 824a7c1 | 2014-10-21 09:46:15 -0700 | [diff] [blame] | 82 | // try Epoll first and if that does work, use nio. |
| 83 | // TODO: make this configurable. |
| 84 | try { |
Madan Jampani | 99e9fe2 | 2014-10-21 13:47:12 -0700 | [diff] [blame] | 85 | clientGroup = new EpollEventLoopGroup(); |
| 86 | serverGroup = new EpollEventLoopGroup(); |
| 87 | serverChannelClass = EpollServerSocketChannel.class; |
| 88 | clientChannelClass = EpollSocketChannel.class; |
| 89 | return; |
Madan Jampani | 824a7c1 | 2014-10-21 09:46:15 -0700 | [diff] [blame] | 90 | } catch (Throwable t) { |
Madan Jampani | cfbc054 | 2014-10-24 20:38:07 -0700 | [diff] [blame] | 91 | log.warn("Failed to initialize native (epoll) transport. Reason: {}. Proceeding with nio.", t.getMessage()); |
Madan Jampani | 824a7c1 | 2014-10-21 09:46:15 -0700 | [diff] [blame] | 92 | } |
| 93 | clientGroup = new NioEventLoopGroup(); |
| 94 | serverGroup = new NioEventLoopGroup(); |
| 95 | serverChannelClass = NioServerSocketChannel.class; |
| 96 | clientChannelClass = NioSocketChannel.class; |
Madan Jampani | 5e83f33 | 2014-10-20 15:35:09 -0700 | [diff] [blame] | 97 | } |
| 98 | |
Madan Jampani | 8710093 | 2014-10-21 16:46:12 -0700 | [diff] [blame] | 99 | public NettyMessagingService(String ip, int port) { |
| 100 | localEp = new Endpoint(ip, port); |
| 101 | } |
| 102 | |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 103 | public NettyMessagingService() { |
| 104 | // TODO: Default port should be configurable. |
| 105 | this(8080); |
| 106 | } |
| 107 | |
| 108 | // FIXME: Constructor should not throw exceptions. |
| 109 | public NettyMessagingService(int port) { |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 110 | try { |
| 111 | localEp = new Endpoint(java.net.InetAddress.getLocalHost().getHostName(), port); |
| 112 | } catch (UnknownHostException e) { |
| 113 | // bailing out. |
| 114 | throw new RuntimeException(e); |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | public void activate() throws Exception { |
Madan Jampani | 86ed055 | 2014-10-03 16:45:42 -0700 | [diff] [blame] | 119 | channels.setTestOnBorrow(true); |
| 120 | channels.setTestOnReturn(true); |
Madan Jampani | 5e83f33 | 2014-10-20 15:35:09 -0700 | [diff] [blame] | 121 | initEventLoopGroup(); |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 122 | startAcceptingConnections(); |
| 123 | } |
| 124 | |
| 125 | public void deactivate() throws Exception { |
| 126 | channels.close(); |
Madan Jampani | 824a7c1 | 2014-10-21 09:46:15 -0700 | [diff] [blame] | 127 | serverGroup.shutdownGracefully(); |
| 128 | clientGroup.shutdownGracefully(); |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 129 | } |
| 130 | |
Madan Jampani | 8710093 | 2014-10-21 16:46:12 -0700 | [diff] [blame] | 131 | /** |
| 132 | * Returns the local endpoint for this instance. |
| 133 | * @return local end point. |
| 134 | */ |
| 135 | public Endpoint localEp() { |
| 136 | return localEp; |
| 137 | } |
| 138 | |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 139 | @Override |
Madan Jampani | 53e44e6 | 2014-10-07 12:39:51 -0700 | [diff] [blame] | 140 | public void sendAsync(Endpoint ep, String type, byte[] payload) throws IOException { |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 141 | InternalMessage message = new InternalMessage.Builder(this) |
Madan Jampani | 24f9efb | 2014-10-24 18:56:23 -0700 | [diff] [blame] | 142 | .withId(messageIdGenerator.incrementAndGet()) |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 143 | .withSender(localEp) |
| 144 | .withType(type) |
| 145 | .withPayload(payload) |
| 146 | .build(); |
| 147 | sendAsync(ep, message); |
| 148 | } |
| 149 | |
| 150 | protected void sendAsync(Endpoint ep, InternalMessage message) throws IOException { |
| 151 | Channel channel = null; |
| 152 | try { |
Madan Jampani | 86ed055 | 2014-10-03 16:45:42 -0700 | [diff] [blame] | 153 | try { |
| 154 | channel = channels.borrowObject(ep); |
| 155 | channel.eventLoop().execute(new WriteTask(channel, message)); |
| 156 | } finally { |
| 157 | channels.returnObject(ep, channel); |
| 158 | } |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 159 | } catch (Exception e) { |
Madan Jampani | 8710093 | 2014-10-21 16:46:12 -0700 | [diff] [blame] | 160 | throw new IOException("Failed to send message to " + ep.toString(), e); |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 161 | } |
| 162 | } |
| 163 | |
| 164 | @Override |
Madan Jampani | 24f9efb | 2014-10-24 18:56:23 -0700 | [diff] [blame] | 165 | public ListenableFuture<byte[]> sendAndReceive(Endpoint ep, String type, byte[] payload) |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 166 | throws IOException { |
Madan Jampani | 24f9efb | 2014-10-24 18:56:23 -0700 | [diff] [blame] | 167 | SettableFuture<byte[]> futureResponse = SettableFuture.create(); |
| 168 | Long messageId = messageIdGenerator.incrementAndGet(); |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 169 | responseFutures.put(messageId, futureResponse); |
| 170 | InternalMessage message = new InternalMessage.Builder(this) |
| 171 | .withId(messageId) |
| 172 | .withSender(localEp) |
| 173 | .withType(type) |
| 174 | .withPayload(payload) |
| 175 | .build(); |
Madan Jampani | 15cd0b8 | 2014-10-28 08:40:23 -0700 | [diff] [blame] | 176 | try { |
| 177 | sendAsync(ep, message); |
| 178 | } catch (IOException e) { |
| 179 | responseFutures.invalidate(messageId); |
| 180 | throw e; |
| 181 | } |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 182 | return futureResponse; |
| 183 | } |
| 184 | |
| 185 | @Override |
| 186 | public void registerHandler(String type, MessageHandler handler) { |
| 187 | // TODO: Is this the right semantics for handler registration? |
| 188 | handlers.putIfAbsent(type, handler); |
| 189 | } |
| 190 | |
Yuta HIGUCHI | e5ca93b | 2014-10-23 09:49:00 -0700 | [diff] [blame] | 191 | @Override |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 192 | public void unregisterHandler(String type) { |
| 193 | handlers.remove(type); |
| 194 | } |
| 195 | |
| 196 | private MessageHandler getMessageHandler(String type) { |
| 197 | return handlers.get(type); |
| 198 | } |
| 199 | |
| 200 | private void startAcceptingConnections() throws InterruptedException { |
| 201 | ServerBootstrap b = new ServerBootstrap(); |
Madan Jampani | 86ed055 | 2014-10-03 16:45:42 -0700 | [diff] [blame] | 202 | b.option(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, 32 * 1024); |
Madan Jampani | ddf7622 | 2014-10-04 23:48:44 -0700 | [diff] [blame] | 203 | b.option(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, 8 * 1024); |
| 204 | // TODO: Need JVM options to configure PooledByteBufAllocator. |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 205 | b.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); |
Madan Jampani | 824a7c1 | 2014-10-21 09:46:15 -0700 | [diff] [blame] | 206 | b.group(serverGroup, clientGroup) |
| 207 | .channel(serverChannelClass) |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 208 | .childHandler(new OnosCommunicationChannelInitializer()) |
| 209 | .option(ChannelOption.SO_BACKLOG, 128) |
| 210 | .childOption(ChannelOption.SO_KEEPALIVE, true); |
| 211 | |
| 212 | // Bind and start to accept incoming connections. |
Madan Jampani | 8710093 | 2014-10-21 16:46:12 -0700 | [diff] [blame] | 213 | b.bind(localEp.port()).sync(); |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | private class OnosCommunicationChannelFactory |
| 217 | implements KeyedPoolableObjectFactory<Endpoint, Channel> { |
| 218 | |
| 219 | @Override |
| 220 | public void activateObject(Endpoint endpoint, Channel channel) |
| 221 | throws Exception { |
| 222 | } |
| 223 | |
| 224 | @Override |
| 225 | public void destroyObject(Endpoint ep, Channel channel) throws Exception { |
| 226 | channel.close(); |
| 227 | } |
| 228 | |
| 229 | @Override |
| 230 | public Channel makeObject(Endpoint ep) throws Exception { |
Madan Jampani | ddf7622 | 2014-10-04 23:48:44 -0700 | [diff] [blame] | 231 | Bootstrap bootstrap = new Bootstrap(); |
| 232 | bootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); |
| 233 | bootstrap.option(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, 32 * 1024); |
| 234 | bootstrap.option(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, 8 * 1024); |
Madan Jampani | 824a7c1 | 2014-10-21 09:46:15 -0700 | [diff] [blame] | 235 | bootstrap.group(clientGroup); |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 236 | // TODO: Make this faster: |
| 237 | // http://normanmaurer.me/presentations/2014-facebook-eng-netty/slides.html#37.0 |
Madan Jampani | 824a7c1 | 2014-10-21 09:46:15 -0700 | [diff] [blame] | 238 | bootstrap.channel(clientChannelClass); |
Madan Jampani | ddf7622 | 2014-10-04 23:48:44 -0700 | [diff] [blame] | 239 | bootstrap.option(ChannelOption.SO_KEEPALIVE, true); |
| 240 | bootstrap.handler(new OnosCommunicationChannelInitializer()); |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 241 | // Start the client. |
Madan Jampani | ddf7622 | 2014-10-04 23:48:44 -0700 | [diff] [blame] | 242 | ChannelFuture f = bootstrap.connect(ep.host(), ep.port()).sync(); |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 243 | return f.channel(); |
| 244 | } |
| 245 | |
| 246 | @Override |
| 247 | public void passivateObject(Endpoint ep, Channel channel) |
| 248 | throws Exception { |
| 249 | } |
| 250 | |
| 251 | @Override |
| 252 | public boolean validateObject(Endpoint ep, Channel channel) { |
| 253 | return channel.isOpen(); |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | private class OnosCommunicationChannelInitializer extends ChannelInitializer<SocketChannel> { |
| 258 | |
Madan Jampani | ddf7622 | 2014-10-04 23:48:44 -0700 | [diff] [blame] | 259 | private final ChannelHandler dispatcher = new InboundMessageDispatcher(); |
Madan Jampani | 53e44e6 | 2014-10-07 12:39:51 -0700 | [diff] [blame] | 260 | private final ChannelHandler encoder = new MessageEncoder(); |
Madan Jampani | ddf7622 | 2014-10-04 23:48:44 -0700 | [diff] [blame] | 261 | |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 262 | @Override |
| 263 | protected void initChannel(SocketChannel channel) throws Exception { |
| 264 | channel.pipeline() |
Madan Jampani | ddf7622 | 2014-10-04 23:48:44 -0700 | [diff] [blame] | 265 | .addLast("encoder", encoder) |
Madan Jampani | 53e44e6 | 2014-10-07 12:39:51 -0700 | [diff] [blame] | 266 | .addLast("decoder", new MessageDecoder(NettyMessagingService.this)) |
Madan Jampani | ddf7622 | 2014-10-04 23:48:44 -0700 | [diff] [blame] | 267 | .addLast("handler", dispatcher); |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 268 | } |
| 269 | } |
| 270 | |
Yuta HIGUCHI | e5ca93b | 2014-10-23 09:49:00 -0700 | [diff] [blame] | 271 | private static class WriteTask implements Runnable { |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 272 | |
Madan Jampani | 86ed055 | 2014-10-03 16:45:42 -0700 | [diff] [blame] | 273 | private final InternalMessage message; |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 274 | private final Channel channel; |
| 275 | |
Madan Jampani | 86ed055 | 2014-10-03 16:45:42 -0700 | [diff] [blame] | 276 | public WriteTask(Channel channel, InternalMessage message) { |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 277 | this.channel = channel; |
Madan Jampani | 86ed055 | 2014-10-03 16:45:42 -0700 | [diff] [blame] | 278 | this.message = message; |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | @Override |
| 282 | public void run() { |
Madan Jampani | ddf7622 | 2014-10-04 23:48:44 -0700 | [diff] [blame] | 283 | channel.writeAndFlush(message, channel.voidPromise()); |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 284 | } |
| 285 | } |
| 286 | |
Madan Jampani | ddf7622 | 2014-10-04 23:48:44 -0700 | [diff] [blame] | 287 | @ChannelHandler.Sharable |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 288 | private class InboundMessageDispatcher extends SimpleChannelInboundHandler<InternalMessage> { |
| 289 | |
| 290 | @Override |
| 291 | protected void channelRead0(ChannelHandlerContext ctx, InternalMessage message) throws Exception { |
| 292 | String type = message.type(); |
| 293 | if (type.equals(InternalMessage.REPLY_MESSAGE_TYPE)) { |
| 294 | try { |
Madan Jampani | 24f9efb | 2014-10-24 18:56:23 -0700 | [diff] [blame] | 295 | SettableFuture<byte[]> futureResponse = |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 296 | NettyMessagingService.this.responseFutures.getIfPresent(message.id()); |
| 297 | if (futureResponse != null) { |
Madan Jampani | 24f9efb | 2014-10-24 18:56:23 -0700 | [diff] [blame] | 298 | futureResponse.set(message.payload()); |
Madan Jampani | f1d425a | 2014-10-07 09:52:36 -0700 | [diff] [blame] | 299 | } else { |
Madan Jampani | 15cd0b8 | 2014-10-28 08:40:23 -0700 | [diff] [blame] | 300 | log.warn("Received a reply for message id:[{}]. " |
| 301 | + "But was unable to locate the request handle", message.id()); |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 302 | } |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 303 | } finally { |
| 304 | NettyMessagingService.this.responseFutures.invalidate(message.id()); |
| 305 | } |
| 306 | return; |
| 307 | } |
| 308 | MessageHandler handler = NettyMessagingService.this.getMessageHandler(type); |
| 309 | handler.handle(message); |
| 310 | } |
Madan Jampani | 86ed055 | 2014-10-03 16:45:42 -0700 | [diff] [blame] | 311 | |
Madan Jampani | 86ed055 | 2014-10-03 16:45:42 -0700 | [diff] [blame] | 312 | @Override |
| 313 | public void exceptionCaught(ChannelHandlerContext context, Throwable cause) { |
Madan Jampani | 29e5dfd | 2014-10-07 17:26:25 -0700 | [diff] [blame] | 314 | log.error("Exception inside channel handling pipeline.", cause); |
Madan Jampani | 86ed055 | 2014-10-03 16:45:42 -0700 | [diff] [blame] | 315 | context.close(); |
| 316 | } |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 317 | } |
| 318 | } |