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)
    

  • 相关阅读:
    修改requests_html.AsyncHTMLSessions使得支持url参数
    MyBatis查询返回Map示例代码
    java.util.ConcurrentModificationException 异常原因和解决方法
    Springboot整合RabbitMQ(四)——设置消息过期时间TTL
    MySql Lock wait timeout exceeded该如何处理? (转载)
    对开发流程优化的建议
    容器未正常启动-->docker ps看不到,docker ps -a可以看到-->执行命令时出现Container is not running
    Linux下C语言多线程编程
    curl库相关使用
    PCB走线&过孔载流分析
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6199559.html
Copyright © 2011-2022 走看看