当前位置: 首页>>代码示例>>Python>>正文


Python factory.coordinator函数代码示例

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


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


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