emptyList();
+ }
+
+ @Override
+ public void close() throws IOException {
+ }
+
+ @Override
+ public void receiveSpan(Span span) {
+ }
+}
diff --git a/hbase-noop-htrace/src/main/java/org/apache/htrace/core/ProbabilitySampler.java b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/ProbabilitySampler.java
new file mode 100644
index 0000000..cb208bb
--- /dev/null
+++ b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/ProbabilitySampler.java
@@ -0,0 +1,35 @@
+/*
+ * 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.htrace.core;
+
+/**
+ * Sampler that returns true a certain percentage of the time. Specify the frequency interval by
+ * configuring a {@code double} value for {@link #SAMPLER_FRACTION_CONF_KEY}.
+ */
+public class ProbabilitySampler extends Sampler {
+ @SuppressWarnings("VisibilityModifier")
+ public final double threshold = 0.0d;
+ public final static String SAMPLER_FRACTION_CONF_KEY = "sampler.fraction";
+
+ public ProbabilitySampler(HTraceConfiguration conf) {
+ }
+
+ @Override
+ public boolean next() {
+ return false;
+ }
+}
diff --git a/hbase-noop-htrace/src/main/java/org/apache/htrace/core/Sampler.java b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/Sampler.java
new file mode 100644
index 0000000..1f613e3
--- /dev/null
+++ b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/Sampler.java
@@ -0,0 +1,64 @@
+/*
+ * 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.htrace.core;
+
+/**
+ * Extremely simple callback to determine the frequency that an action should
+ * be performed.
+ *
+ * For example, the next() function may look like this:
+ *
+ *
+ * public boolean next() {
+ * return Math.random() > 0.5;
+ * }
+ *
+ *
+ * This would trace 50% of all gets, 75% of all puts and would not trace any
+ * other requests.
+ */
+public abstract class Sampler {
+ /**
+ * A {@link Sampler} builder. It takes a {@link Sampler} class name and
+ * constructs an instance of that class, with the provided configuration.
+ */
+ public static class Builder {
+ public Builder(HTraceConfiguration conf) {
+ }
+
+ public Builder reset() {
+ return this;
+ }
+
+ public Builder className(String className) {
+ return this;
+ }
+
+ public Builder classLoader(ClassLoader classLoader) {
+ return this;
+ }
+
+ public Sampler build() {
+ return NEVER;
+ }
+ }
+
+ public static final Sampler ALWAYS = AlwaysSampler.INSTANCE;
+ public static final Sampler NEVER = NeverSampler.INSTANCE;
+
+ public abstract boolean next();
+}
diff --git a/hbase-noop-htrace/src/main/java/org/apache/htrace/core/ScheduledTraceExecutorService.java b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/ScheduledTraceExecutorService.java
new file mode 100644
index 0000000..2c8d5c9
--- /dev/null
+++ b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/ScheduledTraceExecutorService.java
@@ -0,0 +1,66 @@
+/*
+ * 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.htrace.core;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * A convenience wrapper around a {@link ScheduledExecutorService} for
+ * automatically propagating trace scopes to executable tasks.
+ *
+ * Recurring tasks will use independent scopes per execution, but will all be
+ * tied to the same parent scope (if any).
+ */
+public class ScheduledTraceExecutorService extends TraceExecutorService
+ implements ScheduledExecutorService {
+ final ScheduledExecutorService impl;
+
+ ScheduledTraceExecutorService(Tracer tracer, String scopeName,
+ ScheduledExecutorService impl) {
+ super(tracer, scopeName, impl);
+ this.impl = impl;
+ }
+
+ @Override
+ public ScheduledFuture> schedule(Runnable command, long delay,
+ TimeUnit unit) {
+ return impl.schedule(command, delay, unit);
+ }
+
+ @Override
+ public ScheduledFuture schedule(Callable callable, long delay,
+ TimeUnit unit) {
+ return impl.schedule(callable, delay, unit);
+ }
+
+ @Override
+ public ScheduledFuture> scheduleAtFixedRate(Runnable command,
+ long initialDelay, long period, TimeUnit unit) {
+ return impl.scheduleAtFixedRate(command, initialDelay, period, unit);
+ }
+
+ @Override
+ public ScheduledFuture> scheduleWithFixedDelay(Runnable command,
+ long initialDelay, long delay, TimeUnit unit) {
+ return impl.scheduleWithFixedDelay(command, initialDelay, delay,
+ unit);
+ }
+
+}
diff --git a/hbase-noop-htrace/src/main/java/org/apache/htrace/core/Span.java b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/Span.java
new file mode 100644
index 0000000..d97a41c
--- /dev/null
+++ b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/Span.java
@@ -0,0 +1,164 @@
+/*
+ * 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.htrace.core;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Base interface for gathering and reporting statistics about a block of
+ * execution.
+ *
+ * Spans should form a directed acyclic graph structure. It should be
+ * possible to keep following the parents of a span until you arrive at a
+ * span with no parents.
+ *
+ * * removed Jackson stuff, including annotation on Span and a serialization
+ * implementation.
+ */
+public interface Span {
+ /**
+ * The block has completed, stop the clock
+ */
+ void stop();
+
+ /**
+ * Get the span start time.
+ *
+ * @return The start time, in approximate milliseconds since the epoch.
+ */
+ long getStartTimeMillis();
+
+ /**
+ * Get the span stop time.
+ *
+ * @return The stop time, in approximate milliseconds since the epoch.
+ */
+ long getStopTimeMillis();
+
+ /**
+ * Return the total amount of time elapsed since start was called, if running,
+ * or difference between stop and start
+ *
+ * @return The elapsed time in milliseconds.
+ */
+ long getAccumulatedMillis();
+
+ /**
+ * Has the span been started and not yet stopped?
+ *
+ * @return True if the span is still running (has no stop time).
+ */
+ boolean isRunning();
+
+ /**
+ * Return a textual description of this span.
+ *
+ * @return The description of this span. Will never be null.
+ */
+ String getDescription();
+
+ /**
+ * A pseudo-unique (random) number assigned to this span instance.
+ *
+ * @return The spanID. This object is immutable and is safe to access
+ * from multiple threads.
+ */
+ SpanId getSpanId();
+
+ /**
+ * Create a child span of this span with the given description
+ * @deprecated Since 4.0.0. Use {@link MilliSpan.Builder}
+ * @param description The description to set on the child span.
+ * @return A new child span.
+ */
+ @Deprecated
+ Span child(String description);
+
+ @Override
+ String toString();
+
+ /**
+ * Returns the parent IDs of the span.
+ *
+ * @return The array of parents, or an empty array if there are no parents.
+ */
+ SpanId[] getParents();
+
+ /**
+ * Set the parents of this span.
+ *
+ * Any existing parents will be cleared by this call.
+ *
+ * @param parents The parents to set.
+ */
+ void setParents(SpanId[] parents);
+
+ /**
+ * Add a data annotation associated with this span
+ *
+ * @param key The key to set.
+ * @param value The value to set.
+ */
+ void addKVAnnotation(String key, String value);
+
+ /**
+ * Add a timeline annotation associated with this span
+ *
+ * @param msg The annotation to set. It will be associated with
+ * the current time.
+ */
+ void addTimelineAnnotation(String msg);
+
+ /**
+ * Get the key-value annotations associated with this span.
+ *
+ * @return The annotation map in read-only form.
+ * Will never be null.
+ */
+ Map getKVAnnotations();
+
+ /**
+ * Get the timeline annotation list.
+ *
+ * @return The annotation list in read-only form.
+ * Will never be null.
+ */
+ List getTimelineAnnotations();
+
+ /**
+ * Return a unique id for the process from which this Span originated.
+ *
+ * @return The tracer id. Will never be null.
+ */
+ String getTracerId();
+
+ /**
+ * Set the tracer id of a span.
+ *
+ * @param s The tracer ID to set.
+ */
+ void setTracerId(String s);
+
+ /**
+ * Serialize to Json
+ *
+ * @return A JSON string with the span data.
+ */
+ String toJson();
+
+}
diff --git a/hbase-noop-htrace/src/main/java/org/apache/htrace/core/SpanId.java b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/SpanId.java
new file mode 100644
index 0000000..f2e3413
--- /dev/null
+++ b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/SpanId.java
@@ -0,0 +1,89 @@
+/*
+ * 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.htrace.core;
+
+/**
+ * Uniquely identifies an HTrace span.
+ *
+ * Span IDs are 128 bits in total. The upper 64 bits of a span ID is the same
+ * as the upper 64 bits of the parent span, if there is one. The lower 64 bits
+ * are always random.
+ *
+ * * All Span IDs are 0.
+ */
+public final class SpanId implements Comparable {
+
+ /**
+ * The invalid span ID, which is all zeroes.
+ *
+ * It is also the "least" span ID in the sense that it is considered
+ * smaller than any other span ID.
+ */
+ @SuppressWarnings("VisibilityModifier")
+ public static SpanId INVALID = new SpanId(0, 0);
+
+
+ public static SpanId fromRandom() {
+ return INVALID;
+ }
+
+ public static SpanId fromString(String str) {
+ return INVALID;
+ }
+
+ public SpanId(long high, long low) {
+ }
+
+ public long getHigh() {
+ return 0L;
+ }
+
+ public long getLow() {
+ return 0L;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof SpanId)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int compareTo(SpanId other) {
+ return 0;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return "00000000000000000000000000000000";
+ }
+
+ public boolean isValid() {
+ return false;
+ }
+
+ public SpanId newChildId() {
+ return INVALID;
+ }
+}
diff --git a/hbase-noop-htrace/src/main/java/org/apache/htrace/core/SpanReceiver.java b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/SpanReceiver.java
new file mode 100644
index 0000000..4eefae8
--- /dev/null
+++ b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/SpanReceiver.java
@@ -0,0 +1,102 @@
+/*
+ * 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.htrace.core;
+
+import java.io.Closeable;
+
+
+/**
+ * The collector within a process that is the destination of Spans when a
+ * trace is running. {@code SpanReceiver} implementations are expected to
+ * provide a constructor with the signature
+ *
+ *
+ * public SpanReceiverImpl(HTraceConfiguration)
+ *
+ */
+public abstract class SpanReceiver implements Closeable {
+ /**
+ * A {@link SpanReceiver} builder. It takes a {@link SpanReceiver} class name
+ * and constructs an instance of that class, with the provided configuration.
+ */
+ public static class Builder {
+
+ public Builder(HTraceConfiguration conf) {
+ }
+
+ /**
+ * Set this builder back to defaults.
+ *
+ * @return this instance.
+ */
+ public Builder reset() {
+ return this;
+ }
+
+ public Builder className(final String className) {
+ return this;
+ }
+
+ /**
+ * Configure whether we should log errors during build().
+ *
+ * @param logErrors Whether we should log errors during build().
+ * @return This instance
+ */
+ public Builder logErrors(boolean logErrors) {
+ return this;
+ }
+
+ public Builder classLoader(ClassLoader classLoader) {
+ return this;
+ }
+
+ public SpanReceiver build() {
+ return Holder.SINGLETON;
+ }
+ }
+
+ /**
+ * Get the ID for this SpanReceiver.
+ *
+ * @return The unique ID identifying this SpanReceiver.
+ */
+ public final long getId() {
+ return 0xdeadbeefL;
+ }
+
+ protected SpanReceiver() {
+ }
+
+ /**
+ * Called when a Span is stopped and can now be stored.
+ *
+ * @param span The span to store with this SpanReceiver.
+ */
+ public abstract void receiveSpan(Span span);
+
+ private static final class Holder {
+ static final SpanReceiver SINGLETON = new SpanReceiver() {
+ @Override
+ public void receiveSpan(Span span) {
+ }
+ @Override
+ public void close() {
+ }
+ };
+ }
+}
diff --git a/hbase-noop-htrace/src/main/java/org/apache/htrace/core/StandardOutSpanReceiver.java b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/StandardOutSpanReceiver.java
new file mode 100644
index 0000000..5ffb232
--- /dev/null
+++ b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/StandardOutSpanReceiver.java
@@ -0,0 +1,36 @@
+/*
+ * 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.htrace.core;
+
+import java.io.IOException;
+
+/**
+ * Used for testing. Simply prints to standard out any spans it receives.
+ */
+public class StandardOutSpanReceiver extends SpanReceiver {
+
+ public StandardOutSpanReceiver(HTraceConfiguration conf) {
+ }
+
+ @Override
+ public void receiveSpan(Span span) {
+ }
+
+ @Override
+ public void close() throws IOException {
+ }
+}
diff --git a/hbase-noop-htrace/src/main/java/org/apache/htrace/core/TimelineAnnotation.java b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/TimelineAnnotation.java
new file mode 100644
index 0000000..8825e01
--- /dev/null
+++ b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/TimelineAnnotation.java
@@ -0,0 +1,36 @@
+/*
+ * 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.htrace.core;
+
+public class TimelineAnnotation {
+
+ public TimelineAnnotation(long time, String msg) {
+ }
+
+ public long getTime() {
+ return 0;
+ }
+
+ public String getMessage() {
+ return "";
+ }
+
+ @Override
+ public String toString() {
+ return "";
+ }
+}
diff --git a/hbase-noop-htrace/src/main/java/org/apache/htrace/core/TraceCallable.java b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/TraceCallable.java
new file mode 100644
index 0000000..13393c3
--- /dev/null
+++ b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/TraceCallable.java
@@ -0,0 +1,40 @@
+/*
+ * 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.htrace.core;
+
+import java.util.concurrent.Callable;
+
+/**
+ * Wrap a Callable with a Span that survives a change in threads.
+ */
+public class TraceCallable implements Callable {
+ private final Callable impl;
+
+ public TraceCallable(Tracer tracer, SpanId parentId, Callable impl,
+ String description) {
+ this.impl = impl;
+ }
+
+ @Override
+ public V call() throws Exception {
+ return impl.call();
+ }
+
+ public Callable getImpl() {
+ return impl;
+ }
+}
diff --git a/hbase-noop-htrace/src/main/java/org/apache/htrace/core/TraceExecutorService.java b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/TraceExecutorService.java
new file mode 100644
index 0000000..6aabf66
--- /dev/null
+++ b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/TraceExecutorService.java
@@ -0,0 +1,111 @@
+/*
+ * 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.htrace.core;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+/**
+ * A convenience wrapper around an {@link ExecutorService} for automatically
+ * propagating trace scopes to executable tasks.
+ */
+public class TraceExecutorService implements ExecutorService {
+ private final ExecutorService impl;
+
+ TraceExecutorService(Tracer tracer, String scopeName,
+ ExecutorService impl) {
+ this.impl = impl;
+ }
+
+ @Override
+ public void execute(Runnable command) {
+ impl.execute(command);
+ }
+
+ @Override
+ public void shutdown() {
+ impl.shutdown();
+ }
+
+ @Override
+ public List shutdownNow() {
+ return impl.shutdownNow();
+ }
+
+ @Override
+ public boolean isShutdown() {
+ return impl.isShutdown();
+ }
+
+ @Override
+ public boolean isTerminated() {
+ return impl.isTerminated();
+ }
+
+ @Override
+ public boolean awaitTermination(long timeout, TimeUnit unit)
+ throws InterruptedException {
+ return impl.awaitTermination(timeout, unit);
+ }
+
+ @Override
+ public Future submit(Callable task) {
+ return impl.submit(task);
+ }
+
+ @Override
+ public Future submit(Runnable task, T result) {
+ return impl.submit(task, result);
+ }
+
+ @Override
+ public Future> submit(Runnable task) {
+ return impl.submit(task);
+ }
+
+ @Override
+ public List> invokeAll(Collection extends Callable> tasks)
+ throws InterruptedException {
+ return impl.invokeAll(tasks);
+ }
+
+ @Override
+ public List> invokeAll(Collection extends Callable> tasks,
+ long timeout, TimeUnit unit) throws InterruptedException {
+ return impl.invokeAll(tasks, timeout, unit);
+ }
+
+ @Override
+ public T invokeAny(Collection extends Callable> tasks)
+ throws InterruptedException, ExecutionException {
+ return impl.invokeAny(tasks);
+ }
+
+ @Override
+ public T invokeAny(Collection extends Callable> tasks, long timeout,
+ TimeUnit unit) throws InterruptedException, ExecutionException,
+ TimeoutException {
+ return impl.invokeAny(tasks, timeout, unit);
+ }
+
+}
diff --git a/hbase-noop-htrace/src/main/java/org/apache/htrace/core/TraceRunnable.java b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/TraceRunnable.java
new file mode 100644
index 0000000..738f7b1
--- /dev/null
+++ b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/TraceRunnable.java
@@ -0,0 +1,51 @@
+/*
+ * 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.htrace.core;
+
+/**
+ * Wrap a Runnable with a Span that survives a change in threads.
+ */
+public class TraceRunnable implements Runnable {
+ private final Runnable runnable;
+
+ /**
+ * @param tracer The Tracer to use for tracing.
+ * @param parent The TraceScope to read parent span ID from.
+ * @param runnable The Runnable that will be executed.
+ * @param description An optional description to set on the trace when executing.
+ * @deprecated Use {@link #TraceRunnable(Tracer, SpanId, Runnable, String)} instead.
+ */
+ @Deprecated
+ public TraceRunnable(Tracer tracer, TraceScope parent,
+ Runnable runnable, String description) {
+ this.runnable = runnable;
+ }
+
+ public TraceRunnable(Tracer tracer, SpanId parentId,
+ Runnable runnable, String description) {
+ this.runnable = runnable;
+ }
+
+ @Override
+ public void run() {
+ runnable.run();
+ }
+
+ public Runnable getRunnable() {
+ return runnable;
+ }
+}
diff --git a/hbase-noop-htrace/src/main/java/org/apache/htrace/core/TraceScope.java b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/TraceScope.java
new file mode 100644
index 0000000..b1bfaba
--- /dev/null
+++ b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/TraceScope.java
@@ -0,0 +1,82 @@
+/*
+ * 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.htrace.core;
+
+import java.io.Closeable;
+
+/**
+ * Create a new TraceScope at major transitions. Hosts current tracing context.
+ */
+@SuppressWarnings("FinalClass")
+public class TraceScope implements Closeable {
+
+ private TraceScope() {
+ }
+
+ /**
+ * Returns the span which this scope is managing.
+ *
+ * @return The span.
+ */
+ public Span getSpan() {
+ return null;
+ }
+
+ /**
+ * Returns the span ID which this scope is managing.
+ *
+ * @return The span ID.
+ */
+ public SpanId getSpanId() {
+ return SpanId.INVALID;
+ }
+
+ /**
+ * Detach this TraceScope from the current thread.
+ *
+ * It is OK to "leak" TraceScopes which have been detached. They will not
+ * consume any resources other than a small amount of memory until they are
+ * garbage collected. On the other hand, trace scopes which are still
+ * attached must never be leaked.
+ */
+ public void detach() {
+ }
+
+ /**
+ * Attach this TraceScope to the current thread.
+ */
+ public void reattach() {
+ }
+
+ /**
+ * Close this TraceScope, ending the trace span it is managing.
+ */
+ @Override
+ public void close() {
+ }
+
+ public void addKVAnnotation(String key, String value) {
+ }
+
+ public void addTimelineAnnotation(String msg) {
+ }
+
+ static final class Holder {
+ public static final TraceScope SINGLETON = new TraceScope();
+ }
+
+}
diff --git a/hbase-noop-htrace/src/main/java/org/apache/htrace/core/Tracer.java b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/Tracer.java
new file mode 100644
index 0000000..47ef23b
--- /dev/null
+++ b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/Tracer.java
@@ -0,0 +1,231 @@
+/*
+ * 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.htrace.core;
+
+import java.io.Closeable;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.ScheduledExecutorService;
+
+/**
+ * Use a Tracer instance inside a 'process' to collect and distribute its trace Spans.
+ * Example processes are an HDFS DataNode or an HBase RegionServer. A Tracer instance is your
+ * one-stop shop for all things tracing.
+ *
+ */
+@SuppressWarnings("FinalClass")
+public class Tracer implements Closeable {
+ public final static String SPAN_RECEIVER_CLASSES_KEY = "span.receiver.classes";
+ public final static String SAMPLER_CLASSES_KEY = "sampler.classes";
+
+ public static class Builder {
+ /**
+ * @deprecated Since 4.0.0. Use Constructor that takes a name argument instead
+ */
+ @Deprecated
+ public Builder() {
+ }
+
+ public Builder(final String name) {
+ }
+
+ /**
+ * @param name The name of the Tracer to create.
+ * @return this
+ * @deprecated Since 4.0.0. Use Constructor that takes a name argument instead.
+ */
+ @Deprecated
+ public Builder name(String name) {
+ return this;
+ }
+
+ /**
+ * @param conf The configuration to set.
+ * @return this
+ */
+ public Builder conf(HTraceConfiguration conf) {
+ return this;
+ }
+
+ /**
+ * @param tracerPool The pool to set.
+ * @return this
+ */
+ public Builder tracerPool(TracerPool tracerPool) {
+ return this;
+ }
+
+ /**
+ * @return The new Tracer object.
+ */
+ public Tracer build() {
+ return SINGLETON;
+ }
+ }
+
+ private final static Tracer SINGLETON = new Tracer();
+
+ /**
+ * @return If the current thread is tracing, this function returns the Tracer that is
+ * being used; otherwise, it returns null.
+ */
+ public static Tracer curThreadTracer() {
+ return SINGLETON;
+ }
+
+ private Tracer() {
+ }
+
+ public String getTracerId() {
+ return "";
+ }
+
+ /**
+ * Create a new trace scope.
+ *
+ * If there are no scopes above the current scope, we will apply our
+ * configured samplers. Otherwise, we will create a trace Span only if this thread
+ * is already tracing, or if the passed parentID was valid.
+ *
+ * @param description The description of the new span to create.
+ * @param parentId If this is a valid span ID, it will be added to
+ * the parents of the new span we create.
+ * @return The new trace scope.
+ */
+ public TraceScope newScope(String description, SpanId parentId) {
+ return TraceScope.Holder.SINGLETON;
+ }
+
+ /**
+ * Create a new trace scope.
+ *
+ * If there are no scopes above the current scope, we will apply our
+ * configured samplers. Otherwise, we will create a trace Span only if this thread
+ * is already tracing.
+ * @param description The description of the new span to create.
+ * @return The new trace scope.
+ */
+ public TraceScope newScope(String description) {
+ return TraceScope.Holder.SINGLETON;
+ }
+
+ /**
+ * Return a null trace scope.
+ *
+ * @return The null trace scope.
+ */
+ public TraceScope newNullScope() {
+ return TraceScope.Holder.SINGLETON;
+ }
+
+ /**
+ * Wrap the callable in a TraceCallable, if tracing.
+ *
+ * @param The subclass of callable.
+ * @param callable The callable to wrap.
+ * @param description A description of the callable, or null if there
+ * is no description.
+ * @return The callable provided, wrapped if tracing, 'callable' if not.
+ */
+ public Callable wrap(Callable callable, String description) {
+ return callable;
+ }
+
+ /**
+ * Wrap the runnable in a TraceRunnable, if tracing
+ *
+ * @param runnable The runnable to wrap.
+ * @param description A description of the runnable, or null if there is
+ * no description.
+ * @return The runnable provided, wrapped if tracing, 'runnable' if not.
+ */
+ public Runnable wrap(Runnable runnable, String description) {
+ return runnable;
+ }
+
+ public TraceExecutorService newTraceExecutorService(ExecutorService impl) {
+ return newTraceExecutorService(impl, null);
+ }
+
+ public TraceExecutorService newTraceExecutorService(ExecutorService impl,
+ String scopeName) {
+ return new TraceExecutorService(this, scopeName, impl);
+ }
+
+ public ScheduledTraceExecutorService newTraceExecutorService(
+ ScheduledExecutorService impl) {
+ return newTraceExecutorService(impl, null);
+ }
+
+ public ScheduledTraceExecutorService newTraceExecutorService(
+ ScheduledExecutorService impl, String scopeName) {
+ return new ScheduledTraceExecutorService(this, scopeName, impl);
+ }
+
+ public TracerPool getTracerPool() {
+ return TracerPool.getGlobalTracerPool();
+ }
+
+ /**
+ * Returns an array of all the current Samplers.
+ *
+ * Note that if the current Samplers change, those changes will not be
+ * reflected in this array. In other words, this array may be stale.
+ *
+ * @return The current samplers.
+ */
+ public Sampler[] getSamplers() {
+ return new Sampler[0];
+ }
+
+ /**
+ * Add a new Sampler.
+ *
+ * @param sampler The new sampler to add.
+ * You cannot add a particular Sampler object more
+ * than once. You may add multiple Sampler objects
+ * of the same type, although this is not recommended.
+ *
+ * @return True if the sampler was added; false if it already had
+ * been added earlier.
+ */
+ public synchronized boolean addSampler(Sampler sampler) {
+ return true;
+ }
+
+ /**
+ * Remove a Sampler.
+ *
+ * @param sampler The sampler to remove.
+ * @return True only if the sampler was removed.
+ */
+ public synchronized boolean removeSampler(Sampler sampler) {
+ return false;
+ }
+
+ public static Span getCurrentSpan() {
+ return null;
+ }
+
+ public static SpanId getCurrentSpanId() {
+ return SpanId.INVALID;
+ }
+
+ @Override
+ public synchronized void close() {
+ }
+}
diff --git a/hbase-noop-htrace/src/main/java/org/apache/htrace/core/TracerId.java b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/TracerId.java
new file mode 100644
index 0000000..abb2c96
--- /dev/null
+++ b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/TracerId.java
@@ -0,0 +1,55 @@
+/*
+ * 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.htrace.core;
+
+/**
+ * The HTrace tracer ID.
+ *
+ * HTrace tracer IDs are created from format strings.
+ * Format strings contain variables which the TracerId class will
+ * replace with the correct values at runtime.
+ *
+ *
+ * - %{tname}: the tracer name supplied when creating the Tracer.
+ * - %{pname}: the process name obtained from the JVM.
+ * - %{ip}: will be replaced with an ip address.
+ * - %{pid}: the numerical process ID from the operating system.
+ *
+ *
+ * For example, the string "%{pname}/%{ip}" will be replaced with something
+ * like: DataNode/192.168.0.1, assuming that the process' name is DataNode
+ * and its IP address is 192.168.0.1.
+ *
+ * ID strings can contain backslashes as escapes.
+ * For example, "\a" will map to "a". "\%{ip}" will map to the literal
+ * string "%{ip}", not the IP address. A backslash itself can be escaped by a
+ * preceding backslash.
+ */
+public final class TracerId {
+
+ /**
+ * The configuration key to use for process id
+ */
+ public static final String TRACER_ID_KEY = "tracer.id";
+
+ public TracerId(HTraceConfiguration conf, String tracerName) {
+ }
+
+ public String get() {
+ return TRACER_ID_KEY;
+ }
+}
diff --git a/hbase-noop-htrace/src/main/java/org/apache/htrace/core/TracerPool.java b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/TracerPool.java
new file mode 100644
index 0000000..22c83bd
--- /dev/null
+++ b/hbase-noop-htrace/src/main/java/org/apache/htrace/core/TracerPool.java
@@ -0,0 +1,155 @@
+/*
+ * 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.htrace.core;
+
+/**
+ * A pool of Tracer objects.
+ *
+ * There may be more than one {@link Tracer} running inside a single 'process'; for example,
+ * unit tests may spin up a DataNode, a NameNode, and HDFS clients all running in a single JVM
+ * instance, each with its own Tracer. TracerPool is where all Tracer instances register
+ * on creation so Tracers can coordinate around shared resources such as {@link SpanReceiver}
+ * instances. TracerPool takes care of properly cleaning up registered Tracer instances on shutdown.
+ */
+public class TracerPool {
+
+ /**
+ * The global pool of tracer objects.
+ *
+ * This is the pool that new tracers get put into by default.
+ */
+ static final TracerPool GLOBAL = new TracerPool("Global");
+
+ /**
+ * Get the global tracer pool.
+ *
+ * @return The tracer pool.
+ */
+ public static TracerPool getGlobalTracerPool() {
+ return GLOBAL;
+ }
+
+ public TracerPool(String name) {
+ }
+
+ /**
+ * Return the name of this TracerPool.
+ *
+ * @return The name.
+ */
+ public String getName() {
+ return "";
+ }
+
+ /**
+ * Returns an array of all the current span receivers.
+ *
+ * Note that if the current span receivers change, those changes will not be
+ * reflected in this array. In other words, this array may be stale.
+ *
+ * @return An array of the current span receivers.
+ */
+ public SpanReceiver[] getReceivers() {
+ return new SpanReceiver[0];
+ }
+
+ /**
+ * Add a new span receiver.
+ *
+ * @param receiver The new receiver to add.
+ *
+ * @return True if the new receiver was added; false if it
+ * already was there.
+ */
+ public synchronized boolean addReceiver(SpanReceiver receiver) {
+ // since we are not tracking these, maybe we should close them immediately?
+ // for now do nothing, since we should just be getting empty receivers that do not do anything.
+ return true;
+ }
+
+ /**
+ * Remove a span receiver.
+ *
+ * @param receiver The receiver to remove.
+ *
+ * @return True if the receiver was removed; false if it
+ * did not exist in this pool.
+ */
+ public synchronized boolean removeReceiver(SpanReceiver receiver) {
+ return false;
+ }
+
+ /**
+ * Remove and close a span receiver.
+ *
+ * @param receiver The receiver to remove.
+ *
+ * @return True if the receiver was removed; false if it
+ * did not exist in this pool.
+ */
+ public boolean removeAndCloseReceiver(SpanReceiver receiver) {
+ return false;
+ }
+
+ /**
+ * Given a SpanReceiver class name, return the existing instance of that span
+ * receiver, if possible; otherwise, invoke the callable to create a new
+ * instance.
+ *
+ * @param className The span receiver class name.
+ * @param conf The HTrace configuration.
+ * @param classLoader The class loader to use.
+ *
+ * @return The SpanReceiver.
+ */
+ public synchronized SpanReceiver loadReceiverType(String className,
+ HTraceConfiguration conf, ClassLoader classLoader) {
+ SpanReceiver receiver = new SpanReceiver.Builder(conf).
+ className(className).
+ classLoader(classLoader).
+ build();
+ return receiver;
+ }
+
+ /**
+ * Returns an array of all the current Tracers.
+ *
+ * Note that if the current Tracers change, those changes will not be
+ * reflected in this array. In other words, this array may be stale.
+ *
+ * @return The current array of tracers.
+ */
+ public synchronized Tracer[] getTracers() {
+ return new Tracer[0];
+ }
+
+ /**
+ * Add a new Tracer.
+ */
+ synchronized void addTracer(Tracer tracer) {
+ }
+
+ /**
+ * Remove a Tracer.
+ *
+ * If the Tracer removed was the last one, we will close all the SpanReceiver
+ * objects that we're managing.
+ */
+ synchronized void removeTracer(Tracer tracer) {
+ }
+
+}
diff --git a/hbase-noop-htrace/src/test/java/org/apache/hbase/htrace_noop/TestHBaseTestingUtilityWithHTraceNoop.java b/hbase-noop-htrace/src/test/java/org/apache/hbase/htrace_noop/TestHBaseTestingUtilityWithHTraceNoop.java
new file mode 100644
index 0000000..507e72a
--- /dev/null
+++ b/hbase-noop-htrace/src/test/java/org/apache/hbase/htrace_noop/TestHBaseTestingUtilityWithHTraceNoop.java
@@ -0,0 +1,62 @@
+/**
+ *
+ * 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.hbase.htrace_noop;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class TestHBaseTestingUtilityWithHTraceNoop {
+ private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ TEST_UTIL.startMiniCluster();
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ TEST_UTIL.shutdownMiniCluster();
+ }
+
+ @Test
+ public void testPutThenCountWithNewTable() throws Exception {
+ TableName tableName = TableName.valueOf("test");
+
+ Table table = TEST_UTIL.createTable(tableName, "cf");
+
+ Put put1 = new Put(Bytes.toBytes("r1"));
+ put1.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("c"), Bytes.toBytes(1));
+ table.put(put1);
+
+ Put put2 = new Put(Bytes.toBytes("r2"));
+ put2.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("c"), Bytes.toBytes(2));
+ table.put(put2);
+
+ int rows = TEST_UTIL.countRows(tableName);
+ assertEquals(2, rows);
+ }
+}
diff --git a/pom.xml b/pom.xml
index 6e3a136..ef5af83 100644
--- a/pom.xml
+++ b/pom.xml
@@ -59,6 +59,7 @@
hbase-shaded-miscellaneous
hbase-shaded-jetty
hbase-shaded-jersey
+ hbase-noop-htrace
scm:git:git://git.apache.org/hbase-thirdparty.git