def __init__(self, config, stop_handler): # Process initialization code threading.Thread.__init__(self) logger.debug('Initializing Controller thread.') self.lock = threading.Lock() self.config = config self.metrics_config = config.getMetricGroupConfig() self.events_cache = [] hostinfo = HostInfo(config) self.application_metric_map = ApplicationMetricMap(hostinfo.get_hostname(), hostinfo.get_ip_address()) self.event_queue = Queue(config.get_max_queue_size()) self.metric_collector = MetricsCollector(self.event_queue, self.application_metric_map, hostinfo) self.server_url = config.get_server_address() self.sleep_interval = config.get_collector_sleep_interval() self._stop_handler = stop_handler self.initialize_events_cache() self.emitter = Emitter(self.config, self.application_metric_map, stop_handler) self._t = None