• 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

  • 相关阅读:
    99年人民币冠号大全
    9910的5种水印冠号发行量分布图
    儿童、青少年长身高的注意事项
    钱币评级流程与方法
    99版人民币收藏价值分析
    四、五版币冠字号发行量统计排行
    如何收藏第四套人民币大全套
    第四套荧光钞大全介绍
    小程序加载中提示实现
    微信小程序navigateBack如何带参数
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349176.html
Copyright © 2020-2023  润新知