php zookeeper api介绍
来源:互联网 发布:淘宝手机兼职 编辑:程序博客网 时间:2024/06/05 19:43
简介
Apache Zookeeper 是由 Apache Hadoop 的 Zookeeper 子项目发展而来,现在已经成为了 Apache 的顶级项目。Zookeeper 为分布式系统提供了高效可靠且易于使用的协同服务,它可以为分布式应用提供相当多的服务,诸如统一命名服务,配置管理,状态同步和组服务等。 Zookeeper 接口简单,开发人员不必过多地纠结在分布式系统编程难于处理的同步和一致性问题上,你可以使用 Zookeeper 提供的现成(off-the-shelf)服务来实现分布式系统的配置管理,组管理,Leader 选举等功能。
Zookeeper 维护了大规模分布式系统中的常用对象,比如配置信息,层次化命名空间等,本文将从开发者的角度详细介绍 Zookeeper 的配置信息的意义以及 Zookeeper 的典型应用场景(配置文件的管理、集群管理、分布式队列、同步锁、Leader 选举、队列管理等)。
上一篇博客主要讲了Apache Zookeeper的安装与配置,本文主要介绍Zookeeper PHP API
Zookeeper PHP API
安装php-zookeeper扩展,Mac机子上本人习惯用homebrew来管理自己的环境,下面介绍怎样用homebrew安装这个扩展
不知道怎么安装homebrew的童鞋们看这里https://brew.sh/
$brew install php56-zookeeper
安装完之后,通过下面的命令查看是否安装成功
$php -m[PHP Modules]apcapcubcmathbz2calendarCorectypecurldatedbadomeregexiffileinfofilterftpgdgettexthashiconvigbinaryjsonldaplibxmlmbstringmcryptmemcachemhashmongodbmysqlimysqlndodbcopensslpcntlpcrePDOpdo_mysqlPDO_ODBCpdo_sqlitePharposixreadlineredisReflectionsessionshmopSimpleXMLsoapsocketsSPLsqlite3standardswoolesysvmsgsysvsemsysvshmtokenizerwddxxdebugxmlxmlreaderxmlrpcxmlwriterxslzipzlibzookeeper[Zend Modules]Xdebug
下面给出PHP API基本操作
<?php// 创建一个与服务器的连接$zookeeper = new Zookeeper('127.0.0.1:2181');$aclArray = array(array('perms' => Zookeeper::PERM_ALL,'scheme' => 'world','id' => 'anyone',));// 创建一个目录节点$path = '/path';if ( ! $zookeeper->exists($path))$zookeeper->create($path, "parent", $aclArray);$childPath = '/path/child';if ( ! $zookeeper->exists($childPath))$zookeeper->create($childPath,"child",$aclArray);function callback(){ echo "callback01";}// 判断目录是否存在if ($zookeeper->exists($childPath)){ // 取出子目录节点内容 var_dump($zookeeper->get($childPath,call_user_func("callback")));}$zookeeper->set($childPath,'child01');// 判断目录是否存在if ($zookeeper->exists($childPath)){ // 取出子目录节点内容 var_dump($zookeeper->get($childPath));}// 删除目录节点$zookeeper->delete($childPath);// 判断目录是否存在if ($zookeeper->exists($childPath)){ var_dump("true");} else { var_dump("false");}
上面只介绍了一些常用的方法,要想了解更多的方法,请查看https://secure.php.net/manual/en/class.zookeeper.php
阅读全文
0 0
- php zookeeper api介绍
- ZooKeeper API介绍
- 03.ZooKeeper读书笔记之基本API介绍
- zookeeper基本api介绍和使用
- 【ZooKeeper】Java客户端API使用介绍。
- ZooKeeper API
- ZooKeeper API
- zookeeper api
- zookeeper API
- ZooKeeper API
- Zookeeper API
- zookeeper API
- ZooKeeper介绍
- zookeeper介绍
- ZooKeeper介绍
- zookeeper介绍
- Zookeeper介绍
- zookeeper介绍
- Android事件处理
- intellij idea 鼠标放上去提示参数
- Opencv标定相机
- linux学习笔记之文件处理命令与链接命令
- 安卓编译出错
- php zookeeper api介绍
- 51nod1200 石子游戏 V2
- Android Studio 常用调试技巧
- 【LeetCode 300 Longest Increasing Subsequence】最长递增子序列
- 我的Mac键盘失灵了(u,i,o,j,k,l,k,m无效了)-- Mac鼠标键的开启和关闭
- 自定义cell默认初始化方法
- nginx.conf server节点一般设置
- SetRegistryKey的作用
- easyui简单使用记录