Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
Zookeeper >> mail # user >> how to set the starting value of the created sequence?


Copy link to this message
-
Re: how to set the starting value of the created sequence?
As far as I know this is based on information stored by the server in
the parent node, and is not settable by the user.

On Mon, Nov 14, 2011 at 10:10 PM, Yuhan Zhang <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I'd like to create a distributed unique int key with zookeeper sequential
> by:
>     String file = zooKeeper.create( folderPath + "/0", new byte[0],
> Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);
>     String sequence = file.substring(file.lastIndexOf("/")+1);
> zooKeeper.delete(file, 0);
>     int id = Integer.parseInt( sequence );
>
> It works fine, even though the sequence number may not be adjacent.
> However, I'd like to have the key to start at a certain value,
> say 1000, as the ids under 1000 has been in use. Currently I will have to
> call this function until it generates an id greater than 1000. Is there a
> way in zooKeeper to set the starting value of the created sequence?
>
> Thank you.
>
> Yuhan
>
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB