Exemple #1
0
 def install_code(self, db):
     self.extra_objs = [
         skytools.DBSchema("londiste", sql_file='londiste.sql'),
         skytools.DBFunction("londiste.global_add_table",
                             2,
                             sql_file='londiste.upgrade_2.1_to_3.1.sql'),
     ]
     CascadeAdmin.install_code(self, db)
Exemple #2
0
 def install_code(self, db):
     fn = skytools.installer_find_file('londiste.sql')
     main_sql = open(fn, 'r').read()
     noschema_sql = main_sql.replace('create schema', '-- create schema')
     self.extra_objs = [
         skytools.DBSchema("londiste", sql_file = 'londiste.sql'),
         skytools.DBFunction("londiste.global_add_table", 2, sql = noschema_sql),
     ]
     CascadeAdmin.install_code(self, db)
Exemple #3
0
    def __init__(self, args):
        """Londiste setup init."""
        CascadeAdmin.__init__(self, 'londiste3', 'db', args, worker_setup = True)

        # compat
        self.queue_name = self.cf.get('pgq_queue_name', '')
        # real
        if not self.queue_name:
            self.queue_name = self.cf.get('queue_name')

        self.set_name = self.queue_name
Exemple #4
0
    def __init__(self, args):
        """Londiste setup init."""
        CascadeAdmin.__init__(self, "londiste3", "db", args, worker_setup=True)

        # compat
        self.queue_name = self.cf.get("pgq_queue_name", "")
        # real
        if not self.queue_name:
            self.queue_name = self.cf.get("queue_name")

        self.set_name = self.queue_name

        londiste.handler.load_handler_modules(self.cf)
Exemple #5
0
    def __init__(self, args):
        """Londiste setup init."""
        CascadeAdmin.__init__(self, 'londiste3', 'db', args, worker_setup = True)

        # compat
        self.queue_name = self.cf.get('pgq_queue_name', '')
        # real
        if not self.queue_name:
            self.queue_name = self.cf.get('queue_name')

        self.set_name = self.queue_name

        londiste.handler.load_handler_modules(self.cf)
Exemple #6
0
 def load_extra_status(self, curs, node):
     """Fetch extra info."""
     CascadeAdmin.load_extra_status(self, curs, node)
     curs.execute("select * from londiste.get_table_list(%s)", [self.queue_name])
     n_ok = n_half = n_ign = 0
     for tbl in curs.fetchall():
         if not tbl['local']:
             n_ign += 1
         elif tbl['merge_state'] == 'ok':
             n_ok += 1
         else:
             n_half += 1
     node.add_info_line('Tables: %d/%d/%d' % (n_ok, n_half, n_ign))
Exemple #7
0
 def load_extra_status(self, curs, node):
     """Fetch extra info."""
     CascadeAdmin.load_extra_status(self, curs, node)
     curs.execute("select * from londiste.get_table_list(%s)", [self.queue_name])
     n_ok = n_half = n_ign = 0
     for tbl in curs.fetchall():
         if not tbl['local']:
             n_ign += 1
         elif tbl['merge_state'] == 'ok':
             n_ok += 1
         else:
             n_half += 1
     node.add_info_line('Tables: %d/%d/%d' % (n_ok, n_half, n_ign))
Exemple #8
0
    def __init__(self, args):
        """Londiste setup init."""
        CascadeAdmin.__init__(self, 'londiste3', 'db', args, worker_setup = True)

        # compat
        self.queue_name = self.cf.get('pgq_queue_name', '')
        # real
        if not self.queue_name:
            self.queue_name = self.cf.get('queue_name')

        self.set_name = self.queue_name

        self.lock_timeout = self.cf.getfloat('lock_timeout', 10)

        londiste.handler.load_handler_modules(self.cf)
Exemple #9
0
    def init_optparse(self, parser=None):
        """Add londiste switches to cascadeadmin ones."""

        p = CascadeAdmin.init_optparse(self, parser)
        p.add_option("--expect-sync", action="store_true", dest="expect_sync",
                    help = "no copy needed", default=False)
        p.add_option("--skip-truncate", action="store_true", dest="skip_truncate",
                    help = "dont delete old data", default=False)
        p.add_option("--copy-condition", dest="copy_condition",
                help = "copy: where expression")
        p.add_option("--force", action="store_true",
                    help="force", default=False)
        p.add_option("--all", action="store_true",
                    help="include all tables", default=False)
        p.add_option("--create", action="store_true",
                    help="include all tables", default=False)
        p.add_option("--create-only",
                    help="pkey,fkeys,indexes")
        p.add_option("--trigger-flags",
                    help="Set trigger flags (BAIUDLQ)")
        p.add_option("--trigger-arg", action="append",
                    help="Custom trigger arg")
        p.add_option("--no-triggers", action="store_true",
                    help="Custom trigger arg")
        p.add_option("--handler", action="append",
                    help="add: Custom handler for table")
        return p
