Author: tmckay Date: 2013-01-02 16:27:36 +0000 (Wed, 02 Jan 2013) New Revision: 5625
Modified: branches/elephant/sage/python/sage/aviary/aviaryoperations.py Log: Allow ref ids to be urls, tests for presence of "://"
Modified: branches/elephant/sage/python/sage/aviary/aviaryoperations.py =================================================================== --- branches/elephant/sage/python/sage/aviary/aviaryoperations.py 2012-12-19 20:34:52 UTC (rev 5624) +++ branches/elephant/sage/python/sage/aviary/aviaryoperations.py 2013-01-02 16:27:36 UTC (rev 5625) @@ -981,6 +981,32 @@ def get_task_tracker_list(self, callback=None): return self._get_node_list(self.get_task_tracker, callback)
+ def _make_id(self, client, val): + + def url(v): + try: + return "://" in v + except Exception: + pass + return False + + ref = client.factory.create("ns1:HadoopID") + try: + if url(val): + ref.ipc = val + else: + ref.id = str(val) + except Exception: + raise Exception("Invalid HadoopID value") + return ref + + def _make_id_list(self, client, vals): + refs = [] + for v in vals: + ref = self._make_id(client, v) + refs.append(ref) + return refs + def _start_node(self, host, ref_id, bin_file, owner, count, meth_name, callback): assert callable(callback) @@ -1006,14 +1032,7 @@ self.client_pool.return_object(client) callback(*result_tuple(result, host))
- ref = client.factory.create("ns1:HadoopID") - try: - # 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 - #ref.ipc = id - ref.id = str(ref_id) - except Exception: - raise Exception("Invalid HadoopID value") + ref = self._make_id(client, ref_id)
t = CallThread(self.call_client_retry, my_callback, client, meth_name, ref, bin_file, owner, count) @@ -1049,17 +1068,7 @@ host, meth_name)
- refs = [] - for id in ids: - new_ref = client.factory.create("ns1:HadoopID") - try: - # 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) + refs = self._make_id_list(client, ids)
def result_tuple(result, host): data = None
cumin-developers@lists.fedorahosted.org