• zookeepr 临时节点


    from kazoo.client import KazooClient
    
    from kazoo.client import KazooState 
    
    import time
    
    print time.ctime()
    
    zk = KazooClient(hosts='20.5.101.15:12181',timeout=100)
    
    print zk
    
    print zk.state
    
    zk.start()
    
    print zk.state
    
    print '---------------------------------'
    
    zk.stop()
    
    print zk.state
    
    zk.start()
    
    print zk.state
    
    print zk.state
    
    print zk.state
    
    while True:
    
      time.sleep(1)
    
      print zk.get_children('/')
    
      print zk.get('/scan/001')
    
     
    
      [u'aa', u'cluster', u'controller', u'brokers', u'zookeeper', u'scan', u'admin', u'isr_change_notification', u'log_dir_event_notification', u'controller_epoch', u'aaayyy', u'mynode', u'consumers', u'latest_producer_id_block', u'config']
    
    ('', ZnodeStat(czxid=8589935253L, mzxid=8589935253L, ctime=1529570656357L, mtime=1529570656357L, version=0, cversion=0, aversion=0, ephemeralOwner=0, dataLength=0, numChildren=0, pzxid=8589935253L))
    
    [u'aa', u'cluster', u'controller', u'brokers', u'zookeeper', u'scan', u'admin', u'isr_change_notification', u'log_dir_event_notification', u'controller_epoch', u'aaayyy', u'mynode', u'consumers', u'latest_producer_id_block', u'config']
    
    ('', ZnodeStat(czxid=8589935253L, mzxid=8589935253L, ctime=1529570656357L, mtime=1529570656357L, version=0, cversion=0, aversion=0, ephemeralOwner=0, dataLength=0, numChildren=0, pzxid=8589935253L)) 
    
    临时节点: 
    
    ('', ZnodeStat(czxid=8589935253L, mzxid=8589935253L, ctime=1529570656357L, mtime=1529570656357L, version=0, cversion=0, aversion=0, ephemeralOwner=0, dataLength=0, numChildren=0, pzxid=8589935253L))
    
    ('', ZnodeStat(czxid=8589935271L, mzxid=8589935271L, ctime=1529570763614L, mtime=1529570763614L, version=0, cversion=0, aversion=0, ephemeralOwner=244355283532578946L, dataLength=0, numChildren=0, pzxid=8589935271L))
    
    [u'aa', u'cluster', u'controller', u'brokers', u'zookeeper', u'scan', u'admin', u'isr_change_notification', u'log_dir_event_notification', u'controller_epoch', u'aaayyy', u'mynode', u'consumers', u'latest_producer_id_block', u'config']
    
    ('', ZnodeStat(czxid=8589935253L, mzxid=8589935253L, ctime=1529570656357L, mtime=1529570656357L, version=0, cversion=0, aversion=0, ephemeralOwner=0, dataLength=0, numChildren=0, pzxid=8589935253L))
    
    ('', ZnodeStat(czxid=8589935271L, mzxid=8589935271L, ctime=1529570763614L, mtime=1529570763614L, version=0, cversion=0, aversion=0, ephemeralOwner=244355283532578946L, dataLength=0, numChildren=0, pzxid=8589935271L)) 
     
    [u'001', u'002']
    
    ('ceshi 001', ZnodeStat(czxid=8589935302L, mzxid=8589935302L, ctime=1529571007087L, mtime=1529571007087L, version=0, cversion=0, aversion=0, ephemeralOwner=0, dataLength=9, numChildren=0, pzxid=8589935302L))
    
    ('ceshi 002', ZnodeStat(czxid=8589935313L, mzxid=8589935313L, ctime=1529571049153L, mtime=1529571049153L, version=0, cversion=0, aversion=0, ephemeralOwner=244355283532578964L, dataLength=9, numChildren=0, pzxid=8589935313L)) 
     
    ('ceshi 002', ZnodeStat(czxid=8589935313L, mzxid=8589935313L, ctime=1529571049153L, mtime=1529571049153L, version=0, cversion=0, aversion=0, ephemeralOwner=244355283532578964L, dataLength=9, numChildren=0, pzxid=8589935313L))
    
    [u'001']
    
    ('ceshi 001', ZnodeStat(czxid=8589935302L, mzxid=8589935302L, ctime=1529571007087L, mtime=1529571007087L, version=0, cversion=0, aversion=0, ephemeralOwner=0, dataLength=9, numChildren=0, pzxid=8589935302L))
    
    Traceback (most recent call last):
    
      File "C:/Users/tlcb/PycharmProjects/untitled/rizhiyi/t1.py", line 22, in <module>
    
        print zk.get('/scan/002')
    
      File "C:Python27libsite-packageskazooclient.py", line 1042, in get
    
        return self.get_async(path, watch=watch).get()
    
      File "C:Python27libsite-packageskazoohandlersutils.py", line 79, in get
    
        raise self._exception
    
    kazoo.exceptions.NoNodeError

  • 相关阅读:
    蓝桥杯 猴子分苹果
    蓝桥杯 王、后传说 dfs
    蓝桥杯 C*++ Calculations 贪心
    python random模块 分类: python python Module python基础学习 2013-06-26 12:06 383人阅读 评论(0) 收藏
    去除列表中不重复的元素 分类: python 小练习 2013-06-25 14:59 245人阅读 评论(0) 收藏
    去除文件每行的第一个字符 分类: python 2013-06-24 15:03 414人阅读 评论(0) 收藏
    用户输入内容长度限制的异常 分类: python异常 2013-06-24 10:48 335人阅读 评论(0) 收藏
    使用python下载文件 分类: python python下载 2013-06-22 16:58 277人阅读 评论(0) 收藏
    猜数字 分类: python 小练习 python基础学习 2013-06-20 15:16 160人阅读 评论(0) 收藏
    Linux系统中ls命令用法详解 分类: ubuntu 2013-06-20 14:29 261人阅读 评论(0) 收藏
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349176.html
Copyright © 2020-2023  润新知