You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@zookeeper.apache.org by Grigory Dzhavadyan <gr...@gmail.com> on 2012/06/08 23:15:38 UTC

Generating Events With Incorrect types

Hello,

I'm using the Zookeeper C API to set a watch on a non-existent node
using the `zoo_wexists' function.

When I create that node, I'm expecting the event handler to be called
with `type' equal to `ZOO_CREATED_EVENT'. However, instead it's being
called with type equal to `ZOO_CHANGED_EVENT'. Why is that so and what
should I do to receive the correct type in the event handler?

Re: Generating Events With Incorrect types

Posted by Patrick Hunt <ph...@apache.org>.
Would be a good improvement, but tough from a b/w compatibility
perspective. Propose for 4.0 by entering a JIRA? Thanks!

Patrick

On Mon, Jun 11, 2012 at 10:27 AM, Grigory Dzhavadyan
<gr...@gmail.com> wrote:
> Hi,
>
> It appears that I have mixed up the order of "event type" and
> "connection state" arguments in the handler function. Both are
> integers, so the compiler did not say anything. A hard-to-notice error
> :-). Maybe it would make sense to turn those into enums? At least the
> C++ compiler would complain, I guess.
>
> On Fri, Jun 8, 2012 at 3:51 PM, Michi Mutsuzaki <mi...@cs.stanford.edu> wrote:
>> Hi Grigory,
>>
>> Yes, you should get ZOO_CREATED_EVENT. Could you post a short program
>> that reproduces the issue?
>>
>> Thanks!
>> --Michi
>>
>> On Fri, Jun 8, 2012 at 2:15 PM, Grigory Dzhavadyan
>> <gr...@gmail.com> wrote:
>>> Hello,
>>>
>>> I'm using the Zookeeper C API to set a watch on a non-existent node
>>> using the `zoo_wexists' function.
>>>
>>> When I create that node, I'm expecting the event handler to be called
>>> with `type' equal to `ZOO_CREATED_EVENT'. However, instead it's being
>>> called with type equal to `ZOO_CHANGED_EVENT'. Why is that so and what
>>> should I do to receive the correct type in the event handler?

Re: Generating Events With Incorrect types

Posted by Grigory Dzhavadyan <gr...@gmail.com>.
Hi,

It appears that I have mixed up the order of "event type" and
"connection state" arguments in the handler function. Both are
integers, so the compiler did not say anything. A hard-to-notice error
:-). Maybe it would make sense to turn those into enums? At least the
C++ compiler would complain, I guess.

On Fri, Jun 8, 2012 at 3:51 PM, Michi Mutsuzaki <mi...@cs.stanford.edu> wrote:
> Hi Grigory,
>
> Yes, you should get ZOO_CREATED_EVENT. Could you post a short program
> that reproduces the issue?
>
> Thanks!
> --Michi
>
> On Fri, Jun 8, 2012 at 2:15 PM, Grigory Dzhavadyan
> <gr...@gmail.com> wrote:
>> Hello,
>>
>> I'm using the Zookeeper C API to set a watch on a non-existent node
>> using the `zoo_wexists' function.
>>
>> When I create that node, I'm expecting the event handler to be called
>> with `type' equal to `ZOO_CREATED_EVENT'. However, instead it's being
>> called with type equal to `ZOO_CHANGED_EVENT'. Why is that so and what
>> should I do to receive the correct type in the event handler?

Re: Generating Events With Incorrect types

Posted by Patrick Hunt <ph...@apache.org>.
fyi if you want to easily reproduce using the c cli:
https://issues.apache.org/jira/browse/ZOOKEEPER-1481

Patrick

On Fri, Jun 8, 2012 at 4:04 PM, Patrick Hunt <ph...@apache.org> wrote:
> I just tried this with the C cli and I get:
>
> Watcher CREATED_EVENT state = CONNECTED_STATE for path /bar
>
> in all cases (tried with and without a specified watcher, also tried
> both the single and multi threaded versions)
>
> Can you try the cli yourself? (use 2, one to watch the znode, the
> other to create it)
>
> btw, I was using branch 3.4 for testing (although I'd be surprised if
> this were different in 3.3 or 3.5...)
>
> Patrick
>
> On Fri, Jun 8, 2012 at 3:51 PM, Michi Mutsuzaki <mi...@cs.stanford.edu> wrote:
>> Hi Grigory,
>>
>> Yes, you should get ZOO_CREATED_EVENT. Could you post a short program
>> that reproduces the issue?
>>
>> Thanks!
>> --Michi
>>
>> On Fri, Jun 8, 2012 at 2:15 PM, Grigory Dzhavadyan
>> <gr...@gmail.com> wrote:
>>> Hello,
>>>
>>> I'm using the Zookeeper C API to set a watch on a non-existent node
>>> using the `zoo_wexists' function.
>>>
>>> When I create that node, I'm expecting the event handler to be called
>>> with `type' equal to `ZOO_CREATED_EVENT'. However, instead it's being
>>> called with type equal to `ZOO_CHANGED_EVENT'. Why is that so and what
>>> should I do to receive the correct type in the event handler?

Re: Generating Events With Incorrect types

Posted by Patrick Hunt <ph...@apache.org>.
I just tried this with the C cli and I get:

Watcher CREATED_EVENT state = CONNECTED_STATE for path /bar

in all cases (tried with and without a specified watcher, also tried
both the single and multi threaded versions)

Can you try the cli yourself? (use 2, one to watch the znode, the
other to create it)

btw, I was using branch 3.4 for testing (although I'd be surprised if
this were different in 3.3 or 3.5...)

Patrick

On Fri, Jun 8, 2012 at 3:51 PM, Michi Mutsuzaki <mi...@cs.stanford.edu> wrote:
> Hi Grigory,
>
> Yes, you should get ZOO_CREATED_EVENT. Could you post a short program
> that reproduces the issue?
>
> Thanks!
> --Michi
>
> On Fri, Jun 8, 2012 at 2:15 PM, Grigory Dzhavadyan
> <gr...@gmail.com> wrote:
>> Hello,
>>
>> I'm using the Zookeeper C API to set a watch on a non-existent node
>> using the `zoo_wexists' function.
>>
>> When I create that node, I'm expecting the event handler to be called
>> with `type' equal to `ZOO_CREATED_EVENT'. However, instead it's being
>> called with type equal to `ZOO_CHANGED_EVENT'. Why is that so and what
>> should I do to receive the correct type in the event handler?

Re: Generating Events With Incorrect types

Posted by Michi Mutsuzaki <mi...@cs.stanford.edu>.
Hi Grigory,

Yes, you should get ZOO_CREATED_EVENT. Could you post a short program
that reproduces the issue?

Thanks!
--Michi

On Fri, Jun 8, 2012 at 2:15 PM, Grigory Dzhavadyan
<gr...@gmail.com> wrote:
> Hello,
>
> I'm using the Zookeeper C API to set a watch on a non-existent node
> using the `zoo_wexists' function.
>
> When I create that node, I'm expecting the event handler to be called
> with `type' equal to `ZOO_CREATED_EVENT'. However, instead it's being
> called with type equal to `ZOO_CHANGED_EVENT'. Why is that so and what
> should I do to receive the correct type in the event handler?