HTRACE-90. Remove Guava and shade other depdendencies in HTrace subprojects (cmccabe)
diff --git a/htrace-hbase/pom.xml b/htrace-hbase/pom.xml
index fb976ee..b48c894 100644
--- a/htrace-hbase/pom.xml
+++ b/htrace-hbase/pom.xml
@@ -75,6 +75,30 @@
         <artifactId>maven-compiler-plugin</artifactId>
       </plugin>
       <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <configuration>
+              <relocations>
+                <relocation>
+                  <pattern>org.apache.commons.logging</pattern>
+                  <shadedPattern>org.apache.htrace.commons.logging</shadedPattern>
+                </relocation>
+                <relocation>
+                  <pattern>com.google.protobuf</pattern>
+                  <shadedPattern>org.apache.htrace.com.google.protobuf</shadedPattern>
+                </relocation>
+              </relocations>
+            </configuration>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
         <artifactId>maven-javadoc-plugin</artifactId>
       </plugin>
       <plugin>
@@ -107,18 +131,11 @@
       <groupId>com.google.protobuf</groupId>
       <artifactId>protobuf-java</artifactId>
       <version>${protobuf.version}</version>
-      <scope>provided</scope>
     </dependency>
     <!-- Global deps. -->
     <dependency>
       <groupId>commons-logging</groupId>
       <artifactId>commons-logging</artifactId>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>com.google.guava</groupId>
-      <artifactId>guava</artifactId>
-      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>junit</groupId>
diff --git a/htrace-hbase/src/main/java/org/apache/htrace/impl/HBaseSpanReceiver.java b/htrace-hbase/src/main/java/org/apache/htrace/impl/HBaseSpanReceiver.java
index b03291e..bb9c3a8 100644
--- a/htrace-hbase/src/main/java/org/apache/htrace/impl/HBaseSpanReceiver.java
+++ b/htrace-hbase/src/main/java/org/apache/htrace/impl/HBaseSpanReceiver.java
@@ -27,6 +27,7 @@
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -50,8 +51,6 @@
 import org.apache.htrace.TraceScope;
 import org.apache.htrace.protobuf.generated.SpanProtos;
 
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-
 /**
  * HBase is an open source distributed datastore.
  * This span receiver store spans into HBase.
@@ -107,7 +106,18 @@
    * This will be the same factory for the lifetime of this object so that
    * no thread names will ever be duplicated.
    */
-  private final ThreadFactory tf;
+  private final ThreadFactory tf = new ThreadFactory() {
+    private final AtomicLong receiverIdx = new AtomicLong(0);
+
+    @Override
+    public Thread newThread(Runnable r) {
+      Thread t = new Thread(r);
+      t.setDaemon(true);
+      t.setName(String.format("hbaseSpanReceiver-%d",
+            receiverIdx.getAndIncrement()));
+      return t;
+    }
+  };
 
   private ExecutorService service;
   private final HTraceConfiguration conf;
@@ -119,9 +129,6 @@
 
   public HBaseSpanReceiver(HTraceConfiguration conf) {
     this.queue = new ArrayBlockingQueue<Span>(1000);
-    this.tf = new ThreadFactoryBuilder().setDaemon(true)
-                                        .setNameFormat("hbaseSpanReceiver-%d")
-                                        .build();
     this.conf = conf;
     this.hconf = HBaseConfiguration.create();
     this.table = Bytes.toBytes(conf.get(TABLE_KEY, DEFAULT_TABLE));
@@ -356,4 +363,4 @@
     receiver.close();
     System.out.println("trace id: " + traceid);
   }
-}
\ No newline at end of file
+}
diff --git a/htrace-hbase/src/test/java/org/apache/htrace/impl/TestHBaseSpanReceiver.java b/htrace-hbase/src/test/java/org/apache/htrace/impl/TestHBaseSpanReceiver.java
index 52b344c..c990c18 100644
--- a/htrace-hbase/src/test/java/org/apache/htrace/impl/TestHBaseSpanReceiver.java
+++ b/htrace-hbase/src/test/java/org/apache/htrace/impl/TestHBaseSpanReceiver.java
@@ -49,9 +49,6 @@
 import org.junit.Ignore;
 import org.junit.Test;
 
