Hi Rakesh, Thanks for the response.
On Fri, Jun 20, 2014 at 10:42 AM, Rakesh R <[email protected]> wrote: > Hi Lahiru, > > >>>>>>>>>>> In this case can I just get the node with /leader/serv or > should I get with /leader/serv_000000001 > > > > In your example, ZK created the znode as /leader/serv_000000001. There is > no client API to get the znode by passing only the prefix, you have to pass > the complete path like, > > zkClient.exists( "/leader/serv_000000001", false);. You can use > zkClient.getChildren("/leader", false) to know the created znode name. > > > Adding one more point about the usage: "znode type" depends on the > usecase, what we are going to achieve using znode. > > One example of sequential node is, say there is a requirement to build a > simple queue(FIFO). Sequential behaviour will help to abstract those > ordering complexities, whoever comes first will get the lowest number. Now > he can focus on the application side logic based on the sequence number > maintained by ZK. In this case, all the participant clients should have a > common agreement on znode prefix, like in the example "/leader/serv_" > Definitely this is useful for me in the future. Regards Lahiru > > Best Regards, > Rakesh > > -----Original Message----- > From: Lahiru Gunathilake [mailto:[email protected]] > Sent: 20 June 2014 19:21 > To: [email protected] > Subject: Re: EPEHMERAL_SEQUENCIAL and EPHEMERAL_SEQUENTIAL constants > > Hi Edward, > > Thank You very much for the response. > > Yes I wanted to know about sequencial node part. > > so the usecase is when two clients try to create same nodes with same name > zk change the naming ? If my system is well defined and no random node > creation I do not need this feature ? > > If I have random node creation I always have to get the childnodes and > then get the nodes based on naming ? or can I just stick to the name I gave > when I tried to save the node ? > In your example I think clients tried to create the nodes with the name > /leader/serv but zk created something else. > ex: leader/serv_000000001 > > In this case can I just get the node with /leader/serv or should I get with > /leader/serv_000000001 > > Anyways for my application I do not need this because I do not have a > scenario where naming is nondeterministic between zk clients. > > Regards > Lahiru > > > On Fri, Jun 20, 2014 at 9:42 AM, Edward Ribeiro <[email protected]> > wrote: > > > Hi Lahiru, > > > > You mean EPHEMERAL and EPHEMERAL_SEQUENTIAL, right? > > > > A znode is created by a client logged on a session. Both EPHEMERAL and > > EPHEMERAL_SEQUENTIAL znodes are deleted once the session -- where the > > znode was created -- expires (that is, the user disconnects). The > > difference between the two types of ephemeral node is that > > EPHEMERAL_SEQUENTIAL allows you to create an atomic and sequentially > increasing number suffixes. > > > > For example, if three clients are trying to create child > > ephemeral_sequential znodes of a '/leader' parent znode at the same > > time they will be generated as follows (for example): > > > > /leader/serv_000000001 > > /leader/serv_000000002 > > /leader/serv_000000003 > > > > the number suffix was automatically appended by ZK such that no two > > clients will generate the same znode (serv_00000001, for example). If > > the client which created znode 'serv_00000002' disconnects then ZK > > automatically deletes that znode. > > > > Got it? > > > > Edward > > > > > > > > > > > > On Thu, Jun 19, 2014 at 2:53 PM, Lahiru Gunathilake > > <[email protected]> > > wrote: > > > > > When creating a node we have to parse the constants and there are four. > > > PERSISTENT, PERSISTENT_SEQUENTIAL, EPHEMERAL, EPHEMERAL_SEQUENTIAL > > > > > > I do not really get the description of two constants > > > EPEHMERAL_SEQUENCIAL and EPHEMERAL_SEQUENTIAL. In API docs it says > like below. > > > > > > The znode will be deleted upon the client's disconnect, and its name > > > will be appended with a monotonically increasing number. > > > > > > Can someone please describe me what this is about. > > > > > > Regards > > > Lahiru > > > > > > -- > > > System Analyst Programmer > > > PTI Lab > > > Indiana University > > > > > > > > > -- > System Analyst Programmer > PTI Lab > Indiana University > -- System Analyst Programmer PTI Lab Indiana University
