zoukankan      html  css  js  c++  java
  • 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)
    

  • 相关阅读:
    移动 ProgramDataPackage Cache 文件夹
    Visual Studio 2017
    微信小程序 View:flex 布局
    echarts 模拟迁徙
    树莓派3 Windows 10 IoT Core
    Lumia 830 win10m 启用触摸按键
    青岛旅游
    <孤独者生存(小小辛巴投资手记)>读书笔记
    Python.Unix和Linux系统管理指南
    <低风险投资之路>读书笔记
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6199559.html
Copyright © 2011-2022 走看看