accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject [1/2] git commit: ACCUMULO-1490 run the trace examples in the integration test
Date Thu, 12 Sep 2013 18:33:24 GMT
Updated Branches:
  refs/heads/master 9190eb453 -> e39f57685


ACCUMULO-1490 run the trace examples in the integration test


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

Branch: refs/heads/master
Commit: e39f57685c5480c9ac9c8aecc7c5705b4e7a704b
Parents: cff5cc2
Author: Eric Newton <eric.newton@gmail.com>
Authored: Thu Sep 12 14:33:18 2013 -0400
Committer: Eric Newton <eric.newton@gmail.com>
Committed: Thu Sep 12 14:33:23 2013 -0400

----------------------------------------------------------------------
 .../examples/simple/client/TracingExample.java  | 15 ++++-----
 .../accumulo/test/functional/ExamplesIT.java    | 35 ++++++++++++++++++--
 2 files changed, 39 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/e39f5768/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/TracingExample.java
----------------------------------------------------------------------
diff --git a/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/TracingExample.java
b/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/TracingExample.java
index 46752c8..da511a1 100644
--- a/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/TracingExample.java
+++ b/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/TracingExample.java
@@ -89,16 +89,16 @@ public class TracingExample {
 	
 	private void createEntries(Opts opts) throws TableNotFoundException, AccumuloException,
AccumuloSecurityException {
 		
-		
+		// Trace the write operation. Note, unless you flush the BatchWriter, you will not capture
+		// the write operation as it is occurs asynchronously. You can optionally create additional
Spans
+		// within a given Trace as seen below around the flush
+		Trace.on("Client Write");
+		System.out.println("TraceID: " + Long.toHexString(Trace.currentTrace().traceId()));
 		BatchWriter batchWriter = opts.getConnector().createBatchWriter(opts.getTableName(), new
BatchWriterConfig());
 	    
 		Mutation m = new Mutation("row");
 		m.put("cf", "cq", "value");
 		
-		// Trace the write operation. Note, unless you flush the BatchWriter, you will not capture
-		// the write operation as it is occurs asynchronously. You can optionally create additional
Spans
-		// within a given Trace as seen below around the flush
-		Trace.on("Client Write");
 		
 	    batchWriter.addMutation(m);
 	    Span flushSpan = Trace.start("Client Flush");
@@ -106,9 +106,8 @@ public class TracingExample {
 	    flushSpan.stop();
 	    
 	    // Use Trace.offNoFlush() if you don't want the operation to block.
-	    Trace.off();
-	    
 	    batchWriter.close();
+	    Trace.off();
 	}
 	
 	private void readEntries(Opts opts) throws TableNotFoundException, AccumuloException, AccumuloSecurityException
{
@@ -117,7 +116,7 @@ public class TracingExample {
 		
 		// Trace the read operation.  
 		Span readSpan = Trace.on("Client Read");
-		
+		System.out.println("TraceID: " + Long.toHexString(Trace.currentTrace().traceId()));
 		int numberOfEntriesRead = 0;
 		for (Entry<Key,Value> entry : scanner) {
 			System.out.println(entry.getKey().toString() + " -> " + entry.getValue().toString());

http://git-wip-us.apache.org/repos/asf/accumulo/blob/e39f5768/test/src/test/java/org/apache/accumulo/test/functional/ExamplesIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/ExamplesIT.java b/test/src/test/java/org/apache/accumulo/test/functional/ExamplesIT.java
index c690ce0..af2107a 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/ExamplesIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/ExamplesIT.java
@@ -24,6 +24,8 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map.Entry;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.accumulo.core.cli.BatchWriterOpts;
 import org.apache.accumulo.core.client.BatchScanner;
@@ -47,6 +49,8 @@ import org.apache.accumulo.examples.simple.client.RandomBatchWriter;
 import org.apache.accumulo.examples.simple.client.ReadWriteExample;
 import org.apache.accumulo.examples.simple.client.RowOperations;
 import org.apache.accumulo.examples.simple.client.SequentialBatchWriter;
+import org.apache.accumulo.examples.simple.client.TraceDumpExample;
+import org.apache.accumulo.examples.simple.client.TracingExample;
 import org.apache.accumulo.examples.simple.constraints.MaxMutationSize;
 import org.apache.accumulo.examples.simple.dirlist.Ingest;
 import org.apache.accumulo.examples.simple.dirlist.QueryUtil;
@@ -68,6 +72,7 @@ import org.apache.accumulo.examples.simple.shard.Reverse;
 import org.apache.accumulo.minicluster.MiniAccumuloCluster.LogWriter;
 import org.apache.accumulo.minicluster.MemoryUnit;
 import org.apache.accumulo.minicluster.MiniAccumuloConfig;
+import org.apache.accumulo.server.trace.TraceServer;
 import org.apache.accumulo.server.util.Admin;
 import org.apache.accumulo.test.TestIngest;
 import org.apache.accumulo.test.VerifyIngest;
@@ -100,19 +105,43 @@ public class ExamplesIT extends ConfigurableMacIT {
     String dir = cluster.getConfig().getDir().getAbsolutePath();
     FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());
     
+    Process trace = cluster.exec(TraceServer.class);
+    while (!c.tableOperations().exists("trace"))
+      UtilWaitThread.sleep(500);
+    
+    log.info("trace example");
+    Process p = cluster.exec(TracingExample.class, "-i", instance, "-z", keepers, "-u", user,
"-p", passwd, "-C", "-D", "-c");
+    assertEquals(0, p.waitFor());
+    for(LogWriter writer : cluster.getLogWriters()) {
+      writer.flush();
+    }
+    String result = FunctionalTestUtils.readAll(cluster, TracingExample.class, p);
+    Pattern pattern = Pattern.compile("TraceID: ([0-9a-f]+)");
+    Matcher matcher = pattern.matcher(result);
+    int count = 0;
+    while (matcher.find()) {
+      p = cluster.exec(TraceDumpExample.class, "-i", instance, "-z", keepers, "-u", user,
"-p", passwd, "--traceid", matcher.group(1));
+      assertEquals(0, p.waitFor());
+      count++;
+    }
+    assertTrue(count > 0);
+    result = FunctionalTestUtils.readAll(cluster, TraceDumpExample.class, p);
+    assertTrue(result.contains("myHost@myApp"));
+    trace.destroy();
+    
     
     log.info("testing dirlist example (a little)");
     c.securityOperations().changeUserAuthorizations(user, new Authorizations(auths.split(",")));
     assertEquals(0, cluster.exec(Ingest.class, "-i", instance, "-z", keepers, "-u", user,
"-p", passwd, 
         "--dirTable", "dirTable", "--indexTable", "indexTable", "--dataTable", "dataTable",
         "--vis", visibility, "--chunkSize", 10000 + "", cluster.getConfig().getDir().getAbsolutePath()).waitFor());
-    Process p = cluster.exec(QueryUtil.class, "-i", instance, "-z", keepers, "-p", passwd,
"-u", user,
+    p = cluster.exec(QueryUtil.class, "-i", instance, "-z", keepers, "-p", passwd, "-u",
user,
         "-t", "indexTable", "--auths", auths, "--search", "--path", "accumulo-site.xml");
     assertEquals(0, p.waitFor());
     for(LogWriter writer : cluster.getLogWriters()) {
       writer.flush();
     }
-    String result = FunctionalTestUtils.readAll(cluster, QueryUtil.class, p);
+    result = FunctionalTestUtils.readAll(cluster, QueryUtil.class, p);
     System.out.println("result " + result);
     assertTrue(result.contains("accumulo-site.xml"));
 
@@ -127,7 +156,7 @@ public class ExamplesIT extends ConfigurableMacIT {
     m.put("a", "b", "c");
     bw.addMutation(m);
     UtilWaitThread.sleep(1000);
-    int count = 0;
+    count = 0;
     for (@SuppressWarnings("unused") Entry<Key,Value> line : c.createScanner("filtertest",
Authorizations.EMPTY))
       count++;
     assertEquals(0, count);


Mime
View raw message