accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [3/5] accumulo git commit: ACCUMULO-3355 Catch the case when we find no traces and quit early.
Date Fri, 21 Nov 2014 04:04:19 GMT
ACCUMULO-3355 Catch the case when we find no traces and quit early.

If we don't quit early, we end up creating this absurd date and sending
it back to the user. Also fixed two tests that were unnecessarily
nuking the entire trace table. The Scanner they create is bounded for
their trace session; there is no reason to delete the rest of the records.


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

Branch: refs/heads/master
Commit: 0934298e09a2d311e7d9a9cd86b611f285f791b4
Parents: 32c18d5
Author: Josh Elser <elserj@apache.org>
Authored: Thu Nov 20 16:30:03 2014 -0500
Committer: Josh Elser <elserj@apache.org>
Committed: Thu Nov 20 16:30:03 2014 -0500

----------------------------------------------------------------------
 .../apache/accumulo/core/trace/TraceDump.java   | 24 ++++++++++++--------
 .../accumulo/test/ConditionalWriterIT.java      |  1 -
 .../test/TracerRecoversAfterOfflineTableIT.java |  3 +--
 3 files changed, 15 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/0934298e/core/src/main/java/org/apache/accumulo/core/trace/TraceDump.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/trace/TraceDump.java b/core/src/main/java/org/apache/accumulo/core/trace/TraceDump.java
index b44cc3e..4e9ea8c 100644
--- a/core/src/main/java/org/apache/accumulo/core/trace/TraceDump.java
+++ b/core/src/main/java/org/apache/accumulo/core/trace/TraceDump.java
@@ -28,7 +28,6 @@ import java.util.List;
 import java.util.Map.Entry;
 import java.util.Set;
 
-import org.apache.accumulo.trace.thrift.RemoteSpan;
 import org.apache.accumulo.core.cli.ClientOnDefaultTable;
 import org.apache.accumulo.core.cli.ScannerOpts;
 import org.apache.accumulo.core.client.Connector;
@@ -36,6 +35,7 @@ import org.apache.accumulo.core.client.Scanner;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Range;
 import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.trace.thrift.RemoteSpan;
 import org.apache.hadoop.io.Text;
 
 import com.beust.jcommander.Parameter;
@@ -43,7 +43,7 @@ import com.beust.jcommander.Parameter;
 
 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")
     boolean list = false;
@@ -59,7 +59,7 @@ public class TraceDump {
     List<String> traceIds = new ArrayList<String>();
     Opts() { super("trace");}
   }
-  
+
   public static void main(String[] args) throws Exception {
     Opts opts = new Opts();
     ScannerOpts scanOpts = new ScannerOpts();
@@ -73,7 +73,7 @@ public class TraceDump {
     }
     System.exit(code);
   }
-  
+
   public static List<RemoteSpan> sortByStart(Collection<RemoteSpan> spans) {
     List<RemoteSpan> spanList = new ArrayList<RemoteSpan>(spans);
     Collections.sort(spanList, new Comparator<RemoteSpan>() {
@@ -84,7 +84,7 @@ public class TraceDump {
     });
     return spanList;
   }
-  
+
   private static int listSpans(Opts opts, ScannerOpts scanOpts) throws Exception {
     PrintStream out = System.out;
     long endTime = System.currentTimeMillis();
@@ -101,15 +101,15 @@ public class TraceDump {
     }
     return 0;
   }
-  
+
   public interface Printer {
     void print(String line);
   }
-  
+
   private static int dumpTrace(Opts opts, ScannerOpts scanOpts) throws Exception {
     final PrintStream out = System.out;
     Connector conn = opts.getConnector();
-    
+
     int count = 0;
     for (String traceId : opts.traceIds) {
       Scanner scanner = conn.createScanner(opts.getTableName(), opts.auths);
@@ -125,7 +125,7 @@ public class TraceDump {
     }
     return count > 0 ? 0 : 1;
   }
-  
+
   public static int printTrace(Scanner scanner, final Printer out) {
     int count = 0;
     SpanTree tree = new SpanTree();
@@ -137,9 +137,13 @@ public class TraceDump {
       if (span.parentId <= 0)
         count++;
     }
+    if (Long.MAX_VALUE == start) {
+      out.print("Did not find any traces!");
+      return 0;
+    }
     out.print(String.format("Trace started at %s", TraceFormatter.formatDate(new Date(start))));
     out.print("Time  Start  Service@Location       Name");
-    
+
     final long finalStart = start;
     Set<Long> visited = tree.visit(new SpanTreeVisitor() {
       @Override

http://git-wip-us.apache.org/repos/asf/accumulo/blob/0934298e/test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java b/test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java
index 516cd46..8406570 100644
--- a/test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java
@@ -1232,7 +1232,6 @@ public class ConditionalWriterIT extends SimpleMacIT {
 
     String tableName = getUniqueNames(1)[0];
     conn.tableOperations().create(tableName);
-    conn.tableOperations().deleteRows("trace", null, null);
 
     DistributedTrace.enable(conn.getInstance(), new ZooReader(conn.getInstance().getZooKeepers(),
30*1000), "testTrace", "localhost");
     Span root = Trace.on("traceTest");

http://git-wip-us.apache.org/repos/asf/accumulo/blob/0934298e/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
b/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
index 3b32150..bd186a9 100644
--- a/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
@@ -66,8 +66,7 @@ public class TracerRecoversAfterOfflineTableIT extends ConfigurableMacIT
{
       }
     }
 
-    log.info("Deleting trace table records and taking table offline");
-    conn.tableOperations().deleteRows("trace", null, null);
+    log.info("Taking table offline");
     conn.tableOperations().offline("trace", true);
 
     String tableName = getUniqueNames(1)[0];


Mime
View raw message