Exemple #10
0
    def init_optparse(self, parser=None):
        """Add londiste switches to cascadeadmin ones."""

        p = CascadeAdmin.init_optparse(self, parser)
        p.add_option("--expect-sync", action="store_true", dest="expect_sync",
                    help = "no copy needed", default=False)
        p.add_option("--skip-truncate", action="store_true", dest="skip_truncate",
                    help = "dont delete old data", default=False)
        p.add_option("--copy-condition", dest="copy_condition",
                help = "copy: where expression")
        p.add_option("--force", action="store_true",
                    help="force", default=False)
        p.add_option("--all", action="store_true",
                    help="include all tables", default=False)
        p.add_option("--create", action="store_true",
                    help="create, minimal", default=False)
        p.add_option("--create-full", action="store_true",
                    help="create, full")
        p.add_option("--trigger-flags",
                    help="Set trigger flags (BAIUDLQ)")
        p.add_option("--trigger-arg", action="append",
                    help="Custom trigger arg")
        p.add_option("--no-triggers", action="store_true",
                    help="Custom trigger arg")
        p.add_option("--handler", action="store",
                help="add: Custom handler for table")
        p.add_option("--handler-arg", action="append",
                    help="add: Argument to custom handler")
        p.add_option("--merge-all", action="store_true",
                    help="merge tables from all source queues", default=False)
        p.add_option("--no-merge", action="store_true",
                    help="don't merge tables from source queues", default=False)
        return p
Exemple #11
0
    def init_optparse(self, parser=None):
        """Add londiste switches to cascadeadmin ones."""

        p = CascadeAdmin.init_optparse(self, parser)
        p.add_option("--expect-sync", action="store_true", dest="expect_sync",
                    help = "no copy needed", default=False)
        p.add_option("--skip-truncate", action="store_true", dest="skip_truncate",
                    help = "dont delete old data", default=False)
        p.add_option("--copy-condition", dest="copy_condition",
                help = "copy: where expression")
        p.add_option("--force", action="store_true",
                    help="force", default=False)
        p.add_option("--all", action="store_true",
                    help="include all tables", default=False)
        p.add_option("--create", action="store_true",
                    help="create, minimal", default=False)
        p.add_option("--create-full", action="store_true",
                    help="create, full")
        p.add_option("--trigger-flags",
                    help="Set trigger flags (BAIUDLQ)")
        p.add_option("--trigger-arg", action="append",
                    help="Custom trigger arg")
        p.add_option("--no-triggers", action="store_true",
                    help="Custom trigger arg")
        p.add_option("--handler", action="store",
                help="add: Custom handler for table")
        p.add_option("--handler-arg", action="append",
                    help="add: Argument to custom handler")
        return p
Exemple #12
0
    def init_optparse(self, parser=None):
        """Add londiste switches to cascadeadmin ones."""

        p = CascadeAdmin.init_optparse(self, parser)
        p.add_option("--expect-sync", action="store_true", dest="expect_sync",
                    help = "no copy needed", default=False)
        p.add_option("--skip-truncate", action="store_true", dest="skip_truncate",
                    help = "dont delete old data", default=False)
        p.add_option("--force", action="store_true",
                    help="force", default=False)
        p.add_option("--all", action="store_true",
                    help="include all tables", default=False)
        p.add_option("--create", action="store_true",
                    help="include all tables", default=False)
        p.add_option("--create-only",
                    help="pkey,fkeys,indexes")
        return p
Exemple #13
0
    def init_optparse(self, parser=None):
        """Add londiste switches to cascadeadmin ones."""

        p = CascadeAdmin.init_optparse(self, parser)
        p.add_option("--expect-sync", action="store_true", dest="expect_sync",
                help = "no copy needed", default=False)
        p.add_option("--skip-truncate", action="store_true", dest="skip_truncate",
                help = "do not delete old data", default=False)
        p.add_option("--find-copy-node", action="store_true", dest="find_copy_node",
                help = "add: find table source for copy by walking upwards")
        p.add_option("--copy-node", metavar = "NODE", dest="copy_node",
                help = "add: use NODE as source for initial copy")
        p.add_option("--force", action="store_true",
                help="force", default=False)
        p.add_option("--all", action="store_true",
                help="include all tables", default=False)
        p.add_option("--wait-sync", action="store_true",
                help = "add: wait until all tables are in sync"),
        p.add_option("--create", action="store_true",
                help="create, minimal", default=False)
        p.add_option("--create-full", action="store_true",
                help="create, full")
        p.add_option("--trigger-flags",
                help="set trigger flags (BAIUDLQ)")
        p.add_option("--trigger-arg", action="append",
                help="custom trigger arg")
        p.add_option("--no-triggers", action="store_true",
                help="no triggers on table")
        p.add_option("--handler", action="store",
                help="add: custom handler for table")
        p.add_option("--handler-arg", action="append",
                help="add: argument to custom handler")
        p.add_option("--merge-all", action="store_true",
                help="merge tables from all source queues", default=False)
        p.add_option("--no-merge", action="store_true",
                help="do not merge tables from source queues", default=False)
        p.add_option("--max-parallel-copy", metavar = "NUM", type = "int",
                help="max number of parallel copy processes")
        p.add_option("--dest-table", metavar = "NAME",
                help="add: name for actual table")
        p.add_option("--skip-non-existing", action="store_true",
                help="add: skip object that does not exist")
        return p
