コード例 #1
0
ファイル: hidra_events.py プロジェクト: schooft/hidra
    def __init__(self, eventdetector_base_config):

        EventDetectorBase.__init__(self,
                                   eventdetector_base_config,
                                   name=__name__)

        # base class sets
        #   self.config_all - all configurations
        #   self.config_ed - the config of the event detector
        #   self.config - the module specific config
        #   self.ed_type -  the name of the eventdetector module
        #   self.log_queue
        #   self.log

        self.ipc_addresses = None
        self.endpoints = None

        self.context = None
        self.ext_context = None
        self.monitoringdevice = None
        self.mon_socket = None

        self.set_required_params()

        self.check_config()
        self.setup()
コード例 #2
0
ファイル: inotify_events.py プロジェクト: schooft/hidra
    def __init__(self, eventdetector_base_config):

        EventDetectorBase.__init__(self,
                                   eventdetector_base_config,
                                   name=__name__)

        # sets
        #   self.config_all - all configurations
        #   self.config_ed - the config of the event detector
        #   self.config - the module specific config
        #   self.ed_type -  the name of the eventdetector module
        #   self.log_queue
        #   self.log

        self.paths = None
        self.mon_subdirs = None
        self.mon_regex_per_event = None
        self.mon_regex = None
        self.timeout = None
        self.history = None
        self.lock = None

        self.cleanup_time = None
        self.action_time = None
        self.cleanup_thread = None

        self._get_remaining_events = None

        self._set_required_params()

        # check that the required_params are set inside of module specific
        # config
        self.check_config()
        self.check_monitored_dir()
        self._setup()
コード例 #3
0
ファイル: http_events.py プロジェクト: schooft/hidra
    def __init__(self, eventdetector_base_config):

        EventDetectorBase.__init__(self,
                                   eventdetector_base_config,
                                   name=__name__)

        # base class sets
        #   self.config_all - all configurations
        #   self.config_ed - the config of the event detector
        #   self.config - the module specific config
        #   self.ed_type -  the name of the eventdetector module
        #   self.log_queue
        #   self.log

        self.session = None
        self.det_ip = None
        self.det_api_version = None
        self.file_writer_url = None
        self.data_url = None

        # time to sleep after detector returned emtpy file list
        self.sleep_time = 0.5
        self.files_downloaded = None

        self.required_params = [
            "det_ip", "det_api_version", "history_size", "fix_subdirs"
        ]

        # check that the required_params are set inside of module specific
        # config
        self.check_config()
        self.setup()
コード例 #4
0
ファイル: sync_lambda_events.py プロジェクト: schooft/hidra
    def __init__(self, eventdetector_base_config):

        EventDetectorBase.__init__(self, eventdetector_base_config,
                                   name=__name__)

        # base class sets
        #   self.config_all - all configurations
        #   self.config_ed - the config of the event detector
        #   self.config - the module specific config
        #   self.ed_type -  the name of the eventdetector module
        #   self.log_queue
        #   self.log

        self.sync_thread = None
        self.lock = None
        self.data_queue = multiprocessing.Queue()
        self.shutdown_event = None

        self.connections = None
        self.internal_com_socket = None

        self.required_params = {
            "eventdetector": {
                self.ed_type: [
                    "buffer_size",
                    "wait_time",
                    "internal_com_endpoint",
                    "device_names",
                ]
            }
        }

        self.setup()
コード例 #5
0
    def __init__(self, eventdetector_base_config):

        EventDetectorBase.__init__(self,
                                   eventdetector_base_config,
                                   name=__name__)

        # base class sets
        #   self.config_all - all configurations
        #   self.config_ed - the config of the event detector
        #   self.config - the module specific config
        #   self.ed_type -  the name of the eventdetector module
        #   self.log_queue
        #   self.log

        self.sync_thread = None
        self.lock = None
        self.monitored_dir = None

        self.required_params = {
            "eventdetector": {
                self.ed_type: [
                    "monitored_dir", "fix_subdirs", "buffer_size",
                    "kafka_server", "kafka_topic", "operation", "detids",
                    "n_detectors"
                ]
            }
        }

        self.setup()
コード例 #6
0
ファイル: zmq_events.py プロジェクト: schooft/hidra
    def __init__(self, eventdetector_base_config):

        # needs to be initialized before parent init
        # reason: if the latter fails stop would otherwise run into problems
        self.ext_context = None
        self.context = None
        self.event_socket = None

        EventDetectorBase.__init__(self,
                                   eventdetector_base_config,
                                   name=__name__)

        # base class sets
        #   self.config_all - all configurations
        #   self.config_ed - the config of the event detector
        #   self.config - the module specific config
        #   self.ed_type -  the name of the eventdetector module
        #   self.log_queue
        #   self.log

        self.ext_context = None
        self.context = None
        self.event_socket = None

        self.ipc_addresses = None
        self.tcp_addresses = None
        self.endpoints = None

        self.set_required_params()

        # check that the required_params are set inside of module specific
        # config
        self.check_config()
        self.setup()
