Repository: incubator-htrace Updated Branches: refs/heads/master feaccb807 -> f425e63c3
HTRACE-90. Remove Guava and shade other depdendencies in HTrace subprojects (cmccabe) Project: http://git-wip-us.apache.org/repos/asf/incubator-htrace/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-htrace/commit/f425e63c Tree: http://git-wip-us.apache.org/repos/asf/incubator-htrace/tree/f425e63c Diff: http://git-wip-us.apache.org/repos/asf/incubator-htrace/diff/f425e63c Branch: refs/heads/master Commit: f425e63c37f8edad82c1f1915afc317f7e420eb4 Parents: feaccb8 Author: Colin P. Mccabe <[email protected]> Authored: Fri Jan 30 19:32:39 2015 -0800 Committer: Colin P. Mccabe <[email protected]> Committed: Fri Jan 30 19:32:39 2015 -0800 ---------------------------------------------------------------------- htrace-hbase/pom.xml | 31 ++++++++++++++---- .../apache/htrace/impl/HBaseSpanReceiver.java | 21 ++++++++---- .../htrace/impl/TestHBaseSpanReceiver.java | 3 -- htrace-zipkin/pom.xml | 34 ++++++++++++++++---- .../apache/htrace/impl/ZipkinSpanReceiver.java | 19 +++++++---- pom.xml | 5 --- 6 files changed, 79 insertions(+), 34 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/f425e63c/htrace-hbase/pom.xml ---------------------------------------------------------------------- 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 @@ language governing permissions and limitations under the License. --> <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 @@ language governing permissions and limitations under the License. --> <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> http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/f425e63c/htrace-hbase/src/main/java/org/apache/htrace/impl/HBaseSpanReceiver.java ---------------------------------------------------------------------- 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.Executors; 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.Trace; 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 @@ public class HBaseSpanReceiver implements SpanReceiver { * 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 class HBaseSpanReceiver implements SpanReceiver { 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 @@ public class HBaseSpanReceiver implements SpanReceiver { receiver.close(); System.out.println("trace id: " + traceid); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/f425e63c/htrace-hbase/src/test/java/org/apache/htrace/impl/TestHBaseSpanReceiver.java ---------------------------------------------------------------------- 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.BeforeClass; 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(); http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/f425e63c/htrace-zipkin/pom.xml ---------------------------------------------------------------------- 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 @@ language governing permissions and limitations under the License. --> </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 @@ language governing permissions and limitations under the License. --> <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> http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/f425e63c/htrace-zipkin/src/main/java/org/apache/htrace/impl/ZipkinSpanReceiver.java ---------------------------------------------------------------------- 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.nio.ByteBuffer; 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 @@ public class ZipkinSpanReceiver implements SpanReceiver { * 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 class ZipkinSpanReceiver implements SpanReceiver { 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); } http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/f425e63c/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 8bf899a..e02250f 100644 --- a/pom.xml +++ b/pom.xml @@ -287,11 +287,6 @@ language governing permissions and limitations under the License. --> <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>
