예제 #1
0
 def __init__(self, conf_path=''):
     logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s',
                         level=logging.DEBUG)
     self.conf = Configure(conf_path).conf
     self.meta = MetaManager(self.conf['meta-server'],
                             self.conf['meta-root'])
     self.mmeta = MasterMetaManager(self.conf, self.meta)
 def __init__(self, conf_path=''):
     logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s',
                         level=logging.DEBUG)
     self.conf = Configure(conf_path).conf
     self.meta = MetaManager(self.conf['meta-server'],
                             self.conf['meta-root'])
     logging.info('broker init OK, conf: %s' % str(self.conf))
     logging.info('broker init OK, zk addr: %s, zk root: %s' %
                  (self.conf['meta-server'], self.conf['meta-root']))
예제 #3
0
    def add_segment(self, topic_name):
        topic_path = self.topic_path + '/' + topic_name
        segment_name = "%d" % int(time.time())
        seg_start = 0
        seg_end = 0xffffffff
        seg_host = ''

        seg_attr = {'start': seg_start, 'end': seg_end, 'host': seg_host}
        seg_path = topic_path + '/' + segment_name
        ret = self.meta.create_node_with_property(seg_path,
                                                  json.dumps(seg_attr))
        if ret:
            logging.info('add segment(%s) OK' % seg_path)
            return True
        else:
            logging.warning('add segment(%s) failed' % seg_path)
            return False


if __name__ == '__main__':
    import sys
    sys.path.append('../..')
    from common.MetaManager import MetaManager
    meta = MetaManager('127.0.0.1:2181', '/iotmq')
    mmeta = MasterMetaManager('', meta)

    mmeta.prepare_root_path()
    mmeta.create_topic('test_topic')
    mmeta.add_segment('test_topic')