-import com.google.common.collect.Multimap;
-
-
 public class TestHBaseSpanReceiver {
   private static final Log LOG = LogFactory.getLog(TestHBaseSpanReceiver.class);
   private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
diff --git a/htrace-zipkin/pom.xml b/htrace-zipkin/pom.xml
index 0e2ae64..bb79b1f 100644
--- a/htrace-zipkin/pom.xml
+++ b/htrace-zipkin/pom.xml
@@ -51,6 +51,34 @@
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <configuration>
+              <relocations>
+                <relocation>
+                  <pattern>org.apache.commons.logging</pattern>
+                  <shadedPattern>org.apache.htrace.commons.logging</shadedPattern>
+                </relocation>
+                <relocation>
+                  <pattern>org.apache.thrift</pattern>
+                  <shadedPattern>org.apache.htrace.thrift</shadedPattern>
+                </relocation>
+                <relocation>
+                  <pattern>org.apache.commons.codec</pattern>
+                  <shadedPattern>org.apache.htrace.commons.codec</shadedPattern>
+                </relocation>
+              </relocations>
+            </configuration>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-gpg-plugin</artifactId>
       </plugin>
       <plugin>
@@ -76,12 +104,6 @@
     <dependency>
       <groupId>commons-logging</groupId>
       <artifactId>commons-logging</artifactId>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>com.google.guava</groupId>
-      <artifactId>guava</artifactId>
-      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>junit</groupId>
diff --git a/htrace-zipkin/src/main/java/org/apache/htrace/impl/ZipkinSpanReceiver.java b/htrace-zipkin/src/main/java/org/apache/htrace/impl/ZipkinSpanReceiver.java
index fdb4da7..06ff0ad 100644
--- a/htrace-zipkin/src/main/java/org/apache/htrace/impl/ZipkinSpanReceiver.java
+++ b/htrace-zipkin/src/main/java/org/apache/htrace/impl/ZipkinSpanReceiver.java
@@ -17,7 +17,6 @@
 
 package org.apache.htrace.impl;
 
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
 import com.twitter.zipkin.gen.LogEntry;
 import com.twitter.zipkin.gen.Scribe;
 
@@ -45,6 +44,7 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -119,7 +119,18 @@
    * This will be the same factory for the lifetime of this object so that
    * no thread names will ever be duplicated.
    */
-  private final ThreadFactory tf;
+  private final ThreadFactory tf = new ThreadFactory() {
+    private final AtomicLong receiverIdx = new AtomicLong(0);
+
+    @Override
+    public Thread newThread(Runnable r) {
+      Thread t = new Thread(r);
+      t.setDaemon(true);
+      t.setName(String.format("zipkinSpanReceiver-%d",
+                receiverIdx.getAndIncrement()));
+      return t;
+    }
+  };
 
   ////////////////////
   /// Variables that will change on each call to configure()
@@ -133,10 +144,6 @@
   public ZipkinSpanReceiver(HTraceConfiguration conf) {
     this.queue = new ArrayBlockingQueue<Span>(1000);
     this.protocolFactory = new TBinaryProtocol.Factory();
-
-    tf = new ThreadFactoryBuilder().setDaemon(true)
-        .setNameFormat("zipkinSpanReceiver-%d")
-        .build();
     configure(conf);
   }
 
diff --git a/pom.xml b/pom.xml
index 8bf899a..e02250f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -287,11 +287,6 @@
         <version>1.1.1</version>
       </dependency>
       <dependency>
-        <groupId>com.google.guava</groupId>
-        <artifactId>guava</artifactId>
-        <version>12.0.1</version>
-      </dependency>
-      <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <version>4.10</version>