當前位置: 首頁>>代碼示例>>Python>>正文


Python ProcessContext.get_source_collection方法代碼示例

本文整理匯總了Python中system.process_context.ProcessContext.get_source_collection方法的典型用法代碼示例。如果您正苦於以下問題:Python ProcessContext.get_source_collection方法的具體用法?Python ProcessContext.get_source_collection怎麽用?Python ProcessContext.get_source_collection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在system.process_context.ProcessContext的用法示例。


在下文中一共展示了ProcessContext.get_source_collection方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create_unit_of_work

# 需要導入模塊: from system.process_context import ProcessContext [as 別名]
# 或者: from system.process_context.ProcessContext import get_source_collection [as 別名]
def create_unit_of_work(process_name, first_object_id, last_object_id):
    """ method is used to insert unit_of_work """
    source_collection = ProcessContext.get_source_collection(process_name)
    target_collection = ProcessContext.get_target_collection(process_name)
    logger = ProcessContext.get_logger(process_name)
    
    unit_of_work = UnitOfWorkEntry()
    unit_of_work.set_timestamp('UNIT_TEST')
    unit_of_work.set_start_id(first_object_id)
    unit_of_work.set_end_id(last_object_id)
    unit_of_work.set_source_collection(source_collection)
    unit_of_work.set_target_collection(target_collection)
    unit_of_work.set_state(UnitOfWorkEntry.STATE_REQUESTED)
    unit_of_work.set_process_name(process_name)
    unit_of_work.set_number_of_retries(0)
    
    uow_id = unit_of_work_helper.insert(logger, unit_of_work)
    return uow_id
開發者ID:strategist922,項目名稱:scheduler,代碼行數:20,代碼來源:base_fixtures.py

示例2: compute_scope_of_processing

# 需要導入模塊: from system.process_context import ProcessContext [as 別名]
# 或者: from system.process_context.ProcessContext import get_source_collection [as 別名]
    def compute_scope_of_processing(self, process_name, start_time, end_time, time_record):
        """method reads collection and identify slice for processing"""
        source_collection_name = ProcessContext.get_source_collection(process_name)
        target_collection_name = ProcessContext.get_target_collection(process_name)
        source_collection = CollectionContext.get_collection(self.logger, source_collection_name)

        query = { AbstractModel.TIMESTAMP : { '$gte' : start_time, '$lt' : end_time } }
        asc_search = source_collection.find(spec=query, fields='_id').sort('_id', ASCENDING).limit(1)
        if asc_search.count() == 0:
            raise LookupError('No messages in timeperiod: %s:%s in collection %s'
                                % (start_time, end_time, source_collection_name))
        first_object_id = asc_search[0]['_id']

        dec_search = source_collection.find(spec=query, fields='_id').sort('_id', DESCENDING).limit(1)
        last_object_id = dec_search[0]['_id']

        unit_of_work = UnitOfWorkEntry()
        unit_of_work.set_timestamp(start_time)
        unit_of_work.set_start_id(str(first_object_id))
        unit_of_work.set_end_id(str(last_object_id))
        unit_of_work.set_start_timestamp(start_time)
        unit_of_work.set_end_timestamp(end_time)
        unit_of_work.set_created_at(datetime.utcnow())
        unit_of_work.set_source_collection(source_collection_name)
        unit_of_work.set_target_collection(target_collection_name)
        unit_of_work.set_state(unit_of_work.STATE_REQUESTED)
        unit_of_work.set_process_name(process_name)
        unit_of_work.set_number_of_retries(0)

        try:
            uow_id = unit_of_work_helper.insert(self.logger, unit_of_work)
        except DuplicateKeyError as e:
            e.first_object_id = str(first_object_id)
            e.last_object_id = str(last_object_id)
            e.process_name = process_name
            e.timestamp = start_time
            raise e

        self.publishers.get_publisher(process_name).publish(str(uow_id))
        msg = 'Published: UOW %r for %r in timeperiod %r.' % (uow_id, process_name, start_time)
        self._log_message(INFO, process_name, time_record, msg)
        return unit_of_work
開發者ID:strategist922,項目名稱:scheduler,代碼行數:44,代碼來源:regular_pipeline.py

示例3: _get_source_collection

# 需要導入模塊: from system.process_context import ProcessContext [as 別名]
# 或者: from system.process_context.ProcessContext import get_source_collection [as 別名]
 def _get_source_collection(self):
     """collection with data for processing"""
     return CollectionContext.get_collection(self.logger, ProcessContext.get_source_collection(self.process_name))
開發者ID:strategist922,項目名稱:scheduler,代碼行數:5,代碼來源:abstract_aware_worker.py


注:本文中的system.process_context.ProcessContext.get_source_collection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。