You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by Thomas Koch <th...@koch.ro> on 2010/08/22 15:19:41 UTC

WIP: introduce ClientCnxnSocket classes for nicer netty integration

Hi,

I got permission from Patrick to try to make the java client netty 
introduction a little bit nicer. I could need a little help now at one point.
Please have a look at 
<http://github.com/thkoch2001/zookeeper/tree/use_netty2/src/java/main/org/apache/zookeeper/>

The classes ClientCnxnSocketNIO and ClientCnxnSocketNetty are used by 
ClientCnxn.SendThread. Both have a method xyz() now, where I've moved some 
lines of code that were different in the run() loop of both implementations.

If you could help me to move the logic from xyz() back in the run() method 
with fitting calls to the socket() class, then I might be done. I'm a bit 
puzzled because in NIO there's first a selector.select(to) and then 
doWrites(), while in Netty there's first doWrites() and then 
outgoingQueue.wait(to).

Best regards,

Thomas Koch, http://www.koch.ro

Re: WIP: introduce ClientCnxnSocket classes for nicer netty integration

Posted by Patrick Hunt <ph...@apache.org>.
On 08/22/2010 06:19 AM, Thomas Koch wrote:
> If you could help me to move the logic from xyz() back in the run() method
> with fitting calls to the socket() class, then I might be done. I'm a bit
> puzzled because in NIO there's first a selector.select(to) and then
> doWrites(), while in Netty there's first doWrites() and then
> outgoingQueue.wait(to).
>

The control logic is indeed "swapped" here for nio/netty. In the NIO 
case we have set flags that specify whether we are interested in 
performing writes or not (nio will return once a socket we've expressed 
interest in is available to write, it could return immediately). In 
netty we have a queue of packets and write them to the channel (under 
which I'm assuming netty does similar to what we are doing in our nio 
code). The packet generating code will notify outgoing queue when new 
packets are added to the queue.

In the NIO case we are essentially saying "wait to write until something 
can be written", while in the netty case we are "write everything and 
then wait until more packets are available to write".

That help?

Patrick