accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bil...@apache.org
Subject [3/3] accumulo git commit: ACCUMULO-3715 handle unrooted spans better and fix TraceDump options
Date Sat, 11 Apr 2015 00:15:39 GMT
ACCUMULO-3715 handle unrooted spans better and fix TraceDump options


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

Branch: refs/heads/master
Commit: 3a99300a2b897f9f8740a3efa0271c43536ef0cc
Parents: 7e72d56
Author: Billie Rinaldi <billie.rinaldi@gmail.com>
Authored: Thu Apr 9 08:30:06 2015 -0700
Committer: Billie Rinaldi <billie.rinaldi@gmail.com>
Committed: Fri Apr 10 17:01:00 2015 -0700

----------------------------------------------------------------------
 .../monitor/servlets/trace/ShowTrace.java       | 90 ++++++++++----------
 .../org/apache/accumulo/tracer/TraceDump.java   | 19 ++---
 2 files changed, 54 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/3a99300a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/ShowTrace.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/ShowTrace.java
b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/ShowTrace.java
index 4e05b89..a4a67d7 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/ShowTrace.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/ShowTrace.java
@@ -130,61 +130,63 @@ public class ShowTrace extends Basic {
     Set<Long> visited = tree.visit(new SpanTreeVisitor() {
       @Override
       public void visit(int level, RemoteSpan parent, RemoteSpan node, Collection<RemoteSpan>
children) {
-        sb.append("<tr>\n");
-        sb.append(String.format("<td class='right'>%d+</td><td class='left'>%d</td>%n",
node.stop - node.start, node.start - finalStart));
-        sb.append(String.format("<td style='text-indent: %dpx'>%s@%s</td>%n",
level * 10, node.svc, node.sender));
-        sb.append("<td>" + node.description + "</td>");
-        boolean hasData = node.data != null && !node.data.isEmpty();
-        boolean hasAnnotations = node.annotations != null && !node.annotations.isEmpty();
-        if (hasData || hasAnnotations) {
-          String hexSpanId = Long.toHexString(node.spanId);
-          sb.append("<td><input type='checkbox' id=\"");
-          sb.append(hexSpanId);
-          sb.append(checkboxIdSuffix);
-          sb.append("\" onclick='toggle(\"" + Long.toHexString(node.spanId) + "\")'></td>\n");
-        } else {
-          sb.append("<td></td>\n");
-        }
-        sb.append("</tr>\n");
-        sb.append("<tr id='" + Long.toHexString(node.spanId) + "' style='display:none'>");
-        sb.append("<td colspan='5'>\n");
-        if (hasData || hasAnnotations) {
-          sb.append("  <table class='indent,noborder'>\n");
-          if (hasData) {
-            sb.append("  <tr><th>Key</th><th>Value</th></tr>\n");
-            for (Entry<ByteBuffer,ByteBuffer> entry : node.data.entrySet()) {
-              String key = new String(entry.getKey().array(), entry.getKey().arrayOffset(),
entry.getKey().limit(), UTF_8);
-              String value = new String(entry.getValue().array(), entry.getValue().arrayOffset(),
entry.getValue().limit(), UTF_8);
-              sb.append("  <tr><td>" + BasicServlet.sanitize(key) + "</td>");
-              sb.append("<td>" + BasicServlet.sanitize(value) + "</td></tr>\n");
-            }
-          }
-          if (hasAnnotations) {
-            sb.append("  <tr><th>Annotation</th><th>Time Offset</th></tr>\n");
-            for (Annotation entry : node.annotations) {
-              sb.append("  <tr><td>" + BasicServlet.sanitize(entry.getMsg())
+ "</td>");
-              sb.append(String.format("<td>%d</td></tr>\n", entry.getTime()
- finalStart));
-            }
-          }
-          sb.append("  </table>");
-        }
-        sb.append("</td>\n");
-        sb.append("</tr>\n");
+        appendRow(sb, level, node, finalStart);
       }
     });
     tree.nodes.keySet().removeAll(visited);
     if (!tree.nodes.isEmpty()) {
-      sb.append("<span type='warn'>Warning: the following spans are not rooted!</span>\n");
-      sb.append("<ul>\n");
+      sb.append("<tr><td colspan=10>The following spans are not rooted (probably
due to a parent span of length 0ms):<td></tr>\n");
       for (RemoteSpan span : TraceDump.sortByStart(tree.nodes.values())) {
-        sb.append(String.format("<li>%s %s %s</li>\n", Long.toHexString(span.spanId),
Long.toHexString(span.parentId), span.description));
+        appendRow(sb, 0, span, finalStart);
       }
-      sb.append("</ul>\n");
     }
     sb.append("</table>\n");
     sb.append("</div>\n");
   }
 
