• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python factory.coordinator函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pulp.server.dispatch.factory.coordinator函数的典型用法代码示例。如果您正苦于以下问题:Python coordinator函数的具体用法?Python coordinator怎么用?Python coordinator使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了coordinator函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _run_scheduled_calls

    def _run_scheduled_calls(self):
        """
        Run call requests that are currently scheduled to run

        NOTE: the scheduler no longer schedules arbitrary call request, instead
        it now only supports call request from the itineraries package
        """
        coordinator = dispatch_factory.coordinator()

        for call_group in self._get_scheduled_call_groups():

            # this is a bit of hack and presumes that the first call in the call
            # group is the most important, need to re-think this and implement
            # something more general (counter-based?)
            # but for right now, the presumption is correct
            call_group[0].add_life_cycle_callback(dispatch_constants.CALL_COMPLETE_LIFE_CYCLE_CALLBACK,
                                                  scheduler_complete_callback)

            if len(call_group) == 1:
                call_report_list = [coordinator.execute_call_asynchronously(call_group[0])]
            else:
                call_report_list = coordinator.execute_multiple_calls(call_group)


            for call_request, call_report in zip(call_group, call_report_list):
                log_msg = _('Scheduled %(c)s: %(r)s [reasons: %(s)s]') % {'c': str(call_request),
                                                                          'r': call_report.response,
                                                                          's': pformat(call_report.reasons)}

                if call_report.response is dispatch_constants.CALL_REJECTED_RESPONSE:
                    _LOG.error(log_msg)
                else:
                    _LOG.info(log_msg)
开发者ID:bartwo,项目名称:pulp,代码行数:33,代码来源:scheduler.py


示例2: _get_call_report

 def _get_call_report():
     context = dispatch_factory.context()
     coordinator = dispatch_factory.coordinator()
     call_report_list = coordinator.find_call_reports(call_request_id=context.call_request_id)
     if not call_report_list:
         return None
     return call_report_list[0].serialize()
开发者ID:ashcrow,项目名称:pulp,代码行数:7,代码来源:data.py


示例3: _run_scheduled_calls

    def _run_scheduled_calls(self):
        """
        Find call requests that are currently scheduled to run
        """
        coordinator = dispatch_factory.coordinator()

        now = datetime.datetime.utcnow()
        query = {'next_run': {'$lte': now}}

        for scheduled_call in self.scheduled_call_collection.find(query):

            if not scheduled_call['enabled']:
                # update the next run information for disabled calls
                self.update_next_run(scheduled_call)
                continue

            serialized_call_request = scheduled_call['serialized_call_request']

            call_request = call.CallRequest.deserialize(serialized_call_request)
            call_request.add_life_cycle_callback(dispatch_constants.CALL_COMPLETE_LIFE_CYCLE_CALLBACK, scheduler_complete_callback)

            call_report = call.CallReport.from_call_request(call_request, schedule_id=str(scheduled_call['_id']))
            call_report = coordinator.execute_call_asynchronously(call_request, call_report)

            log_msg = _('Scheduled %(c)s: %(r)s [reasons: %(s)s]') % {'c': str(call_request),
                                                                      'r': call_report.response,
                                                                      's': pformat(call_report.reasons)}

            if call_report.response is dispatch_constants.CALL_REJECTED_RESPONSE:
                _LOG.error(log_msg)
            else:
                _LOG.info(log_msg)
开发者ID:ryanschneider,项目名称:pulp,代码行数:32,代码来源:scheduler.py


示例4: failed

 def failed(self, reply):
     log.info('Task RMI (failed)\n%s', reply)
     taskid = reply.any
     exception = reply.exval
     traceback = reply.xstate['trace']
     coordinator = factory.coordinator()
     coordinator.complete_call_failure(taskid, exception, traceback)
开发者ID:ehelms,项目名称:pulp,代码行数:7,代码来源:services.py


示例5: _execute_itinerary

    def _execute_itinerary(self, scheduled_call):
        """
        Execute the scheduled itinerary call request to get the call requests
        that implement the scheduled call

        :param scheduled_call: the scheduled call
        :type  scheduled_call: bson.BSON
        :return: call requests for the scheduled itinerary call
        :rtype:  list of pulp.server.dispatch.call.CallRequest
        """

        coordinator = dispatch_factory.coordinator()

        # scheduled calls are always itinerary calls
        itinerary_call_request = call.CallRequest.deserialize(scheduled_call['serialized_call_request'])
        itinerary_call_request.archive = False # don't keep a history of these calls

        itinerary_call_report = call.CallReport.from_call_request(itinerary_call_request)
        itinerary_call_report.serialize_result = False # don't try to serialize the result

        # use the coordinator to execute the itinerary call, it already has all
        # the machinery to handle the call request and report instances
        itinerary_call_report = coordinator.execute_call_synchronously(itinerary_call_request,
                                                                       itinerary_call_report)

        # the call request group is the result of the itinerary call
        call_request_group = itinerary_call_report.result

        self._set_call_group_scheduler_hooks(scheduled_call, call_request_group)

        return call_request_group
开发者ID:ashcrow,项目名称:pulp,代码行数:31,代码来源:scheduler.py


