This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Modifies the pipeline to handle HTTP requests | |
* @param ctx The calling channel handler context | |
* @param maxRequestSize The maximum request size in bytes | |
*/ | |
private void switchToHttp(final ChannelHandlerContext ctx, final int maxRequestSize) { | |
ChannelPipeline p = ctx.pipeline(); | |
p.addLast("compressor", new HttpContentCompressor()); | |
p.addLast("httpHandler", new HttpServerCodec()); // TODO: config ? | |
p.addLast("decompressor", new HttpContentDecompressor()); | |
p.addLast("aggregator", new HttpObjectAggregator(maxRequestSize)); | |
p.addLast("handler", rpchandler); | |
} |
Another issue popped up related to Netty 4's HttpResponseStatus. As mentioned before, many Netty 4 classes have been de-getter-izationed where immutable attributes don't have a getX method, so what was formerly getStatus() is now status(). Fair enough. But beware.... Many of these classes do not have explicit Jackson [JSON] serializers, since Jackson has typically figured it out on the fly using..... yup. BeanInfo. And since HttpResponseStatus no longer has a bean like signature, Jackson gripes like this:
No serializer found for class io.netty.handler.codec.http.HttpResponseStatus and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: java.util.HashMap["httpResponse"])
Not a big deal. Just need to hunt all these cases down and define explicit serializers for each.
Anyways, both Telnet and JSON data import is now working through the PutDataPointRpc.
Also found a number of instances where I had ByteBuf.retain()ed, the incoming buffer to prevent them from being reclaimed before the pipeline is done with them. Well in these cases, the buffer also needs to be ByteBuf.release()d. This error tipped me off to that:
2016-04-05 06:21:37,447 ERROR [EpollServerWorkerThread#1] ResourceLeakDetector: LEAK: ByteBuf.release() was not called before it's garbage-collected. See http://netty.io/wiki/reference-counted-objects.html for more information.
WARNING: 4 leak records were discarded because the leak record count is limited to 4. Use system property io.netty.leakDetection.maxRecords to increase the limit.
Recent access records: 5.
The leak detection makes it easy to find these cases and I've closed out all the ones I've come across so far. Netty 4 reports some fairly detailed stats on pooled buffers, and since I think Direct Pooled buffers will be a major improvement for OpenTSDB, I'm going to surface these through the stats collector.