+  private static void appendRow(StringBuilder sb, int level, RemoteSpan node, long finalStart)
{
+    sb.append("<tr>\n");
+    sb.append(String.format("<td class='right'>%d+</td><td class='left'>%d</td>%n",
node.stop - node.start, node.start - finalStart));
+    sb.append(String.format("<td style='text-indent: %dpx'>%s@%s</td>%n", level
* 10, node.svc, node.sender));
+    sb.append("<td>" + node.description + "</td>");
+    boolean hasData = node.data != null && !node.data.isEmpty();
+    boolean hasAnnotations = node.annotations != null && !node.annotations.isEmpty();
+    if (hasData || hasAnnotations) {
+      String hexSpanId = Long.toHexString(node.spanId);
+      sb.append("<td><input type='checkbox' id=\"");
+      sb.append(hexSpanId);
+      sb.append(checkboxIdSuffix);
+      sb.append("\" onclick='toggle(\"" + Long.toHexString(node.spanId) + "\")'></td>\n");
+    } else {
+      sb.append("<td></td>\n");
+    }
+    sb.append("</tr>\n");
+    sb.append("<tr id='" + Long.toHexString(node.spanId) + "' style='display:none'>");
+    sb.append("<td colspan='5'>\n");
+    if (hasData || hasAnnotations) {
+      sb.append("  <table class='indent,noborder'>\n");
+      if (hasData) {
+        sb.append("  <tr><th>Key</th><th>Value</th></tr>\n");
+        for (Entry<ByteBuffer,ByteBuffer> entry : node.data.entrySet()) {
+          String key = new String(entry.getKey().array(), entry.getKey().arrayOffset(), entry.getKey().limit(),
UTF_8);
+          String value = new String(entry.getValue().array(), entry.getValue().arrayOffset(),
entry.getValue().limit(), UTF_8);
+          sb.append("  <tr><td>" + BasicServlet.sanitize(key) + "</td>");
+          sb.append("<td>" + BasicServlet.sanitize(value) + "</td></tr>\n");
+        }
+      }
+      if (hasAnnotations) {
+        sb.append("  <tr><th>Annotation</th><th>Time Offset</th></tr>\n");
+        for (Annotation entry : node.annotations) {
+          sb.append("  <tr><td>" + BasicServlet.sanitize(entry.getMsg()) + "</td>");
+          sb.append(String.format("<td>%d</td></tr>\n", entry.getTime()
- finalStart));
+        }
+      }
+      sb.append("  </table>");
+    }
+    sb.append("</td>\n");
+    sb.append("</tr>\n");
+  }
+
   @Override
   protected String getBodyAttributes() {
     return " onload=\"" + pageLoadFunctionName + "()\" ";

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3a99300a/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceDump.java
----------------------------------------------------------------------
diff --git a/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceDump.java b/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceDump.java
index e4eb70e..0a87469 100644
--- a/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceDump.java
+++ b/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceDump.java
@@ -45,16 +45,12 @@ public class TraceDump {
   static final long DEFAULT_TIME_IN_MILLIS = 10 * 60 * 1000l;
 
   static class Opts extends ClientOnDefaultTable {
-    @Parameter(names = {"-l", "--list"}, description = "List recent traces")
+    @Parameter(names = {"-r", "--recent"}, description = "List recent traces")
     boolean list = false;
-    @Parameter(names = {"-s", "--start"}, description = "The start time of traces to display")
-    String start;
-    @Parameter(names = {"-e", "--end"}, description = "The end time of traces to display")
-    String end;
-    @Parameter(names = {"-d", "--dump"}, description = "Dump the traces")
+    @Parameter(names = {"-ms", "--ms"}, description = "Time period of recent traces to list
in ms")
+    long length = DEFAULT_TIME_IN_MILLIS;
+    @Parameter(names = {"-d", "--dump"}, description = "Dump all traces")
     boolean dump = false;
-    @Parameter(names = {"-i", "--instance"}, description = "URL to point to accumulo.")
-    String instance;
     @Parameter(description = " <trace id> { <trace id> ... }")
     List<String> traceIds = new ArrayList<String>();
 
@@ -91,7 +87,7 @@ public class TraceDump {
   private static int listSpans(Opts opts, ScannerOpts scanOpts) throws Exception {
     PrintStream out = System.out;
     long endTime = System.currentTimeMillis();
-    long startTime = endTime - DEFAULT_TIME_IN_MILLIS;
+    long startTime = endTime - opts.length;
     Connector conn = opts.getConnector();
     Scanner scanner = conn.createScanner(opts.getTableName(), opts.auths);
     scanner.setBatchSize(scanOpts.scanBatchSize);
@@ -157,9 +153,10 @@ public class TraceDump {
     });
     tree.nodes.keySet().removeAll(visited);
     if (!tree.nodes.isEmpty()) {
-      out.print("Warning: the following spans are not rooted!");
+      out.print("The following spans are not rooted (probably due to a parent span of length
0ms):");
       for (RemoteSpan span : sortByStart(tree.nodes.values())) {
-        out.print(String.format("%s %s %s", Long.toHexString(span.spanId), Long.toHexString(span.parentId),
span.description));
+        String fmt = "%5d+%-5d %" + 1 + "s%s@%s %s";
+        out.print(String.format(fmt, span.stop - span.start, span.start - finalStart, "",
span.svc, span.sender, span.description));
       }
       return -1;
     }


Mime
View raw message