示例6: _run_scheduled_calls

    def _run_scheduled_calls(self):
        """
        Run call requests that are currently scheduled to run

        NOTE: the scheduler no longer schedules arbitrary call request, instead
        it now only supports call request from the itineraries package
        """
        coordinator = dispatch_factory.coordinator()

        for call_group in self._get_scheduled_call_groups():

            for call_request in call_group:
                call_request.add_life_cycle_callback(dispatch_constants.CALL_COMPLETE_LIFE_CYCLE_CALLBACK,
                                                     scheduler_complete_callback)

            if len(call_group) == 1:
                call_report_list = [coordinator.execute_call_asynchronously(call_group[0])]
            else:
                call_report_list = coordinator.execute_multiple_calls(call_group)


            for call_request, call_report in zip(call_group, call_report_list):
                log_msg = _('Scheduled %(c)s: %(r)s [reasons: %(s)s]') % {'c': str(call_request),
                                                                          'r': call_report.response,
                                                                          's': pformat(call_report.reasons)}

                if call_report.response is dispatch_constants.CALL_REJECTED_RESPONSE:
                    _LOG.error(log_msg)
                else:
                    _LOG.info(log_msg)
开发者ID:pkilambi,项目名称:pulp,代码行数:30,代码来源:scheduler.py


示例7: _get_scheduled_call_groups

    def _get_scheduled_call_groups(self):
        """
        Get call requests, by call group, that are currently scheduled to run
        """

        coordinator = dispatch_factory.coordinator()

        now = datetime.datetime.utcnow()
        query = {'next_run': {'$lte': now}}

        for scheduled_call in self.scheduled_call_collection.find(query):

            if not scheduled_call['enabled']:
                # update the next run information for disabled calls
                self.update_next_run(scheduled_call)
                continue

            # get the itinerary call request and execute
            serialized_call_request = scheduled_call['serialized_call_request']
            call_request = call.CallRequest.deserialize(serialized_call_request)
            call_report = coordinator.execute_call_synchronously(call_request)

            # call request group is the return of an itinerary function
            call_request_group = call_report.result
            map(lambda r: setattr(r, 'schedule_id', str(scheduled_call['_id'])), call_request_group)
            yield  call_request_group
开发者ID:pkilambi,项目名称:pulp,代码行数:26,代码来源:scheduler.py


示例8: GET

 def GET(self):
     valid_filters = ['tag']
     filters = self.filters(valid_filters)
     criteria = {'tags': filters.get('tag', [])}
     coordinator = dispatch_factory.coordinator()
     call_reports = coordinator.find_call_reports(**criteria)
     serialized_call_reports = [c.serialize() for c in call_reports]
     return self.ok(serialized_call_reports)
开发者ID:stpierre,项目名称:pulp,代码行数:8,代码来源:dispatch.py


示例9: DELETE

 def DELETE(self, task_group_id):
     coordinator = dispatch_factory.coordinator()
     results = coordinator.cancel_multiple_calls(task_group_id)
     if not results:
         raise TaskGroupNotFound(task_group_id)
     if None in results.values():
         raise TaskGroupCancelNotImplemented(task_group_id)
     return self.accepted(results)
开发者ID:stpierre,项目名称:pulp,代码行数:8,代码来源:dispatch.py


示例10: _current_task_state

def _current_task_state():
    context = dispatch_factory.context()
    if context.call_request_id is None:
        return None
    coordinator = dispatch_factory.coordinator()
    tasks = coordinator._find_tasks(call_request_id=context.call_request_id)
    if not tasks:
        return None
    return tasks[0].state
开发者ID:ryanschneider,项目名称:pulp,代码行数:9,代码来源:sync.py


示例11: execute_multiple

def execute_multiple(call_request_list):
    """
    Execute multiple calls as a task group via the coordinator.
    @param call_request_list: list of call request instances
    @type call_request_list: list
    """
    coordinator = dispatch_factory.coordinator()
    call_report_list = coordinator.execute_multiple_calls(call_request_list)
    raise MultipleOperationsPostponed(call_report_list)
开发者ID:ehelms,项目名称:pulp,代码行数:9,代码来源:execution.py


示例12: GET

 def GET(self):
     valid_filters = ['tag', 'id']
     filters = self.filters(valid_filters)
     criteria = {'tags': filters.get('tag', [])}
     if 'id' in filters:
         criteria['call_request_id_list'] = filters['id']
     coordinator = dispatch_factory.coordinator()
     call_reports = coordinator.find_call_reports(**criteria)
     serialized_call_reports = [c.serialize() for c in call_reports]
     return self.ok(serialized_call_reports)
开发者ID:ashcrow,项目名称:pulp,代码行数:10,代码来源:dispatch.py


示例13: GET

 def GET(self, call_request_group_id):
     link = serialization.link.link_obj('/pulp/api/v2/task_groups/%s/' % call_request_group_id)
     coordinator = dispatch_factory.coordinator()
     call_reports = coordinator.find_call_reports(call_request_group_id=call_request_group_id)
     serialized_call_reports = [c.serialize() for c in call_reports]
     archived_calls = dispatch_history.find_archived_calls(task_group_id=call_request_group_id)
     serialized_call_reports.extend(c['serialized_call_report'] for c in archived_calls)
     if not serialized_call_reports:
         raise TaskGroupNotFound(call_request_group_id)
     map(lambda r: r.update(link), serialized_call_reports)
     return self.ok(serialized_call_reports)
