File indexing completed on 2026-04-11 08:41:04
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 import logging
0011
0012 from pilot.eventservice.esprocess.esprocess import ESProcess
0013 from pilot.eventservice.esprocess.eshook import ESHook
0014
0015 logger = logging.getLogger(__name__)
0016
0017 """
0018 ES manager to setup and run ESProcess.
0019 """
0020
0021
0022 class ESManager:
0023 def __init__(self, hook):
0024 """
0025 Initialization: setup ES hooks.
0026
0027 :param hook: an instance of ESHook.
0028 """
0029 logger.info('initializing hooks')
0030 if not isinstance(hook, ESHook):
0031 raise Exception("hook(%s) is not instance of %s" % (hook, ESHook))
0032
0033 self.__hook = hook
0034 logger.info('initialized hooks')
0035
0036 def run(self):
0037 """
0038 Initialize and run ESProcess.
0039 """
0040
0041 logger.debug('gettting payload')
0042 payload = self.__hook.get_payload()
0043 logger.debug('got payload: %s' % payload)
0044
0045 logger.info('init ESProcess')
0046 process = ESProcess(payload)
0047 process.set_get_event_ranges_hook(self.__hook.get_event_ranges)
0048 process.set_handle_out_message_hook(self.__hook.handle_out_message)
0049
0050 logger.info('ESProcess starts to run')
0051 process.start()
0052 process.join()
0053 logger.info('ESProcess finishes')