Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Net-ZooKeeper CPAN distribution.

Report information
The Basics
Id: 72702
Status: resolved
Priority: 0/
Queue: Net-ZooKeeper

People
Owner: Nobody in particular
Requestors: aleksey.mashanov [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: 0.38



Subject: No way to get state of Net::ZooKeeper handle
Just want to call zoo_state(). --- ZooKeeper.xs 2011-11-24 19:45:29.000000000 +0400 +++ ZooKeeper.xs 2011-11-24 19:52:52.000000000 +0400 @@ -128,7 +128,8 @@ {"hosts", 0, 0, 0, 0}, {"session_timeout", 0, 0, 0, 0}, {"session_id", 0, 0, 0, 0}, - {"pending_watches", 0, 0, 0, 0} + {"pending_watches", 0, 0, 0, 0}, + {"state", 0, 0, 0, 0} }; static zk_key_t zk_stat_keys[NUM_STAT_KEYS] = { @@ -1051,6 +1052,9 @@ /* cleanup any completed watches not tied to a handle */ val = newSVuv(_zk_release_watches(aTHX_ zk->first_watch, 0)); } + else if (strcaseEQ(key, "state")) { + val = newSViv(zoo_state(zk->handle)); + } if (val) { ST(0) = sv_2mortal(val); --- ZooKeeper.pm 2009-07-15 20:56:06.000000000 +0400 +++ ZooKeeper.pm 2011-11-24 19:52:03.000000000 +0400 @@ -514,6 +514,14 @@ This attribute is B<read-only> and may not be modified. +=item state + +The state of the Net::ZooKeeper connection at current time. +See C<:states> for a list of the possible connection states. +If zero, no connection has established yet. + +This attribute is B<read-only> and may not be modified. + =back =head2 Net::ZooKeeper::Stat
From: chrishammond [...] ymail.com
On Thu Nov 24 11:47:57 2011, amashanov wrote: Show quoted text
> Just want to call zoo_state(). > > --- ZooKeeper.xs 2011-11-24 19:45:29.000000000 +0400 > +++ ZooKeeper.xs 2011-11-24 19:52:52.000000000 +0400 > @@ -128,7 +128,8 @@ > {"hosts", 0, 0, 0, 0}, > {"session_timeout", 0, 0, 0, 0}, > {"session_id", 0, 0, 0, 0}, > - {"pending_watches", 0, 0, 0, 0} > + {"pending_watches", 0, 0, 0, 0}, > + {"state", 0, 0, 0, 0} > }; >
I think we'd want to increment NUM_KEYS on line 48 here, too?
From: chrishammond [...] ymail.com
On Fri Jan 13 05:44:04 2012, chrishammond wrote: Show quoted text
> I think we'd want to increment NUM_KEYS on line 48 here, too?
Also, update t/20_tie.t - +++ Net-ZooKeeper-0.35/t/20_tie.t 2011-04-05 08:24:28.000000000 - 0400 @@ -17,7 +17,7 @@ # limitations under the License. use File::Spec; -use Test::More tests => 54; +use Test::More tests => 55; BEGIN { use_ok('Net::ZooKeeper', qw(:all)) }; @@ -115,11 +115,11 @@ 'NEXTKEY(): invalid handle'); my @keys = keys(%{$zkh}); - is(scalar(@keys), 7, + is(scalar(@keys), 8, 'keys(): count of keys from handle'); @keys = keys(%{$copy_zkh}); - is(scalar(@keys), 7, + is(scalar(@keys), 8, 'keys(): count of keys from copied dereferenced handle'); is($attr->FIRSTKEY(), 'data_read_len', @@ -128,7 +128,10 @@ is($attr->NEXTKEY('session_id'), 'pending_watches', 'NEXTKEY(): retrieved last key using inner hash'); - is($attr->NEXTKEY('pending_watches'), undef, + is($attr->NEXTKEY('pending_watches'), 'state', + 'NEXTKEY(): undef returned after last key using inner hash'); + + is($attr->NEXTKEY('state'), undef, 'NEXTKEY(): undef returned after last key using inner hash'); ok(scalar(%{$zkh}),
Patched in 0.38