in registry/automatic/ZookeeperClient.php [59:97]
public function connectZk($address, $ephemeral = false)
{
$ret = true;
$this->address = $address;
$this->ephemeral = $ephemeral;
try
{
if ($ephemeral)
{
$this->zookeeper = new \Zookeeper($this->address, array($this,'connect_cb'));
}
else
{
$this->zookeeper = new \Zookeeper($this->address);
if($this->zookeeper)
{
while(\Zookeeper::CONNECTED_STATE != $this->zookeeper->getState()
&&($this->waiteForConnectStateTimes > 0))
{
//等待连接状态
$this->waiteForConnectStateTimes--;
$this->logger->debug("wait for connect state");
usleep(50000);
}
}
}
if(empty($this->zookeeper))
{
$ret = false;
}
}
catch (\Exception $e)
{
$ret = false;
$this->logger->error($e->getMessage().'|address:'.$this->address);
}
return $ret;
}