(self, *args)
Reload data from provider node.
Reload data from provider node.
Reload data from provider node .
def cmd_resync(self, *args):
        """Reload data from provider node."""
        db = self.get_database('db')
        args = self.expand_arg_list(db, 'r', True, args)

        if not self.options.find_copy_node:
            self.load_local_info()
            src_db = self.get_provider_db()
            src_curs = src_db.cursor()
            src_tbls = self.fetch_set_tables(src_curs)
            src_db.commit()

            problems = 0
            for tbl in args:
                tbl = skytools.fq_name(tbl)
                if tbl not in src_tbls or not src_tbls[tbl]['local']:
                    self.log.error("Table %s does not exist on provider, need to switch to different provider", tbl)
                    problems += 1
            if problems > 0:
                self.log.error("Problems, cancelling operation")
                sys.exit(1)

        if self.options.find_copy_node or self.options.copy_node:
            q = "select table_name, table_attrs from londiste.get_table_list(%s) where local"
            cur = db.cursor()
            cur.execute(q, [self.set_name])
            for row in cur.fetchall():
                if row['table_name'] not in args:
                    continue
                attrs = skytools.db_urldecode (row['table_attrs'] or '')

                if self.options.find_copy_node:
                    attrs['copy_node'] = '?'
                elif self.options.copy_node:
                    attrs['copy_node'] = self.options.copy_node

                attrs = skytools.db_urlencode (attrs)
                q = "select * from londiste.local_set_table_attrs (%s, %s, %s)"
                self.exec_cmd(db, q, [self.set_name, row['table_name'], attrs])

        q = "select * from londiste.local_set_table_state(%s, %s, null, null)"
        self.exec_cmd_many(db, q, [self.set_name], args)
def cmd_resync ( self , * args ) : db = self . get_database ( 'db' ) args = self . expand_arg_list ( db , 'r' , True , args ) if not self . options . find_copy_node : self . load_local_info ( ) src_db = self . get_provider_db ( ) src_curs = src_db . cursor ( ) src_tbls = self . fetch_set_tables ( src_curs ) src_db . commit ( ) problems = 0 for tbl in args : tbl = skytools . fq_name ( tbl ) if tbl not in src_tbls or not src_tbls [ tbl ] [ 'local' ] : self . log . error ( "Table %s does not exist on provider, need to switch to different provider" , tbl ) problems += 1 if problems > 0 : self . log . error ( "Problems, cancelling operation" ) sys . exit ( 1 ) if self . options . find_copy_node or self . options . copy_node : q = "select table_name, table_attrs from londiste.get_table_list(%s) where local" cur = db . cursor ( ) cur . execute ( q , [ self . set_name ] ) for row in cur . fetchall ( ) : if row [ 'table_name' ] not in args : continue attrs = skytools . db_urldecode ( row [ 'table_attrs' ] or '' ) if self . options . find_copy_node : attrs [ 'copy_node' ] = '?' elif self . options . copy_node : attrs [ 'copy_node' ] = self . options . copy_node attrs = skytools . db_urlencode ( attrs ) q = "select * from londiste.local_set_table_attrs (%s, %s, %s)" self . exec_cmd ( db , q , [ self . set_name , row [ 'table_name' ] , attrs ] ) q = "select * from londiste.local_set_table_state(%s, %s, null, null)" self . exec_cmd_many ( db , q , [ self . set_name ] , args )