php-zookeeper icon indicating copy to clipboard operation
php-zookeeper copied to clipboard

What exactly getChildren function does internally ?

Open pramodpatilolx opened this issue 9 years ago • 3 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 ?

pramodpatilolx avatar Oct 04 '16 07:10 pramodpatilolx

Did you kill instances before 'getChildren'?

Timandes avatar Oct 05 '16 00:10 Timandes

@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.

pramodpatilolx avatar Oct 05 '16 05:10 pramodpatilolx

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...?

Timandes avatar Oct 06 '16 00:10 Timandes