Пример #1
0
 def pgb_run (self, seconds=60, concurrency=25, filename=None, background=False):
     # run pgbench -T 10 to populate db with some data
     cmd = [PGBENCH, '-T', '%d' % seconds, '-c', '%d' % concurrency] + self.database.get_db_cmdline_args()
     if filename:
         cmd += ['-f', filename]
     if background:
         run_in_background(cmd)
     else:
         run_cmd(cmd)
Пример #2
0
    def modify_db_for_replication(self):
        "add pk's, foreign keys, partitions, ..."
        # add support for moddatetime triggers from contrib
        cmd = ['psql'] + self.database.get_db_cmdline_args() + ['-f', '/usr/share/postgresql/8.4/contrib/moddatetime.sql']
#        print cmd
        run_cmd(cmd)
        # modify db and commit
        with open('/tmp/prepare_pgbenchdb_for_londiste.sql', 'w') as f:
            f.write(pgbencdb_mods)
        howto("create file /tmp/prepare_pgbenchdb_for_londiste.sql with the following ...\n----\n%s\n----\n" % pgbencdb_mods)
        howto(". . . and then execute it")
        cmd = ['psql'] + self.database.get_db_cmdline_args() + ['-f', '/tmp/prepare_pgbenchdb_for_londiste.sql']
        run_cmd(cmd)
Пример #3
0
 def create_node(self):
     cmd = [LONDISTE, self.inifile, 'create-'+self.node_type,
            self.node_name] + self.connect_string.split()
     if self.node_type in ['branch', 'leaf']:
         cmd += ['--provider=%s' % self.provider_connect_string]
     retcode, out, err = run_cmd (cmd)
     if retcode:
         raise Exception, 'create failed %s ' % ' '.join(cmd)
Пример #4
0
 def status(self):
     "prints replication status"
     cmd = [LONDISTE, self.inifile, 'status']
     retcode, stdout, stderr = run_cmd(cmd)
     if retcode:
         print stderr
         raise Exception, 'status failed:  %s.' % ' '.join(cmd)
     print stdout
Пример #5
0
 def compare_tables(self):
     "compares tables between provider and subscriber"
     cmd = [LONDISTE, self.inifile, 'compare']
     retcode, stdout, stderr = run_cmd(cmd)
     if retcode:
         print stderr
         raise Exception, 'compare failed:  %s.' % ' '.join(cmd)
     print stdout, stderr
Пример #6
0
 def stop(self):
     "stops the replay process" # TODO - should check for existing pidfile
     try:
         cmd = [LONDISTE, '-d',  self.inifile, '--stop']
         retcode, out, err = run_cmd (cmd)
         if retcode:
             raise Exception, 'stop failed: %s.' % ' '.join(cmd)
     except:
         pass
Пример #7
0
 def stop(self):
     "stops pgqd"
     pidfile = '%s/pid/pgqd.pid' % self.basedir
     try:
         pid = open(pidfile).read().strip()
         cmd = ['kill', pid]
         retcode, out, err = run_cmd(cmd)
     except:
         pass # ok to not have a pidfile in partially set up cluster
Пример #8
0
 def execute(self, sql, name=None):
     if not name:
         name = '/tmp/%04d%02d%02dt%02d%02d%02d.ddl' % time.localtime(time.time())[:6]
     with open(name, 'w') as f:
         f.write(sql)
     cmd = [LONDISTE, self.inifile, 'execute', name]
     retcode, stdout, stderr = run_cmd(cmd)
     if retcode:
         print stderr
         raise Exception, 'execute failed:  %s.' % ' '.join(cmd) 
     print stdout
Пример #9
0
 def install_ticker(self):
     "installs pgq on master"
     run_cmd([PGQADM, self.ticker_ini, 'install'])
Пример #10
0
 def check_data(self):
     run_cmd([LONDISTE, self.provider_ini, 'compare'])
Пример #11
0
 def add_tables_on_subscriber(self, tablelist):
     run_cmd([LONDISTE, self.subscriber_ini, 'subscriber', 'add'] + tablelist)
Пример #12
0
    def add_tables_on_provider(self, tablelist):
#        print [LONDISTE, self.provider_ini, 'provider', 'add'] + tablelist
        run_cmd([LONDISTE, self.provider_ini, 'provider', 'add'] + tablelist)
Пример #13
0
 def stop_londiste_replay(self):
     run_cmd([LONDISTE, self.subscriber_ini, '--stop'])
Пример #14
0
 def install_londiste_on_provider(self):
     run_cmd([LONDISTE, self.provider_ini, 'provider', 'install'])
Пример #15
0
 def stop_ticker(self):
     "stops ticker on provider"
     run_cmd([PGQADM, self.ticker_ini, '--stop'])
Пример #16
0
    def start(self):
        "starts pgqd"
        cmd = [PGQD, '-d', self.inifile]
#        print 'pgqd.start()', cmd
        retcode, out, err = run_cmd(cmd)
Пример #17
0
 def start_ticker(self):
     "starts ticker on provider"
     # print "start_ticker() ::",[PGQADM, self.ticker_ini, 'ticker', '-d']
     run_cmd([PGQADM, self.ticker_ini, 'ticker', '-d'])
Пример #18
0
    def start(self):
        cmd = [LONDISTE, '-d',  self.inifile, 'replay']
#        print '%s.start()' % self.database.dbname, cmd
        retcode, out, err = run_cmd (cmd)
        if retcode:
            raise Exception, 'start failed %s ' % ' '.join(cmd)
Пример #19
0
 def pgb_init_db(self):
     "just run 'pgbench -i -s'"
     # run pgbench -i -s %(self.scale)s
     cmd = [PGBENCH, '-i', '-s', str(self.scale), '-F', '80'] + self.database.get_db_cmdline_args()
     run_cmd(cmd)
Пример #20
0
 def start_londiste_replay(self):
     run_cmd([LONDISTE, self.subscriber_ini, 'replay', '-d'])
Пример #21
0
 def install_londiste_on_subscriber(self):
     run_cmd([LONDISTE, self.subscriber_ini, 'subscriber', 'install'])
Пример #22
0
 def add_tables(self, tablelist=[], flags=['--all']):
     "adds tables to replication, by default adds all user tables"
     cmd = [LONDISTE, self.inifile, 'add-table'] + tablelist + flags
     retcode, out, err = run_cmd(cmd)
     if retcode:
         raise Exception, 'add_tables failed:  %s.' % ' '.join(cmd)