You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@zookeeper.apache.org by Lahiru Gunathilake <gl...@gmail.com> on 2014/06/19 19:53:41 UTC
EPEHMERAL_SEQUENCIAL and EPHEMERAL_SEQUENTIAL constants
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
Re: EPEHMERAL_SEQUENCIAL and EPHEMERAL_SEQUENTIAL constants
Posted by Lahiru Gunathilake <gl...@gmail.com>.
Thanks Edward !
On Sun, Jun 22, 2014 at 8:32 PM, Edward Ribeiro <ed...@gmail.com>
wrote:
> Hi,
>
> Rakesh already answered your question, but let me just reinforce some
> points:
>
>
> On Fri, Jun 20, 2014 at 10:50 AM, Lahiru Gunathilake <gl...@gmail.com>
> wrote:
>
> >
> > so the usecase is when two clients try to create same nodes with same
> name
> >
> > z
> >
> > k
> >
> >
> > ch
> >
> > a
> >
> > n
> >
> > g
> >
> > e
> >
> >
> > t
> >
> > h
> >
> > e
> >
> >
> > n
> >
> > a
> >
> > m
> >
> > i
> >
> > n
> >
> > g
> >
> >
> > ?
> >
> >
> >
>
> Nope. When creating a sequential znode you inform a prefix (e.g., "serv_")
> and ZK provides the number part. The final name will be your prefix + the
> number (i.e., serv_0000007). The big plus is that the number part is
> atomically and sequentially provided so no more than one client will create
> the znode with this full path name.
>
>
>
> > I
> >
> >
> >
> >
> > f my system is well defined and no ra
> >
> > ndom node
> >
> > creation I do not need this feature ?
> >
> >
>
> This feature is used for leader election among ZK clients, for example.
> Other cases can for sure make use of sequential znodes.
>
>
> >
> >
> > In this case can I just get th
> >
> > e node with /leader/serv or should I get with
> > /leader/serv_000000001
> >
> >
>
> Later option, as Rakesh wrote.
>
>
> >
> >
> >
> > Anyways for my application I do not need this because I do not have a
> > scenario where naming is nondeterministic between zk clients.
> >
> >
>
> I would not say that it is "non deterministic". More like, you have an
> atomically increasing numbered znode suffix name. ;)
>
> Regards,
> Edward
>
--
System Analyst Programmer
PTI Lab
Indiana University
Re: EPEHMERAL_SEQUENCIAL and EPHEMERAL_SEQUENTIAL constants
Posted by Edward Ribeiro <ed...@gmail.com>.
Hi,
Rakesh already answered your question, but let me just reinforce some
points:
On Fri, Jun 20, 2014 at 10:50 AM, Lahiru Gunathilake <gl...@gmail.com>
wrote:
>
> so the usecase is when two clients try to create same nodes with same name
>
> z
>
> k
>
>
> ch
>
> a
>
> n
>
> g
>
> e
>
>
> t
>
> h
>
> e
>
>
> n
>
> a
>
> m
>
> i
>
> n
>
> g
>
>
> ?
>
>
>
Nope. When creating a sequential znode you inform a prefix (e.g., "serv_")
and ZK provides the number part. The final name will be your prefix + the
number (i.e., serv_0000007). The big plus is that the number part is
atomically and sequentially provided so no more than one client will create
the znode with this full path name.
> I
>
>
>
>
> f my system is well defined and no ra
>
> ndom node
>
> creation I do not need this feature ?
>
>
This feature is used for leader election among ZK clients, for example.
Other cases can for sure make use of sequential znodes.
>
>
> In this case can I just get th
>
> e node with /leader/serv or should I get with
> /leader/serv_000000001
>
>
Later option, as Rakesh wrote.
>
>
>
> Anyways for my application I do not need this because I do not have a
> scenario where naming is nondeterministic between zk clients.
>
>
I would not say that it is "non deterministic". More like, you have an
atomically increasing numbered znode suffix name. ;)
Regards,
Edward
Re: EPEHMERAL_SEQUENCIAL and EPHEMERAL_SEQUENTIAL constants
Posted by Lahiru Gunathilake <gl...@gmail.com>.
Hi Rakesh,
Thanks for the response.
On Fri, Jun 20, 2014 at 10:42 AM, Rakesh R <ra...@huawei.com> 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:glahiru@gmail.com]
> Sent: 20 June 2014 19:21
> To: user@zookeeper.apache.org
> 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 <ed...@gmail.com>
> 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
> > <gl...@gmail.com>
> > 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
RE: EPEHMERAL_SEQUENCIAL and EPHEMERAL_SEQUENTIAL constants
Posted by Rakesh R <ra...@huawei.com>.
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_"
Best Regards,
Rakesh
-----Original Message-----
From: Lahiru Gunathilake [mailto:glahiru@gmail.com]
Sent: 20 June 2014 19:21
To: user@zookeeper.apache.org
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 <ed...@gmail.com>
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
> <gl...@gmail.com>
> 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
Re: EPEHMERAL_SEQUENCIAL and EPHEMERAL_SEQUENTIAL constants
Posted by Lahiru Gunathilake <gl...@gmail.com>.
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 <ed...@gmail.com>
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 <gl...@gmail.com>
> 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
Re: EPEHMERAL_SEQUENCIAL and EPHEMERAL_SEQUENTIAL constants
Posted by Edward Ribeiro <ed...@gmail.com>.
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 <gl...@gmail.com>
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
>