コード例 #7
0
    def __init__(self, eventdetector_base_config):

        EventDetectorBase.__init__(self, eventdetector_base_config,
                                   name=__name__)

        # base class sets
        #   self.config_all - all configurations
        #   self.config_ed - the config of the event detector
        #   self.config - the module specific config
        #   self.ed_type -  the name of the eventdetector module
        #   self.log_queue
        #   self.log

        self.required_params = []

        # check that the required_params are set inside of module specific
        # config
        self.check_config()
        self._setup()
コード例 #8
0
    def __init__(self, eventdetector_base_config):

        EventDetectorBase.__init__(self,
                                   eventdetector_base_config,
                                   name=__name__)

        # base class sets
        #   self.config_all - all configurations
        #   self.config_ed - the config of the event detector
        #   self.config - the module specific config
        #   self.ed_type -  the name of the eventdetector module
        #   self.log_queue
        #   self.log

        self.required_params = [
            "det_ip", "det_api_version", "history_size", "fix_subdirs"
        ]

        # check that the required_params are set inside of module specific
        # config
        self.check_config()

        self.event_detector_impl = create_eventdetector_impl(log=self.log,
                                                             **self.config)
コード例 #9
0
    def __init__(self, eventdetector_base_config):

        EventDetectorBase.__init__(self,
                                   eventdetector_base_config,
                                   name=__name__)

        # base class sets
        #   self.config_all - all configurations
        #   self.config_ed - the config of the event detector
        #   self.config - the module specific config
        #   self.ed_type -  the name of the eventdetector module
        #   self.log_queue
        #   self.log

        self.mon_dir = None
        self.mon_subdirs = None
        self.paths = None
        self.lock = None

        # TODO add in watchdog config
        self.timeout = 2

        self.observer_threads = None
        self.checking_thread = None
        self.stop_request = threading.Event()

        self.required_params = [
            "monitored_dir", "fix_subdirs", ["monitored_events", dict],
            "time_till_closed", "action_time"
        ]

        # check that the required_params are set inside of module specific
        # config
        self.check_config()
        self.check_monitored_dir()
        self.setup()
コード例 #10
0
ファイル: xfel_events.py プロジェクト: schooft/hidra
    def __init__(self, config, log_queue):

        EventDetectorBase.__init__(self,
                                   config=config,
                                   log_queue=log_queue,
                                   logger_name="xfel_events")

        #        if helpers.is_windows():
        #            required_params = ["context",
        #                               "xfel_connections",
        #                               "ext_ip",
        #                               "data_fetcher_port"]

        required_params = [
            "context", "xfel_connections", "ipc_path", "main_pid",
            "sync_buffer_size"
        ]

        # Check format of config
        check_passed, config_reduced = helpers.check_config(
            required_params, config, self.log)

        # Only proceed if the configuration was correct
        if check_passed:
            self.log.info(
                "Configuration for event detector: {0}".format(config_reduced))
        else:
            raise Exception("Wrong configuration")

        self.xfel_connections = config["xfel_connections"]
        self.n_connectors = len(self.xfel_connections)

        self.multiproc_queue = Queue()
        self.lock = threading.Lock()
        self.run_event = threading.Event()

        self.control_queue = Queue()

        self._stopped = False

        # for Windows
        #        self.data_fetcher_con_str = ("tcp://{}:{}"
        #                                     .format(config["ext_ip"],
        #                                             config["data_fetcher_port"]))

        self.data_fetcher_con_str = ("ipc://{}/{}_{}".format(
            config["ipc_path"], config["main_pid"], "data_fetcher"))

        self.connector_p = []
        for i, con in enumerate(self.xfel_connections):
            con_str = "tcp://{}:{}".format(con[0], con[1])
            p = Process(target=Connector,
                        kwargs=(dict(
                            p_id=i,
                            log_queue=log_queue,
                            control_queue=self.control_queue,
                            con_str=con_str,
                            multiproc_queue=self.multiproc_queue,
                        )))
            self.connector_p.append(p)

        # use a run event to communicate to thread when to stop
        self.run_event.set()
        self.sync_thread = Synchronizing(
            log_queue=log_queue,
            multiproc_queue=self.multiproc_queue,
            run_event=self.run_event,
            lock=self.lock,
            n_connectors=self.n_connectors,
            sync_buffer_size=config['sync_buffer_size'])
        self.sync_thread.start()

        for p in self.connector_p:
            p.start()

        # set up monitoring socket where the events are sent to
        if config["context"] is not None:
            self.context = config["context"]
            self.ext_context = True
        else:
            self.log.info("Registering ZMQ context")
            self.context = zmq.Context()
            self.ext_context = False

        self.data_fetcher_socket = None

        self.create_sockets()