Author: tmckay Date: 2012-12-17 15:04:46 +0000 (Mon, 17 Dec 2012) New Revision: 5605
Modified: branches/elephant/sage/python/sage/aviary/aviaryoperations.py Log: Treat ids as strings in _operate_on_ids. Add get_whatever_list routines for all nodes/trackers
Modified: branches/elephant/sage/python/sage/aviary/aviaryoperations.py =================================================================== --- branches/elephant/sage/python/sage/aviary/aviaryoperations.py 2012-12-14 22:07:55 UTC (rev 5604) +++ branches/elephant/sage/python/sage/aviary/aviaryoperations.py 2012-12-17 15:04:46 UTC (rev 5605) @@ -958,12 +958,24 @@ return self._operate_on_ids(host, ids, callback, "getTaskTracker")
def get_name_node_list(self, callback=None): + return self._get_node_list(self.get_name_node, callback) + + def get_data_node_list(self, callback=None): + return self._get_node_list(self.get_data_node, callback) + + def get_job_tracker_list(self, callback=None): + return self._get_node_list(self.get_job_tracker, callback) + + def get_task_tracker_list(self, callback=None): + return self._get_node_list(self.get_task_tracker, callback) + + def _get_node_list(self, proc, callback): try: status = "OK" hosts = self.get_hosts(self.resource, self.subtype) data = [] for h in hosts: - s, n = self.get_name_node(h, []) + s, n = proc(h, []) if s == "OK": data.extend(n) except Exception, e: @@ -972,7 +984,7 @@ if callback: callback(status, data) else: - return (status, data) + return (status, data)
def _operate_on_ids(self, host, ids, callback, meth_name): if callback: @@ -991,10 +1003,10 @@ for id in ids: new_ref = client.factory.create("ns1:HadoopID") try: - if type(id) in (str,unicode): - new_ref.ipc = id - else: - new_ref.id = float(id) + # In the future, if we would like to use URLs as ids, + # we can test for a URL value and set new_ref.ipc instead + #new_ref.ipc = id + new_ref.id = str(id) except Exception: raise Exception("Invalid HadoopID value") refs.append(new_ref)
cumin-developers@lists.fedorahosted.org