开发者ID:ryanschneider,项目名称:pulp,代码行数:11,代码来源:dispatch.py


示例14: progress

 def progress(self, reply):
     """
     Notification (reply) indicating an RMI has reported status.
     This information is relayed to the task coordinator.
     @param reply: A progress reply object.
     @type reply: L{gofer.rmi.async.Progress}
     """
     log.info('Task RMI (progress)\n%s', reply)
     taskid = reply.any
     coordinator = factory.coordinator()
     coordinator.report_call_progress(taskid, reply.details)
开发者ID:ashcrow,项目名称:pulp,代码行数:11,代码来源:services.py


示例15: DELETE

 def DELETE(self, call_request_id):
     coordinator = dispatch_factory.coordinator()
     result = coordinator.cancel_call(call_request_id)
     if result is None:
         raise MissingResource(call_request_id)
     if result is False:
         raise TaskCancelNotImplemented(call_request_id)
     # if we've gotten here, the call request *should* exist
     call_report = coordinator.find_call_reports(call_request_id=call_request_id)[0]
     serialized_call_report = call_report.serialize()
     serialized_call_report.update(serialization.link.current_link_obj())
     return self.accepted(serialized_call_report)
开发者ID:domcleal,项目名称:pulp,代码行数:12,代码来源:dispatch.py


示例16: succeeded

 def succeeded(self, reply):
     """
     Notification (reply) indicating an RMI succeeded.
     This information is relayed to the task coordinator.
     @param reply: A successful reply object.
     @type reply: L{gofer.rmi.async.Succeeded}
     """
     log.info('Task RMI (succeeded)\n%s', reply)
     taskid = reply.any
     result = reply.retval
     coordinator = factory.coordinator()
     coordinator.complete_call_success(taskid, result)
开发者ID:ashcrow,项目名称:pulp,代码行数:12,代码来源:services.py


示例17: failed

 def failed(self, reply):
     """
     Notification (reply) indicating an RMI failed.
     This information is relayed to the task coordinator.
     @param reply: A failure reply object.
     @type reply: L{gofer.rmi.async.Failed}
     """
     log.info('Task RMI (failed)\n%s', reply)
     taskid = reply.any
     exception = reply.exval
     traceback = reply.xstate['trace']
     coordinator = factory.coordinator()
     coordinator.complete_call_failure(taskid, exception, traceback)
开发者ID:ashcrow,项目名称:pulp,代码行数:13,代码来源:services.py


示例18: execute_multiple

def execute_multiple(call_request_list):
    """
    Execute multiple calls as a task group via the coordinator.
    @param call_request_list: list of call request instances
    @type call_request_list: list
    """
    coordinator = dispatch_factory.coordinator()
    call_report_list = coordinator.execute_multiple_calls(call_request_list)
    if call_report_list[0].response is dispatch_constants.CALL_REJECTED_RESPONSE:
        # the coordinator will put the reasons on the call report that conflicted
        reasons = reduce(lambda p, c: c.reasons or p, call_report_list, None)
        raise ConflictingOperation(reasons)
    raise MultipleOperationsPostponed(call_report_list)
开发者ID:ashcrow,项目名称:pulp,代码行数:13,代码来源:execution.py


示例19: execute_async

def execute_async(controller, call_request, call_report=None):
    """
    Execute a call request asynchronously via the coordinator.
    @param controller: web services rest controller
    @type  controller: pulp.server.webservices.controller.base.JSONController
    @param call_request: call request to execute
    @type  call_request: pulp.server.dispatch.call.CallRequest
    @return: http server response
    """
    coordinator = dispatch_factory.coordinator()
    call_report = coordinator.execute_call_asynchronously(call_request, call_report)
    if call_report.response is dispatch_constants.CALL_REJECTED_RESPONSE:
        raise ConflictingOperation(call_report.reasons)
    raise OperationPostponed(call_report)
开发者ID:ashcrow,项目名称:pulp,代码行数:14,代码来源:execution.py


示例20: setUp

    def setUp(self):
        super(PulpWebserviceTests, self).setUp()
        self.coordinator = dispatch_factory.coordinator()
        self.success_failure = None
        self.result = None
        self.exception = None
        self.traceback = None

        # The built in PulpTest clean will automatically delete users between
        # test runs, so we can't just create the user in the class level setup.
        user_manager = manager_factory.user_manager()
        roles = []
        roles.append(manager_factory.role_manager().super_user_role)
        user_manager.create_user(login='ws-user', password='ws-user', roles=roles)
开发者ID:ehelms,项目名称:pulp,代码行数:14,代码来源:base.py



注:本文中的pulp.server.dispatch.factory.coordinator函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python factory.scheduler函数代码示例发布时间:2022-05-25
下一篇:
Python factory._task_queue函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap