def main(_, opts): path_detector = FixedPathDetector(opts.root) task_observer = TaskObserver(path_detector) task_observer.start() server = configure_server(task_observer) thread = ExceptionalThread(target=lambda: server.run('0.0.0.0', opts.port, 'cherrypy')) thread.daemon = True thread.start() sleep_forever()
def main(_, opts): path_detector = FixedPathDetector(opts.root) task_observer = TaskObserver(path_detector) task_observer.start() server = configure_server(task_observer) thread = ExceptionalThread( target=lambda: server.run('0.0.0.0', opts.port, 'cherrypy')) thread.daemon = True thread.start() sleep_forever()
def main(_, options): path_detector = ChainedPathDetector( FixedPathDetector(options.root), MesosPathDetector(options.mesos_root), ) observer = TaskObserver(path_detector) observer.start() root_server = configure_server(observer) thread = ExceptionalThread(target=lambda: root_server.run('0.0.0.0', options.port, 'cherrypy')) thread.daemon = True thread.start() sleep_forever()
def main(_, options): path_detector = ChainedPathDetector( FixedPathDetector(options.root), MesosPathDetector(options.mesos_root), ) observer = TaskObserver(path_detector) observer.start() root_server = configure_server(observer) thread = ExceptionalThread( target=lambda: root_server.run('0.0.0.0', options.port, 'cherrypy')) thread.daemon = True thread.start() sleep_forever()
def initialize(options): path_detector = ChainedPathDetector( FixedPathDetector(options.root), MesosPathDetector(options.mesos_root), ) polling_interval = Amount(options.polling_interval_secs, Time.SECONDS) return TaskObserver(path_detector, interval=polling_interval)
def test_run_loop(self): """Test observer run loop.""" mock_task_detector = create_autospec(spec=ObserverTaskDetector) with patch( "apache.thermos.observer.task_observer.ObserverTaskDetector", return_value=mock_task_detector) as mock_detector: with patch('threading._Event.wait') as mock_wait: run_count = 3 interval = 15 observer = TaskObserver(mock_detector, interval=Amount(interval, Time.SECONDS)) observer.start() while len(mock_wait.mock_calls) < run_count: pass observer.stop() assert len(mock_task_detector.mock_calls) >= run_count assert len(mock_wait.mock_calls) >= run_count args = mock_wait.mock_calls[1][1] assert interval == args[0]
def initialize(options): path_detector = MesosPathDetector(options.mesos_root) disk_collector_settings = DiskCollectorSettings( options.agent_api_url, options.executor_id_json_path, options.disk_usage_json_path, Amount(options.task_disk_collection_interval_secs, Time.SECONDS)) return TaskObserver( path_detector, Amount(options.polling_interval_secs, Time.SECONDS), Amount(options.task_process_collection_interval_secs, Time.SECONDS), enable_mesos_disk_collector=options.enable_mesos_disk_collector, disk_collector_settings=disk_collector_settings)
def main(args, opts): if args: print("ERROR: unrecognized arguments: %s\n" % (" ".join(args)), file=sys.stderr) app.help() sys.exit(1) root_server = HttpServer() root_server.mount_routes(DiagnosticsEndpoints()) task_observer = TaskObserver(opts.root) task_observer.start() bottle_wrapper = BottleObserver(task_observer) root_server.mount_routes(bottle_wrapper) def run(): root_server.run('0.0.0.0', opts.port, 'cherrypy') et = ExceptionalThread(target=run) et.daemon = True et.start() et.join()
def main(args, opts): if args: print("ERROR: unrecognized arguments: %s\n" % (" ".join(args)), file=sys.stderr) app.help() sys.exit(1) root_server = HttpServer() root_server.mount_routes(DiagnosticsEndpoints()) task_observer = TaskObserver(opts.root) task_observer.start() bottle_wrapper = BottleObserver(task_observer) root_server.mount_routes(bottle_wrapper) def run(): root_server.run('0.0.0.0', opts.port, 'cherrypy') et = ExceptionalThread(target=run) et.daemon = True et.start() et.join()
def test_run_loop(self): """Test observer run loop.""" mock_task_detector = create_autospec(spec=ObserverTaskDetector) with patch( "apache.thermos.observer.task_observer.ObserverTaskDetector", return_value=mock_task_detector) as mock_detector: with patch('threading._Event.wait') as mock_wait: run_count = 3 interval = 15 observer = TaskObserver(mock_detector, interval=Amount( interval, Time.SECONDS)) observer.start() while len(mock_wait.mock_calls) < run_count: pass observer.stop() assert len(mock_task_detector.mock_calls) >= run_count assert len(mock_wait.mock_calls) >= run_count args = mock_wait.mock_calls[1][1] assert interval == args[0]
def initialize(options): path_detector = MesosPathDetector(options.mesos_root) return TaskObserver( path_detector, Amount(options.polling_interval_secs, Time.SECONDS), Amount(options.task_process_collection_interval_secs, Time.SECONDS), Amount(options.task_disk_collection_interval_secs, Time.SECONDS))
def make_observer(cls): return TaskObserver(FixedPathDetector(MOCK_BASE_PATH))