You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by bi...@apache.org on 2014/11/08 00:05:24 UTC
[06/15] accumulo git commit: ACCUMULO-898 refactoring and deprecation
of old tracing
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/trace/pom.xml
----------------------------------------------------------------------
diff --git a/trace/pom.xml b/trace/pom.xml
index d64e3cc..b4e4b7e 100644
--- a/trace/pom.xml
+++ b/trace/pom.xml
@@ -27,72 +27,12 @@
<description>A distributed tracing library for Apache Accumulo.</description>
<dependencies>
<dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.thrift</groupId>
- <artifactId>libthrift</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
+ <groupId>org.apache.accumulo</groupId>
+ <artifactId>accumulo-core</artifactId>
</dependency>
<dependency>
<groupId>org.htrace</groupId>
<artifactId>htrace-core</artifactId>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <configuration>
- <excludeFilterFile>src/main/findbugs/exclude-filter.xml</excludeFilterFile>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
- <profiles>
- <profile>
- <id>thrift</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-thrift</id>
- <goals>
- <goal>exec</goal>
- </goals>
- <phase>generate-sources</phase>
- <configuration>
- <executable>${basedir}/src/main/scripts/generate-thrift.sh</executable>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
</project>
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/trace/src/main/findbugs/exclude-filter.xml
----------------------------------------------------------------------
diff --git a/trace/src/main/findbugs/exclude-filter.xml b/trace/src/main/findbugs/exclude-filter.xml
deleted file mode 100644
index 408a32c..0000000
--- a/trace/src/main/findbugs/exclude-filter.xml
+++ /dev/null
@@ -1,21 +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.
--->
-<FindBugsFilter>
- <Match>
- <Class name="~org\.apache\.accumulo\.trace\.thrift\..*" />
- </Match>
-</FindBugsFilter>
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/trace/src/main/java/org/apache/accumulo/trace/instrument/CloudtraceSpan.java
----------------------------------------------------------------------
diff --git a/trace/src/main/java/org/apache/accumulo/trace/instrument/CloudtraceSpan.java b/trace/src/main/java/org/apache/accumulo/trace/instrument/CloudtraceSpan.java
index fb9744e..3d75917 100644
--- a/trace/src/main/java/org/apache/accumulo/trace/instrument/CloudtraceSpan.java
+++ b/trace/src/main/java/org/apache/accumulo/trace/instrument/CloudtraceSpan.java
@@ -19,8 +19,9 @@ package org.apache.accumulo.trace.instrument;
import java.util.Map;
/**
- * Base interface for gathering and reporting statistics about a block of execution.
+ * @deprecated only used for ensuring backwards compatibility
*/
+@Deprecated
public interface CloudtraceSpan {
static final long ROOT_SPAN_ID = 0;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/trace/src/main/java/org/apache/accumulo/trace/instrument/CountSampler.java
----------------------------------------------------------------------
diff --git a/trace/src/main/java/org/apache/accumulo/trace/instrument/CountSampler.java b/trace/src/main/java/org/apache/accumulo/trace/instrument/CountSampler.java
index b291ee9..56a3989 100644
--- a/trace/src/main/java/org/apache/accumulo/trace/instrument/CountSampler.java
+++ b/trace/src/main/java/org/apache/accumulo/trace/instrument/CountSampler.java
@@ -17,8 +17,9 @@
package org.apache.accumulo.trace.instrument;
/**
- * use org.htrace.impl.CountSampler instead
+ * @deprecated since 1.7, use org.htrace.impl.CountSampler instead
*/
+@Deprecated
public class CountSampler extends org.htrace.impl.CountSampler implements Sampler {
public CountSampler(long frequency) {
super(frequency);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/trace/src/main/java/org/apache/accumulo/trace/instrument/Sampler.java
----------------------------------------------------------------------
diff --git a/trace/src/main/java/org/apache/accumulo/trace/instrument/Sampler.java b/trace/src/main/java/org/apache/accumulo/trace/instrument/Sampler.java
index 3813530..94e5e67 100644
--- a/trace/src/main/java/org/apache/accumulo/trace/instrument/Sampler.java
+++ b/trace/src/main/java/org/apache/accumulo/trace/instrument/Sampler.java
@@ -17,8 +17,9 @@
package org.apache.accumulo.trace.instrument;
/**
- * use org.htrace.Sampler instead
+ * @deprecated since 1.7, use org.htrace.Sampler instead
*/
+@Deprecated
public interface Sampler extends org.htrace.Sampler<Object> {
boolean next();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/trace/src/main/java/org/apache/accumulo/trace/instrument/Span.java
----------------------------------------------------------------------
diff --git a/trace/src/main/java/org/apache/accumulo/trace/instrument/Span.java b/trace/src/main/java/org/apache/accumulo/trace/instrument/Span.java
index 84275ce..7c0e8bc 100644
--- a/trace/src/main/java/org/apache/accumulo/trace/instrument/Span.java
+++ b/trace/src/main/java/org/apache/accumulo/trace/instrument/Span.java
@@ -18,94 +18,27 @@ package org.apache.accumulo.trace.instrument;
import static java.nio.charset.StandardCharsets.UTF_8;
-import org.htrace.NullScope;
-import org.htrace.TimelineAnnotation;
-import org.htrace.TraceScope;
-
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
/**
- * This is a wrapper for a TraceScope object, which is a wrapper for a Span and its parent.
+ * @deprecated since 1.7, use {@link org.apache.accumulo.core.trace.Span} instead
*/
-public class Span implements org.htrace.Span, CloudtraceSpan {
+@Deprecated
+public class Span extends org.apache.accumulo.core.trace.Span implements CloudtraceSpan {
public static final long ROOT_SPAN_ID = org.htrace.Span.ROOT_SPAN_ID;
- public static final Span NULL_SPAN = new Span(NullScope.INSTANCE);
- private TraceScope scope = null;
- protected org.htrace.Span span = null;
-
- public Span(TraceScope scope) {
- this.scope = scope;
- this.span = scope.getSpan();
- }
-
- public Span(org.htrace.Span span) {
- this.span = span;
- }
-
- public TraceScope getScope() {
- return scope;
- }
-
- public org.htrace.Span getSpan() {
- return span;
- }
-
- public long traceId() {
- return span.getTraceId();
- }
-
- public void data(String k, String v) {
- if (span != null)
- span.addKVAnnotation(k.getBytes(UTF_8), v.getBytes(UTF_8));
- }
- @Override
- public void stop() {
- if (scope == null) {
- if (span != null) {
- span.stop();
- }
- } else {
- scope.close();
- }
- }
-
- @Override
- public long getStartTimeMillis() {
- return span.getStartTimeMillis();
- }
-
- @Override
- public long getStopTimeMillis() {
- return span.getStopTimeMillis();
+ public Span(org.apache.accumulo.core.trace.Span span) {
+ super(span.getScope());
}
- @Override
- public long getAccumulatedMillis() {
- return span.getAccumulatedMillis();
+ public Span(org.htrace.TraceScope scope) {
+ super(scope);
}
- @Override
- public boolean isRunning() {
- return span.isRunning();
- }
-
- @Override
- public String getDescription() {
- return span.getDescription();
- }
-
- @Override
- public long getSpanId() {
- return span.getSpanId();
- }
-
- @Override
- public long getTraceId() {
- return span.getTraceId();
+ public Span(org.htrace.Span span) {
+ super(span);
}
@Override
@@ -113,41 +46,6 @@ public class Span implements org.htrace.Span, CloudtraceSpan {
return new Span(span.child(s));
}
- @Override
- public long getParentId() {
- return span.getParentId();
- }
-
- @Override
- public void addKVAnnotation(byte[] k, byte[] v) {
- span.addKVAnnotation(k, v);
- }
-
- @Override
- public void addTimelineAnnotation(String s) {
- span.addTimelineAnnotation(s);
- }
-
- @Override
- public Map<byte[], byte[]> getKVAnnotations() {
- return span.getKVAnnotations();
- }
-
- @Override
- public List<TimelineAnnotation> getTimelineAnnotations() {
- return span.getTimelineAnnotations();
- }
-
- @Override
- public String getProcessId() {
- return span.getProcessId();
- }
-
- @Override
- public String toString() {
- return span.toString();
- }
-
public void start() {
throw new UnsupportedOperationException("can't start span");
}
@@ -177,7 +75,7 @@ public class Span implements org.htrace.Span, CloudtraceSpan {
}
@Override
- public Map<String,String> getData() {
+ public Map<String, String> getData() {
Map<byte[],byte[]> data = span.getKVAnnotations();
HashMap<String,String> stringData = new HashMap<>();
for (Entry<byte[],byte[]> d : data.entrySet()) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/trace/src/main/java/org/apache/accumulo/trace/instrument/Trace.java
----------------------------------------------------------------------
diff --git a/trace/src/main/java/org/apache/accumulo/trace/instrument/Trace.java b/trace/src/main/java/org/apache/accumulo/trace/instrument/Trace.java
index 5ad52fb..ddf3d69 100644
--- a/trace/src/main/java/org/apache/accumulo/trace/instrument/Trace.java
+++ b/trace/src/main/java/org/apache/accumulo/trace/instrument/Trace.java
@@ -16,127 +16,70 @@
*/
package org.apache.accumulo.trace.instrument;
+import org.apache.accumulo.core.trace.wrappers.TraceExecutorService;
import org.apache.accumulo.trace.thrift.TInfo;
-import org.htrace.TraceInfo;
-import org.htrace.wrappers.TraceProxy;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
/**
- * Utility class for tracing within Accumulo. Not intended for client use!
- *
+ * @deprecated since 1.7, use {@link org.apache.accumulo.core.trace.Trace} instead
*/
-public class Trace {
- /**
- * Start a trace span with a given description.
- */
+@Deprecated
+public class Trace extends org.apache.accumulo.core.trace.Trace {
+ // Initiate tracing if it isn't already started
public static Span on(String description) {
- return on(description, Sampler.ALWAYS);
- }
-
- /**
- * Start a trace span with a given description with the given sampler.
- */
- public static <T> Span on(String description, org.htrace.Sampler<T> sampler) {
- return new Span(org.htrace.Trace.startSpan(description, sampler));
+ return new Span(org.apache.accumulo.core.trace.Trace.on(description));
}
- /**
- * Finish the current trace.
- */
+ // Turn tracing off:
public static void off() {
- org.htrace.Span span = org.htrace.Trace.currentSpan();
- if (span != null) {
- span.stop();
- org.htrace.Tracer.getInstance().continueSpan(null);
- }
+ org.apache.accumulo.core.trace.Trace.off();
}
- /**
- * @deprecated since 1.7, use {@link #off()} instead
- */
- @Deprecated
public static void offNoFlush() {
- off();
+ org.apache.accumulo.core.trace.Trace.offNoFlush();
}
- /**
- * Returns whether tracing is currently on.
- */
+ // Are we presently tracing?
public static boolean isTracing() {
- return org.htrace.Trace.isTracing();
+ return org.apache.accumulo.core.trace.Trace.isTracing();
}
- /**
- * Return the current span.
- * @deprecated since 1.7 -- it is better to save the span you create in a local variable and call its methods, rather than retrieving the current span
- */
- @Deprecated
+ // If we are tracing, return the current span, else null
public static Span currentTrace() {
return new Span(org.htrace.Trace.currentSpan());
}
- /**
- * Get the trace id of the current span.
- */
- public static long currentTraceId() {
- return org.htrace.Trace.currentSpan().getTraceId();
- }
-
- /**
- * Start a new span with a given description, if already tracing.
- */
+ // Create a new time span, if tracing is on
public static Span start(String description) {
- return new Span(org.htrace.Trace.startSpan(description));
+ return new Span(org.apache.accumulo.core.trace.Trace.start(description));
}
- /**
- * Continue a trace by starting a new span with a given parent and description.
- */
+ // Start a trace in the current thread from information passed via RPC
public static Span trace(TInfo info, String description) {
- if (info.traceId == 0) {
- return Span.NULL_SPAN;
- }
- TraceInfo ti = new TraceInfo(info.traceId, info.parentId);
- return new Span(org.htrace.Trace.startSpan(description, ti));
+ return new Span(org.apache.accumulo.core.trace.Trace.trace(info, description));
}
- /**
- * Start a new span with a given description and parent.
- * @deprecated since 1.7 -- use htrace API
- */
- @Deprecated
+ // Initiate a trace in this thread, starting now
public static Span startThread(Span parent, String description) {
return new Span(org.htrace.Trace.startSpan(description, parent.getSpan()));
}
- /**
- * Add data to the current span.
- */
- public static void data(String k, String v) {
- org.htrace.Span span = org.htrace.Trace.currentSpan();
- if (span != null)
- span.addKVAnnotation(k.getBytes(UTF_8), v.getBytes(UTF_8));
+ // Stop a trace in this thread, starting now
+ public static void endThread(Span span) {
+ TraceExecutorService.endThread(span.getSpan());
}
- /**
- * Wrap a runnable in a TraceRunnable, if tracing.
- */
+ // Wrap the runnable in a new span, if tracing
public static Runnable wrap(Runnable runnable) {
- if (isTracing()) {
- return new TraceRunnable(org.htrace.Trace.currentSpan(), runnable);
- } else {
- return runnable;
- }
+ return org.apache.accumulo.core.trace.Trace.wrap(runnable);
}
// Wrap all calls to the given object with spans
public static <T> T wrapAll(T instance) {
- return TraceProxy.trace(instance);
+ return org.apache.accumulo.core.trace.Trace.wrapAll(instance);
}
// Sample trace all calls to the given object
public static <T> T wrapAll(T instance, Sampler dist) {
- return TraceProxy.trace(instance, dist);
+ return org.apache.accumulo.core.trace.Trace.wrapAll(instance, dist);
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/trace/src/main/java/org/apache/accumulo/trace/instrument/TraceCallable.java
----------------------------------------------------------------------
diff --git a/trace/src/main/java/org/apache/accumulo/trace/instrument/TraceCallable.java b/trace/src/main/java/org/apache/accumulo/trace/instrument/TraceCallable.java
deleted file mode 100644
index f682d61..0000000
--- a/trace/src/main/java/org/apache/accumulo/trace/instrument/TraceCallable.java
+++ /dev/null
@@ -1,69 +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.accumulo.trace.instrument;
-
-import org.htrace.Span;
-import org.htrace.Trace;
-import org.htrace.TraceScope;
-
-import java.util.concurrent.Callable;
-
-/**
- * Wrap a Callable with a Span that survives a change in threads.
- *
- */
-public class TraceCallable<V> implements Callable<V> {
- private final Callable<V> impl;
- private final Span parent;
- private final String description;
-
- TraceCallable(Callable<V> impl) {
- this(Trace.currentSpan(), impl);
- }
-
- TraceCallable(Span parent, Callable<V> impl) {
- this(parent, impl, null);
- }
-
- TraceCallable(Span parent, Callable<V> impl, String description) {
- this.impl = impl;
- this.parent = parent;
- this.description = description;
- }
-
- @Override
- public V call() throws Exception {
- if (parent != null) {
- TraceScope chunk = Trace.startSpan(getDescription(), parent);
- try {
- return impl.call();
- } finally {
- TraceExecutorService.endThread(chunk.getSpan());
- }
- } else {
- return impl.call();
- }
- }
-
- public Callable<V> getImpl() {
- return impl;
- }
-
- private String getDescription() {
- return this.description == null ? Thread.currentThread().getName() : description;
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/trace/src/main/java/org/apache/accumulo/trace/instrument/TraceExecutorService.java
----------------------------------------------------------------------
diff --git a/trace/src/main/java/org/apache/accumulo/trace/instrument/TraceExecutorService.java b/trace/src/main/java/org/apache/accumulo/trace/instrument/TraceExecutorService.java
deleted file mode 100644
index 36563d7..0000000
--- a/trace/src/main/java/org/apache/accumulo/trace/instrument/TraceExecutorService.java
+++ /dev/null
@@ -1,123 +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.accumulo.trace.instrument;
-
-import org.htrace.Span;
-import org.htrace.Tracer;
-
-import java.util.ArrayList;
-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;
-
-public class TraceExecutorService implements ExecutorService {
-
- private final ExecutorService impl;
-
- public TraceExecutorService(ExecutorService impl) {
- this.impl = impl;
- }
-
- @Override
- public void execute(Runnable command) {
- impl.execute(new TraceRunnable(command));
- }
-
- @Override
- public void shutdown() {
- impl.shutdown();
- }
-
- @Override
- public List<Runnable> 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 <T> Future<T> submit(Callable<T> task) {
- return impl.submit(new TraceCallable<T>(task));
- }
-
- @Override
- public <T> Future<T> submit(Runnable task, T result) {
- return impl.submit(new TraceRunnable(task), result);
- }
-
- @Override
- public Future<?> submit(Runnable task) {
- return impl.submit(new TraceRunnable(task));
- }
-
- private <T> Collection<? extends Callable<T>> wrapCollection(Collection<? extends Callable<T>> tasks) {
- List<Callable<T>> result = new ArrayList<Callable<T>>();
- for (Callable<T> task : tasks) {
- result.add(new TraceCallable<T>(task));
- }
- return result;
- }
-
- @Override
- public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException {
- return impl.invokeAll(wrapCollection(tasks));
- }
-
- @Override
- public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException {
- return impl.invokeAll(wrapCollection(tasks), timeout, unit);
- }
-
- @Override
- public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
- return impl.invokeAny(wrapCollection(tasks));
- }
-
- @Override
- public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException,
- TimeoutException {
- return impl.invokeAny(wrapCollection(tasks), timeout, unit);
- }
-
- /**
- * Finish a given trace and set the span for the current thread to null.
- */
- public static void endThread(Span span) {
- if (span != null) {
- span.stop();
- Tracer.getInstance().continueSpan(null);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/trace/src/main/java/org/apache/accumulo/trace/instrument/TraceRunnable.java
----------------------------------------------------------------------
diff --git a/trace/src/main/java/org/apache/accumulo/trace/instrument/TraceRunnable.java b/trace/src/main/java/org/apache/accumulo/trace/instrument/TraceRunnable.java
deleted file mode 100644
index 0ddeb9e..0000000
--- a/trace/src/main/java/org/apache/accumulo/trace/instrument/TraceRunnable.java
+++ /dev/null
@@ -1,79 +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.accumulo.trace.instrument;
-
-import org.htrace.Span;
-import org.htrace.Trace;
-import org.htrace.TraceScope;
-
-/**
- * Wrap a Runnable with a Span that survives a change in threads.
- *
- */
-public class TraceRunnable implements Runnable, Comparable<TraceRunnable> {
-
- private final Span parent;
- private final Runnable runnable;
- private final String description;
-
- public TraceRunnable(Runnable runnable) {
- this(Trace.currentSpan(), runnable);
- }
-
- public TraceRunnable(Span parent, Runnable runnable) {
- this(parent, runnable, null);
- }
-
- public TraceRunnable(Span parent, Runnable runnable, String description) {
- this.parent = parent;
- this.runnable = runnable;
- this.description = description;
- }
-
- @Override
- public void run() {
- if (parent != null) {
- TraceScope chunk = Trace.startSpan(getDescription(), parent);
- try {
- runnable.run();
- } finally {
- TraceExecutorService.endThread(chunk.getSpan());
- }
- } else {
- runnable.run();
- }
- }
-
- private String getDescription() {
- return this.description == null ? Thread.currentThread().getName() : description;
- }
-
- @Override
- public boolean equals(Object o) {
- if (o instanceof TraceRunnable) {
- return 0 == this.compareTo((TraceRunnable) o);
- }
-
- return false;
- }
-
- @SuppressWarnings({"rawtypes", "unchecked"})
- @Override
- public int compareTo(TraceRunnable o) {
- return ((Comparable) this.runnable).compareTo(o.runnable);
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/trace/src/main/java/org/apache/accumulo/trace/instrument/Tracer.java
----------------------------------------------------------------------
diff --git a/trace/src/main/java/org/apache/accumulo/trace/instrument/Tracer.java b/trace/src/main/java/org/apache/accumulo/trace/instrument/Tracer.java
deleted file mode 100644
index 246d1eb..0000000
--- a/trace/src/main/java/org/apache/accumulo/trace/instrument/Tracer.java
+++ /dev/null
@@ -1,35 +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.accumulo.trace.instrument;
-
-import org.apache.accumulo.trace.thrift.TInfo;
-import org.htrace.Span;
-
-public class Tracer {
- private static final TInfo DONT_TRACE = new TInfo(0, 0);
-
- /**
- * Obtain {@link org.apache.accumulo.trace.thrift.TInfo} for the current span.
- */
- public static TInfo traceInfo() {
- Span span = org.htrace.Trace.currentSpan();
- if (span != null) {
- return new TInfo(span.getTraceId(), span.getSpanId());
- }
- return DONT_TRACE;
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/trace/src/main/java/org/apache/accumulo/trace/instrument/thrift/RpcClientInvocationHandler.java
----------------------------------------------------------------------
diff --git a/trace/src/main/java/org/apache/accumulo/trace/instrument/thrift/RpcClientInvocationHandler.java b/trace/src/main/java/org/apache/accumulo/trace/instrument/thrift/RpcClientInvocationHandler.java
deleted file mode 100644
index ea57fe7..0000000
--- a/trace/src/main/java/org/apache/accumulo/trace/instrument/thrift/RpcClientInvocationHandler.java
+++ /dev/null
@@ -1,54 +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.accumulo.trace.instrument.thrift;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.apache.accumulo.trace.instrument.Span;
-import org.apache.accumulo.trace.instrument.Trace;
-import org.apache.accumulo.trace.instrument.Tracer;
-import org.apache.accumulo.trace.thrift.TInfo;
-
-public class RpcClientInvocationHandler<I> implements InvocationHandler {
-
- private final I instance;
-
- protected RpcClientInvocationHandler(final I clientInstance) {
- instance = clientInstance;
- }
-
- @Override
- public Object invoke(Object obj, Method method, Object[] args) throws Throwable {
- if (args == null || args.length < 1 || args[0] != null) {
- return method.invoke(instance, args);
- }
- Class<?> klass = method.getParameterTypes()[0];
- if (TInfo.class.isAssignableFrom(klass)) {
- args[0] = Tracer.traceInfo();
- }
- Span span = Trace.start("client:" + method.getName());
- try {
- return method.invoke(instance, args);
- } catch (InvocationTargetException ex) {
- throw ex.getCause();
- } finally {
- span.stop();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/trace/src/main/java/org/apache/accumulo/trace/instrument/thrift/RpcServerInvocationHandler.java
----------------------------------------------------------------------
diff --git a/trace/src/main/java/org/apache/accumulo/trace/instrument/thrift/RpcServerInvocationHandler.java b/trace/src/main/java/org/apache/accumulo/trace/instrument/thrift/RpcServerInvocationHandler.java
deleted file mode 100644
index 4188bf4..0000000
--- a/trace/src/main/java/org/apache/accumulo/trace/instrument/thrift/RpcServerInvocationHandler.java
+++ /dev/null
@@ -1,53 +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.accumulo.trace.instrument.thrift;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.apache.accumulo.trace.instrument.Span;
-import org.apache.accumulo.trace.instrument.Trace;
-import org.apache.accumulo.trace.thrift.TInfo;
-
-public class RpcServerInvocationHandler<I> implements InvocationHandler {
-
- private final I instance;
-
- protected RpcServerInvocationHandler(final I serverInstance) {
- instance = serverInstance;
- }
-
- @Override
- public Object invoke(Object obj, Method method, Object[] args) throws Throwable {
- if (args == null || args.length < 1 || args[0] == null || !(args[0] instanceof TInfo)) {
- try {
- return method.invoke(instance, args);
- } catch (InvocationTargetException ex) {
- throw ex.getCause();
- }
- }
- Span span = Trace.trace((TInfo) args[0], method.getName());
- try {
- return method.invoke(instance, args);
- } catch (InvocationTargetException ex) {
- throw ex.getCause();
- } finally {
- span.stop();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/trace/src/main/java/org/apache/accumulo/trace/instrument/thrift/TraceWrap.java
----------------------------------------------------------------------
diff --git a/trace/src/main/java/org/apache/accumulo/trace/instrument/thrift/TraceWrap.java b/trace/src/main/java/org/apache/accumulo/trace/instrument/thrift/TraceWrap.java
deleted file mode 100644
index ed91042..0000000
--- a/trace/src/main/java/org/apache/accumulo/trace/instrument/thrift/TraceWrap.java
+++ /dev/null
@@ -1,57 +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.accumulo.trace.instrument.thrift;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-
-/**
- * To move trace data from client to server, the RPC call must be annotated to take a TInfo object as its first argument. The user can simply pass null, so long
- * as they wrap their Client and Service objects with these functions.
- *
- * <pre>
- * Trace.on("remoteMethod");
- * Iface c = new Client();
- * c = TraceWrap.client(c);
- * c.remoteMethod(null, arg2, arg3);
- * Trace.off();
- * </pre>
- *
- * The wrapper will see the annotated method and send or re-establish the trace information.
- *
- * Note that the result of these calls is a Proxy object that conforms to the basic interfaces, but is not your concrete instance.
- *
- */
-public class TraceWrap {
-
- public static <T> T service(final T instance) {
- InvocationHandler handler = new RpcServerInvocationHandler<T>(instance);
- return wrappedInstance(handler, instance);
- }
-
- public static <T> T client(final T instance) {
- InvocationHandler handler = new RpcClientInvocationHandler<T>(instance);
- return wrappedInstance(handler, instance);
- }
-
- private static <T> T wrappedInstance(final InvocationHandler handler, final T instance) {
- @SuppressWarnings("unchecked")
- T proxiedInstance = (T) Proxy.newProxyInstance(instance.getClass().getClassLoader(), instance.getClass().getInterfaces(), handler);
- return proxiedInstance;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/trace/src/main/java/org/apache/accumulo/trace/thrift/Annotation.java
----------------------------------------------------------------------
diff --git a/trace/src/main/java/org/apache/accumulo/trace/thrift/Annotation.java b/trace/src/main/java/org/apache/accumulo/trace/thrift/Annotation.java
deleted file mode 100644
index c00744e..0000000
--- a/trace/src/main/java/org/apache/accumulo/trace/thrift/Annotation.java
+++ /dev/null
@@ -1,502 +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.
- */
-/**
- * Autogenerated by Thrift Compiler (0.9.1)
- *
- * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
- * @generated
- */
-package org.apache.accumulo.trace.thrift;
-
-import org.apache.thrift.scheme.IScheme;
-import org.apache.thrift.scheme.SchemeFactory;
-import org.apache.thrift.scheme.StandardScheme;
-
-import org.apache.thrift.scheme.TupleScheme;
-import org.apache.thrift.protocol.TTupleProtocol;
-import org.apache.thrift.protocol.TProtocolException;
-import org.apache.thrift.EncodingUtils;
-import org.apache.thrift.TException;
-import org.apache.thrift.async.AsyncMethodCallback;
-import org.apache.thrift.server.AbstractNonblockingServer.*;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.EnumMap;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.EnumSet;
-import java.util.Collections;
-import java.util.BitSet;
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@SuppressWarnings("all") public class Annotation implements org.apache.thrift.TBase<Annotation, Annotation._Fields>, java.io.Serializable, Cloneable, Comparable<Annotation> {
- private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Annotation");
-
- private static final org.apache.thrift.protocol.TField TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("time", org.apache.thrift.protocol.TType.I64, (short)1);
- private static final org.apache.thrift.protocol.TField MSG_FIELD_DESC = new org.apache.thrift.protocol.TField("msg", org.apache.thrift.protocol.TType.STRING, (short)2);
-
- private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
- static {
- schemes.put(StandardScheme.class, new AnnotationStandardSchemeFactory());
- schemes.put(TupleScheme.class, new AnnotationTupleSchemeFactory());
- }
-
- public long time; // required
- public String msg; // required
-
- /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
- @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
- TIME((short)1, "time"),
- MSG((short)2, "msg");
-
- private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
-
- static {
- for (_Fields field : EnumSet.allOf(_Fields.class)) {
- byName.put(field.getFieldName(), field);
- }
- }
-
- /**
- * Find the _Fields constant that matches fieldId, or null if its not found.
- */
- public static _Fields findByThriftId(int fieldId) {
- switch(fieldId) {
- case 1: // TIME
- return TIME;
- case 2: // MSG
- return MSG;
- default:
- return null;
- }
- }
-
- /**
- * Find the _Fields constant that matches fieldId, throwing an exception
- * if it is not found.
- */
- public static _Fields findByThriftIdOrThrow(int fieldId) {
- _Fields fields = findByThriftId(fieldId);
- if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
- return fields;
- }
-
- /**
- * Find the _Fields constant that matches name, or null if its not found.
- */
- public static _Fields findByName(String name) {
- return byName.get(name);
- }
-
- private final short _thriftId;
- private final String _fieldName;
-
- _Fields(short thriftId, String fieldName) {
- _thriftId = thriftId;
- _fieldName = fieldName;
- }
-
- public short getThriftFieldId() {
- return _thriftId;
- }
-
- public String getFieldName() {
- return _fieldName;
- }
- }
-
- // isset id assignments
- private static final int __TIME_ISSET_ID = 0;
- private byte __isset_bitfield = 0;
- public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
- static {
- Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
- tmpMap.put(_Fields.TIME, new org.apache.thrift.meta_data.FieldMetaData("time", org.apache.thrift.TFieldRequirementType.DEFAULT,
- new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
- tmpMap.put(_Fields.MSG, new org.apache.thrift.meta_data.FieldMetaData("msg", org.apache.thrift.TFieldRequirementType.DEFAULT,
- new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
- metaDataMap = Collections.unmodifiableMap(tmpMap);
- org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Annotation.class, metaDataMap);
- }
-
- public Annotation() {
- }
-
- public Annotation(
- long time,
- String msg)
- {
- this();
- this.time = time;
- setTimeIsSet(true);
- this.msg = msg;
- }
-
- /**
- * Performs a deep copy on <i>other</i>.
- */
- public Annotation(Annotation other) {
- __isset_bitfield = other.__isset_bitfield;
- this.time = other.time;
- if (other.isSetMsg()) {
- this.msg = other.msg;
- }
- }
-
- public Annotation deepCopy() {
- return new Annotation(this);
- }
-
- @Override
- public void clear() {
- setTimeIsSet(false);
- this.time = 0;
- this.msg = null;
- }
-
- public long getTime() {
- return this.time;
- }
-
- public Annotation setTime(long time) {
- this.time = time;
- setTimeIsSet(true);
- return this;
- }
-
- public void unsetTime() {
- __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __TIME_ISSET_ID);
- }
-
- /** Returns true if field time is set (has been assigned a value) and false otherwise */
- public boolean isSetTime() {
- return EncodingUtils.testBit(__isset_bitfield, __TIME_ISSET_ID);
- }
-
- public void setTimeIsSet(boolean value) {
- __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __TIME_ISSET_ID, value);
- }
-
- public String getMsg() {
- return this.msg;
- }
-
- public Annotation setMsg(String msg) {
- this.msg = msg;
- return this;
- }
-
- public void unsetMsg() {
- this.msg = null;
- }
-
- /** Returns true if field msg is set (has been assigned a value) and false otherwise */
- public boolean isSetMsg() {
- return this.msg != null;
- }
-
- public void setMsgIsSet(boolean value) {
- if (!value) {
- this.msg = null;
- }
- }
-
- public void setFieldValue(_Fields field, Object value) {
- switch (field) {
- case TIME:
- if (value == null) {
- unsetTime();
- } else {
- setTime((Long)value);
- }
- break;
-
- case MSG:
- if (value == null) {
- unsetMsg();
- } else {
- setMsg((String)value);
- }
- break;
-
- }
- }
-
- public Object getFieldValue(_Fields field) {
- switch (field) {
- case TIME:
- return Long.valueOf(getTime());
-
- case MSG:
- return getMsg();
-
- }
- throw new IllegalStateException();
- }
-
- /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
- public boolean isSet(_Fields field) {
- if (field == null) {
- throw new IllegalArgumentException();
- }
-
- switch (field) {
- case TIME:
- return isSetTime();
- case MSG:
- return isSetMsg();
- }
- throw new IllegalStateException();
- }
-
- @Override
- public boolean equals(Object that) {
- if (that == null)
- return false;
- if (that instanceof Annotation)
- return this.equals((Annotation)that);
- return false;
- }
-
- public boolean equals(Annotation that) {
- if (that == null)
- return false;
-
- boolean this_present_time = true;
- boolean that_present_time = true;
- if (this_present_time || that_present_time) {
- if (!(this_present_time && that_present_time))
- return false;
- if (this.time != that.time)
- return false;
- }
-
- boolean this_present_msg = true && this.isSetMsg();
- boolean that_present_msg = true && that.isSetMsg();
- if (this_present_msg || that_present_msg) {
- if (!(this_present_msg && that_present_msg))
- return false;
- if (!this.msg.equals(that.msg))
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return 0;
- }
-
- @Override
- public int compareTo(Annotation other) {
- if (!getClass().equals(other.getClass())) {
- return getClass().getName().compareTo(other.getClass().getName());
- }
-
- int lastComparison = 0;
-
- lastComparison = Boolean.valueOf(isSetTime()).compareTo(other.isSetTime());
- if (lastComparison != 0) {
- return lastComparison;
- }
- if (isSetTime()) {
- lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.time, other.time);
- if (lastComparison != 0) {
- return lastComparison;
- }
- }
- lastComparison = Boolean.valueOf(isSetMsg()).compareTo(other.isSetMsg());
- if (lastComparison != 0) {
- return lastComparison;
- }
- if (isSetMsg()) {
- lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.msg, other.msg);
- if (lastComparison != 0) {
- return lastComparison;
- }
- }
- return 0;
- }
-
- public _Fields fieldForId(int fieldId) {
- return _Fields.findByThriftId(fieldId);
- }
-
- public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
- schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
- }
-
- public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
- schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder("Annotation(");
- boolean first = true;
-
- sb.append("time:");
- sb.append(this.time);
- first = false;
- if (!first) sb.append(", ");
- sb.append("msg:");
- if (this.msg == null) {
- sb.append("null");
- } else {
- sb.append(this.msg);
- }
- first = false;
- sb.append(")");
- return sb.toString();
- }
-
- public void validate() throws org.apache.thrift.TException {
- // check for required fields
- // check for sub-struct validity
- }
-
- private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
- try {
- write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
- } catch (org.apache.thrift.TException te) {
- throw new java.io.IOException(te);
- }
- }
-
- private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
- try {
- // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
- __isset_bitfield = 0;
- read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
- } catch (org.apache.thrift.TException te) {
- throw new java.io.IOException(te);
- }
- }
-
- private static class AnnotationStandardSchemeFactory implements SchemeFactory {
- public AnnotationStandardScheme getScheme() {
- return new AnnotationStandardScheme();
- }
- }
-
- private static class AnnotationStandardScheme extends StandardScheme<Annotation> {
-
- public void read(org.apache.thrift.protocol.TProtocol iprot, Annotation struct) throws org.apache.thrift.TException {
- org.apache.thrift.protocol.TField schemeField;
- iprot.readStructBegin();
- while (true)
- {
- schemeField = iprot.readFieldBegin();
- if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
- break;
- }
- switch (schemeField.id) {
- case 1: // TIME
- if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
- struct.time = iprot.readI64();
- struct.setTimeIsSet(true);
- } else {
- org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
- }
- break;
- case 2: // MSG
- if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
- struct.msg = iprot.readString();
- struct.setMsgIsSet(true);
- } else {
- org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
- }
- break;
- default:
- org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
- }
- iprot.readFieldEnd();
- }
- iprot.readStructEnd();
-
- // check for required fields of primitive type, which can't be checked in the validate method
- struct.validate();
- }
-
- public void write(org.apache.thrift.protocol.TProtocol oprot, Annotation struct) throws org.apache.thrift.TException {
- struct.validate();
-
- oprot.writeStructBegin(STRUCT_DESC);
- oprot.writeFieldBegin(TIME_FIELD_DESC);
- oprot.writeI64(struct.time);
- oprot.writeFieldEnd();
- if (struct.msg != null) {
- oprot.writeFieldBegin(MSG_FIELD_DESC);
- oprot.writeString(struct.msg);
- oprot.writeFieldEnd();
- }
- oprot.writeFieldStop();
- oprot.writeStructEnd();
- }
-
- }
-
- private static class AnnotationTupleSchemeFactory implements SchemeFactory {
- public AnnotationTupleScheme getScheme() {
- return new AnnotationTupleScheme();
- }
- }
-
- private static class AnnotationTupleScheme extends TupleScheme<Annotation> {
-
- @Override
- public void write(org.apache.thrift.protocol.TProtocol prot, Annotation struct) throws org.apache.thrift.TException {
- TTupleProtocol oprot = (TTupleProtocol) prot;
- BitSet optionals = new BitSet();
- if (struct.isSetTime()) {
- optionals.set(0);
- }
- if (struct.isSetMsg()) {
- optionals.set(1);
- }
- oprot.writeBitSet(optionals, 2);
- if (struct.isSetTime()) {
- oprot.writeI64(struct.time);
- }
- if (struct.isSetMsg()) {
- oprot.writeString(struct.msg);
- }
- }
-
- @Override
- public void read(org.apache.thrift.protocol.TProtocol prot, Annotation struct) throws org.apache.thrift.TException {
- TTupleProtocol iprot = (TTupleProtocol) prot;
- BitSet incoming = iprot.readBitSet(2);
- if (incoming.get(0)) {
- struct.time = iprot.readI64();
- struct.setTimeIsSet(true);
- }
- if (incoming.get(1)) {
- struct.msg = iprot.readString();
- struct.setMsgIsSet(true);
- }
- }
- }
-
-}
-