brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [43/50] brooklyn-ui git commit: more reporting, esp on known errors to help debugging, and related web console fixes
Date Mon, 01 Feb 2016 17:52:02 GMT
more reporting, esp on known errors to help debugging, and related web console fixes


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

Branch: refs/heads/0.4.0
Commit: 9a34e9ed40dba0afe2b44470ff2be49046a39179
Parents: fcbcce3
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Mon Sep 10 03:35:21 2012 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Mon Sep 10 23:25:09 2012 -0700

----------------------------------------------------------------------
 .../brooklyn/web/console/EntityController.groovy       |  5 ++++-
 .../services/brooklyn/web/console/EntityService.groovy | 13 ++++++-------
 .../web/console/ManagementContextService.groovy        |  2 +-
 .../brooklyn/web/console/TestWebApplication.groovy     |  6 +++---
 .../brooklyn/web/console/entity/TaskSummary.groovy     |  6 +++---
 .../java/brooklyn/web/console/EntityServiceTest.groovy |  5 +++--
 6 files changed, 20 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/9a34e9ed/usage/web-console/grails-app/controllers/brooklyn/web/console/EntityController.groovy
----------------------------------------------------------------------
diff --git a/usage/web-console/grails-app/controllers/brooklyn/web/console/EntityController.groovy
b/usage/web-console/grails-app/controllers/brooklyn/web/console/EntityController.groovy
index 5e4e72a..ca754c2 100644
--- a/usage/web-console/grails-app/controllers/brooklyn/web/console/EntityController.groovy
+++ b/usage/web-console/grails-app/controllers/brooklyn/web/console/EntityController.groovy
@@ -188,7 +188,10 @@ class EntityController {
         try {
             render entityService.getTasksOfEntity(params.id) as JSON
         } catch (NoSuchEntity e) {
-            render(status: 404, text: '{message: "Entity with specified id '+params.id+'does
not exist"}')
+            render(status: 404, text: '{message: "Entity with specified id '+params.id+'
does not exist"}')
+        } catch (StringIndexOutOfBoundsException e) {
+            println "ERROR returning 404, but tasks fyi are "+entityService.getTasksOfEntity(params.id);
+            render(status: 404, text: '{message: "Entity with specified id '+params.id+'
caused error rendering as json"}')
         }
     }
 

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/9a34e9ed/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 5500e98..086263c 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
@@ -36,27 +36,26 @@ public class EntityService {
     public static class NoSuchEntity extends Exception {}
 
     // TODO Want to handle pagination better; for now we just restrict list to 20 most recent
-    /** returns only _effector_ calls */
+    /** returns only _effector_ calls, in submission order (reversed) */
     public List<TaskSummary> getTasksOfAllEntities() {
         final int MAX_NUM_RETURNED = 20
         
         List<TaskSummary> result = managementContextService.executionManager.getTasksWithAllTags(
                 [AbstractManagementContext.EFFECTOR_TAG]).collect { new TaskSummary(it) }
-                
         Collections.sort(result, {TaskSummary t1, TaskSummary t2 -> 
-                return new Long(t2.rawSubmitTimeUtc - t1.rawSubmitTimeUtc).intValue() } as
Comparator)
+                return t2.rawSubmitTimeUtc.compareTo(t1.rawSubmitTimeUtc) } as Comparator)
         
         return result.subList(0, Math.min(MAX_NUM_RETURNED, result.size()))
     }
 
-    /** returns any active task or any invoked effector */
+    /** returns any active task or any invoked effector, in order of submission time, but
with active tasks first */
     public Collection<TaskSummary> getTasksOfEntity(String entityId) {
         Entity e = getEntity(entityId)
         if (!e) throw new NoSuchEntity()
 
-        List taskSummaries = managementContextService.executionManager.getTasksWithAllTags([e]).collect
{ new TaskSummary(it) }
+        List taskSummaries = managementContextService.executionManager.getTasksWithTag(e).collect
{ new TaskSummary(it) }
         // only show active subtasks, and effectors
-        taskSummaries = taskSummaries.findAll { TaskSummary t -> t.endTimeUtc==-1 || t.isEffector
};
+        taskSummaries = taskSummaries.findAll { TaskSummary t -> !t.endTimeUtc || t.isEffector
};
         Collections.sort(taskSummaries, 
             { TaskSummary t1, TaskSummary t2 ->
                 if (t1.endTimeUtc && !t2.endTimeUtc) {
@@ -68,7 +67,7 @@ public class EntityService {
                     return -1;
                 }
                 //otherwise sort by start time
-                return t2.rawSubmitTimeUtc - t1.rawSubmitTimeUtc;
+                return t2.rawSubmitTimeUtc.compareTo(t1.rawSubmitTimeUtc);
             } as Comparator);
         return taskSummaries;
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/9a34e9ed/usage/web-console/grails-app/services/brooklyn/web/console/ManagementContextService.groovy
----------------------------------------------------------------------
diff --git a/usage/web-console/grails-app/services/brooklyn/web/console/ManagementContextService.groovy
b/usage/web-console/grails-app/services/brooklyn/web/console/ManagementContextService.groovy
index bd1f2ca..1324433 100644
--- a/usage/web-console/grails-app/services/brooklyn/web/console/ManagementContextService.groovy
+++ b/usage/web-console/grails-app/services/brooklyn/web/console/ManagementContextService.groovy
@@ -32,7 +32,7 @@ class ManagementContextService {
         // TODO use a different mechanism for specifying test-app
         if (!managementContext) {
             managementContext = new LocalManagementContext();
-            managementContext.manage(new TestWebApplication())
+            managementContext.manage(new TestWebApplication(mgmt: managementContext))
         }
         // END TODO
 

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/9a34e9ed/usage/web-console/grails-app/utils/brooklyn/web/console/TestWebApplication.groovy
----------------------------------------------------------------------
diff --git a/usage/web-console/grails-app/utils/brooklyn/web/console/TestWebApplication.groovy
b/usage/web-console/grails-app/utils/brooklyn/web/console/TestWebApplication.groovy
index 2850ee5..5968ee3 100644
--- a/usage/web-console/grails-app/utils/brooklyn/web/console/TestWebApplication.groovy
+++ b/usage/web-console/grails-app/utils/brooklyn/web/console/TestWebApplication.groovy
@@ -119,10 +119,10 @@ public class TestWebApplication extends AbstractApplication {
         Runnable r = new Runnable() {
             void run() {
                 while (true) {
-                    Sensor sensor = new BasicAttributeSensor(Sensor.class, "test.sensor",
"Added and removed every 20s")
-                    entity.addSensor(sensor)
+                    Sensor sensor = new BasicAttributeSensor(String.class, "test.sensor",
"Added and removed every 20s")
+                    entity.setAttribute(sensor, "X")
                     Thread.sleep(20*1000L)
-                    entity.removeSensor(sensor.name)
+                    entity.removeAttribute(sensor)
                     Thread.sleep(20*1000L)
                 }
             }

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/9a34e9ed/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 ade872a..836c693 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
@@ -19,7 +19,7 @@ public class TaskSummary {
     final String displayName;
     final String description;
     final String id;
-    final Set<String> tags;
+    final Collection<String> tags;
     final long rawSubmitTimeUtc;
     final String submitTimeUtc;
     final String startTimeUtc;
@@ -52,8 +52,8 @@ public class TaskSummary {
         this.currentStatus = task.statusSummary
         this.detailedStatus = task.getStatusDetail(true)
         
-        this.tags = tags;
-        this.isEffector = tags?.contains AbstractManagementContext.EFFECTOR_TAG;
+        this.tags = task.tags.collect { ""+it };
+        this.isEffector = task.tags?.contains(AbstractManagementContext.EFFECTOR_TAG);
     }
 
     public String toString() {

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/9a34e9ed/usage/web-console/src/test/java/brooklyn/web/console/EntityServiceTest.groovy
----------------------------------------------------------------------
diff --git a/usage/web-console/src/test/java/brooklyn/web/console/EntityServiceTest.groovy
b/usage/web-console/src/test/java/brooklyn/web/console/EntityServiceTest.groovy
index d3567a7..db3e6f1 100644
--- a/usage/web-console/src/test/java/brooklyn/web/console/EntityServiceTest.groovy
+++ b/usage/web-console/src/test/java/brooklyn/web/console/EntityServiceTest.groovy
@@ -15,13 +15,13 @@ import brooklyn.entity.basic.AbstractGroup
 import brooklyn.entity.basic.MethodEffector
 import brooklyn.entity.trait.Startable
 import brooklyn.location.Location
-import brooklyn.location.basic.SimulatedLocation;
+import brooklyn.location.basic.SimulatedLocation
 import brooklyn.web.console.entity.TaskSummary
 
 import com.google.common.collect.Iterables
 
 class EntityServiceTest {
-    def testService
+    EntityService testService
 
     Entity testEntity
     List<Entity> testEntities
@@ -162,6 +162,7 @@ class EntityServiceTest {
         
         tier.invoke(eff)
         List<TaskSummary> tasks = testService.getTasksOfEntity(tier.id)
+        if (!tasks) fail("Should have had a task on "+tier.id+", since we invoked "+eff);
         TaskSummary task = tasks.get(0)
         
         assertEquals(task.entityDisplayName, tier.displayName)


Mime
View raw message