コード例 #1
0
 def execute(self):
     schema, table = UpdateHistoryTable.HISTORY_TABLE.split('.')
     exists = CheckTableExists(database=self.dump_database,
                               schema=schema,
                               table=table,
                               master_port=self.master_port).run()
     if not exists:
         conn = None
         CREATE_HISTORY_TABLE = """ create table %s (rec_date timestamp, start_time char(8), end_time char(8), options text, dump_key varchar(20), dump_exit_status smallint, script_exit_status smallint, exit_text varchar(10)) distributed by (rec_date); """ % UpdateHistoryTable.HISTORY_TABLE
         try:
             dburl = dbconn.DbURL(port=self.master_port,
                                  dbname=self.dump_database)
             conn = dbconn.connect(dburl)
             execSQL(conn, CREATE_HISTORY_TABLE)
             conn.commit()
         except Exception, e:
             logger.exception(
                 "Unable to create %s in %s database" %
                 (UpdateHistoryTable.HISTORY_TABLE, self.dump_database))
             return
         else:
             logger.info(
                 "Created %s in %s database" %
                 (UpdateHistoryTable.HISTORY_TABLE, self.dump_database))
         finally:
コード例 #2
0
 def execute(self):
     dburl = dbconn.DbURL()
     query = self.UPDATE_VERIFICATION_ENTRY % (self.state, self.done,
                                               self.mismatch, self.token)
     with dbconn.connect(dburl, allowSystemTableMods='dml') as conn:
         dbconn.execSQL(conn, query)
         conn.commit()
コード例 #3
0
 def execute(self):
     dburl = dbconn.DbURL()
     query = self.INSERT_VERIFICATION_ENTRY % (
         self.token, self.type, self.content, VerificationState.RUNNING)
     with dbconn.connect(dburl, allowSystemTableMods='dml') as conn:
         dbconn.execSQL(conn, query)
         conn.commit()
コード例 #4
0
 def _analyze(self, restore_db, master_port):
     conn = None
     logger.info('Commencing analyze of %s database, please wait' %
                 restore_db)
     try:
         dburl = dbconn.DbURL(port=master_port, dbname=restore_db)
         conn = dbconn.connect(dburl)
         execSQL(conn, 'analyze')
         conn.commit()
     except Exception, e:
         logger.warn('Issue with analyze of %s database' % restore_db)
コード例 #5
0
    def pauseFaultProber(self):
        assert not self.__isPaused
        assert self.__masterDbUrl is not None  # must be initialized
        assert self.__conn is None

        logger.debug("Pausing fault prober")

        self.__conn = dbconn.connect(
            self.__masterDbUrl, True
        )  # use utility mode so we don't do any segment connection stuff
        dbconn.execSQL(self.__conn, "set gp_fts_probe_pause = on")

        self.__isPaused = True
コード例 #6
0
 def _analyze(self, restore_db, restore_tables, master_port):
     conn = None
     try:
         dburl = dbconn.DbURL(port=master_port, dbname=restore_db)
         conn = dbconn.connect(dburl)
         for table in restore_tables:
             logger.info(
                 'Commencing analyze of %s in %s database, please wait...' %
                 (table, restore_db))
             try:
                 execSQL(conn, 'analyze %s' % table)
                 conn.commit()
             except Exception, e:
                 logger.warn(
                     'Issue with analyze of %s table, check log file for details'
                     % table)
             else:
                 logger.info('Analyze of %s table completed without error' %
                             table)
     finally:
         if conn is not None:
             conn.close()
コード例 #7
0
 def run(self):
     dbconn.execSQL(self.cancel_conn, self.query)
コード例 #8
0
            finally:
                if conn is not None:
                    conn.close()

        translate_rc_to_msg = {0: "COMPLETED", 1: "WARNING", 2: "FATAL"}
        exit_msg = translate_rc_to_msg[self.pseudo_exit_status]
        APPEND_HISTORY_TABLE = """ insert into %s values (now(), '%s', '%s', '%s', '%s', %d, %d, '%s'); """ % (
            UpdateHistoryTable.HISTORY_TABLE, self.time_start, self.time_end,
            self.options_list, self.timestamp, self.dump_exit_status,
            self.pseudo_exit_status, exit_msg)
        conn = None
        try:
            dburl = dbconn.DbURL(port=self.master_port,
                                 dbname=self.dump_database)
            conn = dbconn.connect(dburl)
            execSQL(conn, APPEND_HISTORY_TABLE)
            conn.commit()
        except Exception, e:
            logger.exception(
                "Failed to insert record into %s in %s database" %
                (UpdateHistoryTable.HISTORY_TABLE, self.dump_database))
        else:
            logger.info("Inserted dump record into %s in %s database" %
                        (UpdateHistoryTable.HISTORY_TABLE, self.dump_database))
        finally:
            if conn is not None:
                conn.close()


class DumpGlobal(Operation):
    def __init__(self, timestamp, master_datadir, backup_dir, ddboost):
コード例 #9
0
 def execute(self):
     dburl = dbconn.DbURL()
     query = self.REMOVE_VERIFICATION_ENTRY % self.token
     with dbconn.connect(dburl, allowSystemTableMods='dml') as conn:
         dbconn.execSQL(conn, query)
         conn.commit()