aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wick...@apache.org
Subject git commit: Fix TaskObserver for json endpoint usage.
Date Wed, 02 Jul 2014 18:06:09 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master b58418ef4 -> 84ee1571d


Fix TaskObserver for json endpoint usage.

Testing Done:
The `/j/task?task_id=id1,id2,...` endpoint now works.

Reviewed at https://reviews.apache.org/r/23211/


Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/84ee1571
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/84ee1571
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/84ee1571

Branch: refs/heads/master
Commit: 84ee1571dd8a1110f3d0d74c39b917651ca13bc3
Parents: b58418e
Author: Kevin Burg <kburg1029@gmail.com>
Authored: Wed Jul 2 11:04:03 2014 -0700
Committer: Brian Wickman <wickman@apache.org>
Committed: Wed Jul 2 11:04:03 2014 -0700

----------------------------------------------------------------------
 .../python/apache/thermos/observer/http/json.py |  4 ++--
 .../apache/thermos/observer/task_observer.py    | 20 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/84ee1571/src/main/python/apache/thermos/observer/http/json.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/thermos/observer/http/json.py b/src/main/python/apache/thermos/observer/http/json.py
index b81232c..4ba5324 100644
--- a/src/main/python/apache/thermos/observer/http/json.py
+++ b/src/main/python/apache/thermos/observer/http/json.py
@@ -45,11 +45,11 @@ class TaskObserverJSONBindings(object):
     task_ids = HttpServer.Request.GET.get('task_id', [])
     if task_ids:
       task_ids = urllib.unquote(task_ids).split(',')
-    return self._observer.task(task_ids)
+    return self._observer.tasks(task_ids)
 
   @HttpServer.route("/j/task/:task_id")
   def handle_task(self, task_id):
-    return self._observer.task([task_id])
+    return self._observer.tasks([task_id])
 
   @HttpServer.route("/j/process/:task_id")
   @HttpServer.route("/j/process/:task_id/:process")

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/84ee1571/src/main/python/apache/thermos/observer/task_observer.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/thermos/observer/task_observer.py b/src/main/python/apache/thermos/observer/task_observer.py
index b2114db..cd528dc 100644
--- a/src/main/python/apache/thermos/observer/task_observer.py
+++ b/src/main/python/apache/thermos/observer/task_observer.py
@@ -364,6 +364,26 @@ class TaskObserver(ExceptionalThread, Lockable):
       for st in state.statuses]
 
   @Lockable.sync
+  def tasks(self, task_ids):
+    """
+      Return information about an iterable of tasks [task_id1, task_id2, ...]
+      in the following form.
+
+      {
+        task_id1 : self._task(task_id1),
+        task_id2 : self._task(task_id2),
+        ...
+      }
+    """
+    res = {}
+    for task_id in task_ids:
+      d = self._task(task_id)
+      task_struct = d.pop('task_struct')
+      d['task'] = task_struct.get()
+      res[task_id] = d
+    return res
+
+  @Lockable.sync
   def _task(self, task_id):
     """
       Return composite information about a particular task task_id, given the below


Mime
View raw message