camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject git commit: CAMEL-6384: Added BacklogDebugger MBean for live debugging of Camel routes.
Date Tue, 04 Jun 2013 08:40:13 GMT
Updated Branches:
  refs/heads/master 8aa6aa6c3 -> fdd1f5bdf


CAMEL-6384: Added BacklogDebugger MBean for live debugging of Camel routes.


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

Branch: refs/heads/master
Commit: fdd1f5bdfae6f1227690195995b8ca04c657cd7a
Parents: 8aa6aa6
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Tue Jun 4 10:39:59 2013 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Tue Jun 4 10:39:59 2013 +0200

----------------------------------------------------------------------
 .../processor/interceptor/BacklogDebugger.java     |    6 +
 .../camel/management/BacklogDebuggerTest.java      |   96 +++++++++++++++
 2 files changed, 102 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/fdd1f5bd/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogDebugger.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogDebugger.java
b/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogDebugger.java
index 1e331e7..b243968 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogDebugger.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogDebugger.java
@@ -299,6 +299,12 @@ public class BacklogDebugger extends ServiceSupport implements InterceptStrategy
     }
 
     public void stepBreakpoint(String nodeId) {
+        // if we are already in single step mode, then infer stepping
+        if (isSingleStepMode()) {
+            logger.log("stepBreakpoint " + nodeId + " is already in single step mode, so
stepping instead.");
+            step();
+        }
+
         logger.log("Step breakpoint " + nodeId);
         // we want to step current exchange to next
         BacklogTracerEventMessage msg = suspendedBreakpointMessages.get(nodeId);

http://git-wip-us.apache.org/repos/asf/camel/blob/fdd1f5bd/camel-core/src/test/java/org/apache/camel/management/BacklogDebuggerTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/management/BacklogDebuggerTest.java
b/camel-core/src/test/java/org/apache/camel/management/BacklogDebuggerTest.java
index 5583ea9..05f77ef 100644
--- a/camel-core/src/test/java/org/apache/camel/management/BacklogDebuggerTest.java
+++ b/camel-core/src/test/java/org/apache/camel/management/BacklogDebuggerTest.java
@@ -371,6 +371,102 @@ public class BacklogDebuggerTest extends ManagementTestSupport {
         assertEquals("Should not be in step mode", Boolean.FALSE, stepMode);
     }
 
+    @SuppressWarnings("unchecked")
+    public void testBacklogDebuggerStepCurrentNode() throws Exception {
+        MBeanServer mbeanServer = getMBeanServer();
+        ObjectName on = new ObjectName("org.apache.camel:context=localhost/camel-1,type=tracer,name=BacklogDebugger");
+        assertNotNull(on);
+        mbeanServer.isRegistered(on);
+
+        Boolean enabled = (Boolean) mbeanServer.getAttribute(on, "Enabled");
+        assertEquals("Should not be enabled", Boolean.FALSE, enabled);
+
+        // enable debugger
+        mbeanServer.invoke(on, "enableDebugger", null, null);
+
+        enabled = (Boolean) mbeanServer.getAttribute(on, "Enabled");
+        assertEquals("Should be enabled", Boolean.TRUE, enabled);
+
+        // add breakpoint at bar
+        mbeanServer.invoke(on, "addBreakpoint", new Object[]{"foo"}, new String[]{"java.lang.String"});
+
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(0);
+        mock.setSleepForEmptyTest(1000);
+
+        template.sendBody("seda:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+
+        // add breakpoint at bar
+        Set<String> nodes = (Set<String>) mbeanServer.invoke(on, "getSuspendedBreakpointNodeIds",
null, null);
+        assertNotNull(nodes);
+        assertEquals(1, nodes.size());
+        assertEquals("foo", nodes.iterator().next());
+
+        Boolean stepMode = (Boolean) mbeanServer.getAttribute(on, "SingleStepMode");
+        assertEquals("Should not be in step mode", Boolean.FALSE, stepMode);
+
+        // step breakpoint
+        mbeanServer.invoke(on, "stepBreakpoint", new Object[]{"foo"}, new String[]{"java.lang.String"});
+
+        // then at bar now
+        Thread.sleep(1000);
+        nodes = (Set<String>) mbeanServer.invoke(on, "getSuspendedBreakpointNodeIds",
null, null);
+        assertNotNull(nodes);
+        assertEquals(1, nodes.size());
+        assertEquals("bar", nodes.iterator().next());
+        stepMode = (Boolean) mbeanServer.getAttribute(on, "SingleStepMode");
+        assertEquals("Should be in step mode", Boolean.TRUE, stepMode);
+
+        // step
+        mbeanServer.invoke(on, "stepBreakpoint", new Object[]{"bar"}, new String[]{"java.lang.String"});
+
+        // then at transform now
+        Thread.sleep(1000);
+        nodes = (Set<String>) mbeanServer.invoke(on, "getSuspendedBreakpointNodeIds",
null, null);
+        assertNotNull(nodes);
+        assertEquals(1, nodes.size());
+        assertEquals("transform", nodes.iterator().next());
+        stepMode = (Boolean) mbeanServer.getAttribute(on, "SingleStepMode");
+        assertEquals("Should be in step mode", Boolean.TRUE, stepMode);
+
+        // step
+        mbeanServer.invoke(on, "stepBreakpoint", new Object[]{"transform"}, new String[]{"java.lang.String"});
+
+        // then at cheese now
+        Thread.sleep(1000);
+        nodes = (Set<String>) mbeanServer.invoke(on, "getSuspendedBreakpointNodeIds",
null, null);
+        assertNotNull(nodes);
+        assertEquals(1, nodes.size());
+        assertEquals("cheese", nodes.iterator().next());
+        stepMode = (Boolean) mbeanServer.getAttribute(on, "SingleStepMode");
+        assertEquals("Should be in step mode", Boolean.TRUE, stepMode);
+
+        // step
+        mbeanServer.invoke(on, "stepBreakpoint", new Object[]{"cheese"}, new String[]{"java.lang.String"});
+
+        // then at result now
+        Thread.sleep(1000);
+        nodes = (Set<String>) mbeanServer.invoke(on, "getSuspendedBreakpointNodeIds",
null, null);
+        assertNotNull(nodes);
+        assertEquals(1, nodes.size());
+        assertEquals("result", nodes.iterator().next());
+        stepMode = (Boolean) mbeanServer.getAttribute(on, "SingleStepMode");
+        assertEquals("Should be in step mode", Boolean.TRUE, stepMode);
+
+        // step
+        mbeanServer.invoke(on, "stepBreakpoint", new Object[]{"result"}, new String[]{"java.lang.String"});
+
+        // then the exchange is completed
+        Thread.sleep(1000);
+        nodes = (Set<String>) mbeanServer.invoke(on, "getSuspendedBreakpointNodeIds",
null, null);
+        assertNotNull(nodes);
+        assertEquals(0, nodes.size());
+        stepMode = (Boolean) mbeanServer.getAttribute(on, "SingleStepMode");
+        assertEquals("Should not be in step mode", Boolean.FALSE, stepMode);
+    }
+
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {


Mime
View raw message