camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/5] camel git commit: CAMEL-8223: Inflight repository to allow browsing of current inflight exchanges
Date Fri, 09 Jan 2015 12:41:59 GMT
Repository: camel
Updated Branches:
  refs/heads/master 4ec817aa7 -> 22d596737


CAMEL-8223: Inflight repository to allow browsing of current inflight exchanges


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/22d59673
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/22d59673
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/22d59673

Branch: refs/heads/master
Commit: 22d5967376969396efeea411c6a6cf26a2eb7948
Parents: f812a45
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Jan 9 13:00:48 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Jan 9 13:41:46 2015 +0100

----------------------------------------------------------------------
 .../jolokia/DefaultJolokiaCamelController.java  | 25 ++++++++++----------
 .../commands/jolokia/JolokiaRemoteTest.java     |  9 +++++++
 2 files changed, 22 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/22d59673/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/DefaultJolokiaCamelController.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/DefaultJolokiaCamelController.java
b/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/DefaultJolokiaCamelController.java
index 0a44998..1ef0920 100644
--- a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/DefaultJolokiaCamelController.java
+++ b/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/DefaultJolokiaCamelController.java
@@ -235,22 +235,23 @@ public class DefaultJolokiaCamelController extends AbstractCamelController
imple
 
         ObjectName found = lookupCamelContext(camelContextName);
         if (found != null) {
-            String pattern = String.format("%s:context=%s,type=services,name=\"%s\"", found.getDomain(),
found.getKeyProperty("context"), "DefaultInflightRepository");
+            String pattern = String.format("%s:context=%s,type=services,name=DefaultInflightRepository",
found.getDomain(), found.getKeyProperty("context"));
             ObjectName on = ObjectName.getInstance(pattern);
             J4pExecResponse er = jolokia.execute(new J4pExecRequest(on, "browse(int,boolean)",
limit, sortByLongestDuration));
             if (er != null) {
                 JSONObject data = er.getValue();
-                for (Object obj : data.values()) {
-                    JSONObject data2 = (JSONObject) obj;
-                    JSONObject inflight = (JSONObject) data2.values().iterator().next();
-
-                    Map<String, Object> row = new LinkedHashMap<String, Object>();
-                    row.put("exchangeId", asString(inflight.get("exchangeId")));
-                    row.put("routeId", asString(inflight.get("routeIdId")));
-                    row.put("nodeId", asString(inflight.get("nodeId")));
-                    row.put("duration", asString(inflight.get("duration")));
-                    row.put("elapsed", asString(inflight.get("elapsed")));
-                    answer.add(row);
+                if (data != null) {
+                    for (Object obj : data.values()) {
+                        JSONObject inflight = (JSONObject) obj;
+
+                        Map<String, Object> row = new LinkedHashMap<String, Object>();
+                        row.put("exchangeId", asString(inflight.get("exchangeId")));
+                        row.put("routeId", asString(inflight.get("routeId")));
+                        row.put("nodeId", asString(inflight.get("nodeId")));
+                        row.put("duration", asString(inflight.get("duration")));
+                        row.put("elapsed", asString(inflight.get("elapsed")));
+                        answer.add(row);
+                    }
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/22d59673/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java
b/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java
index 95e1c7f..758b823 100644
--- a/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java
+++ b/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaRemoteTest.java
@@ -204,4 +204,13 @@ public class JolokiaRemoteTest {
         System.out.println(data);
     }
 
+    @Test
+    public void testInflight() throws Exception {
+        controller = new DefaultJolokiaCamelController();
+        controller.connect(url, null, null);
+
+        List<Map<String, Object>> data = controller.browseInflightExchanges("myCamel",
500, false);
+        System.out.println(data);
+    }
+
 }


Mime
View raw message