php连接zookeeper 报Uncaught exception 'ZookeeperNoNodeException' with message 'no node'

来源:互联网 发布:虚荣英雄数据 编辑:程序博客网 时间:2024/06/11 18:01

作者在php连接zookeeper的时候,通过create命令创建节点,

<?php$zookeeper = new Zookeeper('locahost:2181');$aclArray = array(  array(    'perms'  => Zookeeper::PERM_ALL,    'scheme' => 'world',    'id'     => 'anyone',  ));$path = '/path/to/newnode';$realPath = $zookeeper->create($path, null, $aclArray);if ($realPath)  echo $realPath;else  echo 'ERR';?>在创建/path/to/newnode的时候报错Uncaught exception 'ZookeeperNoNodeException' with message 'no node',通过在git上找到了例子

/**
* Equivalent of “mkdir -p” on ZooKeeper
*
* @param string pathThepathtothenode@paramstringvalue The value to assign to each new node along the path
*
* @return bool
*/
public function makePath(path,value = ”) {
parts=explode(/,path);
parts=arrayfilter(parts);
subpath=;while(count(parts) > 1) {
subpath.=/.arrayshift(parts);
if (!this>zookeeper>exists(subpath)) {
this>makeNode(subpath, $value);
}
}
}

“`
原来要创建多层次的node,需要进行递归创建。

阅读全文
0 0
原创粉丝点击