brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [42/50] brooklyn-ui git commit: also report who _submitted_ a task, and test for that
Date Mon, 01 Feb 2016 17:52:01 GMT
also report who _submitted_ a task, and test for that


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/fcbcce38
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/fcbcce38
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/fcbcce38

Branch: refs/heads/0.4.0
Commit: fcbcce38052aabf71d34154e5ccc9679fee9b138
Parents: b3386a7
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Sun Sep 9 16:44:22 2012 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Mon Sep 10 23:25:09 2012 -0700

----------------------------------------------------------------------
 .../brooklyn/web/console/EntityService.groovy   | 23 ++++++++++++++++----
 .../web/console/entity/TaskSummary.groovy       |  5 +++++
 2 files changed, 24 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/fcbcce38/usage/web-console/grails-app/services/brooklyn/web/console/EntityService.groovy
----------------------------------------------------------------------
diff --git a/usage/web-console/grails-app/services/brooklyn/web/console/EntityService.groovy
b/usage/web-console/grails-app/services/brooklyn/web/console/EntityService.groovy
index b64aa95..5500e98 100644
--- a/usage/web-console/grails-app/services/brooklyn/web/console/EntityService.groovy
+++ b/usage/web-console/grails-app/services/brooklyn/web/console/EntityService.groovy
@@ -35,8 +35,8 @@ public class EntityService {
 
     public static class NoSuchEntity extends Exception {}
 
-    // TODO Should this return Task objects, and let the EntityController convert them to
TaskSummary?
     // TODO Want to handle pagination better; for now we just restrict list to 20 most recent
+    /** returns only _effector_ calls */
     public List<TaskSummary> getTasksOfAllEntities() {
         final int MAX_NUM_RETURNED = 20
         
@@ -49,13 +49,28 @@ public class EntityService {
         return result.subList(0, Math.min(MAX_NUM_RETURNED, result.size()))
     }
 
-    // TODO Should this return Task objects, and let the EntityController convert them to
TaskSummary?
+    /** returns any active task or any invoked effector */
     public Collection<TaskSummary> getTasksOfEntity(String entityId) {
         Entity e = getEntity(entityId)
         if (!e) throw new NoSuchEntity()
 
-        return managementContextService.executionManager.getTasksWithAllTags(
-                [e, AbstractManagementContext.EFFECTOR_TAG]).collect { new TaskSummary(it)
}
+        List taskSummaries = managementContextService.executionManager.getTasksWithAllTags([e]).collect
{ new TaskSummary(it) }
+        // only show active subtasks, and effectors
+        taskSummaries = taskSummaries.findAll { TaskSummary t -> t.endTimeUtc==-1 || t.isEffector
};
+        Collections.sort(taskSummaries, 
+            { TaskSummary t1, TaskSummary t2 ->
+                if (t1.endTimeUtc && !t2.endTimeUtc) {
+                    //only t2 active, put it first
+                    return 1;
+                }
+                if (t2.endTimeUtc && !t1.endTimeUtc) {
+                    //only t1 active, put it first
+                    return -1;
+                }
+                //otherwise sort by start time
+                return t2.rawSubmitTimeUtc - t1.rawSubmitTimeUtc;
+            } as Comparator);
+        return taskSummaries;
     }
 
     private void unsubscribeEntitySensors() {

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/fcbcce38/usage/web-console/grails-app/utils/brooklyn/web/console/entity/TaskSummary.groovy
----------------------------------------------------------------------
diff --git a/usage/web-console/grails-app/utils/brooklyn/web/console/entity/TaskSummary.groovy
b/usage/web-console/grails-app/utils/brooklyn/web/console/entity/TaskSummary.groovy
index daa4de4..ade872a 100644
--- a/usage/web-console/grails-app/utils/brooklyn/web/console/entity/TaskSummary.groovy
+++ b/usage/web-console/grails-app/utils/brooklyn/web/console/entity/TaskSummary.groovy
@@ -6,6 +6,7 @@ import java.text.SimpleDateFormat
 
 import brooklyn.entity.Entity
 import brooklyn.management.Task
+import brooklyn.management.internal.AbstractManagementContext;
 
 /** Summary of a Brooklyn Task   */
 public class TaskSummary {
@@ -25,6 +26,7 @@ public class TaskSummary {
     final String endTimeUtc;
     final String currentStatus;
     final String detailedStatus;
+    final boolean isEffector;
 
     // formatter is not thread-safe; use thread-local storage
     private static final ThreadLocal<DateFormat> formatter = new ThreadLocal<DateFormat>()
{
@@ -49,6 +51,9 @@ public class TaskSummary {
         this.endTimeUtc = (task.endTimeUtc == -1) ? "" : formatter.get().format(new Date(task.endTimeUtc))
         this.currentStatus = task.statusSummary
         this.detailedStatus = task.getStatusDetail(true)
+        
+        this.tags = tags;
+        this.isEffector = tags?.contains AbstractManagementContext.EFFECTOR_TAG;
     }
 
     public String toString() {


Mime
View raw message