当前位置: 首页>>代码示例>>Python>>正文


Python GpactivateStandby.create_standby方法代码示例

本文整理汇总了Python中mpp.gpdb.tests.storage.walrepl.gpactivatestandby.GpactivateStandby.create_standby方法的典型用法代码示例。如果您正苦于以下问题:Python GpactivateStandby.create_standby方法的具体用法?Python GpactivateStandby.create_standby怎么用?Python GpactivateStandby.create_standby使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mpp.gpdb.tests.storage.walrepl.gpactivatestandby.GpactivateStandby的用法示例。


在下文中一共展示了GpactivateStandby.create_standby方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: OODClass

# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby import GpactivateStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby.GpactivateStandby import create_standby [as 别名]
class OODClass(MPPTestCase):
    

    def __init__(self,methodName):
        self.gp = GpactivateStandby()
        self.verify = StandbyVerify()
        self.config = GPDBConfig()
        self.disk = Disk()
        self.sdby_mdd = os.environ.get('MASTER_DATA_DIRECTORY')
        self.pgport = os.environ.get('PGPORT')
        super(OODClass,self).__init__(methodName)

    def initiate_standby(self):
        self.gp.create_standby(local='no')


    def check_standby(self):
        self.assertFalse(self.verify.check_standby_processes())

    def get_standby_dbid(self):
       std_sql = "select dbid from gp_segment_configuration where content='-1' and role='m';"
       standby_dbid = PSQL.run_sql_command(std_sql, flags = '-q -t', dbname= 'template1')
       return standby_dbid.strip()

    def restart_standby(self):
        sdby_host =  self.config.get_master_standbyhost()
        stdby_dbid = self.get_standby_dbid()
        cmd="pg_ctl -D %s -o '-p %s --gp_dbid=%s --gp_num_contents_in_cluster=2 --silent-mode=true -i -M master --gp_contentid=-1 -x 0 -E' start &"%(self.sdby_mdd, self.pgport, stdby_dbid)
        self.assertTrue(self.gp.run_remote(sdby_host,cmd, self.pgport, self.sdby_mdd))
        self.assertTrue(self.verify.check_standby_processes())

    def check_diskusage(self, host):  # This now checks for only /data
        (rc, result) = self.disk.get_disk_usage(host, '/data')
        if rc != 0:
            raise Exception ("The specified mount /data is not present for the device")
        else:
            available_usage = result
            return available_usage

    def _fill(self, filename, host):
        cmd_prefix = "ssh " +host+ " \""
        cmd_postfix = "\""
        location = '/data'
        if not os.path.isdir('%s/diskfill/' % location):
            os.makedirs('%s/diskfill/' % location)
        cmd_str = cmd_prefix + "dd if=/dev/zero bs=16384K count=2000 of=" +location+ "/diskfill/" + filename +cmd_postfix
        cmd = Command(name='Fill Disk', cmdStr=cmd_str)
        tinctest.logger.info(" %s" % cmd)
        cmd.run(validateAfter=False)
        result = cmd.get_results()
        if result.rc !=0:
            tinctest.logger.error('disk fill not working. Its already full')

    
    def filldisk(self):
        host =  self.config.get_master_standbyhost()
        disk_usage = self.check_diskusage(host)
        i = 0
        while(int(disk_usage.strip()) >1000000):
            filename = 'new_space_%s' % i
            self._fill(filename, host)
            i +=1
            disk_usage = self.check_diskusage(host)

    def remove_fillfiles(self, filename, host):
        location = '/data'
        cmd_str = "ssh %s rm %s/diskfill/%s*" % (host,location, filename)
        cmd = Command(name='Remove fill files', cmdStr=cmd_str)
        tinctest.logger.info(" %s" % cmd)
        cmd.run(validateAfter=False)
        result = cmd.get_results()
        if result.rc !=0:
            raise Exception('Unable to delete the fill files')
        return

        
    def cleanup(self):
        host =  self.config.get_master_standbyhost()
        self.remove_fillfiles('new_space', host)    
        #Recover segemnts in case segments and standby were on the same host
        cmd = Command(name='gprecoverseg', cmdStr='gprecoverseg -a')
        tinctest.logger.info(" %s" % cmd)
        cmd.run(validateAfter=False)
        result = cmd.get_results()
        if result.rc !=0:
            raise Exception('gprecoverseg failed')
        while(self.config.is_not_insync_segments() == False):
                tinctest.logger.info('Waiting for DB to be in sync')    
开发者ID:50wu,项目名称:gpdb,代码行数:90,代码来源:__init__.py


注:本文中的mpp.gpdb.tests.storage.walrepl.gpactivatestandby.GpactivateStandby.create_standby方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。