diff --git a/hbase-common/pom.xml b/hbase-common/pom.xml
index 6425fc9..49703fc 100644
--- a/hbase-common/pom.xml
+++ b/hbase-common/pom.xml
@@ -206,6 +206,11 @@
commons-io
compile
+
+
+ org.htrace
+ htrace-core
+
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/trace/HBaseHTraceConfiguration.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/trace/HBaseHTraceConfiguration.java
new file mode 100644
index 0000000..b7fa574
--- /dev/null
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/trace/HBaseHTraceConfiguration.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hbase.trace;
+
+import org.apache.hadoop.conf.Configuration;
+import org.htrace.HTraceConfiguration;
+
+public class HBaseHTraceConfiguration extends HTraceConfiguration {
+
+ public static final String KEY_PREFIX = "hbase.";
+ private Configuration conf;
+
+ public HBaseHTraceConfiguration(Configuration conf) {
+ this.conf = conf;
+ }
+
+ @Override
+ public String get(String key) {
+ return conf.get(KEY_PREFIX +key);
+ }
+
+ @Override
+ public String get(String key, String defaultValue) {
+ return conf.get(KEY_PREFIX + key,defaultValue);
+
+ }
+
+ @Override
+ public boolean getBoolean(String key, boolean defaultValue) {
+ return conf.getBoolean(KEY_PREFIX + key, defaultValue);
+ }
+}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/trace/SpanReceiverHost.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/trace/SpanReceiverHost.java
new file mode 100644
index 0000000..c4a7286
--- /dev/null
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/trace/SpanReceiverHost.java
@@ -0,0 +1,141 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.trace;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.htrace.SpanReceiver;
+import org.htrace.Trace;
+
+/**
+ * This class provides functions for reading the names of SpanReceivers from
+ * hbase-site.xml, adding those SpanReceivers to the Tracer, and closing those
+ * SpanReceivers when appropriate.
+ */
+public class SpanReceiverHost {
+ public static final String SPAN_RECEIVERS_CONF_KEY = "hbase.trace.spanreceiver.classes";
+ private static final Log LOG = LogFactory.getLog(SpanReceiverHost.class);
+ private Collection receivers;
+ private Configuration conf;
+ private boolean closed = false;
+
+ private static enum SingletonHolder {
+ INSTANCE;
+ Object lock = new Object();
+ SpanReceiverHost host = null;
+ }
+
+ public static SpanReceiverHost getInstance(Configuration conf) {
+ if (SingletonHolder.INSTANCE.host != null) {
+ return SingletonHolder.INSTANCE.host;
+ }
+ synchronized (SingletonHolder.INSTANCE.lock) {
+ if (SingletonHolder.INSTANCE.host != null) {
+ return SingletonHolder.INSTANCE.host;
+ }
+
+ SpanReceiverHost host = new SpanReceiverHost(conf);
+ host.loadSpanReceivers();
+ SingletonHolder.INSTANCE.host = host;
+ return SingletonHolder.INSTANCE.host;
+ }
+
+ }
+
+ SpanReceiverHost(Configuration conf) {
+ receivers = new HashSet();
+ this.conf = conf;
+ }
+
+ /**
+ * Reads the names of classes specified in the
+ * "hbase.trace.spanreceiver.classes" property and instantiates and registers
+ * them with the Tracer as SpanReceiver's.
+ *
+ */
+ public void loadSpanReceivers() {
+ Class> implClass = null;
+ String[] receiverNames = conf.getStrings(SPAN_RECEIVERS_CONF_KEY);
+ if (receiverNames == null || receiverNames.length == 0) {
+ return;
+ }
+ for (String className : receiverNames) {
+ className = className.trim();
+
+ try {
+ implClass = Class.forName(className);
+ SpanReceiver receiver = loadInstance(implClass);
+ if (receiver != null) {
+ receivers.add(receiver);
+ LOG.info("SpanReceiver " + className + " was loaded successfully.");
+ }
+
+ } catch (ClassNotFoundException e) {
+ LOG.warn("Class " + className + " cannot be found. " + e.getMessage());
+ } catch (IOException e) {
+ LOG.warn("Load SpanReceiver " + className + " failed. "
+ + e.getMessage());
+ }
+ }
+ for (SpanReceiver rcvr : receivers) {
+ Trace.addReceiver(rcvr);
+ }
+ }
+
+ private SpanReceiver loadInstance(Class> implClass)
+ throws IOException {
+ SpanReceiver impl = null;
+ try {
+ Object o = implClass.newInstance();
+ impl = (SpanReceiver)o;
+ impl.configure(new HBaseHTraceConfiguration(this.conf));
+ } catch (SecurityException e) {
+ throw new IOException(e);
+ } catch (IllegalArgumentException e) {
+ throw new IOException(e);
+ } catch (RuntimeException e) {
+ throw new IOException(e);
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+
+ return impl;
+ }
+
+ /**
+ * Calls close() on all SpanReceivers created by this SpanReceiverHost.
+ */
+ public synchronized void closeReceivers() {
+ if (closed) return;
+ closed = true;
+ for (SpanReceiver rcvr : receivers) {
+ try {
+ rcvr.close();
+ } catch (IOException e) {
+ LOG.warn("Unable to close SpanReceiver correctly: " + e.getMessage(), e);
+ }
+ }
+ }
+}
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/trace/HBaseHTraceConfiguration.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/trace/HBaseHTraceConfiguration.java
deleted file mode 100644
index b7fa574..0000000
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/trace/HBaseHTraceConfiguration.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.trace;
-
-import org.apache.hadoop.conf.Configuration;
-import org.htrace.HTraceConfiguration;
-
-public class HBaseHTraceConfiguration extends HTraceConfiguration {
-
- public static final String KEY_PREFIX = "hbase.";
- private Configuration conf;
-
- public HBaseHTraceConfiguration(Configuration conf) {
- this.conf = conf;
- }
-
- @Override
- public String get(String key) {
- return conf.get(KEY_PREFIX +key);
- }
-
- @Override
- public String get(String key, String defaultValue) {
- return conf.get(KEY_PREFIX + key,defaultValue);
-
- }
-
- @Override
- public boolean getBoolean(String key, boolean defaultValue) {
- return conf.getBoolean(KEY_PREFIX + key, defaultValue);
- }
-}
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/trace/SpanReceiverHost.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/trace/SpanReceiverHost.java
deleted file mode 100644
index c4a7286..0000000
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/trace/SpanReceiverHost.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.hbase.trace;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashSet;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.conf.Configuration;
-import org.htrace.SpanReceiver;
-import org.htrace.Trace;
-
-/**
- * This class provides functions for reading the names of SpanReceivers from
- * hbase-site.xml, adding those SpanReceivers to the Tracer, and closing those
- * SpanReceivers when appropriate.
- */
-public class SpanReceiverHost {
- public static final String SPAN_RECEIVERS_CONF_KEY = "hbase.trace.spanreceiver.classes";
- private static final Log LOG = LogFactory.getLog(SpanReceiverHost.class);
- private Collection receivers;
- private Configuration conf;
- private boolean closed = false;
-
- private static enum SingletonHolder {
- INSTANCE;
- Object lock = new Object();
- SpanReceiverHost host = null;
- }
-
- public static SpanReceiverHost getInstance(Configuration conf) {
- if (SingletonHolder.INSTANCE.host != null) {
- return SingletonHolder.INSTANCE.host;
- }
- synchronized (SingletonHolder.INSTANCE.lock) {
- if (SingletonHolder.INSTANCE.host != null) {
- return SingletonHolder.INSTANCE.host;
- }
-
- SpanReceiverHost host = new SpanReceiverHost(conf);
- host.loadSpanReceivers();
- SingletonHolder.INSTANCE.host = host;
- return SingletonHolder.INSTANCE.host;
- }
-
- }
-
- SpanReceiverHost(Configuration conf) {
- receivers = new HashSet();
- this.conf = conf;
- }
-
- /**
- * Reads the names of classes specified in the
- * "hbase.trace.spanreceiver.classes" property and instantiates and registers
- * them with the Tracer as SpanReceiver's.
- *
- */
- public void loadSpanReceivers() {
- Class> implClass = null;
- String[] receiverNames = conf.getStrings(SPAN_RECEIVERS_CONF_KEY);
- if (receiverNames == null || receiverNames.length == 0) {
- return;
- }
- for (String className : receiverNames) {
- className = className.trim();
-
- try {
- implClass = Class.forName(className);
- SpanReceiver receiver = loadInstance(implClass);
- if (receiver != null) {
- receivers.add(receiver);
- LOG.info("SpanReceiver " + className + " was loaded successfully.");
- }
-
- } catch (ClassNotFoundException e) {
- LOG.warn("Class " + className + " cannot be found. " + e.getMessage());
- } catch (IOException e) {
- LOG.warn("Load SpanReceiver " + className + " failed. "
- + e.getMessage());
- }
- }
- for (SpanReceiver rcvr : receivers) {
- Trace.addReceiver(rcvr);
- }
- }
-
- private SpanReceiver loadInstance(Class> implClass)
- throws IOException {
- SpanReceiver impl = null;
- try {
- Object o = implClass.newInstance();
- impl = (SpanReceiver)o;
- impl.configure(new HBaseHTraceConfiguration(this.conf));
- } catch (SecurityException e) {
- throw new IOException(e);
- } catch (IllegalArgumentException e) {
- throw new IOException(e);
- } catch (RuntimeException e) {
- throw new IOException(e);
- } catch (InstantiationException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }
-
- return impl;
- }
-
- /**
- * Calls close() on all SpanReceivers created by this SpanReceiverHost.
- */
- public synchronized void closeReceivers() {
- if (closed) return;
- closed = true;
- for (SpanReceiver rcvr : receivers) {
- try {
- rcvr.close();
- } catch (IOException e) {
- LOG.warn("Unable to close SpanReceiver correctly: " + e.getMessage(), e);
- }
- }
- }
-}
diff --git a/src/main/docbkx/tracing.xml b/src/main/docbkx/tracing.xml
index beb0c89..cdece20 100644
--- a/src/main/docbkx/tracing.xml
+++ b/src/main/docbkx/tracing.xml
@@ -141,8 +141,6 @@
In order to turn on tracing in your client code,
you must initialize the module sending spans to receiver
once per client process.
- (Because SpanReceiverHost is included in hbase-server jar,
- you need it on the client classpath in order to run this example.)