camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1458300 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/api/management/mbean/ main/java/org/apache/camel/management/mbean/ main/java/org/apache/camel/processor/interceptor/ main/java/org/apache/camel/util/ test/java/org/apache...
Date Tue, 19 Mar 2013 14:14:05 GMT
Author: davsclaus
Date: Tue Mar 19 14:14:05 2013
New Revision: 1458300

URL: http://svn.apache.org/r1458300
Log:
CAMEL-6148: More options on BacklogTracer

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedTracerBacklogMBean.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedBacklogTracer.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogTracer.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogTracerInterceptor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/BacklogTracerTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedTracerBacklogMBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedTracerBacklogMBean.java?rev=1458300&r1=1458299&r2=1458300&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedTracerBacklogMBean.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedTracerBacklogMBean.java
Tue Mar 19 14:14:05 2013
@@ -29,10 +29,10 @@ public interface ManagedTracerBacklogMBe
     @ManagedAttribute(description = "Is tracing enabled")
     void setEnabled(boolean enabled);
 
-    @ManagedAttribute(description = "Number of traced messages to keep in the backlog (FIFO
queue)")
+    @ManagedAttribute(description = "Number of maximum traced messages in total to keep in
the backlog (FIFO queue)")
     int getBacklogSize();
 
-    @ManagedAttribute(description = "Number of traced messages to keep in the backlog (FIFO
queue)")
+    @ManagedAttribute(description = "Number of maximum traced messages in total to keep in
the backlog (FIFO queue)")
     void setBacklogSize(int backlogSize);
 
     @ManagedAttribute(description = "Whether to remove traced message from backlog when dumping
trace messages")
@@ -53,16 +53,34 @@ public interface ManagedTracerBacklogMBe
     @ManagedOperation(description = "Resets the trace counter")
     void resetTraceCounter();
 
-    @ManagedOperation(description = "Dumps the traced messages for the given node")
-    List<BacklogTracerEventMessage> dumpTracedMessages(String nodeId);
+    @ManagedAttribute(description = "Number of maximum chars in the message body in the trace
message. Use zero or negative value to have unlimited size.")
+    int getBodyMaxChars();
 
-    @ManagedOperation(description = "Dumps the traced messages for the given node in xml
format")
-    String dumpTracedMessagesAsXml(String nodeId);
+    @ManagedAttribute(description = "Number of maximum chars in the message body in the trace
message. Use zero or negative value to have unlimited size.")
+    void setBodyMaxChars(int bodyMaxChars);
 
-    @ManagedOperation(description = "Dumps the traced messages for all nodes")
+    @ManagedAttribute(description = "Whether to include stream based message body in the
trace message.")
+    boolean isBodyIncludeStreams();
+
+    @ManagedAttribute(description = "Whether to include stream based message body in the
trace message.")
+    void setBodyIncludeStreams(boolean bodyIncludeStreams);
+
+    @ManagedAttribute(description = "Whether to include file based message body in the trace
message.")
+    boolean isBodyIncludeFiles();
+
+    @ManagedAttribute(description = "Whether to include file based message body in the trace
message.")
+    void setBodyIncludeFiles(boolean bodyIncludeFiles);
+
+    @ManagedOperation(description = "Dumps the traced messages for the given node or route")
+    List<BacklogTracerEventMessage> dumpTracedMessages(String nodeOrRouteId);
+
+    @ManagedOperation(description = "Dumps the traced messages for the given node or route
in xml format")
+    String dumpTracedMessagesAsXml(String nodeOrRouteId);
+
+    @ManagedOperation(description = "Dumps all the traced messages")
     List<BacklogTracerEventMessage> dumpAllTracedMessages();
 
-    @ManagedOperation(description = "Dumps the traced messages for all nodes in xml format")
+    @ManagedOperation(description = "Dumps all the traced messages in xml format")
     String dumpAllTracedMessagesAsXml();
 
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedBacklogTracer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedBacklogTracer.java?rev=1458300&r1=1458299&r2=1458300&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedBacklogTracer.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedBacklogTracer.java
Tue Mar 19 14:14:05 2013
@@ -94,16 +94,40 @@ public class ManagedBacklogTracer implem
         backlogTracer.resetTraceCounter();
     }
 
-    public List<BacklogTracerEventMessage> dumpTracedMessages(String nodeId) {
-        return backlogTracer.dumpTracedMessages(nodeId);
+    public int getBodyMaxChars() {
+        return backlogTracer.getBodyMaxChars();
+    }
+
+    public void setBodyMaxChars(int bodyMaxChars) {
+        backlogTracer.setBodyMaxChars(bodyMaxChars);
+    }
+
+    public boolean isBodyIncludeStreams() {
+        return backlogTracer.isBodyIncludeStreams();
+    }
+
+    public void setBodyIncludeStreams(boolean bodyIncludeStreams) {
+        backlogTracer.setBodyIncludeStreams(bodyIncludeStreams);
+    }
+
+    public boolean isBodyIncludeFiles() {
+        return backlogTracer.isBodyIncludeFiles();
+    }
+
+    public void setBodyIncludeFiles(boolean bodyIncludeFiles) {
+        backlogTracer.setBodyIncludeFiles(bodyIncludeFiles);
+    }
+
+    public List<BacklogTracerEventMessage> dumpTracedMessages(String nodeOrRouteId)
{
+        return backlogTracer.dumpTracedMessages(nodeOrRouteId);
     }
 
     public List<BacklogTracerEventMessage> dumpAllTracedMessages() {
         return backlogTracer.dumpAllTracedMessages();
     }
 
-    public String dumpTracedMessagesAsXml(String nodeId) {
-        return backlogTracer.dumpTracedMessagesAsXml(nodeId);
+    public String dumpTracedMessagesAsXml(String nodeOrRouteId) {
+        return backlogTracer.dumpTracedMessagesAsXml(nodeOrRouteId);
     }
 
     public String dumpAllTracedMessagesAsXml() {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogTracer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogTracer.java?rev=1458300&r1=1458299&r2=1458300&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogTracer.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogTracer.java
Tue Mar 19 14:14:05 2013
@@ -44,16 +44,19 @@ import org.apache.camel.util.EndpointHel
  */
 public class BacklogTracer extends ServiceSupport implements InterceptStrategy {
 
-    // lets limit the tracer to 1000 messages per node
-    public static final int MAX_BACKLOG_SIZE = 1000;
+    // lets limit the tracer to 100 thousand messages in total
+    public static final int MAX_BACKLOG_SIZE = 100 * 1000;
     private final CamelContext camelContext;
     private boolean enabled;
     private final AtomicLong traceCounter = new AtomicLong(0);
     // use a queue with a upper limit to avoid storing too many messages
     private final Queue<DefaultBacklogTracerEventMessage> queue = new ArrayBlockingQueue<DefaultBacklogTracerEventMessage>(MAX_BACKLOG_SIZE);
-    // how many of the last messages per node to keep in the backlog
-    private int backlogSize = MAX_BACKLOG_SIZE;
+    // how many of the last messages to keep in the backlog at total
+    private int backlogSize = 1000;
     private boolean removeOnDump = true;
+    private int bodyMaxChars = 128 * 1024;
+    private boolean bodyIncludeStreams;
+    private boolean bodyIncludeFiles = true;
     // a pattern to filter tracing nodes
     private String tracePattern;
     private String[] patterns;
@@ -171,6 +174,30 @@ public class BacklogTracer extends Servi
         this.removeOnDump = removeOnDump;
     }
 
+    public int getBodyMaxChars() {
+        return bodyMaxChars;
+    }
+
+    public void setBodyMaxChars(int bodyMaxChars) {
+        this.bodyMaxChars = bodyMaxChars;
+    }
+
+    public boolean isBodyIncludeStreams() {
+        return bodyIncludeStreams;
+    }
+
+    public void setBodyIncludeStreams(boolean bodyIncludeStreams) {
+        this.bodyIncludeStreams = bodyIncludeStreams;
+    }
+
+    public boolean isBodyIncludeFiles() {
+        return bodyIncludeFiles;
+    }
+
+    public void setBodyIncludeFiles(boolean bodyIncludeFiles) {
+        this.bodyIncludeFiles = bodyIncludeFiles;
+    }
+
     public String getTracePattern() {
         return tracePattern;
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogTracerInterceptor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogTracerInterceptor.java?rev=1458300&r1=1458299&r2=1458300&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogTracerInterceptor.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogTracerInterceptor.java
Tue Mar 19 14:14:05 2013
@@ -66,7 +66,8 @@ public class BacklogTracerInterceptor ex
                 Date timestamp = new Date();
                 String toNode = processorDefinition.getId();
                 String exchangeId = exchange.getExchangeId();
-                String messageAsXml = MessageHelper.dumpAsXml(exchange.getIn(), true, 4);
+                String messageAsXml = MessageHelper.dumpAsXml(exchange.getIn(), true, 4,
+                        backlogTracer.isBodyIncludeStreams(), backlogTracer.isBodyIncludeFiles(),
backlogTracer.getBodyMaxChars());
 
                 // if first we should add a pseudo trace message as well, so we have a starting
message (eg from the route)
                 String routeId = routeDefinition.getId();

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java?rev=1458300&r1=1458299&r2=1458300&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java Tue Mar
19 14:14:05 2013
@@ -286,6 +286,21 @@ public final class MessageHelper {
      * @return the XML
      */
     public static String dumpAsXml(Message message, boolean includeBody, int indent) {
+        return dumpAsXml(message, includeBody, indent, false, true, 128 * 1024);
+    }
+
+    /**
+     * Dumps the message as a generic XML structure.
+     *
+     * @param message the message
+     * @param includeBody whether or not to include the message body
+     * @param indent number of spaces to indent
+     * @param allowStreams whether to include message body if they are stream based
+     * @param allowFiles whether to include message body if they are file based
+     * @param maxChars clip body after maximum chars (to avoid very big messages). Use 0
or negative value to not limit at all.
+     * @return the XML
+     */
+    public static String dumpAsXml(Message message, boolean includeBody, int indent, boolean
allowStreams, boolean allowFiles, int maxChars) {
         StringBuilder sb = new StringBuilder();
 
         StringBuilder prefix = new StringBuilder();
@@ -343,11 +358,7 @@ public final class MessageHelper {
             }
             sb.append(">");
 
-            // dump body value as XML, use Camel type converter to convert to
-            // String
-            // do not allow streams, but allow files, and clip very big message
-            // bodies (128kb)
-            String xml = extractBodyForLogging(message, "", false, true, 128 * 1024);
+            String xml = extractBodyForLogging(message, "", allowStreams, allowFiles, maxChars);
             if (xml != null) {
                 // must always xml encode
                 sb.append(StringHelper.xmlEncode(xml));

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/BacklogTracerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/BacklogTracerTest.java?rev=1458300&r1=1458299&r2=1458300&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/BacklogTracerTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/BacklogTracerTest.java
Tue Mar 19 14:14:05 2013
@@ -21,11 +21,12 @@ import javax.management.Attribute;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.api.management.mbean.BacklogTracerEventMessage;
 import org.apache.camel.builder.RouteBuilder;
-import org.w3c.dom.Document;
-import org.w3c.dom.NodeList;
 
 public class BacklogTracerTest extends ManagementTestSupport {
 



Mime
View raw message