Пример #1
0
    def execute(self, replacement: Replacement, records_count: int) -> int:
        try:
            query = replacement.get_insert_query(self.__local_table_name)
            if query is None:
                return 0
            result_futures = []
            for nodes in self.__connection_pool.get_connections().values():
                result_futures.append(
                    self.__thread_pool.submit(
                        partial(
                            self.__run_multiple_replicas,
                            nodes=nodes,
                            query=query,
                            records_count=records_count,
                            metrics=self.__metrics,
                        )))
            for result in as_completed(result_futures):
                e = result.exception()
                if e is not None:
                    raise e
            return records_count

        except Exception as e:
            count = self.__backup_executor.execute(replacement, records_count)
            logger.warning(
                "Replacement processing failed on the main connection",
                exc_info=e,
            )
            return count
Пример #2
0
 def execute(self, replacement: Replacement, records_count: int) -> int:
     query = replacement.get_insert_query(self.__table)
     if query is None:
         return 0
     self.__runner(self.__connection, query, records_count, self.__metrics)
     return records_count