andreiz / php-zookeeper

A PHP extension for interfacing with Apache ZooKeeper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What exactly getChildren function does internally ?

pramodpatilolx opened this issue · comments

I have 3 zookeepers running and while creating Zookeeper object I specify csv of all 3 hosts.

For eg. \ZooKeeper("host1:port1,host2:port2,host3:port2", null, $timeout);

If I kill one zookeeper node I get 'connection loss' error sometimes from getChildren.
If I kill 2 zookeeper nodes I am always getting 'connection loss' error.

Does getchildren tries to connect to all zookeeper nodes ?
Can someone explain what this fuction internally does ?

Did you kill instances before 'getChildren'?

@Timandes No, I killed the instance when no producer or consumer was running(using zookeeper for kafka cluster management). So there is no chance that it's killed after creating a zookeeper instance and before calling getChildren.

Also one clarification required : Is this function asynchronous ? If it is, then probably I should call getchildren from within the callback.

First, I'm not quite sure the situation you mentioned. But I'm sure that Method 'connect' do nothing but save the list of servers.
Second, @andreiz uses mt lib of zookeeper. So it always has at least two threads no matter the extension uses zoo_a* functions or not. And the callbacks is always called in the worker thread.

Is this what you need?
Or I missed your point again...?