Updated Branches: refs/heads/master eb5e5a489 -> 8f6821171
ACCUMULO-1452, ACCUMULO-1502 Remove warnings introduced previously Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/8f682117 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/8f682117 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/8f682117 Branch: refs/heads/master Commit: 8f68211710cb948640201e65671ac07551d061d1 Parents: eb5e5a4 Author: Christopher Tubbs <ctubb...@apache.org> Authored: Fri Sep 13 17:37:39 2013 -0400 Committer: Christopher Tubbs <ctubb...@apache.org> Committed: Fri Sep 13 17:37:39 2013 -0400 ---------------------------------------------------------------------- .../examples/simple/client/TracingExample.java | 202 +++++++++---------- .../accumulo/test/functional/CleanTmpIT.java | 16 +- 2 files changed, 102 insertions(+), 116 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/8f682117/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 5eb2597..a542263 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 @@ -17,7 +17,6 @@ package org.apache.accumulo.examples.simple.client; -import java.io.IOException; import java.util.Map.Entry; import org.apache.accumulo.core.cli.ClientOnDefaultTable; @@ -42,113 +41,102 @@ import com.beust.jcommander.Parameter; /** * A simple example showing how to use the distributed tracing API in client code - * + * */ public class TracingExample { - - private static final String DEFAULT_TABLE_NAME = "test"; - - static class Opts extends ClientOnDefaultTable { - @Parameter(names = {"-C", "--createtable"}, description = "create table before doing anything") - boolean createtable = false; - @Parameter(names = {"-D", "--deletetable"}, description = "delete table when finished") - boolean deletetable = false; - @Parameter(names = {"-c", "--create"}, description = "create entries before any deletes") - boolean createEntries = false; - @Parameter(names = {"-r", "--read"}, description = "read entries after any creates/deletes") - boolean readEntries = false; - - public Opts() { - super(DEFAULT_TABLE_NAME); - auths = new Authorizations(); - } - } - - public void enableTracing(Opts opts) throws Exception { - DistributedTrace.enable(opts.getInstance(), new ZooReader(opts.getInstance().getZooKeepers(), 1000), "myHost", "myApp"); - } - - public void execute(Opts opts) throws TableNotFoundException, InterruptedException, AccumuloException, AccumuloSecurityException, TableExistsException { - - if (opts.createtable) { - opts.getConnector().tableOperations().create(opts.getTableName()); - } - - if (opts.createEntries) { - createEntries(opts); - } - - if (opts.readEntries) { - readEntries(opts); - } - - if (opts.deletetable) { - opts.getConnector().tableOperations().delete(opts.getTableName()); - } - } - - 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"); - - batchWriter.addMutation(m); - Span flushSpan = Trace.start("Client Flush"); - batchWriter.flush(); - flushSpan.stop(); - - // Use Trace.offNoFlush() if you don't want the operation to block. - batchWriter.close(); - Trace.off(); - } - - private void readEntries(Opts opts) throws TableNotFoundException, AccumuloException, AccumuloSecurityException { - - Scanner scanner = opts.getConnector().createScanner(opts.getTableName(), opts.auths); - - // 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()); - ++numberOfEntriesRead; - } - // You can add additional metadata (key, values) to Spans which will be able to be viewed in the Monitor - readSpan.data("Number of Entries Read", String.valueOf(numberOfEntriesRead)); - - Trace.off(); - } - - - /** - * @param args - * @throws AccumuloSecurityException - * @throws AccumuloException - * @throws TableNotFoundException - * @throws InterruptedException - * @throws KeeperException - * @throws IOException - * @throws TableExistsException - */ - public static void main(String[] args) throws Exception { - - TracingExample tracingExample = new TracingExample(); - Opts opts = new Opts(); - ScannerOpts scannerOpts = new ScannerOpts(); - opts.parseArgs(TracingExample.class.getName(), args, scannerOpts); - - tracingExample.enableTracing(opts); - tracingExample.execute(opts); - } + + private static final String DEFAULT_TABLE_NAME = "test"; + + static class Opts extends ClientOnDefaultTable { + @Parameter(names = {"-C", "--createtable"}, description = "create table before doing anything") + boolean createtable = false; + @Parameter(names = {"-D", "--deletetable"}, description = "delete table when finished") + boolean deletetable = false; + @Parameter(names = {"-c", "--create"}, description = "create entries before any deletes") + boolean createEntries = false; + @Parameter(names = {"-r", "--read"}, description = "read entries after any creates/deletes") + boolean readEntries = false; + + public Opts() { + super(DEFAULT_TABLE_NAME); + auths = new Authorizations(); + } + } + + public void enableTracing(Opts opts) throws Exception { + DistributedTrace.enable(opts.getInstance(), new ZooReader(opts.getInstance().getZooKeepers(), 1000), "myHost", "myApp"); + } + + public void execute(Opts opts) throws TableNotFoundException, InterruptedException, AccumuloException, AccumuloSecurityException, TableExistsException { + + if (opts.createtable) { + opts.getConnector().tableOperations().create(opts.getTableName()); + } + + if (opts.createEntries) { + createEntries(opts); + } + + if (opts.readEntries) { + readEntries(opts); + } + + if (opts.deletetable) { + opts.getConnector().tableOperations().delete(opts.getTableName()); + } + } + + 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"); + + batchWriter.addMutation(m); + Span flushSpan = Trace.start("Client Flush"); + batchWriter.flush(); + flushSpan.stop(); + + // Use Trace.offNoFlush() if you don't want the operation to block. + batchWriter.close(); + Trace.off(); + } + + private void readEntries(Opts opts) throws TableNotFoundException, AccumuloException, AccumuloSecurityException { + + Scanner scanner = opts.getConnector().createScanner(opts.getTableName(), opts.auths); + + // 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()); + ++numberOfEntriesRead; + } + // You can add additional metadata (key, values) to Spans which will be able to be viewed in the Monitor + readSpan.data("Number of Entries Read", String.valueOf(numberOfEntriesRead)); + + Trace.off(); + } + + public static void main(String[] args) throws Exception { + + TracingExample tracingExample = new TracingExample(); + Opts opts = new Opts(); + ScannerOpts scannerOpts = new ScannerOpts(); + opts.parseArgs(TracingExample.class.getName(), args, scannerOpts); + + tracingExample.enableTracing(opts); + tracingExample.execute(opts); + } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/8f682117/test/src/test/java/org/apache/accumulo/test/functional/CleanTmpIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/functional/CleanTmpIT.java b/test/src/test/java/org/apache/accumulo/test/functional/CleanTmpIT.java index c4fb6df..0216a7a 100644 --- a/test/src/test/java/org/apache/accumulo/test/functional/CleanTmpIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/CleanTmpIT.java @@ -17,9 +17,7 @@ package org.apache.accumulo.test.functional; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; @@ -33,7 +31,6 @@ import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Mutation; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.security.Authorizations; -import org.apache.accumulo.core.util.CachedConfiguration; import org.apache.accumulo.minicluster.MiniAccumuloConfig; import org.apache.accumulo.minicluster.ProcessReference; import org.apache.accumulo.minicluster.ServerType; @@ -42,10 +39,10 @@ import org.apache.hadoop.fs.Path; import org.junit.Test; public class CleanTmpIT extends ConfigurableMacIT { - + @Override public void configure(MiniAccumuloConfig cfg) { - Map<String, String> props = new HashMap<String, String>(); + Map<String,String> props = new HashMap<String,String>(); props.put(Property.INSTANCE_ZK_TIMEOUT.getKey(), "3s"); cfg.setSiteConfig(props); cfg.setNumTservers(1); @@ -64,19 +61,20 @@ public class CleanTmpIT extends ConfigurableMacIT { m.put("cf", "cq", "value"); bw.addMutation(m); bw.close(); - + // create a fake _tmp file in its directory String id = c.tableOperations().tableIdMap().get(tableName); FileSystem fs = getCluster().getFileSystem(); Path tmp = new Path(getCluster().getConfig().getAccumuloDir().getPath() + "/tables/" + id + "/default_tablet/junk.rf_tmp"); fs.create(tmp).close(); - for (ProcessReference tserver: getCluster().getProcesses().get(ServerType.TABLET_SERVER)) { + for (ProcessReference tserver : getCluster().getProcesses().get(ServerType.TABLET_SERVER)) { getCluster().killProcess(ServerType.TABLET_SERVER, tserver); } getCluster().start(); - + Scanner scanner = c.createScanner(tableName, Authorizations.EMPTY); - for (@SuppressWarnings("unused") Entry<Key,Value> entry : scanner) + for (@SuppressWarnings("unused") + Entry<Key,Value> entry : scanner) ; assertFalse(!fs.exists(tmp)); }