apache/incubator-flink — pull request #255 by uce (2014-12-09 14:53:45+00:00)
Title: [FLINK-998] Close TCP connections after destroying logical channels

This commit introduces reference-counting to keep track of the InputChannel and OutputChannel instances, which share the same physical TCP connection. This is basically a backport from #254.

When the logical channels are released in the channel manager, the reference count will reach 0 and the respective TCP connection can safely be closed.

Furthermore, the debug thread in the OutboundConnectionQueue is properly shut down and all queued buffers are freed when the channel is closed or an Exception occurs.

I've tested it on a 4 node cluster with parallelism of 32 and the debug output thread showed that connections are closed successfully. I've also tested cancelling. It would be nice to review this thoroughly though. ;-)