Example #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)
Example #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)
Example #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)
Example #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
Example #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
Example #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
Example #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
Example #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
Example #9
0
 def install_ticker(self):
     "installs pgq on master"
     run_cmd([PGQADM, self.ticker_ini, 'install'])
Example #10
0
 def check_data(self):
     run_cmd([LONDISTE, self.provider_ini, 'compare'])
Example #11
0
 def add_tables_on_subscriber(self, tablelist):
     run_cmd([LONDISTE, self.subscriber_ini, 'subscriber', 'add'] + tablelist)
Example #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)
Example #13
0
 def stop_londiste_replay(self):
     run_cmd([LONDISTE, self.subscriber_ini, '--stop'])
Example #14
0
 def install_londiste_on_provider(self):
     run_cmd([LONDISTE, self.provider_ini, 'provider', 'install'])
Example #15
0
 def stop_ticker(self):
     "stops ticker on provider"
     run_cmd([PGQADM, self.ticker_ini, '--stop'])
Example #16
0
    def start(self):
        "starts pgqd"
        cmd = [PGQD, '-d', self.inifile]
#        print 'pgqd.start()', cmd
        retcode, out, err = run_cmd(cmd)
Example #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'])
Example #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)
Example #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)
Example #20
0
 def start_londiste_replay(self):
     run_cmd([LONDISTE, self.subscriber_ini, 'replay', '-d'])
Example #21
0
 def install_londiste_on_subscriber(self):
     run_cmd([LONDISTE, self.subscriber_ini, 'subscriber', 'install'])
Example #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)