Exemple #14
0
    def init_optparse(self, parser=None):
        """Add londiste switches to CascadeAdmin ones."""

        p = CascadeAdmin.init_optparse(self, parser)
        p.add_option("--expect-sync", action="store_true", dest="expect_sync",
                help = "no copy needed", default=False)
        p.add_option("--skip-truncate", action="store_true", dest="skip_truncate",
                help = "do not delete old data", default=False)
        p.add_option("--find-copy-node", action="store_true", dest="find_copy_node",
                help = "add: find table source for copy by walking upwards")
        p.add_option("--copy-node", metavar = "NODE", dest="copy_node",
                help = "add: use NODE as source for initial copy")
        p.add_option("--force", action="store_true",
                help="force", default=False)
        p.add_option("--all", action="store_true",
                help="include all tables", default=False)
        p.add_option("--wait-sync", action="store_true",
                help = "add: wait until all tables are in sync"),
        p.add_option("--create", action="store_true",
                help="create, minimal", default=False)
        p.add_option("--create-full", action="store_true",
                help="create, full")
        p.add_option("--trigger-flags",
                help="set trigger flags (BAIUDLQ)")
        p.add_option("--trigger-arg", action="append",
                help="custom trigger arg")
        p.add_option("--no-triggers", action="store_true",
                help="no triggers on table")
        p.add_option("--handler", action="store",
                help="add: custom handler for table")
        p.add_option("--handler-arg", action="append",
                help="add: argument to custom handler")
        p.add_option("--merge-all", action="store_true",
                help="merge tables from all source queues", default=False)
        p.add_option("--no-merge", action="store_true",
                help="do not merge tables from source queues", default=False)
        p.add_option("--max-parallel-copy", metavar = "NUM", type = "int",
                help="max number of parallel copy processes")
        p.add_option("--dest-table", metavar = "NAME",
                help="add: name for actual table")
        p.add_option("--skip-non-existing", action="store_true",
                help="add: skip object that does not exist")
        return p
Exemple #15
0
    def init_optparse(self, parser=None):
        """Add londiste switches to cascadeadmin ones."""

        p = CascadeAdmin.init_optparse(self, parser)
        p.add_option("--expect-sync",
                     action="store_true",
                     dest="expect_sync",
                     help="no copy needed",
                     default=False)
        p.add_option("--skip-truncate",
                     action="store_true",
                     dest="skip_truncate",
                     help="dont delete old data",
                     default=False)
        p.add_option("--copy-condition",
                     dest="copy_condition",
                     help="copy: where expression")
        p.add_option("--force",
                     action="store_true",
                     help="force",
                     default=False)
        p.add_option("--all",
                     action="store_true",
                     help="include all tables",
                     default=False)
        p.add_option("--create",
                     action="store_true",
                     help="include all tables",
                     default=False)
        p.add_option("--create-only", help="pkey,fkeys,indexes")
        p.add_option("--trigger-arg",
                     action="append",
                     help="Custom trigger arg")
        p.add_option("--handler",
                     action="append",
                     help="add: Custom handler for table")
        return p
Exemple #16
0
    def __init__(self, args):
        """Initialize pgqadm."""
        skytools.DBScript.__init__(self, 'pgqadm', args)
        self.set_single_loop(1)

        if len(self.args) < 2:
            print("need command")
            sys.exit(1)

        int_cmds = {
            'create': self.create_queue,
            'drop': self.drop_queue,
            'register': self.register,
            'unregister': self.unregister,
            'install': self.installer,
            'config': self.change_config,
        }

        cascade_cmds = ['create-node']

        cmd = self.args[1]
        if cmd == "ticker":
            script = pgq.SmallTicker(args)
        elif cmd == "status":
            script = pgq.PGQStatus(args)
        elif cmd in cascade_cmds:
            script = CascadeAdmin(self.service_name, 'db', args)
        elif cmd in int_cmds:
            script = None
            self.work = int_cmds[cmd]
        else:
            print("unknown command")
            sys.exit(1)

        if self.pidfile:
            self.pidfile += ".admin"
        self.run_script = script
Exemple #17
0
 def install_code(self, db):
     self.extra_objs = [
         skytools.DBSchema("londiste", sql_file = 'londiste.sql'),
         skytools.DBFunction("londiste.global_add_table", 2, sql_file = 'londiste.upgrade.2to3.sql'),
     ]
     CascadeAdmin.install_code(self, db)