def get_all_zk_state_managers(conf): """ Connects to all the zookeeper state_managers and returns the connected state_managers instances. """ state_managers = [] state_locations = conf.get_state_locations_of_type("zookeeper") for location in state_locations: name = location['name'] hostport = location['hostport'] host = None port = None if ':' in hostport: hostportlist = hostport.split(':') if len(hostportlist) == 2: host = hostportlist[0] port = int(hostportlist[1]) if not host or not port: raise Exception( "Hostport for %s must be of the format 'host:port'." % (name)) tunnelhost = location['tunnelhost'] rootpath = location['rootpath'] LOG.info("Connecting to zk hostport: " + host + ":" + str(port) + " rootpath: " + rootpath) state_manager = ZkStateManager(name, host, port, rootpath, tunnelhost) try: state_manager.start() except Exception: LOG.error("Exception while connecting to state_manager.") LOG.debug(traceback.format_exc()) state_managers.append(state_manager) return state_managers
def get_all_zk_state_managers(conf): """ Connects to all the zookeeper state_managers and returns the connected state_managers instances. """ state_managers = [] state_locations = conf.get_state_locations_of_type("zookeeper") for location in state_locations: name = location['name'] hostport = location['hostport'] host = None port = None if ':' in hostport: hostportlist = hostport.split(':') if len(hostportlist) == 2: host = hostportlist[0] port = int(hostportlist[1]) if not host or not port: raise Exception("Hostport for %s must be of the format 'host:port'." % (name)) tunnelhost = location['tunnelhost'] rootpath = location['rootpath'] LOG.info("Connecting to zk hostport: " + host + ":" + str(port) + " rootpath: " + rootpath) state_manager = ZkStateManager(name, host, port, rootpath, tunnelhost) try: state_manager.start() except Exception as e: LOG.error("Exception while connecting to state_manager.") traceback.print_exc() state_managers.append(state_manager) return state_managers
def get_all_state_managers(conf): """ @param conf - An instance of Config class Reads the config for requested state managers. Instantiates them, start and then return them. """ state_managers = [] try: state_managers.extend(get_all_zk_state_managers(conf)) state_managers.extend(get_all_file_state_managers(conf)) return state_managers except Exception as ex: LOG.error("Exception while getting state_managers.") raise ex
def get_all_state_managers(conf): """ @param conf - An instance of Config class Reads the config for requested state managers. Instantiates them, start and then return them. """ state_managers = [] try: state_managers.extend(get_all_zk_state_managers(conf)) state_managers.extend(get_all_file_state_managers(conf)) return state_managers except Exception as ex: LOG.error("Exception while getting state_managers.") raise ex
def get_all_file_state_managers(conf): """ Returns all the file state_managers. """ state_managers = [] state_locations = conf.get_state_locations_of_type("file") for location in state_locations: name = location['name'] rootpath = os.path.expanduser(location['rootpath']) LOG.info("Connecting to file state with rootpath: " + rootpath) state_manager = FileStateManager(name, rootpath) try: state_manager.start() except Exception: LOG.error("Exception while connecting to state_manager.") traceback.print_exc() state_managers.append(state_manager) return state_managers
def get_all_file_state_managers(conf): """ Returns all the file state_managers. """ state_managers = [] state_locations = conf.get_state_locations_of_type("file") for location in state_locations: name = location['name'] rootpath = os.path.expanduser(location['rootpath']) LOG.info("Connecting to file state with rootpath: " + rootpath) state_manager = FileStateManager(name, rootpath) try: state_manager.start() except Exception as e: LOG.error("Exception while connecting to state_manager.") traceback.print_exc() state_managers.append(state_manager) return state_managers
def get_all_zk_state_managers(conf): """ Connects to all the zookeeper state_managers and returns the connected state_managers instances. """ state_managers = [] state_locations = conf.get_state_locations_of_type("zookeeper") for location in state_locations: name = location['name'] host = location['host'] port = location['port'] tunnelhost = location['tunnelhost'] rootpath = location['rootpath'] LOG.info("Connecting to zk hostport: " + host + ":" + str(port) + " rootpath: " + rootpath) state_manager = ZkStateManager(name, host, port, rootpath, tunnelhost) try: state_manager.start() except Exception as e: LOG.error("Exception while connecting to state_manager.") traceback.print_exc() state_managers.append(state_manager) return state_managers