(self, initial_loc = None)
Find root node, having start point.
Find root node, having start point.
Find root node having start point .
def find_root_db(self, initial_loc = None):
        """Find root node, having start point."""
        if initial_loc:
            loc = initial_loc
            db = self.get_database('root_db', connstr = loc, profile = 'remote')
        else:
            loc = self.cf.get(self.initial_db_name)
            db = self.get_database('root_db', connstr = loc)

        while 1:
            # query current status
            res = self.exec_query(db, "select * from pgq_node.get_node_info(%s)", [self.queue_name])
            info = res[0]
            node_type = info['node_type']
            if node_type is None:
                self.log.info("Root node not initialized?")
                sys.exit(1)

            self.log.debug("db='%s' -- type='%s' provider='%s'", loc, node_type, info['provider_location'])
            # configured db may not be root anymore, walk upwards then
            if node_type in ('root', 'combined-root'):
                db.commit()
                self.root_node_name = info['node_name']
                return db

            self.close_database('root_db')
            if loc == info['provider_location']:
                raise Exception("find_root_db: got loop: %s" % loc)
            loc = info['provider_location']
            if loc is None:
                self.log.error("Sub node provider not initialized?")
                sys.exit(1)

            db = self.get_database('root_db', connstr = loc, profile = 'remote')

        raise Exception('process canceled')
def find_root_db ( self , initial_loc = None ) : if initial_loc : loc = initial_loc db = self . get_database ( 'root_db' , connstr = loc , profile = 'remote' ) else : loc = self . cf . get ( self . initial_db_name ) db = self . get_database ( 'root_db' , connstr = loc ) while 1 : # query current status res = self . exec_query ( db , "select * from pgq_node.get_node_info(%s)" , [ self . queue_name ] ) info = res [ 0 ] node_type = info [ 'node_type' ] if node_type is None : self . log . info ( "Root node not initialized?" ) sys . exit ( 1 ) self . log . debug ( "db='%s' -- type='%s' provider='%s'" , loc , node_type , info [ 'provider_location' ] ) # configured db may not be root anymore, walk upwards then if node_type in ( 'root' , 'combined-root' ) : db . commit ( ) self . root_node_name = info [ 'node_name' ] return db self . close_database ( 'root_db' ) if loc == info [ 'provider_location' ] : raise Exception ( "find_root_db: got loop: %s" % loc ) loc = info [ 'provider_location' ] if loc is None : self . log . error ( "Sub node provider not initialized?" ) sys . exit ( 1 ) db = self . get_database ( 'root_db' , connstr = loc , profile = 'remote' ) raise Exception ( 'process canceled' )