You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@zookeeper.apache.org by Maarten Koopmans <ma...@vrijheid.net> on 2010/08/24 16:45:57 UTC

Closing a client fails

Hi,

I am using the Zookeeper Java client class from Scala for some synchronous communication (no watches, no async). Fairly simple. Every now and then my application needs to use ZK and then creates a client, does its thing, and closes the client. 

What happens though is that I keep having two threads for every client I've ever opened, which slowly adds up. So now I turned the client into a Singleton, but that acts as a bottleneck (remember, I do/need sync communication).

Any thoughts? From my perspective, the close() method on ZooKeeper should close and clean up the threads. Tested under OS 10.6.4 and Ubuntu 10.04 with the Sun JDK.

Thanks,

Maarten

Re: Closing a client fails

Posted by Patrick Hunt <ph...@apache.org>.
Typically when you call "close" on the ZooKeeper object it will shut down
both the threads (one is the "send" thread, the other is the "event"
thread). Are you sure you're calling the close method?

Perhaps you've found this issue?
https://issues.apache.org/jira/browse/ZOOKEEPER-795

Patrick

On Tue, Aug 24, 2010 at 7:45 AM, Maarten Koopmans <ma...@vrijheid.net>wrote:

> Hi,
>
> I am using the Zookeeper Java client class from Scala for some synchronous
> communication (no watches, no async). Fairly simple. Every now and then my
> application needs to use ZK and then creates a client, does its thing, and
> closes the client.
>
> What happens though is that I keep having two threads for every client I've
> ever opened, which slowly adds up. So now I turned the client into a
> Singleton, but that acts as a bottleneck (remember, I do/need sync
> communication).
>
> Any thoughts? From my perspective, the close() method on ZooKeeper should
> close and clean up the threads. Tested under OS 10.6.4 and Ubuntu 10.04 with
> the Sun JDK.
>
> Thanks,
>
> Maarten