andreiz / php-zookeeper

A PHP extension for interfacing with Apache ZooKeeper
Other
449 stars 215 forks source link

What exactly getChildren function does internally ? #75

Open pramodpatilolx opened 7 years ago

pramodpatilolx commented 7 years ago

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 ?

Timandes commented 7 years ago

Did you kill instances before 'getChildren'?

pramodpatilolx commented 7 years ago

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

Timandes commented 7 years ago

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