Re: Multiple ZooKeeper client instances

2009-04-24 Thread Mahadev Konar
HI Satish, A zookeeper client usually has a very small footprint for memory and cpu. The mutithreaded version of zookeeper client creates an internal thread to do the io and callbacks. I would suggest using the same zookeeper client across the objects to have less number of threads in your clien

Multiple ZooKeeper client instances

2009-04-24 Thread Satish Bhatti
If my application has several objects who are using ZooKeeper for entirely unrelated reasons, is it recommended to create one ZooKeeper client instance and share it, or to create one per object? Do the ZooKeeper client instances have a lot of overhead? I am thinking that having one instance per o

Re: Unique Id Generation

2009-04-24 Thread Ted Dunning
I would expect Ben's method to be slightly faster, but they should be comparable. And, of course you are correct about rewind. Such are the perils of writing code in the email program. On Fri, Apr 24, 2009 at 10:01 AM, Satish Bhatti wrote: > ... Your approach appears to be the fastest, so I th

Re: Unique Id Generation

2009-04-24 Thread Mahadev Konar
Hi Satish, take a look at http://hadoop.apache.org/zookeeper/docs/r3.1.1/zookeeperAdmin.html#sc_mainte nance This can be run as a cron job and will get rid of old unwanted logs and snapshots. mahadev On 4/24/09 10:18 AM, "Satish Bhatti" wrote: > A follow up to this: I implemented method (b

Re: Unique Id Generation

2009-04-24 Thread Satish Bhatti
A follow up to this: I implemented method (b), and ran a test that generated 100K of ids. This generated 1.3G worth of transaction logs. Question: when can these be safely deleted? How does one know which ones may be deleted? Or do they need to exist forever? On Fri, Apr 24, 2009 at 9:52 AM,

Re: Unique Id Generation

2009-04-24 Thread Satish Bhatti
Hello Ted, Your approach appears to be the fastest, so I think I will go with it. By the way, it should be buf.rewind() not buf.reset(). Satish On Thu, Apr 23, 2009 at 6:28 PM, Ted Dunning wrote: > I don't think you meant ephemeral nodes because it isn't very likely that > you would have more

Re: Unique Id Generation

2009-04-24 Thread Ted Dunning
Of the methods proposed, a) recursive sequential files b) latest state file(s) that is updated using a pseudo transaction to give a range of numbers to allocate c) just probe zxid You should be pretty good with any of them. With (a), you have to be careful to avoid race conditions when you get

Re: Unique Id Generation

2009-04-24 Thread Satish Bhatti
Hello Ben, Basically the ids are document Ids. We will eventually have several billion documents in our system, and each has a unique long id. Currently we are using a database sequence to generate these longs. Having eliminated other uses of the database, we didn't want to keep it around just t

Re: Unique Id Generation

2009-04-24 Thread Benjamin Reed
i'm not exactly clear how you use these ideas, but one source of unique ids that are longs is the zxid. if you create a znode, everytime you write to it, you will get a unique zxid in the mzxid member of the stat structure. (you get the stat structure back in the response to the setData.) ben