• get get_children方法


     get 方法:
    [root@wx03 zook]# cat a4.pl 
    use ZooKeeper;
    use AnyEvent;
    use AE;
    use Data::Dumper;
       my $zk = ZooKeeper->new(hosts => '127.0.0.1:2181');
        my $stat = $zk->exists('/zk/child600');
       if ($stat){
                  $zk->delete('/zk/child600');
        }
       my $created_path = $zk->create('/zk/child600', 'child600',
                                       ephemeral => 1, 
                                       sequential => 1,
                                       'acl' => ZOO_OPEN_ACL_UNSAFE);    
        ###获取数据
        my ($data,$stat)=$zk->get('/zk');
        print $data;
    [root@wx03 zook]# perl a4.pl 
    Odd number of elements in hash assignment at /usr/local/perl/lib/site_perl/5.22.1/x86_64-linux/ZooKeeper.pm line 392.
    myData[root@wx03 zook]#
    
    
    get_child 方法:
    
       my $zk = ZooKeeper->new(hosts => '127.0.0.1:2181');
        my $stat = $zk->exists('/zk/child600');
       if ($stat){
                  $zk->delete('/zk/child600');
        }
       my $created_path = $zk->create('/zk/child600', 'child600',
                                       ephemeral => 1, 
                                       sequential => 1,
                                       'acl' => ZOO_OPEN_ACL_UNSAFE);    
        ###获取数据
        my (@data,$stat)=$zk->get_children('/zk');
        foreach (@data){
        print "$_ is $_
    ";
        };
    [root@wx03 zook]# perl a4.pl 
    Odd number of elements in hash assignment at /usr/local/perl/lib/site_perl/5.22.1/x86_64-linux/ZooKeeper.pm line 392.
    $_ is child500
    $_ is child700
    $_ is child600
    $_ is test
    $_ is child300
    $_ is child1
    $_ is child200
    
    
    获取child 子节点的值:
    [root@wx03 zook]# cat a4.pl 
    use ZooKeeper;
    use AnyEvent;
    use AE;
    use Data::Dumper;
       my $zk = ZooKeeper->new(hosts => '127.0.0.1:2181');
        my $stat = $zk->exists('/zk/child600');
       if ($stat){
                  $zk->delete('/zk/child600');
        }
       my $created_path = $zk->create('/zk/child600', 'child600',
                                       ephemeral => 1, 
                                       sequential => 1,
                                       'acl' => ZOO_OPEN_ACL_UNSAFE);    
        ###获取数据
        my (@data,$stat)=$zk->get_children('/zk');
        foreach (@data){
        print "$_ is $_
    ";
        print $zk->get("/zk/$_");
        print "
    ";
        };
    [root@wx03 zook]# perl a4.pl 
    Odd number of elements in hash assignment at /usr/local/perl/lib/site_perl/5.22.1/x86_64-linux/ZooKeeper.pm line 392.
    $_ is test2
    d4rwrHASH(0x14d0e28)
    $_ is child600
    HASH(0x14e5f38)
    $_ is test
    aaaHASH(0x14e5f38)
    $_ is test1
    dadadHASH(0x14e5f38)
    

  • 相关阅读:
    JQuery对id中含有特殊字符的转义处理
    jquery 将disabled的元素置为enabled的三种方法
    jeecg表单页面控件权限设置(请先看官方教程,如果能看懂就不用看这里了)
    Google调用explorer.exe打开本地文件
    C++ URLDecode和URLEncode实现——仅限gb2312,非utf8
    jeecg小吐槽续——自己折腾修改在线开发功能中“默认值”的使用
    jeecg小吐槽
    vue使用vant时间日期选择器,日期转化
    vue获取图片宽高
    微信公众号h5用户授权
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6199560.html
Copyright © 2020-2023  润新知