コード例 #1
0
 def _shutdown_catalog(self):
     """
     This method is responsible for gracefully shutting the
     catalog manager. Currently, it includes dropping the catalog database
     """
     logger.info("Shutting catalog")
     drop_db()
コード例 #2
0
async def realtime_server_status(protocol, server_closed):
    """
        Report status changes.

        `protocol` must provide `connections` and `errors` attributes.

        Completion or cancellation of the `server_closed` future
        stops monitoring.
    """

    previous_connections = 0
    previous_errors = 0

    while not server_closed.done() and not server_closed.cancelled():

        # Only report changes
        if protocol.__connections__ != previous_connections or \
                protocol.__errors__ != previous_errors:

            previous_connections = protocol.__connections__
            previous_errors = protocol.__errors__

            logger.info("Status: " + "connections: " +
                        str(previous_connections) + " " + "errors: " +
                        str(previous_errors))

        # Report changes every 1~s
        await asyncio.sleep(1)
コード例 #3
0
    def execute(self):
        valid_rules = []
        for rule in self.rule_set:
            if not self.root_expr.is_rule_explored(rule.rule_type) and \
                    rule.top_match(self.root_expr.opr):
                valid_rules.append(rule)

        # sort the rules by promise
        valid_rules = sorted(valid_rules, key=lambda x: x.promise())
        for rule in valid_rules:
            binder = Binder(self.root_expr, rule.pattern,
                            self.optimizer_context.memo)
            for match in iter(binder):
                if not rule.check(match, self.optimizer_context):
                    continue
                logger.info('In TopDown, Rule {} matched for {}'.format(
                    rule, self.root_expr))
                after = rule.apply(match, self.optimizer_context)
                new_expr = self.optimizer_context.replace_expression(
                    after, self.root_expr.group_id)
                self.optimizer_context.task_stack.push(
                    TopDownRewrite(new_expr, self.rule_set,
                                   self.optimizer_context))

                self.root_expr.mark_rule_explored(rule.rule_type)
        for child in self.root_expr.children:
            child_expr = self.optimizer_context.memo.groups[child] \
                .logical_exprs[0]
            self.optimizer_context.task_stack.push(
                TopDownRewrite(child_expr, self.rule_set,
                               self.optimizer_context))
コード例 #4
0
def init_db():
    """Create database if doesn't exist and create all tables."""
    engine = SQLConfig().engine
    if not database_exists(engine.url):
        logger.info("Database does not exist, creating database.")
        create_database(engine.url)
    logger.info("Creating tables")
    BaseModel.metadata.create_all()
コード例 #5
0
 def _bootstrap_catalog(self):
     """Bootstraps catalog.
     This method runs all tasks required for using catalog. Currently,
     it includes only one task ie. initializing database. It creates the
     catalog database and tables if they do not exist.
     """
     logger.info("Bootstrapping catalog")
     init_db()