You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@htrace.apache.org by le...@apache.org on 2018/04/11 20:26:51 UTC

[01/12] incubator-htrace git commit: initial span receiver for kudu poc commit

Repository: incubator-htrace
Updated Branches:
  refs/heads/master 4508cd5c3 -> a3b503d7d


http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6752709e/htrace-kudu/src/main/java/org/apache/htrace/protobuf/generated/SpanProtos.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/protobuf/generated/SpanProtos.java b/htrace-kudu/src/main/java/org/apache/htrace/protobuf/generated/SpanProtos.java
new file mode 100644
index 0000000..98b8adb
--- /dev/null
+++ b/htrace-kudu/src/main/java/org/apache/htrace/protobuf/generated/SpanProtos.java
@@ -0,0 +1,2241 @@
+// Generated by the protocol buffer compiler.  DO NOT EDIT!
+// source: Span.proto
+
+package org.apache.htrace.protobuf.generated;
+
+public final class SpanProtos {
+  private SpanProtos() {}
+  public static void registerAllExtensions(
+      com.google.protobuf.ExtensionRegistry registry) {
+  }
+  public interface TimelineAnnotationOrBuilder
+      extends com.google.protobuf.MessageOrBuilder {
+
+    // required int64 time = 1;
+    /**
+     * <code>required int64 time = 1;</code>
+     */
+    boolean hasTime();
+    /**
+     * <code>required int64 time = 1;</code>
+     */
+    long getTime();
+
+    // required string message = 2;
+    /**
+     * <code>required string message = 2;</code>
+     */
+    boolean hasMessage();
+    /**
+     * <code>required string message = 2;</code>
+     */
+    java.lang.String getMessage();
+    /**
+     * <code>required string message = 2;</code>
+     */
+    com.google.protobuf.ByteString
+        getMessageBytes();
+  }
+  /**
+   * Protobuf type {@code TimelineAnnotation}
+   */
+  public static final class TimelineAnnotation extends
+      com.google.protobuf.GeneratedMessage
+      implements TimelineAnnotationOrBuilder {
+    // Use TimelineAnnotation.newBuilder() to construct.
+    private TimelineAnnotation(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
+      super(builder);
+      this.unknownFields = builder.getUnknownFields();
+    }
+    private TimelineAnnotation(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
+
+    private static final TimelineAnnotation defaultInstance;
+    public static TimelineAnnotation getDefaultInstance() {
+      return defaultInstance;
+    }
+
+    public TimelineAnnotation getDefaultInstanceForType() {
+      return defaultInstance;
+    }
+
+    private final com.google.protobuf.UnknownFieldSet unknownFields;
+    @java.lang.Override
+    public final com.google.protobuf.UnknownFieldSet
+        getUnknownFields() {
+      return this.unknownFields;
+    }
+    private TimelineAnnotation(
+        com.google.protobuf.CodedInputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      initFields();
+      int mutable_bitField0_ = 0;
+      com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+          com.google.protobuf.UnknownFieldSet.newBuilder();
+      try {
+        boolean done = false;
+        while (!done) {
+          int tag = input.readTag();
+          switch (tag) {
+            case 0:
+              done = true;
+              break;
+            default: {
+              if (!parseUnknownField(input, unknownFields,
+                                     extensionRegistry, tag)) {
+                done = true;
+              }
+              break;
+            }
+            case 8: {
+              bitField0_ |= 0x00000001;
+              time_ = input.readInt64();
+              break;
+            }
+            case 18: {
+              bitField0_ |= 0x00000002;
+              message_ = input.readBytes();
+              break;
+            }
+          }
+        }
+      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+        throw e.setUnfinishedMessage(this);
+      } catch (java.io.IOException e) {
+        throw new com.google.protobuf.InvalidProtocolBufferException(
+            e.getMessage()).setUnfinishedMessage(this);
+      } finally {
+        this.unknownFields = unknownFields.build();
+        makeExtensionsImmutable();
+      }
+    }
+    public static final com.google.protobuf.Descriptors.Descriptor
+        getDescriptor() {
+      return org.apache.htrace.protobuf.generated.SpanProtos.internal_static_TimelineAnnotation_descriptor;
+    }
+
+    protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+        internalGetFieldAccessorTable() {
+      return org.apache.htrace.protobuf.generated.SpanProtos.internal_static_TimelineAnnotation_fieldAccessorTable
+          .ensureFieldAccessorsInitialized(
+              org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.class, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder.class);
+    }
+
+    public static com.google.protobuf.Parser<TimelineAnnotation> PARSER =
+        new com.google.protobuf.AbstractParser<TimelineAnnotation>() {
+      public TimelineAnnotation parsePartialFrom(
+          com.google.protobuf.CodedInputStream input,
+          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+          throws com.google.protobuf.InvalidProtocolBufferException {
+        return new TimelineAnnotation(input, extensionRegistry);
+      }
+    };
+
+    @java.lang.Override
+    public com.google.protobuf.Parser<TimelineAnnotation> getParserForType() {
+      return PARSER;
+    }
+
+    private int bitField0_;
+    // required int64 time = 1;
+    public static final int TIME_FIELD_NUMBER = 1;
+    private long time_;
+    /**
+     * <code>required int64 time = 1;</code>
+     */
+    public boolean hasTime() {
+      return ((bitField0_ & 0x00000001) == 0x00000001);
+    }
+    /**
+     * <code>required int64 time = 1;</code>
+     */
+    public long getTime() {
+      return time_;
+    }
+
+    // required string message = 2;
+    public static final int MESSAGE_FIELD_NUMBER = 2;
+    private java.lang.Object message_;
+    /**
+     * <code>required string message = 2;</code>
+     */
+    public boolean hasMessage() {
+      return ((bitField0_ & 0x00000002) == 0x00000002);
+    }
+    /**
+     * <code>required string message = 2;</code>
+     */
+    public java.lang.String getMessage() {
+      java.lang.Object ref = message_;
+      if (ref instanceof java.lang.String) {
+        return (java.lang.String) ref;
+      } else {
+        com.google.protobuf.ByteString bs = 
+            (com.google.protobuf.ByteString) ref;
+        java.lang.String s = bs.toStringUtf8();
+        if (bs.isValidUtf8()) {
+          message_ = s;
+        }
+        return s;
+      }
+    }
+    /**
+     * <code>required string message = 2;</code>
+     */
+    public com.google.protobuf.ByteString
+        getMessageBytes() {
+      java.lang.Object ref = message_;
+      if (ref instanceof java.lang.String) {
+        com.google.protobuf.ByteString b = 
+            com.google.protobuf.ByteString.copyFromUtf8(
+                (java.lang.String) ref);
+        message_ = b;
+        return b;
+      } else {
+        return (com.google.protobuf.ByteString) ref;
+      }
+    }
+
+    private void initFields() {
+      time_ = 0L;
+      message_ = "";
+    }
+    private byte memoizedIsInitialized = -1;
+    public final boolean isInitialized() {
+      byte isInitialized = memoizedIsInitialized;
+      if (isInitialized != -1) return isInitialized == 1;
+
+      if (!hasTime()) {
+        memoizedIsInitialized = 0;
+        return false;
+      }
+      if (!hasMessage()) {
+        memoizedIsInitialized = 0;
+        return false;
+      }
+      memoizedIsInitialized = 1;
+      return true;
+    }
+
+    public void writeTo(com.google.protobuf.CodedOutputStream output)
+                        throws java.io.IOException {
+      getSerializedSize();
+      if (((bitField0_ & 0x00000001) == 0x00000001)) {
+        output.writeInt64(1, time_);
+      }
+      if (((bitField0_ & 0x00000002) == 0x00000002)) {
+        output.writeBytes(2, getMessageBytes());
+      }
+      getUnknownFields().writeTo(output);
+    }
+
+    private int memoizedSerializedSize = -1;
+    public int getSerializedSize() {
+      int size = memoizedSerializedSize;
+      if (size != -1) return size;
+
+      size = 0;
+      if (((bitField0_ & 0x00000001) == 0x00000001)) {
+        size += com.google.protobuf.CodedOutputStream
+          .computeInt64Size(1, time_);
+      }
+      if (((bitField0_ & 0x00000002) == 0x00000002)) {
+        size += com.google.protobuf.CodedOutputStream
+          .computeBytesSize(2, getMessageBytes());
+      }
+      size += getUnknownFields().getSerializedSize();
+      memoizedSerializedSize = size;
+      return size;
+    }
+
+    private static final long serialVersionUID = 0L;
+    @java.lang.Override
+    protected java.lang.Object writeReplace()
+        throws java.io.ObjectStreamException {
+      return super.writeReplace();
+    }
+
+    @java.lang.Override
+    public boolean equals(final java.lang.Object obj) {
+      if (obj == this) {
+       return true;
+      }
+      if (!(obj instanceof org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation)) {
+        return super.equals(obj);
+      }
+      org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation other = (org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation) obj;
+
+      boolean result = true;
+      result = result && (hasTime() == other.hasTime());
+      if (hasTime()) {
+        result = result && (getTime()
+            == other.getTime());
+      }
+      result = result && (hasMessage() == other.hasMessage());
+      if (hasMessage()) {
+        result = result && getMessage()
+            .equals(other.getMessage());
+      }
+      result = result &&
+          getUnknownFields().equals(other.getUnknownFields());
+      return result;
+    }
+
+    private int memoizedHashCode = 0;
+    @java.lang.Override
+    public int hashCode() {
+      if (memoizedHashCode != 0) {
+        return memoizedHashCode;
+      }
+      int hash = 41;
+      hash = (19 * hash) + getDescriptorForType().hashCode();
+      if (hasTime()) {
+        hash = (37 * hash) + TIME_FIELD_NUMBER;
+        hash = (53 * hash) + hashLong(getTime());
+      }
+      if (hasMessage()) {
+        hash = (37 * hash) + MESSAGE_FIELD_NUMBER;
+        hash = (53 * hash) + getMessage().hashCode();
+      }
+      hash = (29 * hash) + getUnknownFields().hashCode();
+      memoizedHashCode = hash;
+      return hash;
+    }
+
+    public static org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation parseFrom(
+        com.google.protobuf.ByteString data)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data);
+    }
+    public static org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation parseFrom(
+        com.google.protobuf.ByteString data,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data, extensionRegistry);
+    }
+    public static org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation parseFrom(byte[] data)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data);
+    }
+    public static org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation parseFrom(
+        byte[] data,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data, extensionRegistry);
+    }
+    public static org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation parseFrom(java.io.InputStream input)
+        throws java.io.IOException {
+      return PARSER.parseFrom(input);
+    }
+    public static org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation parseFrom(
+        java.io.InputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws java.io.IOException {
+      return PARSER.parseFrom(input, extensionRegistry);
+    }
+    public static org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation parseDelimitedFrom(java.io.InputStream input)
+        throws java.io.IOException {
+      return PARSER.parseDelimitedFrom(input);
+    }
+    public static org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation parseDelimitedFrom(
+        java.io.InputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws java.io.IOException {
+      return PARSER.parseDelimitedFrom(input, extensionRegistry);
+    }
+    public static org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation parseFrom(
+        com.google.protobuf.CodedInputStream input)
+        throws java.io.IOException {
+      return PARSER.parseFrom(input);
+    }
+    public static org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation parseFrom(
+        com.google.protobuf.CodedInputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws java.io.IOException {
+      return PARSER.parseFrom(input, extensionRegistry);
+    }
+
+    public static Builder newBuilder() { return Builder.create(); }
+    public Builder newBuilderForType() { return newBuilder(); }
+    public static Builder newBuilder(org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation prototype) {
+      return newBuilder().mergeFrom(prototype);
+    }
+    public Builder toBuilder() { return newBuilder(this); }
+
+    @java.lang.Override
+    protected Builder newBuilderForType(
+        com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+      Builder builder = new Builder(parent);
+      return builder;
+    }
+    /**
+     * Protobuf type {@code TimelineAnnotation}
+     */
+    public static final class Builder extends
+        com.google.protobuf.GeneratedMessage.Builder<Builder>
+       implements org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotationOrBuilder {
+      public static final com.google.protobuf.Descriptors.Descriptor
+          getDescriptor() {
+        return org.apache.htrace.protobuf.generated.SpanProtos.internal_static_TimelineAnnotation_descriptor;
+      }
+
+      protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+          internalGetFieldAccessorTable() {
+        return org.apache.htrace.protobuf.generated.SpanProtos.internal_static_TimelineAnnotation_fieldAccessorTable
+            .ensureFieldAccessorsInitialized(
+                org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.class, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder.class);
+      }
+
+      // Construct using org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.newBuilder()
+      private Builder() {
+        maybeForceBuilderInitialization();
+      }
+
+      private Builder(
+          com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+        super(parent);
+        maybeForceBuilderInitialization();
+      }
+      private void maybeForceBuilderInitialization() {
+        if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+        }
+      }
+      private static Builder create() {
+        return new Builder();
+      }
+
+      public Builder clear() {
+        super.clear();
+        time_ = 0L;
+        bitField0_ = (bitField0_ & ~0x00000001);
+        message_ = "";
+        bitField0_ = (bitField0_ & ~0x00000002);
+        return this;
+      }
+
+      public Builder clone() {
+        return create().mergeFrom(buildPartial());
+      }
+
+      public com.google.protobuf.Descriptors.Descriptor
+          getDescriptorForType() {
+        return org.apache.htrace.protobuf.generated.SpanProtos.internal_static_TimelineAnnotation_descriptor;
+      }
+
+      public org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation getDefaultInstanceForType() {
+        return org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.getDefaultInstance();
+      }
+
+      public org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation build() {
+        org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation result = buildPartial();
+        if (!result.isInitialized()) {
+          throw newUninitializedMessageException(result);
+        }
+        return result;
+      }
+
+      public org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation buildPartial() {
+        org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation result = new org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation(this);
+        int from_bitField0_ = bitField0_;
+        int to_bitField0_ = 0;
+        if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
+          to_bitField0_ |= 0x00000001;
+        }
+        result.time_ = time_;
+        if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
+          to_bitField0_ |= 0x00000002;
+        }
+        result.message_ = message_;
+        result.bitField0_ = to_bitField0_;
+        onBuilt();
+        return result;
+      }
+
+      public Builder mergeFrom(com.google.protobuf.Message other) {
+        if (other instanceof org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation) {
+          return mergeFrom((org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation)other);
+        } else {
+          super.mergeFrom(other);
+          return this;
+        }
+      }
+
+      public Builder mergeFrom(org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation other) {
+        if (other == org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.getDefaultInstance()) return this;
+        if (other.hasTime()) {
+          setTime(other.getTime());
+        }
+        if (other.hasMessage()) {
+          bitField0_ |= 0x00000002;
+          message_ = other.message_;
+          onChanged();
+        }
+        this.mergeUnknownFields(other.getUnknownFields());
+        return this;
+      }
+
+      public final boolean isInitialized() {
+        if (!hasTime()) {
+          
+          return false;
+        }
+        if (!hasMessage()) {
+          
+          return false;
+        }
+        return true;
+      }
+
+      public Builder mergeFrom(
+          com.google.protobuf.CodedInputStream input,
+          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+          throws java.io.IOException {
+        org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation parsedMessage = null;
+        try {
+          parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
+        } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+          parsedMessage = (org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation) e.getUnfinishedMessage();
+          throw e;
+        } finally {
+          if (parsedMessage != null) {
+            mergeFrom(parsedMessage);
+          }
+        }
+        return this;
+      }
+      private int bitField0_;
+
+      // required int64 time = 1;
+      private long time_ ;
+      /**
+       * <code>required int64 time = 1;</code>
+       */
+      public boolean hasTime() {
+        return ((bitField0_ & 0x00000001) == 0x00000001);
+      }
+      /**
+       * <code>required int64 time = 1;</code>
+       */
+      public long getTime() {
+        return time_;
+      }
+      /**
+       * <code>required int64 time = 1;</code>
+       */
+      public Builder setTime(long value) {
+        bitField0_ |= 0x00000001;
+        time_ = value;
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>required int64 time = 1;</code>
+       */
+      public Builder clearTime() {
+        bitField0_ = (bitField0_ & ~0x00000001);
+        time_ = 0L;
+        onChanged();
+        return this;
+      }
+
+      // required string message = 2;
+      private java.lang.Object message_ = "";
+      /**
+       * <code>required string message = 2;</code>
+       */
+      public boolean hasMessage() {
+        return ((bitField0_ & 0x00000002) == 0x00000002);
+      }
+      /**
+       * <code>required string message = 2;</code>
+       */
+      public java.lang.String getMessage() {
+        java.lang.Object ref = message_;
+        if (!(ref instanceof java.lang.String)) {
+          java.lang.String s = ((com.google.protobuf.ByteString) ref)
+              .toStringUtf8();
+          message_ = s;
+          return s;
+        } else {
+          return (java.lang.String) ref;
+        }
+      }
+      /**
+       * <code>required string message = 2;</code>
+       */
+      public com.google.protobuf.ByteString
+          getMessageBytes() {
+        java.lang.Object ref = message_;
+        if (ref instanceof String) {
+          com.google.protobuf.ByteString b = 
+              com.google.protobuf.ByteString.copyFromUtf8(
+                  (java.lang.String) ref);
+          message_ = b;
+          return b;
+        } else {
+          return (com.google.protobuf.ByteString) ref;
+        }
+      }
+      /**
+       * <code>required string message = 2;</code>
+       */
+      public Builder setMessage(
+          java.lang.String value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  bitField0_ |= 0x00000002;
+        message_ = value;
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>required string message = 2;</code>
+       */
+      public Builder clearMessage() {
+        bitField0_ = (bitField0_ & ~0x00000002);
+        message_ = getDefaultInstance().getMessage();
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>required string message = 2;</code>
+       */
+      public Builder setMessageBytes(
+          com.google.protobuf.ByteString value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  bitField0_ |= 0x00000002;
+        message_ = value;
+        onChanged();
+        return this;
+      }
+
+      // @@protoc_insertion_point(builder_scope:TimelineAnnotation)
+    }
+
+    static {
+      defaultInstance = new TimelineAnnotation(true);
+      defaultInstance.initFields();
+    }
+
+    // @@protoc_insertion_point(class_scope:TimelineAnnotation)
+  }
+
+  public interface SpanOrBuilder
+      extends com.google.protobuf.MessageOrBuilder {
+
+    // required int64 trace_id = 1;
+    /**
+     * <code>required int64 trace_id = 1;</code>
+     */
+    boolean hasTraceId();
+    /**
+     * <code>required int64 trace_id = 1;</code>
+     */
+    long getTraceId();
+
+    // required int64 parent_id = 2;
+    /**
+     * <code>required int64 parent_id = 2;</code>
+     */
+    boolean hasParentId();
+    /**
+     * <code>required int64 parent_id = 2;</code>
+     */
+    long getParentId();
+
+    // required int64 start = 3;
+    /**
+     * <code>required int64 start = 3;</code>
+     */
+    boolean hasStart();
+    /**
+     * <code>required int64 start = 3;</code>
+     */
+    long getStart();
+
+    // required int64 stop = 4;
+    /**
+     * <code>required int64 stop = 4;</code>
+     */
+    boolean hasStop();
+    /**
+     * <code>required int64 stop = 4;</code>
+     */
+    long getStop();
+
+    // required int64 span_id = 5;
+    /**
+     * <code>required int64 span_id = 5;</code>
+     */
+    boolean hasSpanId();
+    /**
+     * <code>required int64 span_id = 5;</code>
+     */
+    long getSpanId();
+
+    // required string process_id = 6;
+    /**
+     * <code>required string process_id = 6;</code>
+     */
+    boolean hasProcessId();
+    /**
+     * <code>required string process_id = 6;</code>
+     */
+    java.lang.String getProcessId();
+    /**
+     * <code>required string process_id = 6;</code>
+     */
+    com.google.protobuf.ByteString
+        getProcessIdBytes();
+
+    // required string description = 7;
+    /**
+     * <code>required string description = 7;</code>
+     */
+    boolean hasDescription();
+    /**
+     * <code>required string description = 7;</code>
+     */
+    java.lang.String getDescription();
+    /**
+     * <code>required string description = 7;</code>
+     */
+    com.google.protobuf.ByteString
+        getDescriptionBytes();
+
+    // repeated .TimelineAnnotation timeline = 8;
+    /**
+     * <code>repeated .TimelineAnnotation timeline = 8;</code>
+     */
+    java.util.List<org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation> 
+        getTimelineList();
+    /**
+     * <code>repeated .TimelineAnnotation timeline = 8;</code>
+     */
+    org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation getTimeline(int index);
+    /**
+     * <code>repeated .TimelineAnnotation timeline = 8;</code>
+     */
+    int getTimelineCount();
+    /**
+     * <code>repeated .TimelineAnnotation timeline = 8;</code>
+     */
+    java.util.List<? extends org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotationOrBuilder> 
+        getTimelineOrBuilderList();
+    /**
+     * <code>repeated .TimelineAnnotation timeline = 8;</code>
+     */
+    org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotationOrBuilder getTimelineOrBuilder(
+        int index);
+  }
+  /**
+   * Protobuf type {@code Span}
+   */
+  public static final class Span extends
+      com.google.protobuf.GeneratedMessage
+      implements SpanOrBuilder {
+    // Use Span.newBuilder() to construct.
+    private Span(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
+      super(builder);
+      this.unknownFields = builder.getUnknownFields();
+    }
+    private Span(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
+
+    private static final Span defaultInstance;
+    public static Span getDefaultInstance() {
+      return defaultInstance;
+    }
+
+    public Span getDefaultInstanceForType() {
+      return defaultInstance;
+    }
+
+    private final com.google.protobuf.UnknownFieldSet unknownFields;
+    @java.lang.Override
+    public final com.google.protobuf.UnknownFieldSet
+        getUnknownFields() {
+      return this.unknownFields;
+    }
+    private Span(
+        com.google.protobuf.CodedInputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      initFields();
+      int mutable_bitField0_ = 0;
+      com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+          com.google.protobuf.UnknownFieldSet.newBuilder();
+      try {
+        boolean done = false;
+        while (!done) {
+          int tag = input.readTag();
+          switch (tag) {
+            case 0:
+              done = true;
+              break;
+            default: {
+              if (!parseUnknownField(input, unknownFields,
+                                     extensionRegistry, tag)) {
+                done = true;
+              }
+              break;
+            }
+            case 8: {
+              bitField0_ |= 0x00000001;
+              traceId_ = input.readInt64();
+              break;
+            }
+            case 16: {
+              bitField0_ |= 0x00000002;
+              parentId_ = input.readInt64();
+              break;
+            }
+            case 24: {
+              bitField0_ |= 0x00000004;
+              start_ = input.readInt64();
+              break;
+            }
+            case 32: {
+              bitField0_ |= 0x00000008;
+              stop_ = input.readInt64();
+              break;
+            }
+            case 40: {
+              bitField0_ |= 0x00000010;
+              spanId_ = input.readInt64();
+              break;
+            }
+            case 50: {
+              bitField0_ |= 0x00000020;
+              processId_ = input.readBytes();
+              break;
+            }
+            case 58: {
+              bitField0_ |= 0x00000040;
+              description_ = input.readBytes();
+              break;
+            }
+            case 66: {
+              if (!((mutable_bitField0_ & 0x00000080) == 0x00000080)) {
+                timeline_ = new java.util.ArrayList<org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation>();
+                mutable_bitField0_ |= 0x00000080;
+              }
+              timeline_.add(input.readMessage(org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.PARSER, extensionRegistry));
+              break;
+            }
+          }
+        }
+      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+        throw e.setUnfinishedMessage(this);
+      } catch (java.io.IOException e) {
+        throw new com.google.protobuf.InvalidProtocolBufferException(
+            e.getMessage()).setUnfinishedMessage(this);
+      } finally {
+        if (((mutable_bitField0_ & 0x00000080) == 0x00000080)) {
+          timeline_ = java.util.Collections.unmodifiableList(timeline_);
+        }
+        this.unknownFields = unknownFields.build();
+        makeExtensionsImmutable();
+      }
+    }
+    public static final com.google.protobuf.Descriptors.Descriptor
+        getDescriptor() {
+      return org.apache.htrace.protobuf.generated.SpanProtos.internal_static_Span_descriptor;
+    }
+
+    protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+        internalGetFieldAccessorTable() {
+      return org.apache.htrace.protobuf.generated.SpanProtos.internal_static_Span_fieldAccessorTable
+          .ensureFieldAccessorsInitialized(
+              org.apache.htrace.protobuf.generated.SpanProtos.Span.class, org.apache.htrace.protobuf.generated.SpanProtos.Span.Builder.class);
+    }
+
+    public static com.google.protobuf.Parser<Span> PARSER =
+        new com.google.protobuf.AbstractParser<Span>() {
+      public Span parsePartialFrom(
+          com.google.protobuf.CodedInputStream input,
+          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+          throws com.google.protobuf.InvalidProtocolBufferException {
+        return new Span(input, extensionRegistry);
+      }
+    };
+
+    @java.lang.Override
+    public com.google.protobuf.Parser<Span> getParserForType() {
+      return PARSER;
+    }
+
+    private int bitField0_;
+    // required int64 trace_id = 1;
+    public static final int TRACE_ID_FIELD_NUMBER = 1;
+    private long traceId_;
+    /**
+     * <code>required int64 trace_id = 1;</code>
+     */
+    public boolean hasTraceId() {
+      return ((bitField0_ & 0x00000001) == 0x00000001);
+    }
+    /**
+     * <code>required int64 trace_id = 1;</code>
+     */
+    public long getTraceId() {
+      return traceId_;
+    }
+
+    // required int64 parent_id = 2;
+    public static final int PARENT_ID_FIELD_NUMBER = 2;
+    private long parentId_;
+    /**
+     * <code>required int64 parent_id = 2;</code>
+     */
+    public boolean hasParentId() {
+      return ((bitField0_ & 0x00000002) == 0x00000002);
+    }
+    /**
+     * <code>required int64 parent_id = 2;</code>
+     */
+    public long getParentId() {
+      return parentId_;
+    }
+
+    // required int64 start = 3;
+    public static final int START_FIELD_NUMBER = 3;
+    private long start_;
+    /**
+     * <code>required int64 start = 3;</code>
+     */
+    public boolean hasStart() {
+      return ((bitField0_ & 0x00000004) == 0x00000004);
+    }
+    /**
+     * <code>required int64 start = 3;</code>
+     */
+    public long getStart() {
+      return start_;
+    }
+
+    // required int64 stop = 4;
+    public static final int STOP_FIELD_NUMBER = 4;
+    private long stop_;
+    /**
+     * <code>required int64 stop = 4;</code>
+     */
+    public boolean hasStop() {
+      return ((bitField0_ & 0x00000008) == 0x00000008);
+    }
+    /**
+     * <code>required int64 stop = 4;</code>
+     */
+    public long getStop() {
+      return stop_;
+    }
+
+    // required int64 span_id = 5;
+    public static final int SPAN_ID_FIELD_NUMBER = 5;
+    private long spanId_;
+    /**
+     * <code>required int64 span_id = 5;</code>
+     */
+    public boolean hasSpanId() {
+      return ((bitField0_ & 0x00000010) == 0x00000010);
+    }
+    /**
+     * <code>required int64 span_id = 5;</code>
+     */
+    public long getSpanId() {
+      return spanId_;
+    }
+
+    // required string process_id = 6;
+    public static final int PROCESS_ID_FIELD_NUMBER = 6;
+    private java.lang.Object processId_;
+    /**
+     * <code>required string process_id = 6;</code>
+     */
+    public boolean hasProcessId() {
+      return ((bitField0_ & 0x00000020) == 0x00000020);
+    }
+    /**
+     * <code>required string process_id = 6;</code>
+     */
+    public java.lang.String getProcessId() {
+      java.lang.Object ref = processId_;
+      if (ref instanceof java.lang.String) {
+        return (java.lang.String) ref;
+      } else {
+        com.google.protobuf.ByteString bs = 
+            (com.google.protobuf.ByteString) ref;
+        java.lang.String s = bs.toStringUtf8();
+        if (bs.isValidUtf8()) {
+          processId_ = s;
+        }
+        return s;
+      }
+    }
+    /**
+     * <code>required string process_id = 6;</code>
+     */
+    public com.google.protobuf.ByteString
+        getProcessIdBytes() {
+      java.lang.Object ref = processId_;
+      if (ref instanceof java.lang.String) {
+        com.google.protobuf.ByteString b = 
+            com.google.protobuf.ByteString.copyFromUtf8(
+                (java.lang.String) ref);
+        processId_ = b;
+        return b;
+      } else {
+        return (com.google.protobuf.ByteString) ref;
+      }
+    }
+
+    // required string description = 7;
+    public static final int DESCRIPTION_FIELD_NUMBER = 7;
+    private java.lang.Object description_;
+    /**
+     * <code>required string description = 7;</code>
+     */
+    public boolean hasDescription() {
+      return ((bitField0_ & 0x00000040) == 0x00000040);
+    }
+    /**
+     * <code>required string description = 7;</code>
+     */
+    public java.lang.String getDescription() {
+      java.lang.Object ref = description_;
+      if (ref instanceof java.lang.String) {
+        return (java.lang.String) ref;
+      } else {
+        com.google.protobuf.ByteString bs = 
+            (com.google.protobuf.ByteString) ref;
+        java.lang.String s = bs.toStringUtf8();
+        if (bs.isValidUtf8()) {
+          description_ = s;
+        }
+        return s;
+      }
+    }
+    /**
+     * <code>required string description = 7;</code>
+     */
+    public com.google.protobuf.ByteString
+        getDescriptionBytes() {
+      java.lang.Object ref = description_;
+      if (ref instanceof java.lang.String) {
+        com.google.protobuf.ByteString b = 
+            com.google.protobuf.ByteString.copyFromUtf8(
+                (java.lang.String) ref);
+        description_ = b;
+        return b;
+      } else {
+        return (com.google.protobuf.ByteString) ref;
+      }
+    }
+
+    // repeated .TimelineAnnotation timeline = 8;
+    public static final int TIMELINE_FIELD_NUMBER = 8;
+    private java.util.List<org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation> timeline_;
+    /**
+     * <code>repeated .TimelineAnnotation timeline = 8;</code>
+     */
+    public java.util.List<org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation> getTimelineList() {
+      return timeline_;
+    }
+    /**
+     * <code>repeated .TimelineAnnotation timeline = 8;</code>
+     */
+    public java.util.List<? extends org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotationOrBuilder> 
+        getTimelineOrBuilderList() {
+      return timeline_;
+    }
+    /**
+     * <code>repeated .TimelineAnnotation timeline = 8;</code>
+     */
+    public int getTimelineCount() {
+      return timeline_.size();
+    }
+    /**
+     * <code>repeated .TimelineAnnotation timeline = 8;</code>
+     */
+    public org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation getTimeline(int index) {
+      return timeline_.get(index);
+    }
+    /**
+     * <code>repeated .TimelineAnnotation timeline = 8;</code>
+     */
+    public org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotationOrBuilder getTimelineOrBuilder(
+        int index) {
+      return timeline_.get(index);
+    }
+
+    private void initFields() {
+      traceId_ = 0L;
+      parentId_ = 0L;
+      start_ = 0L;
+      stop_ = 0L;
+      spanId_ = 0L;
+      processId_ = "";
+      description_ = "";
+      timeline_ = java.util.Collections.emptyList();
+    }
+    private byte memoizedIsInitialized = -1;
+    public final boolean isInitialized() {
+      byte isInitialized = memoizedIsInitialized;
+      if (isInitialized != -1) return isInitialized == 1;
+
+      if (!hasTraceId()) {
+        memoizedIsInitialized = 0;
+        return false;
+      }
+      if (!hasParentId()) {
+        memoizedIsInitialized = 0;
+        return false;
+      }
+      if (!hasStart()) {
+        memoizedIsInitialized = 0;
+        return false;
+      }
+      if (!hasStop()) {
+        memoizedIsInitialized = 0;
+        return false;
+      }
+      if (!hasSpanId()) {
+        memoizedIsInitialized = 0;
+        return false;
+      }
+      if (!hasProcessId()) {
+        memoizedIsInitialized = 0;
+        return false;
+      }
+      if (!hasDescription()) {
+        memoizedIsInitialized = 0;
+        return false;
+      }
+      for (int i = 0; i < getTimelineCount(); i++) {
+        if (!getTimeline(i).isInitialized()) {
+          memoizedIsInitialized = 0;
+          return false;
+        }
+      }
+      memoizedIsInitialized = 1;
+      return true;
+    }
+
+    public void writeTo(com.google.protobuf.CodedOutputStream output)
+                        throws java.io.IOException {
+      getSerializedSize();
+      if (((bitField0_ & 0x00000001) == 0x00000001)) {
+        output.writeInt64(1, traceId_);
+      }
+      if (((bitField0_ & 0x00000002) == 0x00000002)) {
+        output.writeInt64(2, parentId_);
+      }
+      if (((bitField0_ & 0x00000004) == 0x00000004)) {
+        output.writeInt64(3, start_);
+      }
+      if (((bitField0_ & 0x00000008) == 0x00000008)) {
+        output.writeInt64(4, stop_);
+      }
+      if (((bitField0_ & 0x00000010) == 0x00000010)) {
+        output.writeInt64(5, spanId_);
+      }
+      if (((bitField0_ & 0x00000020) == 0x00000020)) {
+        output.writeBytes(6, getProcessIdBytes());
+      }
+      if (((bitField0_ & 0x00000040) == 0x00000040)) {
+        output.writeBytes(7, getDescriptionBytes());
+      }
+      for (int i = 0; i < timeline_.size(); i++) {
+        output.writeMessage(8, timeline_.get(i));
+      }
+      getUnknownFields().writeTo(output);
+    }
+
+    private int memoizedSerializedSize = -1;
+    public int getSerializedSize() {
+      int size = memoizedSerializedSize;
+      if (size != -1) return size;
+
+      size = 0;
+      if (((bitField0_ & 0x00000001) == 0x00000001)) {
+        size += com.google.protobuf.CodedOutputStream
+          .computeInt64Size(1, traceId_);
+      }
+      if (((bitField0_ & 0x00000002) == 0x00000002)) {
+        size += com.google.protobuf.CodedOutputStream
+          .computeInt64Size(2, parentId_);
+      }
+      if (((bitField0_ & 0x00000004) == 0x00000004)) {
+        size += com.google.protobuf.CodedOutputStream
+          .computeInt64Size(3, start_);
+      }
+      if (((bitField0_ & 0x00000008) == 0x00000008)) {
+        size += com.google.protobuf.CodedOutputStream
+          .computeInt64Size(4, stop_);
+      }
+      if (((bitField0_ & 0x00000010) == 0x00000010)) {
+        size += com.google.protobuf.CodedOutputStream
+          .computeInt64Size(5, spanId_);
+      }
+      if (((bitField0_ & 0x00000020) == 0x00000020)) {
+        size += com.google.protobuf.CodedOutputStream
+          .computeBytesSize(6, getProcessIdBytes());
+      }
+      if (((bitField0_ & 0x00000040) == 0x00000040)) {
+        size += com.google.protobuf.CodedOutputStream
+          .computeBytesSize(7, getDescriptionBytes());
+      }
+      for (int i = 0; i < timeline_.size(); i++) {
+        size += com.google.protobuf.CodedOutputStream
+          .computeMessageSize(8, timeline_.get(i));
+      }
+      size += getUnknownFields().getSerializedSize();
+      memoizedSerializedSize = size;
+      return size;
+    }
+
+    private static final long serialVersionUID = 0L;
+    @java.lang.Override
+    protected java.lang.Object writeReplace()
+        throws java.io.ObjectStreamException {
+      return super.writeReplace();
+    }
+
+    @java.lang.Override
+    public boolean equals(final java.lang.Object obj) {
+      if (obj == this) {
+       return true;
+      }
+      if (!(obj instanceof org.apache.htrace.protobuf.generated.SpanProtos.Span)) {
+        return super.equals(obj);
+      }
+      org.apache.htrace.protobuf.generated.SpanProtos.Span other = (org.apache.htrace.protobuf.generated.SpanProtos.Span) obj;
+
+      boolean result = true;
+      result = result && (hasTraceId() == other.hasTraceId());
+      if (hasTraceId()) {
+        result = result && (getTraceId()
+            == other.getTraceId());
+      }
+      result = result && (hasParentId() == other.hasParentId());
+      if (hasParentId()) {
+        result = result && (getParentId()
+            == other.getParentId());
+      }
+      result = result && (hasStart() == other.hasStart());
+      if (hasStart()) {
+        result = result && (getStart()
+            == other.getStart());
+      }
+      result = result && (hasStop() == other.hasStop());
+      if (hasStop()) {
+        result = result && (getStop()
+            == other.getStop());
+      }
+      result = result && (hasSpanId() == other.hasSpanId());
+      if (hasSpanId()) {
+        result = result && (getSpanId()
+            == other.getSpanId());
+      }
+      result = result && (hasProcessId() == other.hasProcessId());
+      if (hasProcessId()) {
+        result = result && getProcessId()
+            .equals(other.getProcessId());
+      }
+      result = result && (hasDescription() == other.hasDescription());
+      if (hasDescription()) {
+        result = result && getDescription()
+            .equals(other.getDescription());
+      }
+      result = result && getTimelineList()
+          .equals(other.getTimelineList());
+      result = result &&
+          getUnknownFields().equals(other.getUnknownFields());
+      return result;
+    }
+
+    private int memoizedHashCode = 0;
+    @java.lang.Override
+    public int hashCode() {
+      if (memoizedHashCode != 0) {
+        return memoizedHashCode;
+      }
+      int hash = 41;
+      hash = (19 * hash) + getDescriptorForType().hashCode();
+      if (hasTraceId()) {
+        hash = (37 * hash) + TRACE_ID_FIELD_NUMBER;
+        hash = (53 * hash) + hashLong(getTraceId());
+      }
+      if (hasParentId()) {
+        hash = (37 * hash) + PARENT_ID_FIELD_NUMBER;
+        hash = (53 * hash) + hashLong(getParentId());
+      }
+      if (hasStart()) {
+        hash = (37 * hash) + START_FIELD_NUMBER;
+        hash = (53 * hash) + hashLong(getStart());
+      }
+      if (hasStop()) {
+        hash = (37 * hash) + STOP_FIELD_NUMBER;
+        hash = (53 * hash) + hashLong(getStop());
+      }
+      if (hasSpanId()) {
+        hash = (37 * hash) + SPAN_ID_FIELD_NUMBER;
+        hash = (53 * hash) + hashLong(getSpanId());
+      }
+      if (hasProcessId()) {
+        hash = (37 * hash) + PROCESS_ID_FIELD_NUMBER;
+        hash = (53 * hash) + getProcessId().hashCode();
+      }
+      if (hasDescription()) {
+        hash = (37 * hash) + DESCRIPTION_FIELD_NUMBER;
+        hash = (53 * hash) + getDescription().hashCode();
+      }
+      if (getTimelineCount() > 0) {
+        hash = (37 * hash) + TIMELINE_FIELD_NUMBER;
+        hash = (53 * hash) + getTimelineList().hashCode();
+      }
+      hash = (29 * hash) + getUnknownFields().hashCode();
+      memoizedHashCode = hash;
+      return hash;
+    }
+
+    public static org.apache.htrace.protobuf.generated.SpanProtos.Span parseFrom(
+        com.google.protobuf.ByteString data)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data);
+    }
+    public static org.apache.htrace.protobuf.generated.SpanProtos.Span parseFrom(
+        com.google.protobuf.ByteString data,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data, extensionRegistry);
+    }
+    public static org.apache.htrace.protobuf.generated.SpanProtos.Span parseFrom(byte[] data)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data);
+    }
+    public static org.apache.htrace.protobuf.generated.SpanProtos.Span parseFrom(
+        byte[] data,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data, extensionRegistry);
+    }
+    public static org.apache.htrace.protobuf.generated.SpanProtos.Span parseFrom(java.io.InputStream input)
+        throws java.io.IOException {
+      return PARSER.parseFrom(input);
+    }
+    public static org.apache.htrace.protobuf.generated.SpanProtos.Span parseFrom(
+        java.io.InputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws java.io.IOException {
+      return PARSER.parseFrom(input, extensionRegistry);
+    }
+    public static org.apache.htrace.protobuf.generated.SpanProtos.Span parseDelimitedFrom(java.io.InputStream input)
+        throws java.io.IOException {
+      return PARSER.parseDelimitedFrom(input);
+    }
+    public static org.apache.htrace.protobuf.generated.SpanProtos.Span parseDelimitedFrom(
+        java.io.InputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws java.io.IOException {
+      return PARSER.parseDelimitedFrom(input, extensionRegistry);
+    }
+    public static org.apache.htrace.protobuf.generated.SpanProtos.Span parseFrom(
+        com.google.protobuf.CodedInputStream input)
+        throws java.io.IOException {
+      return PARSER.parseFrom(input);
+    }
+    public static org.apache.htrace.protobuf.generated.SpanProtos.Span parseFrom(
+        com.google.protobuf.CodedInputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws java.io.IOException {
+      return PARSER.parseFrom(input, extensionRegistry);
+    }
+
+    public static Builder newBuilder() { return Builder.create(); }
+    public Builder newBuilderForType() { return newBuilder(); }
+    public static Builder newBuilder(org.apache.htrace.protobuf.generated.SpanProtos.Span prototype) {
+      return newBuilder().mergeFrom(prototype);
+    }
+    public Builder toBuilder() { return newBuilder(this); }
+
+    @java.lang.Override
+    protected Builder newBuilderForType(
+        com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+      Builder builder = new Builder(parent);
+      return builder;
+    }
+    /**
+     * Protobuf type {@code Span}
+     */
+    public static final class Builder extends
+        com.google.protobuf.GeneratedMessage.Builder<Builder>
+       implements org.apache.htrace.protobuf.generated.SpanProtos.SpanOrBuilder {
+      public static final com.google.protobuf.Descriptors.Descriptor
+          getDescriptor() {
+        return org.apache.htrace.protobuf.generated.SpanProtos.internal_static_Span_descriptor;
+      }
+
+      protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+          internalGetFieldAccessorTable() {
+        return org.apache.htrace.protobuf.generated.SpanProtos.internal_static_Span_fieldAccessorTable
+            .ensureFieldAccessorsInitialized(
+                org.apache.htrace.protobuf.generated.SpanProtos.Span.class, org.apache.htrace.protobuf.generated.SpanProtos.Span.Builder.class);
+      }
+
+      // Construct using org.apache.htrace.protobuf.generated.SpanProtos.Span.newBuilder()
+      private Builder() {
+        maybeForceBuilderInitialization();
+      }
+
+      private Builder(
+          com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+        super(parent);
+        maybeForceBuilderInitialization();
+      }
+      private void maybeForceBuilderInitialization() {
+        if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+          getTimelineFieldBuilder();
+        }
+      }
+      private static Builder create() {
+        return new Builder();
+      }
+
+      public Builder clear() {
+        super.clear();
+        traceId_ = 0L;
+        bitField0_ = (bitField0_ & ~0x00000001);
+        parentId_ = 0L;
+        bitField0_ = (bitField0_ & ~0x00000002);
+        start_ = 0L;
+        bitField0_ = (bitField0_ & ~0x00000004);
+        stop_ = 0L;
+        bitField0_ = (bitField0_ & ~0x00000008);
+        spanId_ = 0L;
+        bitField0_ = (bitField0_ & ~0x00000010);
+        processId_ = "";
+        bitField0_ = (bitField0_ & ~0x00000020);
+        description_ = "";
+        bitField0_ = (bitField0_ & ~0x00000040);
+        if (timelineBuilder_ == null) {
+          timeline_ = java.util.Collections.emptyList();
+          bitField0_ = (bitField0_ & ~0x00000080);
+        } else {
+          timelineBuilder_.clear();
+        }
+        return this;
+      }
+
+      public Builder clone() {
+        return create().mergeFrom(buildPartial());
+      }
+
+      public com.google.protobuf.Descriptors.Descriptor
+          getDescriptorForType() {
+        return org.apache.htrace.protobuf.generated.SpanProtos.internal_static_Span_descriptor;
+      }
+
+      public org.apache.htrace.protobuf.generated.SpanProtos.Span getDefaultInstanceForType() {
+        return org.apache.htrace.protobuf.generated.SpanProtos.Span.getDefaultInstance();
+      }
+
+      public org.apache.htrace.protobuf.generated.SpanProtos.Span build() {
+        org.apache.htrace.protobuf.generated.SpanProtos.Span result = buildPartial();
+        if (!result.isInitialized()) {
+          throw newUninitializedMessageException(result);
+        }
+        return result;
+      }
+
+      public org.apache.htrace.protobuf.generated.SpanProtos.Span buildPartial() {
+        org.apache.htrace.protobuf.generated.SpanProtos.Span result = new org.apache.htrace.protobuf.generated.SpanProtos.Span(this);
+        int from_bitField0_ = bitField0_;
+        int to_bitField0_ = 0;
+        if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
+          to_bitField0_ |= 0x00000001;
+        }
+        result.traceId_ = traceId_;
+        if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
+          to_bitField0_ |= 0x00000002;
+        }
+        result.parentId_ = parentId_;
+        if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
+          to_bitField0_ |= 0x00000004;
+        }
+        result.start_ = start_;
+        if (((from_bitField0_ & 0x00000008) == 0x00000008)) {
+          to_bitField0_ |= 0x00000008;
+        }
+        result.stop_ = stop_;
+        if (((from_bitField0_ & 0x00000010) == 0x00000010)) {
+          to_bitField0_ |= 0x00000010;
+        }
+        result.spanId_ = spanId_;
+        if (((from_bitField0_ & 0x00000020) == 0x00000020)) {
+          to_bitField0_ |= 0x00000020;
+        }
+        result.processId_ = processId_;
+        if (((from_bitField0_ & 0x00000040) == 0x00000040)) {
+          to_bitField0_ |= 0x00000040;
+        }
+        result.description_ = description_;
+        if (timelineBuilder_ == null) {
+          if (((bitField0_ & 0x00000080) == 0x00000080)) {
+            timeline_ = java.util.Collections.unmodifiableList(timeline_);
+            bitField0_ = (bitField0_ & ~0x00000080);
+          }
+          result.timeline_ = timeline_;
+        } else {
+          result.timeline_ = timelineBuilder_.build();
+        }
+        result.bitField0_ = to_bitField0_;
+        onBuilt();
+        return result;
+      }
+
+      public Builder mergeFrom(com.google.protobuf.Message other) {
+        if (other instanceof org.apache.htrace.protobuf.generated.SpanProtos.Span) {
+          return mergeFrom((org.apache.htrace.protobuf.generated.SpanProtos.Span)other);
+        } else {
+          super.mergeFrom(other);
+          return this;
+        }
+      }
+
+      public Builder mergeFrom(org.apache.htrace.protobuf.generated.SpanProtos.Span other) {
+        if (other == org.apache.htrace.protobuf.generated.SpanProtos.Span.getDefaultInstance()) return this;
+        if (other.hasTraceId()) {
+          setTraceId(other.getTraceId());
+        }
+        if (other.hasParentId()) {
+          setParentId(other.getParentId());
+        }
+        if (other.hasStart()) {
+          setStart(other.getStart());
+        }
+        if (other.hasStop()) {
+          setStop(other.getStop());
+        }
+        if (other.hasSpanId()) {
+          setSpanId(other.getSpanId());
+        }
+        if (other.hasProcessId()) {
+          bitField0_ |= 0x00000020;
+          processId_ = other.processId_;
+          onChanged();
+        }
+        if (other.hasDescription()) {
+          bitField0_ |= 0x00000040;
+          description_ = other.description_;
+          onChanged();
+        }
+        if (timelineBuilder_ == null) {
+          if (!other.timeline_.isEmpty()) {
+            if (timeline_.isEmpty()) {
+              timeline_ = other.timeline_;
+              bitField0_ = (bitField0_ & ~0x00000080);
+            } else {
+              ensureTimelineIsMutable();
+              timeline_.addAll(other.timeline_);
+            }
+            onChanged();
+          }
+        } else {
+          if (!other.timeline_.isEmpty()) {
+            if (timelineBuilder_.isEmpty()) {
+              timelineBuilder_.dispose();
+              timelineBuilder_ = null;
+              timeline_ = other.timeline_;
+              bitField0_ = (bitField0_ & ~0x00000080);
+              timelineBuilder_ = 
+                com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
+                   getTimelineFieldBuilder() : null;
+            } else {
+              timelineBuilder_.addAllMessages(other.timeline_);
+            }
+          }
+        }
+        this.mergeUnknownFields(other.getUnknownFields());
+        return this;
+      }
+
+      public final boolean isInitialized() {
+        if (!hasTraceId()) {
+          
+          return false;
+        }
+        if (!hasParentId()) {
+          
+          return false;
+        }
+        if (!hasStart()) {
+          
+          return false;
+        }
+        if (!hasStop()) {
+          
+          return false;
+        }
+        if (!hasSpanId()) {
+          
+          return false;
+        }
+        if (!hasProcessId()) {
+          
+          return false;
+        }
+        if (!hasDescription()) {
+          
+          return false;
+        }
+        for (int i = 0; i < getTimelineCount(); i++) {
+          if (!getTimeline(i).isInitialized()) {
+            
+            return false;
+          }
+        }
+        return true;
+      }
+
+      public Builder mergeFrom(
+          com.google.protobuf.CodedInputStream input,
+          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+          throws java.io.IOException {
+        org.apache.htrace.protobuf.generated.SpanProtos.Span parsedMessage = null;
+        try {
+          parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
+        } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+          parsedMessage = (org.apache.htrace.protobuf.generated.SpanProtos.Span) e.getUnfinishedMessage();
+          throw e;
+        } finally {
+          if (parsedMessage != null) {
+            mergeFrom(parsedMessage);
+          }
+        }
+        return this;
+      }
+      private int bitField0_;
+
+      // required int64 trace_id = 1;
+      private long traceId_ ;
+      /**
+       * <code>required int64 trace_id = 1;</code>
+       */
+      public boolean hasTraceId() {
+        return ((bitField0_ & 0x00000001) == 0x00000001);
+      }
+      /**
+       * <code>required int64 trace_id = 1;</code>
+       */
+      public long getTraceId() {
+        return traceId_;
+      }
+      /**
+       * <code>required int64 trace_id = 1;</code>
+       */
+      public Builder setTraceId(long value) {
+        bitField0_ |= 0x00000001;
+        traceId_ = value;
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>required int64 trace_id = 1;</code>
+       */
+      public Builder clearTraceId() {
+        bitField0_ = (bitField0_ & ~0x00000001);
+        traceId_ = 0L;
+        onChanged();
+        return this;
+      }
+
+      // required int64 parent_id = 2;
+      private long parentId_ ;
+      /**
+       * <code>required int64 parent_id = 2;</code>
+       */
+      public boolean hasParentId() {
+        return ((bitField0_ & 0x00000002) == 0x00000002);
+      }
+      /**
+       * <code>required int64 parent_id = 2;</code>
+       */
+      public long getParentId() {
+        return parentId_;
+      }
+      /**
+       * <code>required int64 parent_id = 2;</code>
+       */
+      public Builder setParentId(long value) {
+        bitField0_ |= 0x00000002;
+        parentId_ = value;
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>required int64 parent_id = 2;</code>
+       */
+      public Builder clearParentId() {
+        bitField0_ = (bitField0_ & ~0x00000002);
+        parentId_ = 0L;
+        onChanged();
+        return this;
+      }
+
+      // required int64 start = 3;
+      private long start_ ;
+      /**
+       * <code>required int64 start = 3;</code>
+       */
+      public boolean hasStart() {
+        return ((bitField0_ & 0x00000004) == 0x00000004);
+      }
+      /**
+       * <code>required int64 start = 3;</code>
+       */
+      public long getStart() {
+        return start_;
+      }
+      /**
+       * <code>required int64 start = 3;</code>
+       */
+      public Builder setStart(long value) {
+        bitField0_ |= 0x00000004;
+        start_ = value;
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>required int64 start = 3;</code>
+       */
+      public Builder clearStart() {
+        bitField0_ = (bitField0_ & ~0x00000004);
+        start_ = 0L;
+        onChanged();
+        return this;
+      }
+
+      // required int64 stop = 4;
+      private long stop_ ;
+      /**
+       * <code>required int64 stop = 4;</code>
+       */
+      public boolean hasStop() {
+        return ((bitField0_ & 0x00000008) == 0x00000008);
+      }
+      /**
+       * <code>required int64 stop = 4;</code>
+       */
+      public long getStop() {
+        return stop_;
+      }
+      /**
+       * <code>required int64 stop = 4;</code>
+       */
+      public Builder setStop(long value) {
+        bitField0_ |= 0x00000008;
+        stop_ = value;
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>required int64 stop = 4;</code>
+       */
+      public Builder clearStop() {
+        bitField0_ = (bitField0_ & ~0x00000008);
+        stop_ = 0L;
+        onChanged();
+        return this;
+      }
+
+      // required int64 span_id = 5;
+      private long spanId_ ;
+      /**
+       * <code>required int64 span_id = 5;</code>
+       */
+      public boolean hasSpanId() {
+        return ((bitField0_ & 0x00000010) == 0x00000010);
+      }
+      /**
+       * <code>required int64 span_id = 5;</code>
+       */
+      public long getSpanId() {
+        return spanId_;
+      }
+      /**
+       * <code>required int64 span_id = 5;</code>
+       */
+      public Builder setSpanId(long value) {
+        bitField0_ |= 0x00000010;
+        spanId_ = value;
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>required int64 span_id = 5;</code>
+       */
+      public Builder clearSpanId() {
+        bitField0_ = (bitField0_ & ~0x00000010);
+        spanId_ = 0L;
+        onChanged();
+        return this;
+      }
+
+      // required string process_id = 6;
+      private java.lang.Object processId_ = "";
+      /**
+       * <code>required string process_id = 6;</code>
+       */
+      public boolean hasProcessId() {
+        return ((bitField0_ & 0x00000020) == 0x00000020);
+      }
+      /**
+       * <code>required string process_id = 6;</code>
+       */
+      public java.lang.String getProcessId() {
+        java.lang.Object ref = processId_;
+        if (!(ref instanceof java.lang.String)) {
+          java.lang.String s = ((com.google.protobuf.ByteString) ref)
+              .toStringUtf8();
+          processId_ = s;
+          return s;
+        } else {
+          return (java.lang.String) ref;
+        }
+      }
+      /**
+       * <code>required string process_id = 6;</code>
+       */
+      public com.google.protobuf.ByteString
+          getProcessIdBytes() {
+        java.lang.Object ref = processId_;
+        if (ref instanceof String) {
+          com.google.protobuf.ByteString b = 
+              com.google.protobuf.ByteString.copyFromUtf8(
+                  (java.lang.String) ref);
+          processId_ = b;
+          return b;
+        } else {
+          return (com.google.protobuf.ByteString) ref;
+        }
+      }
+      /**
+       * <code>required string process_id = 6;</code>
+       */
+      public Builder setProcessId(
+          java.lang.String value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  bitField0_ |= 0x00000020;
+        processId_ = value;
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>required string process_id = 6;</code>
+       */
+      public Builder clearProcessId() {
+        bitField0_ = (bitField0_ & ~0x00000020);
+        processId_ = getDefaultInstance().getProcessId();
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>required string process_id = 6;</code>
+       */
+      public Builder setProcessIdBytes(
+          com.google.protobuf.ByteString value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  bitField0_ |= 0x00000020;
+        processId_ = value;
+        onChanged();
+        return this;
+      }
+
+      // required string description = 7;
+      private java.lang.Object description_ = "";
+      /**
+       * <code>required string description = 7;</code>
+       */
+      public boolean hasDescription() {
+        return ((bitField0_ & 0x00000040) == 0x00000040);
+      }
+      /**
+       * <code>required string description = 7;</code>
+       */
+      public java.lang.String getDescription() {
+        java.lang.Object ref = description_;
+        if (!(ref instanceof java.lang.String)) {
+          java.lang.String s = ((com.google.protobuf.ByteString) ref)
+              .toStringUtf8();
+          description_ = s;
+          return s;
+        } else {
+          return (java.lang.String) ref;
+        }
+      }
+      /**
+       * <code>required string description = 7;</code>
+       */
+      public com.google.protobuf.ByteString
+          getDescriptionBytes() {
+        java.lang.Object ref = description_;
+        if (ref instanceof String) {
+          com.google.protobuf.ByteString b = 
+              com.google.protobuf.ByteString.copyFromUtf8(
+                  (java.lang.String) ref);
+          description_ = b;
+          return b;
+        } else {
+          return (com.google.protobuf.ByteString) ref;
+        }
+      }
+      /**
+       * <code>required string description = 7;</code>
+       */
+      public Builder setDescription(
+          java.lang.String value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  bitField0_ |= 0x00000040;
+        description_ = value;
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>required string description = 7;</code>
+       */
+      public Builder clearDescription() {
+        bitField0_ = (bitField0_ & ~0x00000040);
+        description_ = getDefaultInstance().getDescription();
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>required string description = 7;</code>
+       */
+      public Builder setDescriptionBytes(
+          com.google.protobuf.ByteString value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  bitField0_ |= 0x00000040;
+        description_ = value;
+        onChanged();
+        return this;
+      }
+
+      // repeated .TimelineAnnotation timeline = 8;
+      private java.util.List<org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation> timeline_ =
+        java.util.Collections.emptyList();
+      private void ensureTimelineIsMutable() {
+        if (!((bitField0_ & 0x00000080) == 0x00000080)) {
+          timeline_ = new java.util.ArrayList<org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation>(timeline_);
+          bitField0_ |= 0x00000080;
+         }
+      }
+
+      private com.google.protobuf.RepeatedFieldBuilder<
+          org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotationOrBuilder> timelineBuilder_;
+
+      /**
+       * <code>repeated .TimelineAnnotation timeline = 8;</code>
+       */
+      public java.util.List<org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation> getTimelineList() {
+        if (timelineBuilder_ == null) {
+          return java.util.Collections.unmodifiableList(timeline_);
+        } else {
+          return timelineBuilder_.getMessageList();
+        }
+      }
+      /**
+       * <code>repeated .TimelineAnnotation timeline = 8;</code>
+       */
+      public int getTimelineCount() {
+        if (timelineBuilder_ == null) {
+          return timeline_.size();
+        } else {
+          return timelineBuilder_.getCount();
+        }
+      }
+      /**
+       * <code>repeated .TimelineAnnotation timeline = 8;</code>
+       */
+      public org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation getTimeline(int index) {
+        if (timelineBuilder_ == null) {
+          return timeline_.get(index);
+        } else {
+          return timelineBuilder_.getMessage(index);
+        }
+      }
+      /**
+       * <code>repeated .TimelineAnnotation timeline = 8;</code>
+       */
+      public Builder setTimeline(
+          int index, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation value) {
+        if (timelineBuilder_ == null) {
+          if (value == null) {
+            throw new NullPointerException();
+          }
+          ensureTimelineIsMutable();
+          timeline_.set(index, value);
+          onChanged();
+        } else {
+          timelineBuilder_.setMessage(index, value);
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .TimelineAnnotation timeline = 8;</code>
+       */
+      public Builder setTimeline(
+          int index, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder builderForValue) {
+        if (timelineBuilder_ == null) {
+          ensureTimelineIsMutable();
+          timeline_.set(index, builderForValue.build());
+          onChanged();
+        } else {
+          timelineBuilder_.setMessage(index, builderForValue.build());
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .TimelineAnnotation timeline = 8;</code>
+       */
+      public Builder addTimeline(org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation value) {
+        if (timelineBuilder_ == null) {
+          if (value == null) {
+            throw new NullPointerException();
+          }
+          ensureTimelineIsMutable();
+          timeline_.add(value);
+          onChanged();
+        } else {
+          timelineBuilder_.addMessage(value);
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .TimelineAnnotation timeline = 8;</code>
+       */
+      public Builder addTimeline(
+          int index, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation value) {
+        if (timelineBuilder_ == null) {
+          if (value == null) {
+            throw new NullPointerException();
+          }
+          ensureTimelineIsMutable();
+          timeline_.add(index, value);
+          onChanged();
+        } else {
+          timelineBuilder_.addMessage(index, value);
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .TimelineAnnotation timeline = 8;</code>
+       */
+      public Builder addTimeline(
+          org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder builderForValue) {
+        if (timelineBuilder_ == null) {
+          ensureTimelineIsMutable();
+          timeline_.add(builderForValue.build());
+          onChanged();
+        } else {
+          timelineBuilder_.addMessage(builderForValue.build());
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .TimelineAnnotation timeline = 8;</code>
+       */
+      public Builder addTimeline(
+          int index, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder builderForValue) {
+        if (timelineBuilder_ == null) {
+          ensureTimelineIsMutable();
+          timeline_.add(index, builderForValue.build());
+          onChanged();
+        } else {
+          timelineBuilder_.addMessage(index, builderForValue.build());
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .TimelineAnnotation timeline = 8;</code>
+       */
+      public Builder addAllTimeline(
+          java.lang.Iterable<? extends org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation> values) {
+        if (timelineBuilder_ == null) {
+          ensureTimelineIsMutable();
+          super.addAll(values, timeline_);
+          onChanged();
+        } else {
+          timelineBuilder_.addAllMessages(values);
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .TimelineAnnotation timeline = 8;</code>
+       */
+      public Builder clearTimeline() {
+        if (timelineBuilder_ == null) {
+          timeline_ = java.util.Collections.emptyList();
+          bitField0_ = (bitField0_ & ~0x00000080);
+          onChanged();
+        } else {
+          timelineBuilder_.clear();
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .TimelineAnnotation timeline = 8;</code>
+       */
+      public Builder removeTimeline(int index) {
+        if (timelineBuilder_ == null) {
+          ensureTimelineIsMutable();
+          timeline_.remove(index);
+          onChanged();
+        } else {
+          timelineBuilder_.remove(index);
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .TimelineAnnotation timeline = 8;</code>
+       */
+      public org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder getTimelineBuilder(
+          int index) {
+        return getTimelineFieldBuilder().getBuilder(index);
+      }
+      /**
+       * <code>repeated .TimelineAnnotation timeline = 8;</code>
+       */
+      public org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotationOrBuilder getTimelineOrBuilder(
+          int index) {
+        if (timelineBuilder_ == null) {
+          return timeline_.get(index);  } else {
+          return timelineBuilder_.getMessageOrBuilder(index);
+        }
+      }
+      /**
+       * <code>repeated .TimelineAnnotation timeline = 8;</code>
+       */
+      public java.util.List<? extends org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotationOrBuilder> 
+           getTimelineOrBuilderList() {
+        if (timelineBuilder_ != null) {
+          return timelineBuilder_.getMessageOrBuilderList();
+        } else {
+          return java.util.Collections.unmodifiableList(timeline_);
+        }
+      }
+      /**
+       * <code>repeated .TimelineAnnotation timeline = 8;</code>
+       */
+      public org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder addTimelineBuilder() {
+        return getTimelineFieldBuilder().addBuilder(
+            org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.getDefaultInstance());
+      }
+      /**
+       * <code>repeated .TimelineAnnotation timeline = 8;</code>
+       */
+      public org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder addTimelineBuilder(
+          int index) {
+        return getTimelineFieldBuilder().addBuilder(
+            index, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.getDefaultInstance());
+      }
+      /**
+       * <code>repeated .TimelineAnnotation timeline = 8;</code>
+       */
+      public java.util.List<org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder> 
+           getTimelineBuilderList() {
+        return getTimelineFieldBuilder().getBuilderList();
+      }
+      private com.google.protobuf.RepeatedFieldBuilder<
+          org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotationOrBuilder> 
+          getTimelineFieldBuilder() {
+        if (timelineBuilder_ == null) {
+          timelineBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
+              org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotationOrBuilder>(
+                  timeline_,
+                  ((bitField0_ & 0x00000080) == 0x00000080),
+                  getParentForChildren(),
+                  isClean());
+          timeline_ = null;
+        }
+        return timelineBuilder_;
+      }
+
+      // @@protoc_insertion_point(builder_scope:Span)
+    }
+
+    static {
+      defaultInstance = new Span(true);
+      defaultInstance.initFields();
+    }
+
+    // @@protoc_insertion_point(class_scope:Span)
+  }
+
+  private static com.google.protobuf.Descriptors.Descriptor
+    internal_static_TimelineAnnotation_descriptor;
+  private static
+    com.google.protobuf.GeneratedMessage.FieldAccessorTable
+      internal_static_TimelineAnnotation_fieldAccessorTable;
+  private static com.google.protobuf.Descriptors.Descriptor
+    internal_static_Span_descriptor;
+  private static
+    com.google.protobuf.GeneratedMessage.FieldAccessorTable
+      internal_static_Span_fieldAccessorTable;
+
+  public static com.google.protobuf.Descriptors.FileDescriptor
+      getDescriptor() {
+    return descriptor;
+  }
+  private static com.google.protobuf.Descriptors.FileDescriptor
+      descriptor;
+  static {
+    java.lang.String[] descriptorData = {
+      "\n\nSpan.proto\"3\n\022TimelineAnnotation\022\014\n\004ti" +
+      "me\030\001 \002(\003\022\017\n\007message\030\002 \002(\t\"\251\001\n\004Span\022\020\n\010tr" +
+      "ace_id\030\001 \002(\003\022\021\n\tparent_id\030\002 \002(\003\022\r\n\005start" +
+      "\030\003 \002(\003\022\014\n\004stop\030\004 \002(\003\022\017\n\007span_id\030\005 \002(\003\022\022\n" +
+      "\nprocess_id\030\006 \002(\t\022\023\n\013description\030\007 \002(\t\022%" +
+      "\n\010timeline\030\010 \003(\0132\023.TimelineAnnotationB0\n" +
+      "\035org.htrace.protobuf.generatedB\nSpanProt" +
+      "osH\001\240\001\001"
+    };
+    com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
+      new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
+        public com.google.protobuf.ExtensionRegistry assignDescriptors(
+            com.google.protobuf.Descriptors.FileDescriptor root) {
+          descriptor = root;
+          internal_static_TimelineAnnotation_descriptor =
+            getDescriptor().getMessageTypes().get(0);
+          internal_static_TimelineAnnotation_fieldAccessorTable = new
+            com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+              internal_static_TimelineAnnotation_descriptor,
+              new java.lang.String[] { "Time", "Message", });
+          internal_static_Span_descriptor =
+            getDescriptor().getMessageTypes().get(1);
+          internal_static_Span_fieldAccessorTable = new
+            com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+              internal_static_Span_descriptor,
+              new java.lang.String[] { "TraceId", "ParentId", "Start", "Stop", "SpanId", "ProcessId", "Description", "Timeline", });
+          return null;
+        }
+      };
+    com.google.protobuf.Descriptors.FileDescriptor
+      .internalBuildGeneratedFileFrom(descriptorData,
+        new com.google.protobuf.Descriptors.FileDescriptor[] {
+        }, assigner);
+  }
+
+  // @@protoc_insertion_point(outer_class_scope)
+}

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6752709e/htrace-kudu/src/main/protobuf/Span.proto
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/protobuf/Span.proto b/htrace-kudu/src/main/protobuf/Span.proto
new file mode 100644
index 0000000..e8dc369
--- /dev/null
+++ b/htrace-kudu/src/main/protobuf/Span.proto
@@ -0,0 +1,38 @@
+/**
+ * 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.
+ */
+
+option java_package = "org.apache.htrace.protobuf.generated";
+option java_outer_classname = "SpanProtos";
+option java_generate_equals_and_hash = true;
+option optimize_for = SPEED;
+
+message TimelineAnnotation {
+  required int64 time = 1;
+  required string message = 2;
+}
+
+message Span {
+  required int64 trace_id = 1;
+  required int64 parent_id = 2;
+  required int64 start = 3;
+  required int64 stop = 4;
+  required int64 span_id = 5;
+  required string process_id = 6;
+  required string description = 7;
+  repeated TimelineAnnotation timeline = 8;
+}

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6752709e/htrace-kudu/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/test/resources/log4j.properties b/htrace-kudu/src/test/resources/log4j.properties
new file mode 100644
index 0000000..416c975
--- /dev/null
+++ b/htrace-kudu/src/test/resources/log4j.properties
@@ -0,0 +1,25 @@
+# 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.
+
+# By default, everything goes to console and file
+log4j.rootLogger=WARN, A1
+
+# A1 is set to be a ConsoleAppender.
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
+log4j.appender.A1.ImmediateFlush=true
+
+log4j.logger.org.apache.htrace=INFO, A1

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6752709e/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 932f29a..879c8f1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -35,6 +35,7 @@ language governing permissions and limitations under the License. -->
     <module>htrace-hbase</module>
     <module>htrace-flume</module>
     <module>htrace-htraced</module>
+    <module>htrace-kudu</module>
   </modules>
 
   <licenses>


[04/12] incubator-htrace git commit: removing hardcoded file system location

Posted by le...@apache.org.
removing hardcoded file system location


Project: http://git-wip-us.apache.org/repos/asf/incubator-htrace/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-htrace/commit/5d38e876
Tree: http://git-wip-us.apache.org/repos/asf/incubator-htrace/tree/5d38e876
Diff: http://git-wip-us.apache.org/repos/asf/incubator-htrace/diff/5d38e876

Branch: refs/heads/master
Commit: 5d38e876d1f4dc400e2783a9d26fa76ef6235023
Parents: be4f53c
Author: Nisala Nirmana <ni...@gmail.com>
Authored: Mon Jul 18 02:21:00 2016 +0530
Committer: Nisala Nirmana <ni...@gmail.com>
Committed: Mon Jul 18 02:21:00 2016 +0530

----------------------------------------------------------------------
 .../src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/5d38e876/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java b/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java
index 99a2839..e045eba 100644
--- a/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java
+++ b/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java
@@ -46,7 +46,7 @@ import java.util.List;
 public class TestKuduSpanReceiver extends BaseKuduTest {
 
   private static final String BIN_DIR_PROP = "binDir";
-  private static final String BIN_DIR_PROP_DEFAULT = "/home/djkevincr/poc/incubator-kudu/build/release/bin";
+  private static final String BIN_DIR_PROP_DEFAULT = "../build/release/bin";
 
   @BeforeClass
   public static void setUpBeforeClass() throws Exception {


[06/12] incubator-htrace git commit: adding colin review changes to span receiver

Posted by le...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/a6ca3ccf/htrace-kudu/src/main/java/org/apache/htrace/protobuf/generated/SpanProtos.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/protobuf/generated/SpanProtos.java b/htrace-kudu/src/main/java/org/apache/htrace/protobuf/generated/SpanProtos.java
deleted file mode 100644
index 98b8adb..0000000
--- a/htrace-kudu/src/main/java/org/apache/htrace/protobuf/generated/SpanProtos.java
+++ /dev/null
@@ -1,2241 +0,0 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: Span.proto
-
-package org.apache.htrace.protobuf.generated;
-
-public final class SpanProtos {
-  private SpanProtos() {}
-  public static void registerAllExtensions(
-      com.google.protobuf.ExtensionRegistry registry) {
-  }
-  public interface TimelineAnnotationOrBuilder
-      extends com.google.protobuf.MessageOrBuilder {
-
-    // required int64 time = 1;
-    /**
-     * <code>required int64 time = 1;</code>
-     */
-    boolean hasTime();
-    /**
-     * <code>required int64 time = 1;</code>
-     */
-    long getTime();
-
-    // required string message = 2;
-    /**
-     * <code>required string message = 2;</code>
-     */
-    boolean hasMessage();
-    /**
-     * <code>required string message = 2;</code>
-     */
-    java.lang.String getMessage();
-    /**
-     * <code>required string message = 2;</code>
-     */
-    com.google.protobuf.ByteString
-        getMessageBytes();
-  }
-  /**
-   * Protobuf type {@code TimelineAnnotation}
-   */
-  public static final class TimelineAnnotation extends
-      com.google.protobuf.GeneratedMessage
-      implements TimelineAnnotationOrBuilder {
-    // Use TimelineAnnotation.newBuilder() to construct.
-    private TimelineAnnotation(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
-      super(builder);
-      this.unknownFields = builder.getUnknownFields();
-    }
-    private TimelineAnnotation(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
-
-    private static final TimelineAnnotation defaultInstance;
-    public static TimelineAnnotation getDefaultInstance() {
-      return defaultInstance;
-    }
-
-    public TimelineAnnotation getDefaultInstanceForType() {
-      return defaultInstance;
-    }
-
-    private final com.google.protobuf.UnknownFieldSet unknownFields;
-    @java.lang.Override
-    public final com.google.protobuf.UnknownFieldSet
-        getUnknownFields() {
-      return this.unknownFields;
-    }
-    private TimelineAnnotation(
-        com.google.protobuf.CodedInputStream input,
-        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
-        throws com.google.protobuf.InvalidProtocolBufferException {
-      initFields();
-      int mutable_bitField0_ = 0;
-      com.google.protobuf.UnknownFieldSet.Builder unknownFields =
-          com.google.protobuf.UnknownFieldSet.newBuilder();
-      try {
-        boolean done = false;
-        while (!done) {
-          int tag = input.readTag();
-          switch (tag) {
-            case 0:
-              done = true;
-              break;
-            default: {
-              if (!parseUnknownField(input, unknownFields,
-                                     extensionRegistry, tag)) {
-                done = true;
-              }
-              break;
-            }
-            case 8: {
-              bitField0_ |= 0x00000001;
-              time_ = input.readInt64();
-              break;
-            }
-            case 18: {
-              bitField0_ |= 0x00000002;
-              message_ = input.readBytes();
-              break;
-            }
-          }
-        }
-      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
-        throw e.setUnfinishedMessage(this);
-      } catch (java.io.IOException e) {
-        throw new com.google.protobuf.InvalidProtocolBufferException(
-            e.getMessage()).setUnfinishedMessage(this);
-      } finally {
-        this.unknownFields = unknownFields.build();
-        makeExtensionsImmutable();
-      }
-    }
-    public static final com.google.protobuf.Descriptors.Descriptor
-        getDescriptor() {
-      return org.apache.htrace.protobuf.generated.SpanProtos.internal_static_TimelineAnnotation_descriptor;
-    }
-
-    protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
-        internalGetFieldAccessorTable() {
-      return org.apache.htrace.protobuf.generated.SpanProtos.internal_static_TimelineAnnotation_fieldAccessorTable
-          .ensureFieldAccessorsInitialized(
-              org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.class, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder.class);
-    }
-
-    public static com.google.protobuf.Parser<TimelineAnnotation> PARSER =
-        new com.google.protobuf.AbstractParser<TimelineAnnotation>() {
-      public TimelineAnnotation parsePartialFrom(
-          com.google.protobuf.CodedInputStream input,
-          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
-          throws com.google.protobuf.InvalidProtocolBufferException {
-        return new TimelineAnnotation(input, extensionRegistry);
-      }
-    };
-
-    @java.lang.Override
-    public com.google.protobuf.Parser<TimelineAnnotation> getParserForType() {
-      return PARSER;
-    }
-
-    private int bitField0_;
-    // required int64 time = 1;
-    public static final int TIME_FIELD_NUMBER = 1;
-    private long time_;
-    /**
-     * <code>required int64 time = 1;</code>
-     */
-    public boolean hasTime() {
-      return ((bitField0_ & 0x00000001) == 0x00000001);
-    }
-    /**
-     * <code>required int64 time = 1;</code>
-     */
-    public long getTime() {
-      return time_;
-    }
-
-    // required string message = 2;
-    public static final int MESSAGE_FIELD_NUMBER = 2;
-    private java.lang.Object message_;
-    /**
-     * <code>required string message = 2;</code>
-     */
-    public boolean hasMessage() {
-      return ((bitField0_ & 0x00000002) == 0x00000002);
-    }
-    /**
-     * <code>required string message = 2;</code>
-     */
-    public java.lang.String getMessage() {
-      java.lang.Object ref = message_;
-      if (ref instanceof java.lang.String) {
-        return (java.lang.String) ref;
-      } else {
-        com.google.protobuf.ByteString bs = 
-            (com.google.protobuf.ByteString) ref;
-        java.lang.String s = bs.toStringUtf8();
-        if (bs.isValidUtf8()) {
-          message_ = s;
-        }
-        return s;
-      }
-    }
-    /**
-     * <code>required string message = 2;</code>
-     */
-    public com.google.protobuf.ByteString
-        getMessageBytes() {
-      java.lang.Object ref = message_;
-      if (ref instanceof java.lang.String) {
-        com.google.protobuf.ByteString b = 
-            com.google.protobuf.ByteString.copyFromUtf8(
-                (java.lang.String) ref);
-        message_ = b;
-        return b;
-      } else {
-        return (com.google.protobuf.ByteString) ref;
-      }
-    }
-
-    private void initFields() {
-      time_ = 0L;
-      message_ = "";
-    }
-    private byte memoizedIsInitialized = -1;
-    public final boolean isInitialized() {
-      byte isInitialized = memoizedIsInitialized;
-      if (isInitialized != -1) return isInitialized == 1;
-
-      if (!hasTime()) {
-        memoizedIsInitialized = 0;
-        return false;
-      }
-      if (!hasMessage()) {
-        memoizedIsInitialized = 0;
-        return false;
-      }
-      memoizedIsInitialized = 1;
-      return true;
-    }
-
-    public void writeTo(com.google.protobuf.CodedOutputStream output)
-                        throws java.io.IOException {
-      getSerializedSize();
-      if (((bitField0_ & 0x00000001) == 0x00000001)) {
-        output.writeInt64(1, time_);
-      }
-      if (((bitField0_ & 0x00000002) == 0x00000002)) {
-        output.writeBytes(2, getMessageBytes());
-      }
-      getUnknownFields().writeTo(output);
-    }
-
-    private int memoizedSerializedSize = -1;
-    public int getSerializedSize() {
-      int size = memoizedSerializedSize;
-      if (size != -1) return size;
-
-      size = 0;
-      if (((bitField0_ & 0x00000001) == 0x00000001)) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeInt64Size(1, time_);
-      }
-      if (((bitField0_ & 0x00000002) == 0x00000002)) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeBytesSize(2, getMessageBytes());
-      }
-      size += getUnknownFields().getSerializedSize();
-      memoizedSerializedSize = size;
-      return size;
-    }
-
-    private static final long serialVersionUID = 0L;
-    @java.lang.Override
-    protected java.lang.Object writeReplace()
-        throws java.io.ObjectStreamException {
-      return super.writeReplace();
-    }
-
-    @java.lang.Override
-    public boolean equals(final java.lang.Object obj) {
-      if (obj == this) {
-       return true;
-      }
-      if (!(obj instanceof org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation)) {
-        return super.equals(obj);
-      }
-      org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation other = (org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation) obj;
-
-      boolean result = true;
-      result = result && (hasTime() == other.hasTime());
-      if (hasTime()) {
-        result = result && (getTime()
-            == other.getTime());
-      }
-      result = result && (hasMessage() == other.hasMessage());
-      if (hasMessage()) {
-        result = result && getMessage()
-            .equals(other.getMessage());
-      }
-      result = result &&
-          getUnknownFields().equals(other.getUnknownFields());
-      return result;
-    }
-
-    private int memoizedHashCode = 0;
-    @java.lang.Override
-    public int hashCode() {
-      if (memoizedHashCode != 0) {
-        return memoizedHashCode;
-      }
-      int hash = 41;
-      hash = (19 * hash) + getDescriptorForType().hashCode();
-      if (hasTime()) {
-        hash = (37 * hash) + TIME_FIELD_NUMBER;
-        hash = (53 * hash) + hashLong(getTime());
-      }
-      if (hasMessage()) {
-        hash = (37 * hash) + MESSAGE_FIELD_NUMBER;
-        hash = (53 * hash) + getMessage().hashCode();
-      }
-      hash = (29 * hash) + getUnknownFields().hashCode();
-      memoizedHashCode = hash;
-      return hash;
-    }
-
-    public static org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation parseFrom(
-        com.google.protobuf.ByteString data)
-        throws com.google.protobuf.InvalidProtocolBufferException {
-      return PARSER.parseFrom(data);
-    }
-    public static org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation parseFrom(
-        com.google.protobuf.ByteString data,
-        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
-        throws com.google.protobuf.InvalidProtocolBufferException {
-      return PARSER.parseFrom(data, extensionRegistry);
-    }
-    public static org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation parseFrom(byte[] data)
-        throws com.google.protobuf.InvalidProtocolBufferException {
-      return PARSER.parseFrom(data);
-    }
-    public static org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation parseFrom(
-        byte[] data,
-        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
-        throws com.google.protobuf.InvalidProtocolBufferException {
-      return PARSER.parseFrom(data, extensionRegistry);
-    }
-    public static org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation parseFrom(java.io.InputStream input)
-        throws java.io.IOException {
-      return PARSER.parseFrom(input);
-    }
-    public static org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation parseFrom(
-        java.io.InputStream input,
-        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
-        throws java.io.IOException {
-      return PARSER.parseFrom(input, extensionRegistry);
-    }
-    public static org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation parseDelimitedFrom(java.io.InputStream input)
-        throws java.io.IOException {
-      return PARSER.parseDelimitedFrom(input);
-    }
-    public static org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation parseDelimitedFrom(
-        java.io.InputStream input,
-        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
-        throws java.io.IOException {
-      return PARSER.parseDelimitedFrom(input, extensionRegistry);
-    }
-    public static org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation parseFrom(
-        com.google.protobuf.CodedInputStream input)
-        throws java.io.IOException {
-      return PARSER.parseFrom(input);
-    }
-    public static org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation parseFrom(
-        com.google.protobuf.CodedInputStream input,
-        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
-        throws java.io.IOException {
-      return PARSER.parseFrom(input, extensionRegistry);
-    }
-
-    public static Builder newBuilder() { return Builder.create(); }
-    public Builder newBuilderForType() { return newBuilder(); }
-    public static Builder newBuilder(org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation prototype) {
-      return newBuilder().mergeFrom(prototype);
-    }
-    public Builder toBuilder() { return newBuilder(this); }
-
-    @java.lang.Override
-    protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessage.BuilderParent parent) {
-      Builder builder = new Builder(parent);
-      return builder;
-    }
-    /**
-     * Protobuf type {@code TimelineAnnotation}
-     */
-    public static final class Builder extends
-        com.google.protobuf.GeneratedMessage.Builder<Builder>
-       implements org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotationOrBuilder {
-      public static final com.google.protobuf.Descriptors.Descriptor
-          getDescriptor() {
-        return org.apache.htrace.protobuf.generated.SpanProtos.internal_static_TimelineAnnotation_descriptor;
-      }
-
-      protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
-          internalGetFieldAccessorTable() {
-        return org.apache.htrace.protobuf.generated.SpanProtos.internal_static_TimelineAnnotation_fieldAccessorTable
-            .ensureFieldAccessorsInitialized(
-                org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.class, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder.class);
-      }
-
-      // Construct using org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.newBuilder()
-      private Builder() {
-        maybeForceBuilderInitialization();
-      }
-
-      private Builder(
-          com.google.protobuf.GeneratedMessage.BuilderParent parent) {
-        super(parent);
-        maybeForceBuilderInitialization();
-      }
-      private void maybeForceBuilderInitialization() {
-        if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
-        }
-      }
-      private static Builder create() {
-        return new Builder();
-      }
-
-      public Builder clear() {
-        super.clear();
-        time_ = 0L;
-        bitField0_ = (bitField0_ & ~0x00000001);
-        message_ = "";
-        bitField0_ = (bitField0_ & ~0x00000002);
-        return this;
-      }
-
-      public Builder clone() {
-        return create().mergeFrom(buildPartial());
-      }
-
-      public com.google.protobuf.Descriptors.Descriptor
-          getDescriptorForType() {
-        return org.apache.htrace.protobuf.generated.SpanProtos.internal_static_TimelineAnnotation_descriptor;
-      }
-
-      public org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation getDefaultInstanceForType() {
-        return org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.getDefaultInstance();
-      }
-
-      public org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation build() {
-        org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation result = buildPartial();
-        if (!result.isInitialized()) {
-          throw newUninitializedMessageException(result);
-        }
-        return result;
-      }
-
-      public org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation buildPartial() {
-        org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation result = new org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation(this);
-        int from_bitField0_ = bitField0_;
-        int to_bitField0_ = 0;
-        if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
-          to_bitField0_ |= 0x00000001;
-        }
-        result.time_ = time_;
-        if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
-          to_bitField0_ |= 0x00000002;
-        }
-        result.message_ = message_;
-        result.bitField0_ = to_bitField0_;
-        onBuilt();
-        return result;
-      }
-
-      public Builder mergeFrom(com.google.protobuf.Message other) {
-        if (other instanceof org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation) {
-          return mergeFrom((org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation)other);
-        } else {
-          super.mergeFrom(other);
-          return this;
-        }
-      }
-
-      public Builder mergeFrom(org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation other) {
-        if (other == org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.getDefaultInstance()) return this;
-        if (other.hasTime()) {
-          setTime(other.getTime());
-        }
-        if (other.hasMessage()) {
-          bitField0_ |= 0x00000002;
-          message_ = other.message_;
-          onChanged();
-        }
-        this.mergeUnknownFields(other.getUnknownFields());
-        return this;
-      }
-
-      public final boolean isInitialized() {
-        if (!hasTime()) {
-          
-          return false;
-        }
-        if (!hasMessage()) {
-          
-          return false;
-        }
-        return true;
-      }
-
-      public Builder mergeFrom(
-          com.google.protobuf.CodedInputStream input,
-          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
-          throws java.io.IOException {
-        org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation parsedMessage = null;
-        try {
-          parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
-        } catch (com.google.protobuf.InvalidProtocolBufferException e) {
-          parsedMessage = (org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation) e.getUnfinishedMessage();
-          throw e;
-        } finally {
-          if (parsedMessage != null) {
-            mergeFrom(parsedMessage);
-          }
-        }
-        return this;
-      }
-      private int bitField0_;
-
-      // required int64 time = 1;
-      private long time_ ;
-      /**
-       * <code>required int64 time = 1;</code>
-       */
-      public boolean hasTime() {
-        return ((bitField0_ & 0x00000001) == 0x00000001);
-      }
-      /**
-       * <code>required int64 time = 1;</code>
-       */
-      public long getTime() {
-        return time_;
-      }
-      /**
-       * <code>required int64 time = 1;</code>
-       */
-      public Builder setTime(long value) {
-        bitField0_ |= 0x00000001;
-        time_ = value;
-        onChanged();
-        return this;
-      }
-      /**
-       * <code>required int64 time = 1;</code>
-       */
-      public Builder clearTime() {
-        bitField0_ = (bitField0_ & ~0x00000001);
-        time_ = 0L;
-        onChanged();
-        return this;
-      }
-
-      // required string message = 2;
-      private java.lang.Object message_ = "";
-      /**
-       * <code>required string message = 2;</code>
-       */
-      public boolean hasMessage() {
-        return ((bitField0_ & 0x00000002) == 0x00000002);
-      }
-      /**
-       * <code>required string message = 2;</code>
-       */
-      public java.lang.String getMessage() {
-        java.lang.Object ref = message_;
-        if (!(ref instanceof java.lang.String)) {
-          java.lang.String s = ((com.google.protobuf.ByteString) ref)
-              .toStringUtf8();
-          message_ = s;
-          return s;
-        } else {
-          return (java.lang.String) ref;
-        }
-      }
-      /**
-       * <code>required string message = 2;</code>
-       */
-      public com.google.protobuf.ByteString
-          getMessageBytes() {
-        java.lang.Object ref = message_;
-        if (ref instanceof String) {
-          com.google.protobuf.ByteString b = 
-              com.google.protobuf.ByteString.copyFromUtf8(
-                  (java.lang.String) ref);
-          message_ = b;
-          return b;
-        } else {
-          return (com.google.protobuf.ByteString) ref;
-        }
-      }
-      /**
-       * <code>required string message = 2;</code>
-       */
-      public Builder setMessage(
-          java.lang.String value) {
-        if (value == null) {
-    throw new NullPointerException();
-  }
-  bitField0_ |= 0x00000002;
-        message_ = value;
-        onChanged();
-        return this;
-      }
-      /**
-       * <code>required string message = 2;</code>
-       */
-      public Builder clearMessage() {
-        bitField0_ = (bitField0_ & ~0x00000002);
-        message_ = getDefaultInstance().getMessage();
-        onChanged();
-        return this;
-      }
-      /**
-       * <code>required string message = 2;</code>
-       */
-      public Builder setMessageBytes(
-          com.google.protobuf.ByteString value) {
-        if (value == null) {
-    throw new NullPointerException();
-  }
-  bitField0_ |= 0x00000002;
-        message_ = value;
-        onChanged();
-        return this;
-      }
-
-      // @@protoc_insertion_point(builder_scope:TimelineAnnotation)
-    }
-
-    static {
-      defaultInstance = new TimelineAnnotation(true);
-      defaultInstance.initFields();
-    }
-
-    // @@protoc_insertion_point(class_scope:TimelineAnnotation)
-  }
-
-  public interface SpanOrBuilder
-      extends com.google.protobuf.MessageOrBuilder {
-
-    // required int64 trace_id = 1;
-    /**
-     * <code>required int64 trace_id = 1;</code>
-     */
-    boolean hasTraceId();
-    /**
-     * <code>required int64 trace_id = 1;</code>
-     */
-    long getTraceId();
-
-    // required int64 parent_id = 2;
-    /**
-     * <code>required int64 parent_id = 2;</code>
-     */
-    boolean hasParentId();
-    /**
-     * <code>required int64 parent_id = 2;</code>
-     */
-    long getParentId();
-
-    // required int64 start = 3;
-    /**
-     * <code>required int64 start = 3;</code>
-     */
-    boolean hasStart();
-    /**
-     * <code>required int64 start = 3;</code>
-     */
-    long getStart();
-
-    // required int64 stop = 4;
-    /**
-     * <code>required int64 stop = 4;</code>
-     */
-    boolean hasStop();
-    /**
-     * <code>required int64 stop = 4;</code>
-     */
-    long getStop();
-
-    // required int64 span_id = 5;
-    /**
-     * <code>required int64 span_id = 5;</code>
-     */
-    boolean hasSpanId();
-    /**
-     * <code>required int64 span_id = 5;</code>
-     */
-    long getSpanId();
-
-    // required string process_id = 6;
-    /**
-     * <code>required string process_id = 6;</code>
-     */
-    boolean hasProcessId();
-    /**
-     * <code>required string process_id = 6;</code>
-     */
-    java.lang.String getProcessId();
-    /**
-     * <code>required string process_id = 6;</code>
-     */
-    com.google.protobuf.ByteString
-        getProcessIdBytes();
-
-    // required string description = 7;
-    /**
-     * <code>required string description = 7;</code>
-     */
-    boolean hasDescription();
-    /**
-     * <code>required string description = 7;</code>
-     */
-    java.lang.String getDescription();
-    /**
-     * <code>required string description = 7;</code>
-     */
-    com.google.protobuf.ByteString
-        getDescriptionBytes();
-
-    // repeated .TimelineAnnotation timeline = 8;
-    /**
-     * <code>repeated .TimelineAnnotation timeline = 8;</code>
-     */
-    java.util.List<org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation> 
-        getTimelineList();
-    /**
-     * <code>repeated .TimelineAnnotation timeline = 8;</code>
-     */
-    org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation getTimeline(int index);
-    /**
-     * <code>repeated .TimelineAnnotation timeline = 8;</code>
-     */
-    int getTimelineCount();
-    /**
-     * <code>repeated .TimelineAnnotation timeline = 8;</code>
-     */
-    java.util.List<? extends org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotationOrBuilder> 
-        getTimelineOrBuilderList();
-    /**
-     * <code>repeated .TimelineAnnotation timeline = 8;</code>
-     */
-    org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotationOrBuilder getTimelineOrBuilder(
-        int index);
-  }
-  /**
-   * Protobuf type {@code Span}
-   */
-  public static final class Span extends
-      com.google.protobuf.GeneratedMessage
-      implements SpanOrBuilder {
-    // Use Span.newBuilder() to construct.
-    private Span(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
-      super(builder);
-      this.unknownFields = builder.getUnknownFields();
-    }
-    private Span(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
-
-    private static final Span defaultInstance;
-    public static Span getDefaultInstance() {
-      return defaultInstance;
-    }
-
-    public Span getDefaultInstanceForType() {
-      return defaultInstance;
-    }
-
-    private final com.google.protobuf.UnknownFieldSet unknownFields;
-    @java.lang.Override
-    public final com.google.protobuf.UnknownFieldSet
-        getUnknownFields() {
-      return this.unknownFields;
-    }
-    private Span(
-        com.google.protobuf.CodedInputStream input,
-        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
-        throws com.google.protobuf.InvalidProtocolBufferException {
-      initFields();
-      int mutable_bitField0_ = 0;
-      com.google.protobuf.UnknownFieldSet.Builder unknownFields =
-          com.google.protobuf.UnknownFieldSet.newBuilder();
-      try {
-        boolean done = false;
-        while (!done) {
-          int tag = input.readTag();
-          switch (tag) {
-            case 0:
-              done = true;
-              break;
-            default: {
-              if (!parseUnknownField(input, unknownFields,
-                                     extensionRegistry, tag)) {
-                done = true;
-              }
-              break;
-            }
-            case 8: {
-              bitField0_ |= 0x00000001;
-              traceId_ = input.readInt64();
-              break;
-            }
-            case 16: {
-              bitField0_ |= 0x00000002;
-              parentId_ = input.readInt64();
-              break;
-            }
-            case 24: {
-              bitField0_ |= 0x00000004;
-              start_ = input.readInt64();
-              break;
-            }
-            case 32: {
-              bitField0_ |= 0x00000008;
-              stop_ = input.readInt64();
-              break;
-            }
-            case 40: {
-              bitField0_ |= 0x00000010;
-              spanId_ = input.readInt64();
-              break;
-            }
-            case 50: {
-              bitField0_ |= 0x00000020;
-              processId_ = input.readBytes();
-              break;
-            }
-            case 58: {
-              bitField0_ |= 0x00000040;
-              description_ = input.readBytes();
-              break;
-            }
-            case 66: {
-              if (!((mutable_bitField0_ & 0x00000080) == 0x00000080)) {
-                timeline_ = new java.util.ArrayList<org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation>();
-                mutable_bitField0_ |= 0x00000080;
-              }
-              timeline_.add(input.readMessage(org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.PARSER, extensionRegistry));
-              break;
-            }
-          }
-        }
-      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
-        throw e.setUnfinishedMessage(this);
-      } catch (java.io.IOException e) {
-        throw new com.google.protobuf.InvalidProtocolBufferException(
-            e.getMessage()).setUnfinishedMessage(this);
-      } finally {
-        if (((mutable_bitField0_ & 0x00000080) == 0x00000080)) {
-          timeline_ = java.util.Collections.unmodifiableList(timeline_);
-        }
-        this.unknownFields = unknownFields.build();
-        makeExtensionsImmutable();
-      }
-    }
-    public static final com.google.protobuf.Descriptors.Descriptor
-        getDescriptor() {
-      return org.apache.htrace.protobuf.generated.SpanProtos.internal_static_Span_descriptor;
-    }
-
-    protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
-        internalGetFieldAccessorTable() {
-      return org.apache.htrace.protobuf.generated.SpanProtos.internal_static_Span_fieldAccessorTable
-          .ensureFieldAccessorsInitialized(
-              org.apache.htrace.protobuf.generated.SpanProtos.Span.class, org.apache.htrace.protobuf.generated.SpanProtos.Span.Builder.class);
-    }
-
-    public static com.google.protobuf.Parser<Span> PARSER =
-        new com.google.protobuf.AbstractParser<Span>() {
-      public Span parsePartialFrom(
-          com.google.protobuf.CodedInputStream input,
-          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
-          throws com.google.protobuf.InvalidProtocolBufferException {
-        return new Span(input, extensionRegistry);
-      }
-    };
-
-    @java.lang.Override
-    public com.google.protobuf.Parser<Span> getParserForType() {
-      return PARSER;
-    }
-
-    private int bitField0_;
-    // required int64 trace_id = 1;
-    public static final int TRACE_ID_FIELD_NUMBER = 1;
-    private long traceId_;
-    /**
-     * <code>required int64 trace_id = 1;</code>
-     */
-    public boolean hasTraceId() {
-      return ((bitField0_ & 0x00000001) == 0x00000001);
-    }
-    /**
-     * <code>required int64 trace_id = 1;</code>
-     */
-    public long getTraceId() {
-      return traceId_;
-    }
-
-    // required int64 parent_id = 2;
-    public static final int PARENT_ID_FIELD_NUMBER = 2;
-    private long parentId_;
-    /**
-     * <code>required int64 parent_id = 2;</code>
-     */
-    public boolean hasParentId() {
-      return ((bitField0_ & 0x00000002) == 0x00000002);
-    }
-    /**
-     * <code>required int64 parent_id = 2;</code>
-     */
-    public long getParentId() {
-      return parentId_;
-    }
-
-    // required int64 start = 3;
-    public static final int START_FIELD_NUMBER = 3;
-    private long start_;
-    /**
-     * <code>required int64 start = 3;</code>
-     */
-    public boolean hasStart() {
-      return ((bitField0_ & 0x00000004) == 0x00000004);
-    }
-    /**
-     * <code>required int64 start = 3;</code>
-     */
-    public long getStart() {
-      return start_;
-    }
-
-    // required int64 stop = 4;
-    public static final int STOP_FIELD_NUMBER = 4;
-    private long stop_;
-    /**
-     * <code>required int64 stop = 4;</code>
-     */
-    public boolean hasStop() {
-      return ((bitField0_ & 0x00000008) == 0x00000008);
-    }
-    /**
-     * <code>required int64 stop = 4;</code>
-     */
-    public long getStop() {
-      return stop_;
-    }
-
-    // required int64 span_id = 5;
-    public static final int SPAN_ID_FIELD_NUMBER = 5;
-    private long spanId_;
-    /**
-     * <code>required int64 span_id = 5;</code>
-     */
-    public boolean hasSpanId() {
-      return ((bitField0_ & 0x00000010) == 0x00000010);
-    }
-    /**
-     * <code>required int64 span_id = 5;</code>
-     */
-    public long getSpanId() {
-      return spanId_;
-    }
-
-    // required string process_id = 6;
-    public static final int PROCESS_ID_FIELD_NUMBER = 6;
-    private java.lang.Object processId_;
-    /**
-     * <code>required string process_id = 6;</code>
-     */
-    public boolean hasProcessId() {
-      return ((bitField0_ & 0x00000020) == 0x00000020);
-    }
-    /**
-     * <code>required string process_id = 6;</code>
-     */
-    public java.lang.String getProcessId() {
-      java.lang.Object ref = processId_;
-      if (ref instanceof java.lang.String) {
-        return (java.lang.String) ref;
-      } else {
-        com.google.protobuf.ByteString bs = 
-            (com.google.protobuf.ByteString) ref;
-        java.lang.String s = bs.toStringUtf8();
-        if (bs.isValidUtf8()) {
-          processId_ = s;
-        }
-        return s;
-      }
-    }
-    /**
-     * <code>required string process_id = 6;</code>
-     */
-    public com.google.protobuf.ByteString
-        getProcessIdBytes() {
-      java.lang.Object ref = processId_;
-      if (ref instanceof java.lang.String) {
-        com.google.protobuf.ByteString b = 
-            com.google.protobuf.ByteString.copyFromUtf8(
-                (java.lang.String) ref);
-        processId_ = b;
-        return b;
-      } else {
-        return (com.google.protobuf.ByteString) ref;
-      }
-    }
-
-    // required string description = 7;
-    public static final int DESCRIPTION_FIELD_NUMBER = 7;
-    private java.lang.Object description_;
-    /**
-     * <code>required string description = 7;</code>
-     */
-    public boolean hasDescription() {
-      return ((bitField0_ & 0x00000040) == 0x00000040);
-    }
-    /**
-     * <code>required string description = 7;</code>
-     */
-    public java.lang.String getDescription() {
-      java.lang.Object ref = description_;
-      if (ref instanceof java.lang.String) {
-        return (java.lang.String) ref;
-      } else {
-        com.google.protobuf.ByteString bs = 
-            (com.google.protobuf.ByteString) ref;
-        java.lang.String s = bs.toStringUtf8();
-        if (bs.isValidUtf8()) {
-          description_ = s;
-        }
-        return s;
-      }
-    }
-    /**
-     * <code>required string description = 7;</code>
-     */
-    public com.google.protobuf.ByteString
-        getDescriptionBytes() {
-      java.lang.Object ref = description_;
-      if (ref instanceof java.lang.String) {
-        com.google.protobuf.ByteString b = 
-            com.google.protobuf.ByteString.copyFromUtf8(
-                (java.lang.String) ref);
-        description_ = b;
-        return b;
-      } else {
-        return (com.google.protobuf.ByteString) ref;
-      }
-    }
-
-    // repeated .TimelineAnnotation timeline = 8;
-    public static final int TIMELINE_FIELD_NUMBER = 8;
-    private java.util.List<org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation> timeline_;
-    /**
-     * <code>repeated .TimelineAnnotation timeline = 8;</code>
-     */
-    public java.util.List<org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation> getTimelineList() {
-      return timeline_;
-    }
-    /**
-     * <code>repeated .TimelineAnnotation timeline = 8;</code>
-     */
-    public java.util.List<? extends org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotationOrBuilder> 
-        getTimelineOrBuilderList() {
-      return timeline_;
-    }
-    /**
-     * <code>repeated .TimelineAnnotation timeline = 8;</code>
-     */
-    public int getTimelineCount() {
-      return timeline_.size();
-    }
-    /**
-     * <code>repeated .TimelineAnnotation timeline = 8;</code>
-     */
-    public org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation getTimeline(int index) {
-      return timeline_.get(index);
-    }
-    /**
-     * <code>repeated .TimelineAnnotation timeline = 8;</code>
-     */
-    public org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotationOrBuilder getTimelineOrBuilder(
-        int index) {
-      return timeline_.get(index);
-    }
-
-    private void initFields() {
-      traceId_ = 0L;
-      parentId_ = 0L;
-      start_ = 0L;
-      stop_ = 0L;
-      spanId_ = 0L;
-      processId_ = "";
-      description_ = "";
-      timeline_ = java.util.Collections.emptyList();
-    }
-    private byte memoizedIsInitialized = -1;
-    public final boolean isInitialized() {
-      byte isInitialized = memoizedIsInitialized;
-      if (isInitialized != -1) return isInitialized == 1;
-
-      if (!hasTraceId()) {
-        memoizedIsInitialized = 0;
-        return false;
-      }
-      if (!hasParentId()) {
-        memoizedIsInitialized = 0;
-        return false;
-      }
-      if (!hasStart()) {
-        memoizedIsInitialized = 0;
-        return false;
-      }
-      if (!hasStop()) {
-        memoizedIsInitialized = 0;
-        return false;
-      }
-      if (!hasSpanId()) {
-        memoizedIsInitialized = 0;
-        return false;
-      }
-      if (!hasProcessId()) {
-        memoizedIsInitialized = 0;
-        return false;
-      }
-      if (!hasDescription()) {
-        memoizedIsInitialized = 0;
-        return false;
-      }
-      for (int i = 0; i < getTimelineCount(); i++) {
-        if (!getTimeline(i).isInitialized()) {
-          memoizedIsInitialized = 0;
-          return false;
-        }
-      }
-      memoizedIsInitialized = 1;
-      return true;
-    }
-
-    public void writeTo(com.google.protobuf.CodedOutputStream output)
-                        throws java.io.IOException {
-      getSerializedSize();
-      if (((bitField0_ & 0x00000001) == 0x00000001)) {
-        output.writeInt64(1, traceId_);
-      }
-      if (((bitField0_ & 0x00000002) == 0x00000002)) {
-        output.writeInt64(2, parentId_);
-      }
-      if (((bitField0_ & 0x00000004) == 0x00000004)) {
-        output.writeInt64(3, start_);
-      }
-      if (((bitField0_ & 0x00000008) == 0x00000008)) {
-        output.writeInt64(4, stop_);
-      }
-      if (((bitField0_ & 0x00000010) == 0x00000010)) {
-        output.writeInt64(5, spanId_);
-      }
-      if (((bitField0_ & 0x00000020) == 0x00000020)) {
-        output.writeBytes(6, getProcessIdBytes());
-      }
-      if (((bitField0_ & 0x00000040) == 0x00000040)) {
-        output.writeBytes(7, getDescriptionBytes());
-      }
-      for (int i = 0; i < timeline_.size(); i++) {
-        output.writeMessage(8, timeline_.get(i));
-      }
-      getUnknownFields().writeTo(output);
-    }
-
-    private int memoizedSerializedSize = -1;
-    public int getSerializedSize() {
-      int size = memoizedSerializedSize;
-      if (size != -1) return size;
-
-      size = 0;
-      if (((bitField0_ & 0x00000001) == 0x00000001)) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeInt64Size(1, traceId_);
-      }
-      if (((bitField0_ & 0x00000002) == 0x00000002)) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeInt64Size(2, parentId_);
-      }
-      if (((bitField0_ & 0x00000004) == 0x00000004)) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeInt64Size(3, start_);
-      }
-      if (((bitField0_ & 0x00000008) == 0x00000008)) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeInt64Size(4, stop_);
-      }
-      if (((bitField0_ & 0x00000010) == 0x00000010)) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeInt64Size(5, spanId_);
-      }
-      if (((bitField0_ & 0x00000020) == 0x00000020)) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeBytesSize(6, getProcessIdBytes());
-      }
-      if (((bitField0_ & 0x00000040) == 0x00000040)) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeBytesSize(7, getDescriptionBytes());
-      }
-      for (int i = 0; i < timeline_.size(); i++) {
-        size += com.google.protobuf.CodedOutputStream
-          .computeMessageSize(8, timeline_.get(i));
-      }
-      size += getUnknownFields().getSerializedSize();
-      memoizedSerializedSize = size;
-      return size;
-    }
-
-    private static final long serialVersionUID = 0L;
-    @java.lang.Override
-    protected java.lang.Object writeReplace()
-        throws java.io.ObjectStreamException {
-      return super.writeReplace();
-    }
-
-    @java.lang.Override
-    public boolean equals(final java.lang.Object obj) {
-      if (obj == this) {
-       return true;
-      }
-      if (!(obj instanceof org.apache.htrace.protobuf.generated.SpanProtos.Span)) {
-        return super.equals(obj);
-      }
-      org.apache.htrace.protobuf.generated.SpanProtos.Span other = (org.apache.htrace.protobuf.generated.SpanProtos.Span) obj;
-
-      boolean result = true;
-      result = result && (hasTraceId() == other.hasTraceId());
-      if (hasTraceId()) {
-        result = result && (getTraceId()
-            == other.getTraceId());
-      }
-      result = result && (hasParentId() == other.hasParentId());
-      if (hasParentId()) {
-        result = result && (getParentId()
-            == other.getParentId());
-      }
-      result = result && (hasStart() == other.hasStart());
-      if (hasStart()) {
-        result = result && (getStart()
-            == other.getStart());
-      }
-      result = result && (hasStop() == other.hasStop());
-      if (hasStop()) {
-        result = result && (getStop()
-            == other.getStop());
-      }
-      result = result && (hasSpanId() == other.hasSpanId());
-      if (hasSpanId()) {
-        result = result && (getSpanId()
-            == other.getSpanId());
-      }
-      result = result && (hasProcessId() == other.hasProcessId());
-      if (hasProcessId()) {
-        result = result && getProcessId()
-            .equals(other.getProcessId());
-      }
-      result = result && (hasDescription() == other.hasDescription());
-      if (hasDescription()) {
-        result = result && getDescription()
-            .equals(other.getDescription());
-      }
-      result = result && getTimelineList()
-          .equals(other.getTimelineList());
-      result = result &&
-          getUnknownFields().equals(other.getUnknownFields());
-      return result;
-    }
-
-    private int memoizedHashCode = 0;
-    @java.lang.Override
-    public int hashCode() {
-      if (memoizedHashCode != 0) {
-        return memoizedHashCode;
-      }
-      int hash = 41;
-      hash = (19 * hash) + getDescriptorForType().hashCode();
-      if (hasTraceId()) {
-        hash = (37 * hash) + TRACE_ID_FIELD_NUMBER;
-        hash = (53 * hash) + hashLong(getTraceId());
-      }
-      if (hasParentId()) {
-        hash = (37 * hash) + PARENT_ID_FIELD_NUMBER;
-        hash = (53 * hash) + hashLong(getParentId());
-      }
-      if (hasStart()) {
-        hash = (37 * hash) + START_FIELD_NUMBER;
-        hash = (53 * hash) + hashLong(getStart());
-      }
-      if (hasStop()) {
-        hash = (37 * hash) + STOP_FIELD_NUMBER;
-        hash = (53 * hash) + hashLong(getStop());
-      }
-      if (hasSpanId()) {
-        hash = (37 * hash) + SPAN_ID_FIELD_NUMBER;
-        hash = (53 * hash) + hashLong(getSpanId());
-      }
-      if (hasProcessId()) {
-        hash = (37 * hash) + PROCESS_ID_FIELD_NUMBER;
-        hash = (53 * hash) + getProcessId().hashCode();
-      }
-      if (hasDescription()) {
-        hash = (37 * hash) + DESCRIPTION_FIELD_NUMBER;
-        hash = (53 * hash) + getDescription().hashCode();
-      }
-      if (getTimelineCount() > 0) {
-        hash = (37 * hash) + TIMELINE_FIELD_NUMBER;
-        hash = (53 * hash) + getTimelineList().hashCode();
-      }
-      hash = (29 * hash) + getUnknownFields().hashCode();
-      memoizedHashCode = hash;
-      return hash;
-    }
-
-    public static org.apache.htrace.protobuf.generated.SpanProtos.Span parseFrom(
-        com.google.protobuf.ByteString data)
-        throws com.google.protobuf.InvalidProtocolBufferException {
-      return PARSER.parseFrom(data);
-    }
-    public static org.apache.htrace.protobuf.generated.SpanProtos.Span parseFrom(
-        com.google.protobuf.ByteString data,
-        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
-        throws com.google.protobuf.InvalidProtocolBufferException {
-      return PARSER.parseFrom(data, extensionRegistry);
-    }
-    public static org.apache.htrace.protobuf.generated.SpanProtos.Span parseFrom(byte[] data)
-        throws com.google.protobuf.InvalidProtocolBufferException {
-      return PARSER.parseFrom(data);
-    }
-    public static org.apache.htrace.protobuf.generated.SpanProtos.Span parseFrom(
-        byte[] data,
-        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
-        throws com.google.protobuf.InvalidProtocolBufferException {
-      return PARSER.parseFrom(data, extensionRegistry);
-    }
-    public static org.apache.htrace.protobuf.generated.SpanProtos.Span parseFrom(java.io.InputStream input)
-        throws java.io.IOException {
-      return PARSER.parseFrom(input);
-    }
-    public static org.apache.htrace.protobuf.generated.SpanProtos.Span parseFrom(
-        java.io.InputStream input,
-        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
-        throws java.io.IOException {
-      return PARSER.parseFrom(input, extensionRegistry);
-    }
-    public static org.apache.htrace.protobuf.generated.SpanProtos.Span parseDelimitedFrom(java.io.InputStream input)
-        throws java.io.IOException {
-      return PARSER.parseDelimitedFrom(input);
-    }
-    public static org.apache.htrace.protobuf.generated.SpanProtos.Span parseDelimitedFrom(
-        java.io.InputStream input,
-        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
-        throws java.io.IOException {
-      return PARSER.parseDelimitedFrom(input, extensionRegistry);
-    }
-    public static org.apache.htrace.protobuf.generated.SpanProtos.Span parseFrom(
-        com.google.protobuf.CodedInputStream input)
-        throws java.io.IOException {
-      return PARSER.parseFrom(input);
-    }
-    public static org.apache.htrace.protobuf.generated.SpanProtos.Span parseFrom(
-        com.google.protobuf.CodedInputStream input,
-        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
-        throws java.io.IOException {
-      return PARSER.parseFrom(input, extensionRegistry);
-    }
-
-    public static Builder newBuilder() { return Builder.create(); }
-    public Builder newBuilderForType() { return newBuilder(); }
-    public static Builder newBuilder(org.apache.htrace.protobuf.generated.SpanProtos.Span prototype) {
-      return newBuilder().mergeFrom(prototype);
-    }
-    public Builder toBuilder() { return newBuilder(this); }
-
-    @java.lang.Override
-    protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessage.BuilderParent parent) {
-      Builder builder = new Builder(parent);
-      return builder;
-    }
-    /**
-     * Protobuf type {@code Span}
-     */
-    public static final class Builder extends
-        com.google.protobuf.GeneratedMessage.Builder<Builder>
-       implements org.apache.htrace.protobuf.generated.SpanProtos.SpanOrBuilder {
-      public static final com.google.protobuf.Descriptors.Descriptor
-          getDescriptor() {
-        return org.apache.htrace.protobuf.generated.SpanProtos.internal_static_Span_descriptor;
-      }
-
-      protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
-          internalGetFieldAccessorTable() {
-        return org.apache.htrace.protobuf.generated.SpanProtos.internal_static_Span_fieldAccessorTable
-            .ensureFieldAccessorsInitialized(
-                org.apache.htrace.protobuf.generated.SpanProtos.Span.class, org.apache.htrace.protobuf.generated.SpanProtos.Span.Builder.class);
-      }
-
-      // Construct using org.apache.htrace.protobuf.generated.SpanProtos.Span.newBuilder()
-      private Builder() {
-        maybeForceBuilderInitialization();
-      }
-
-      private Builder(
-          com.google.protobuf.GeneratedMessage.BuilderParent parent) {
-        super(parent);
-        maybeForceBuilderInitialization();
-      }
-      private void maybeForceBuilderInitialization() {
-        if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
-          getTimelineFieldBuilder();
-        }
-      }
-      private static Builder create() {
-        return new Builder();
-      }
-
-      public Builder clear() {
-        super.clear();
-        traceId_ = 0L;
-        bitField0_ = (bitField0_ & ~0x00000001);
-        parentId_ = 0L;
-        bitField0_ = (bitField0_ & ~0x00000002);
-        start_ = 0L;
-        bitField0_ = (bitField0_ & ~0x00000004);
-        stop_ = 0L;
-        bitField0_ = (bitField0_ & ~0x00000008);
-        spanId_ = 0L;
-        bitField0_ = (bitField0_ & ~0x00000010);
-        processId_ = "";
-        bitField0_ = (bitField0_ & ~0x00000020);
-        description_ = "";
-        bitField0_ = (bitField0_ & ~0x00000040);
-        if (timelineBuilder_ == null) {
-          timeline_ = java.util.Collections.emptyList();
-          bitField0_ = (bitField0_ & ~0x00000080);
-        } else {
-          timelineBuilder_.clear();
-        }
-        return this;
-      }
-
-      public Builder clone() {
-        return create().mergeFrom(buildPartial());
-      }
-
-      public com.google.protobuf.Descriptors.Descriptor
-          getDescriptorForType() {
-        return org.apache.htrace.protobuf.generated.SpanProtos.internal_static_Span_descriptor;
-      }
-
-      public org.apache.htrace.protobuf.generated.SpanProtos.Span getDefaultInstanceForType() {
-        return org.apache.htrace.protobuf.generated.SpanProtos.Span.getDefaultInstance();
-      }
-
-      public org.apache.htrace.protobuf.generated.SpanProtos.Span build() {
-        org.apache.htrace.protobuf.generated.SpanProtos.Span result = buildPartial();
-        if (!result.isInitialized()) {
-          throw newUninitializedMessageException(result);
-        }
-        return result;
-      }
-
-      public org.apache.htrace.protobuf.generated.SpanProtos.Span buildPartial() {
-        org.apache.htrace.protobuf.generated.SpanProtos.Span result = new org.apache.htrace.protobuf.generated.SpanProtos.Span(this);
-        int from_bitField0_ = bitField0_;
-        int to_bitField0_ = 0;
-        if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
-          to_bitField0_ |= 0x00000001;
-        }
-        result.traceId_ = traceId_;
-        if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
-          to_bitField0_ |= 0x00000002;
-        }
-        result.parentId_ = parentId_;
-        if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
-          to_bitField0_ |= 0x00000004;
-        }
-        result.start_ = start_;
-        if (((from_bitField0_ & 0x00000008) == 0x00000008)) {
-          to_bitField0_ |= 0x00000008;
-        }
-        result.stop_ = stop_;
-        if (((from_bitField0_ & 0x00000010) == 0x00000010)) {
-          to_bitField0_ |= 0x00000010;
-        }
-        result.spanId_ = spanId_;
-        if (((from_bitField0_ & 0x00000020) == 0x00000020)) {
-          to_bitField0_ |= 0x00000020;
-        }
-        result.processId_ = processId_;
-        if (((from_bitField0_ & 0x00000040) == 0x00000040)) {
-          to_bitField0_ |= 0x00000040;
-        }
-        result.description_ = description_;
-        if (timelineBuilder_ == null) {
-          if (((bitField0_ & 0x00000080) == 0x00000080)) {
-            timeline_ = java.util.Collections.unmodifiableList(timeline_);
-            bitField0_ = (bitField0_ & ~0x00000080);
-          }
-          result.timeline_ = timeline_;
-        } else {
-          result.timeline_ = timelineBuilder_.build();
-        }
-        result.bitField0_ = to_bitField0_;
-        onBuilt();
-        return result;
-      }
-
-      public Builder mergeFrom(com.google.protobuf.Message other) {
-        if (other instanceof org.apache.htrace.protobuf.generated.SpanProtos.Span) {
-          return mergeFrom((org.apache.htrace.protobuf.generated.SpanProtos.Span)other);
-        } else {
-          super.mergeFrom(other);
-          return this;
-        }
-      }
-
-      public Builder mergeFrom(org.apache.htrace.protobuf.generated.SpanProtos.Span other) {
-        if (other == org.apache.htrace.protobuf.generated.SpanProtos.Span.getDefaultInstance()) return this;
-        if (other.hasTraceId()) {
-          setTraceId(other.getTraceId());
-        }
-        if (other.hasParentId()) {
-          setParentId(other.getParentId());
-        }
-        if (other.hasStart()) {
-          setStart(other.getStart());
-        }
-        if (other.hasStop()) {
-          setStop(other.getStop());
-        }
-        if (other.hasSpanId()) {
-          setSpanId(other.getSpanId());
-        }
-        if (other.hasProcessId()) {
-          bitField0_ |= 0x00000020;
-          processId_ = other.processId_;
-          onChanged();
-        }
-        if (other.hasDescription()) {
-          bitField0_ |= 0x00000040;
-          description_ = other.description_;
-          onChanged();
-        }
-        if (timelineBuilder_ == null) {
-          if (!other.timeline_.isEmpty()) {
-            if (timeline_.isEmpty()) {
-              timeline_ = other.timeline_;
-              bitField0_ = (bitField0_ & ~0x00000080);
-            } else {
-              ensureTimelineIsMutable();
-              timeline_.addAll(other.timeline_);
-            }
-            onChanged();
-          }
-        } else {
-          if (!other.timeline_.isEmpty()) {
-            if (timelineBuilder_.isEmpty()) {
-              timelineBuilder_.dispose();
-              timelineBuilder_ = null;
-              timeline_ = other.timeline_;
-              bitField0_ = (bitField0_ & ~0x00000080);
-              timelineBuilder_ = 
-                com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
-                   getTimelineFieldBuilder() : null;
-            } else {
-              timelineBuilder_.addAllMessages(other.timeline_);
-            }
-          }
-        }
-        this.mergeUnknownFields(other.getUnknownFields());
-        return this;
-      }
-
-      public final boolean isInitialized() {
-        if (!hasTraceId()) {
-          
-          return false;
-        }
-        if (!hasParentId()) {
-          
-          return false;
-        }
-        if (!hasStart()) {
-          
-          return false;
-        }
-        if (!hasStop()) {
-          
-          return false;
-        }
-        if (!hasSpanId()) {
-          
-          return false;
-        }
-        if (!hasProcessId()) {
-          
-          return false;
-        }
-        if (!hasDescription()) {
-          
-          return false;
-        }
-        for (int i = 0; i < getTimelineCount(); i++) {
-          if (!getTimeline(i).isInitialized()) {
-            
-            return false;
-          }
-        }
-        return true;
-      }
-
-      public Builder mergeFrom(
-          com.google.protobuf.CodedInputStream input,
-          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
-          throws java.io.IOException {
-        org.apache.htrace.protobuf.generated.SpanProtos.Span parsedMessage = null;
-        try {
-          parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
-        } catch (com.google.protobuf.InvalidProtocolBufferException e) {
-          parsedMessage = (org.apache.htrace.protobuf.generated.SpanProtos.Span) e.getUnfinishedMessage();
-          throw e;
-        } finally {
-          if (parsedMessage != null) {
-            mergeFrom(parsedMessage);
-          }
-        }
-        return this;
-      }
-      private int bitField0_;
-
-      // required int64 trace_id = 1;
-      private long traceId_ ;
-      /**
-       * <code>required int64 trace_id = 1;</code>
-       */
-      public boolean hasTraceId() {
-        return ((bitField0_ & 0x00000001) == 0x00000001);
-      }
-      /**
-       * <code>required int64 trace_id = 1;</code>
-       */
-      public long getTraceId() {
-        return traceId_;
-      }
-      /**
-       * <code>required int64 trace_id = 1;</code>
-       */
-      public Builder setTraceId(long value) {
-        bitField0_ |= 0x00000001;
-        traceId_ = value;
-        onChanged();
-        return this;
-      }
-      /**
-       * <code>required int64 trace_id = 1;</code>
-       */
-      public Builder clearTraceId() {
-        bitField0_ = (bitField0_ & ~0x00000001);
-        traceId_ = 0L;
-        onChanged();
-        return this;
-      }
-
-      // required int64 parent_id = 2;
-      private long parentId_ ;
-      /**
-       * <code>required int64 parent_id = 2;</code>
-       */
-      public boolean hasParentId() {
-        return ((bitField0_ & 0x00000002) == 0x00000002);
-      }
-      /**
-       * <code>required int64 parent_id = 2;</code>
-       */
-      public long getParentId() {
-        return parentId_;
-      }
-      /**
-       * <code>required int64 parent_id = 2;</code>
-       */
-      public Builder setParentId(long value) {
-        bitField0_ |= 0x00000002;
-        parentId_ = value;
-        onChanged();
-        return this;
-      }
-      /**
-       * <code>required int64 parent_id = 2;</code>
-       */
-      public Builder clearParentId() {
-        bitField0_ = (bitField0_ & ~0x00000002);
-        parentId_ = 0L;
-        onChanged();
-        return this;
-      }
-
-      // required int64 start = 3;
-      private long start_ ;
-      /**
-       * <code>required int64 start = 3;</code>
-       */
-      public boolean hasStart() {
-        return ((bitField0_ & 0x00000004) == 0x00000004);
-      }
-      /**
-       * <code>required int64 start = 3;</code>
-       */
-      public long getStart() {
-        return start_;
-      }
-      /**
-       * <code>required int64 start = 3;</code>
-       */
-      public Builder setStart(long value) {
-        bitField0_ |= 0x00000004;
-        start_ = value;
-        onChanged();
-        return this;
-      }
-      /**
-       * <code>required int64 start = 3;</code>
-       */
-      public Builder clearStart() {
-        bitField0_ = (bitField0_ & ~0x00000004);
-        start_ = 0L;
-        onChanged();
-        return this;
-      }
-
-      // required int64 stop = 4;
-      private long stop_ ;
-      /**
-       * <code>required int64 stop = 4;</code>
-       */
-      public boolean hasStop() {
-        return ((bitField0_ & 0x00000008) == 0x00000008);
-      }
-      /**
-       * <code>required int64 stop = 4;</code>
-       */
-      public long getStop() {
-        return stop_;
-      }
-      /**
-       * <code>required int64 stop = 4;</code>
-       */
-      public Builder setStop(long value) {
-        bitField0_ |= 0x00000008;
-        stop_ = value;
-        onChanged();
-        return this;
-      }
-      /**
-       * <code>required int64 stop = 4;</code>
-       */
-      public Builder clearStop() {
-        bitField0_ = (bitField0_ & ~0x00000008);
-        stop_ = 0L;
-        onChanged();
-        return this;
-      }
-
-      // required int64 span_id = 5;
-      private long spanId_ ;
-      /**
-       * <code>required int64 span_id = 5;</code>
-       */
-      public boolean hasSpanId() {
-        return ((bitField0_ & 0x00000010) == 0x00000010);
-      }
-      /**
-       * <code>required int64 span_id = 5;</code>
-       */
-      public long getSpanId() {
-        return spanId_;
-      }
-      /**
-       * <code>required int64 span_id = 5;</code>
-       */
-      public Builder setSpanId(long value) {
-        bitField0_ |= 0x00000010;
-        spanId_ = value;
-        onChanged();
-        return this;
-      }
-      /**
-       * <code>required int64 span_id = 5;</code>
-       */
-      public Builder clearSpanId() {
-        bitField0_ = (bitField0_ & ~0x00000010);
-        spanId_ = 0L;
-        onChanged();
-        return this;
-      }
-
-      // required string process_id = 6;
-      private java.lang.Object processId_ = "";
-      /**
-       * <code>required string process_id = 6;</code>
-       */
-      public boolean hasProcessId() {
-        return ((bitField0_ & 0x00000020) == 0x00000020);
-      }
-      /**
-       * <code>required string process_id = 6;</code>
-       */
-      public java.lang.String getProcessId() {
-        java.lang.Object ref = processId_;
-        if (!(ref instanceof java.lang.String)) {
-          java.lang.String s = ((com.google.protobuf.ByteString) ref)
-              .toStringUtf8();
-          processId_ = s;
-          return s;
-        } else {
-          return (java.lang.String) ref;
-        }
-      }
-      /**
-       * <code>required string process_id = 6;</code>
-       */
-      public com.google.protobuf.ByteString
-          getProcessIdBytes() {
-        java.lang.Object ref = processId_;
-        if (ref instanceof String) {
-          com.google.protobuf.ByteString b = 
-              com.google.protobuf.ByteString.copyFromUtf8(
-                  (java.lang.String) ref);
-          processId_ = b;
-          return b;
-        } else {
-          return (com.google.protobuf.ByteString) ref;
-        }
-      }
-      /**
-       * <code>required string process_id = 6;</code>
-       */
-      public Builder setProcessId(
-          java.lang.String value) {
-        if (value == null) {
-    throw new NullPointerException();
-  }
-  bitField0_ |= 0x00000020;
-        processId_ = value;
-        onChanged();
-        return this;
-      }
-      /**
-       * <code>required string process_id = 6;</code>
-       */
-      public Builder clearProcessId() {
-        bitField0_ = (bitField0_ & ~0x00000020);
-        processId_ = getDefaultInstance().getProcessId();
-        onChanged();
-        return this;
-      }
-      /**
-       * <code>required string process_id = 6;</code>
-       */
-      public Builder setProcessIdBytes(
-          com.google.protobuf.ByteString value) {
-        if (value == null) {
-    throw new NullPointerException();
-  }
-  bitField0_ |= 0x00000020;
-        processId_ = value;
-        onChanged();
-        return this;
-      }
-
-      // required string description = 7;
-      private java.lang.Object description_ = "";
-      /**
-       * <code>required string description = 7;</code>
-       */
-      public boolean hasDescription() {
-        return ((bitField0_ & 0x00000040) == 0x00000040);
-      }
-      /**
-       * <code>required string description = 7;</code>
-       */
-      public java.lang.String getDescription() {
-        java.lang.Object ref = description_;
-        if (!(ref instanceof java.lang.String)) {
-          java.lang.String s = ((com.google.protobuf.ByteString) ref)
-              .toStringUtf8();
-          description_ = s;
-          return s;
-        } else {
-          return (java.lang.String) ref;
-        }
-      }
-      /**
-       * <code>required string description = 7;</code>
-       */
-      public com.google.protobuf.ByteString
-          getDescriptionBytes() {
-        java.lang.Object ref = description_;
-        if (ref instanceof String) {
-          com.google.protobuf.ByteString b = 
-              com.google.protobuf.ByteString.copyFromUtf8(
-                  (java.lang.String) ref);
-          description_ = b;
-          return b;
-        } else {
-          return (com.google.protobuf.ByteString) ref;
-        }
-      }
-      /**
-       * <code>required string description = 7;</code>
-       */
-      public Builder setDescription(
-          java.lang.String value) {
-        if (value == null) {
-    throw new NullPointerException();
-  }
-  bitField0_ |= 0x00000040;
-        description_ = value;
-        onChanged();
-        return this;
-      }
-      /**
-       * <code>required string description = 7;</code>
-       */
-      public Builder clearDescription() {
-        bitField0_ = (bitField0_ & ~0x00000040);
-        description_ = getDefaultInstance().getDescription();
-        onChanged();
-        return this;
-      }
-      /**
-       * <code>required string description = 7;</code>
-       */
-      public Builder setDescriptionBytes(
-          com.google.protobuf.ByteString value) {
-        if (value == null) {
-    throw new NullPointerException();
-  }
-  bitField0_ |= 0x00000040;
-        description_ = value;
-        onChanged();
-        return this;
-      }
-
-      // repeated .TimelineAnnotation timeline = 8;
-      private java.util.List<org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation> timeline_ =
-        java.util.Collections.emptyList();
-      private void ensureTimelineIsMutable() {
-        if (!((bitField0_ & 0x00000080) == 0x00000080)) {
-          timeline_ = new java.util.ArrayList<org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation>(timeline_);
-          bitField0_ |= 0x00000080;
-         }
-      }
-
-      private com.google.protobuf.RepeatedFieldBuilder<
-          org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotationOrBuilder> timelineBuilder_;
-
-      /**
-       * <code>repeated .TimelineAnnotation timeline = 8;</code>
-       */
-      public java.util.List<org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation> getTimelineList() {
-        if (timelineBuilder_ == null) {
-          return java.util.Collections.unmodifiableList(timeline_);
-        } else {
-          return timelineBuilder_.getMessageList();
-        }
-      }
-      /**
-       * <code>repeated .TimelineAnnotation timeline = 8;</code>
-       */
-      public int getTimelineCount() {
-        if (timelineBuilder_ == null) {
-          return timeline_.size();
-        } else {
-          return timelineBuilder_.getCount();
-        }
-      }
-      /**
-       * <code>repeated .TimelineAnnotation timeline = 8;</code>
-       */
-      public org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation getTimeline(int index) {
-        if (timelineBuilder_ == null) {
-          return timeline_.get(index);
-        } else {
-          return timelineBuilder_.getMessage(index);
-        }
-      }
-      /**
-       * <code>repeated .TimelineAnnotation timeline = 8;</code>
-       */
-      public Builder setTimeline(
-          int index, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation value) {
-        if (timelineBuilder_ == null) {
-          if (value == null) {
-            throw new NullPointerException();
-          }
-          ensureTimelineIsMutable();
-          timeline_.set(index, value);
-          onChanged();
-        } else {
-          timelineBuilder_.setMessage(index, value);
-        }
-        return this;
-      }
-      /**
-       * <code>repeated .TimelineAnnotation timeline = 8;</code>
-       */
-      public Builder setTimeline(
-          int index, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder builderForValue) {
-        if (timelineBuilder_ == null) {
-          ensureTimelineIsMutable();
-          timeline_.set(index, builderForValue.build());
-          onChanged();
-        } else {
-          timelineBuilder_.setMessage(index, builderForValue.build());
-        }
-        return this;
-      }
-      /**
-       * <code>repeated .TimelineAnnotation timeline = 8;</code>
-       */
-      public Builder addTimeline(org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation value) {
-        if (timelineBuilder_ == null) {
-          if (value == null) {
-            throw new NullPointerException();
-          }
-          ensureTimelineIsMutable();
-          timeline_.add(value);
-          onChanged();
-        } else {
-          timelineBuilder_.addMessage(value);
-        }
-        return this;
-      }
-      /**
-       * <code>repeated .TimelineAnnotation timeline = 8;</code>
-       */
-      public Builder addTimeline(
-          int index, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation value) {
-        if (timelineBuilder_ == null) {
-          if (value == null) {
-            throw new NullPointerException();
-          }
-          ensureTimelineIsMutable();
-          timeline_.add(index, value);
-          onChanged();
-        } else {
-          timelineBuilder_.addMessage(index, value);
-        }
-        return this;
-      }
-      /**
-       * <code>repeated .TimelineAnnotation timeline = 8;</code>
-       */
-      public Builder addTimeline(
-          org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder builderForValue) {
-        if (timelineBuilder_ == null) {
-          ensureTimelineIsMutable();
-          timeline_.add(builderForValue.build());
-          onChanged();
-        } else {
-          timelineBuilder_.addMessage(builderForValue.build());
-        }
-        return this;
-      }
-      /**
-       * <code>repeated .TimelineAnnotation timeline = 8;</code>
-       */
-      public Builder addTimeline(
-          int index, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder builderForValue) {
-        if (timelineBuilder_ == null) {
-          ensureTimelineIsMutable();
-          timeline_.add(index, builderForValue.build());
-          onChanged();
-        } else {
-          timelineBuilder_.addMessage(index, builderForValue.build());
-        }
-        return this;
-      }
-      /**
-       * <code>repeated .TimelineAnnotation timeline = 8;</code>
-       */
-      public Builder addAllTimeline(
-          java.lang.Iterable<? extends org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation> values) {
-        if (timelineBuilder_ == null) {
-          ensureTimelineIsMutable();
-          super.addAll(values, timeline_);
-          onChanged();
-        } else {
-          timelineBuilder_.addAllMessages(values);
-        }
-        return this;
-      }
-      /**
-       * <code>repeated .TimelineAnnotation timeline = 8;</code>
-       */
-      public Builder clearTimeline() {
-        if (timelineBuilder_ == null) {
-          timeline_ = java.util.Collections.emptyList();
-          bitField0_ = (bitField0_ & ~0x00000080);
-          onChanged();
-        } else {
-          timelineBuilder_.clear();
-        }
-        return this;
-      }
-      /**
-       * <code>repeated .TimelineAnnotation timeline = 8;</code>
-       */
-      public Builder removeTimeline(int index) {
-        if (timelineBuilder_ == null) {
-          ensureTimelineIsMutable();
-          timeline_.remove(index);
-          onChanged();
-        } else {
-          timelineBuilder_.remove(index);
-        }
-        return this;
-      }
-      /**
-       * <code>repeated .TimelineAnnotation timeline = 8;</code>
-       */
-      public org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder getTimelineBuilder(
-          int index) {
-        return getTimelineFieldBuilder().getBuilder(index);
-      }
-      /**
-       * <code>repeated .TimelineAnnotation timeline = 8;</code>
-       */
-      public org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotationOrBuilder getTimelineOrBuilder(
-          int index) {
-        if (timelineBuilder_ == null) {
-          return timeline_.get(index);  } else {
-          return timelineBuilder_.getMessageOrBuilder(index);
-        }
-      }
-      /**
-       * <code>repeated .TimelineAnnotation timeline = 8;</code>
-       */
-      public java.util.List<? extends org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotationOrBuilder> 
-           getTimelineOrBuilderList() {
-        if (timelineBuilder_ != null) {
-          return timelineBuilder_.getMessageOrBuilderList();
-        } else {
-          return java.util.Collections.unmodifiableList(timeline_);
-        }
-      }
-      /**
-       * <code>repeated .TimelineAnnotation timeline = 8;</code>
-       */
-      public org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder addTimelineBuilder() {
-        return getTimelineFieldBuilder().addBuilder(
-            org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.getDefaultInstance());
-      }
-      /**
-       * <code>repeated .TimelineAnnotation timeline = 8;</code>
-       */
-      public org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder addTimelineBuilder(
-          int index) {
-        return getTimelineFieldBuilder().addBuilder(
-            index, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.getDefaultInstance());
-      }
-      /**
-       * <code>repeated .TimelineAnnotation timeline = 8;</code>
-       */
-      public java.util.List<org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder> 
-           getTimelineBuilderList() {
-        return getTimelineFieldBuilder().getBuilderList();
-      }
-      private com.google.protobuf.RepeatedFieldBuilder<
-          org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotationOrBuilder> 
-          getTimelineFieldBuilder() {
-        if (timelineBuilder_ == null) {
-          timelineBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
-              org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotation.Builder, org.apache.htrace.protobuf.generated.SpanProtos.TimelineAnnotationOrBuilder>(
-                  timeline_,
-                  ((bitField0_ & 0x00000080) == 0x00000080),
-                  getParentForChildren(),
-                  isClean());
-          timeline_ = null;
-        }
-        return timelineBuilder_;
-      }
-
-      // @@protoc_insertion_point(builder_scope:Span)
-    }
-
-    static {
-      defaultInstance = new Span(true);
-      defaultInstance.initFields();
-    }
-
-    // @@protoc_insertion_point(class_scope:Span)
-  }
-
-  private static com.google.protobuf.Descriptors.Descriptor
-    internal_static_TimelineAnnotation_descriptor;
-  private static
-    com.google.protobuf.GeneratedMessage.FieldAccessorTable
-      internal_static_TimelineAnnotation_fieldAccessorTable;
-  private static com.google.protobuf.Descriptors.Descriptor
-    internal_static_Span_descriptor;
-  private static
-    com.google.protobuf.GeneratedMessage.FieldAccessorTable
-      internal_static_Span_fieldAccessorTable;
-
-  public static com.google.protobuf.Descriptors.FileDescriptor
-      getDescriptor() {
-    return descriptor;
-  }
-  private static com.google.protobuf.Descriptors.FileDescriptor
-      descriptor;
-  static {
-    java.lang.String[] descriptorData = {
-      "\n\nSpan.proto\"3\n\022TimelineAnnotation\022\014\n\004ti" +
-      "me\030\001 \002(\003\022\017\n\007message\030\002 \002(\t\"\251\001\n\004Span\022\020\n\010tr" +
-      "ace_id\030\001 \002(\003\022\021\n\tparent_id\030\002 \002(\003\022\r\n\005start" +
-      "\030\003 \002(\003\022\014\n\004stop\030\004 \002(\003\022\017\n\007span_id\030\005 \002(\003\022\022\n" +
-      "\nprocess_id\030\006 \002(\t\022\023\n\013description\030\007 \002(\t\022%" +
-      "\n\010timeline\030\010 \003(\0132\023.TimelineAnnotationB0\n" +
-      "\035org.htrace.protobuf.generatedB\nSpanProt" +
-      "osH\001\240\001\001"
-    };
-    com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
-      new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
-        public com.google.protobuf.ExtensionRegistry assignDescriptors(
-            com.google.protobuf.Descriptors.FileDescriptor root) {
-          descriptor = root;
-          internal_static_TimelineAnnotation_descriptor =
-            getDescriptor().getMessageTypes().get(0);
-          internal_static_TimelineAnnotation_fieldAccessorTable = new
-            com.google.protobuf.GeneratedMessage.FieldAccessorTable(
-              internal_static_TimelineAnnotation_descriptor,
-              new java.lang.String[] { "Time", "Message", });
-          internal_static_Span_descriptor =
-            getDescriptor().getMessageTypes().get(1);
-          internal_static_Span_fieldAccessorTable = new
-            com.google.protobuf.GeneratedMessage.FieldAccessorTable(
-              internal_static_Span_descriptor,
-              new java.lang.String[] { "TraceId", "ParentId", "Start", "Stop", "SpanId", "ProcessId", "Description", "Timeline", });
-          return null;
-        }
-      };
-    com.google.protobuf.Descriptors.FileDescriptor
-      .internalBuildGeneratedFileFrom(descriptorData,
-        new com.google.protobuf.Descriptors.FileDescriptor[] {
-        }, assigner);
-  }
-
-  // @@protoc_insertion_point(outer_class_scope)
-}

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/a6ca3ccf/htrace-kudu/src/main/protobuf/Span.proto
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/protobuf/Span.proto b/htrace-kudu/src/main/protobuf/Span.proto
deleted file mode 100644
index e8dc369..0000000
--- a/htrace-kudu/src/main/protobuf/Span.proto
+++ /dev/null
@@ -1,38 +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.
- */
-
-option java_package = "org.apache.htrace.protobuf.generated";
-option java_outer_classname = "SpanProtos";
-option java_generate_equals_and_hash = true;
-option optimize_for = SPEED;
-
-message TimelineAnnotation {
-  required int64 time = 1;
-  required string message = 2;
-}
-
-message Span {
-  required int64 trace_id = 1;
-  required int64 parent_id = 2;
-  required int64 start = 3;
-  required int64 stop = 4;
-  required int64 span_id = 5;
-  required string process_id = 6;
-  required string description = 7;
-  repeated TimelineAnnotation timeline = 8;
-}


[08/12] incubator-htrace git commit: removing commented code

Posted by le...@apache.org.
removing commented code


Project: http://git-wip-us.apache.org/repos/asf/incubator-htrace/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-htrace/commit/8ccbb896
Tree: http://git-wip-us.apache.org/repos/asf/incubator-htrace/tree/8ccbb896
Diff: http://git-wip-us.apache.org/repos/asf/incubator-htrace/diff/8ccbb896

Branch: refs/heads/master
Commit: 8ccbb89684bd64ef3899991fafaf51db6c41909f
Parents: a6ca3cc
Author: Nisala Nirmana <ni...@gmail.com>
Authored: Mon Aug 8 08:43:13 2016 +0530
Committer: Nisala Nirmana <ni...@gmail.com>
Committed: Mon Aug 8 08:43:13 2016 +0530

----------------------------------------------------------------------
 .../htrace/impl/KuduClientConfiguration.java    | 27 --------------------
 1 file changed, 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/8ccbb896/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java
index 742f0ef..25d6fc4 100644
--- a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java
+++ b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java
@@ -50,33 +50,6 @@ public class KuduClientConfiguration {
     this.socketReadTimeout = socketReadTimeout;
   }
 
-  /*
-  public void setWorkerCount(int workerCount) {
-    this.workerCount = workerCount;
-  }
-
-  public void setBossCount(int bossCount) {
-    this.bossCount = bossCount;
-  }
-
-  public void setIsStatisticsEnabled(boolean isStatisticsEnabled) {
-    this.isStatisticsEnabled = isStatisticsEnabled;
-  }
-
-  public void setAdminOperationTimeout(long adminOperationTimeout) {
-    this.adminOperationTimeout = adminOperationTimeout;
-  }
-
-  public void setOperationTimeout(long operationTimeout) {
-    this.operationTimeout = operationTimeout;
-  }
-
-  public void setSocketReadTimeout(long socketReadTimeout) {
-    this.socketReadTimeout = socketReadTimeout;
-  }
-
-  */
-
   public KuduClient buildClient() {
     KuduClientBuilder builder = new KuduClient
             .KuduClientBuilder(host.concat(":").concat(port));


[11/12] incubator-htrace git commit: adding colin review fixes on storing all parents

Posted by le...@apache.org.
adding colin review fixes on storing all parents


Project: http://git-wip-us.apache.org/repos/asf/incubator-htrace/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-htrace/commit/641d05bf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-htrace/tree/641d05bf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-htrace/diff/641d05bf

Branch: refs/heads/master
Commit: 641d05bfe3b65e4df7c9097d7f3a3c8f76179f9b
Parents: 4b2e213
Author: Nisala Nirmana <ni...@gmail.com>
Authored: Mon Aug 29 01:41:56 2016 +0530
Committer: Nisala Nirmana <ni...@gmail.com>
Committed: Mon Aug 29 01:41:56 2016 +0530

----------------------------------------------------------------------
 .../htrace/impl/KuduReceiverConstants.java      |  7 ++-
 .../apache/htrace/impl/KuduSpanReceiver.java    | 41 +++++++++----
 .../htrace/impl/TestKuduSpanReceiver.java       | 61 +++++++++++++++-----
 .../apache/htrace/impl/TestKuduSpanViewer.java  |  6 --
 4 files changed, 83 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/641d05bf/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduReceiverConstants.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduReceiverConstants.java b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduReceiverConstants.java
index 805ec80..c7f7484 100644
--- a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduReceiverConstants.java
+++ b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduReceiverConstants.java
@@ -25,14 +25,17 @@ public class KuduReceiverConstants {
   static final String DEFAULT_KUDU_MASTER_PORT = "7051";
   static final String KUDU_SPAN_TABLE_KEY = "kudu.span.table";
   static final String DEFAULT_KUDU_SPAN_TABLE = "span";
+  static final String KUDU_SPAN_PARENT_TABLE_KEY = "kudu.span.parent.table";
+  static final String DEFAULT_KUDU_SPAN_PARENT_TABLE = "span.parent";
   static final String KUDU_SPAN_TIMELINE_ANNOTATION_TABLE_KEY = "kudu.span.timeline.annotation.table";
   static final String DEFAULT_KUDU_SPAN_TIMELINE_ANNOTATION_TABLE = "span.timeline";
   static final String DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID = "trace_id";
   static final String DEFAULT_KUDU_COLUMN_SPAN_START_TIME = "start_time";
   static final String DEFAULT_KUDU_COLUMN_SPAN_STOP_TIME = "stop_time";
   static final String DEFAULT_KUDU_COLUMN_SPAN_SPAN_ID = "span_id";
-  static final String DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_LOW = "parent_id_low";
-  static final String DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_HIGH = "parent_id_high";
+  static final String DEFAULT_KUDU_COLUMN_PARENT_ID_LOW = "parent_id_low";
+  static final String DEFAULT_KUDU_COLUMN_PARENT_ID_HIGH = "parent_id_high";
+  static final String DEFAULT_KUDU_COLUMN_PARENT_CHILD_SPANID = "parent_child_span_id";
   static final String DEFAULT_KUDU_COLUMN_SPAN_DESCRIPTION = "description";
   static final String DEFAULT_KUDU_COLUMN_SPAN_PARENT = "parent";
   static final String DEFAULT_KUDU_COLUMN_TIMELINE_TIME = "time";

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/641d05bf/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java
index 745f24d..5db017b 100644
--- a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java
+++ b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java
@@ -44,8 +44,6 @@ public class KuduSpanReceiver extends SpanReceiver {
   private String column_span_start_time;
   private String column_span_stop_time;
   private String column_span_span_id;
-  private String column_span_parent_id_low;
-  private String column_span_parent_id_high;
   private String column_span_description;
   private String column_span_parent;
 
@@ -55,6 +53,15 @@ public class KuduSpanReceiver extends SpanReceiver {
   private String column_timeline_message;
   private String column_timeline_span_id;
 
+  private String table_span_parent;
+  private String column_parent_id_low;
+  private String column_parent_id_high;
+  private String column_parent_child_span_id;
+
+  private KuduTable tableSpan;
+  private KuduTable tableTimeline;
+  private KuduTable tableParent;
+
   public KuduSpanReceiver(HTraceConfiguration conf) {
 
     String masterHost;
@@ -114,13 +121,18 @@ public class KuduSpanReceiver extends SpanReceiver {
     this.table_span = conf.get(KuduReceiverConstants.KUDU_SPAN_TABLE_KEY, KuduReceiverConstants.DEFAULT_KUDU_SPAN_TABLE);
     this.table_timeline = conf.get(KuduReceiverConstants.KUDU_SPAN_TIMELINE_ANNOTATION_TABLE_KEY,
             KuduReceiverConstants.DEFAULT_KUDU_SPAN_TIMELINE_ANNOTATION_TABLE);
+    this.table_span_parent = conf.get(KuduReceiverConstants.KUDU_SPAN_PARENT_TABLE_KEY,
+            KuduReceiverConstants.DEFAULT_KUDU_SPAN_PARENT_TABLE);
     //default column names have used
     this.column_span_trace_id = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID;
     this.column_span_start_time = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_START_TIME;
     this.column_span_stop_time = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_STOP_TIME;
     this.column_span_span_id = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_SPAN_ID;
-    this.column_span_parent_id_low = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_LOW;
-    this.column_span_parent_id_high = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_HIGH;
+
+    this.column_parent_id_low = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_PARENT_ID_LOW;
+    this.column_parent_id_high = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_PARENT_ID_HIGH;
+    this.column_parent_child_span_id = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_PARENT_CHILD_SPANID;
+
     this.column_span_description = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_DESCRIPTION;
     this.column_span_parent = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT;
     this.column_timeline_time = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_TIME;
@@ -134,6 +146,13 @@ public class KuduSpanReceiver extends SpanReceiver {
       }
       session = client.newSession();
     }
+    try {
+      tableSpan = client.openTable(table_span);
+      tableTimeline = client.openTable(table_timeline);
+      tableParent = client.openTable(table_span_parent);
+    } catch (java.lang.Exception ex) {
+      LOG.warn("Failed to open kudu tables to store Spans. " + ex.getMessage());
+    }
   }
 
   @Override
@@ -153,7 +172,6 @@ public class KuduSpanReceiver extends SpanReceiver {
   @Override
   public void receiveSpan(Span span) {
    try {
-      KuduTable tableSpan = client.openTable(table_span);
       Insert spanInsert = tableSpan.newInsert();
       PartialRow spanRow = spanInsert.getRow();
       spanRow.addLong(column_span_trace_id, span.getSpanId().getLow());
@@ -161,12 +179,16 @@ public class KuduSpanReceiver extends SpanReceiver {
       spanRow.addLong(column_span_stop_time, span.getStopTimeMillis());
       spanRow.addLong(column_span_span_id, span.getSpanId().getHigh());
       if (span.getParents().length == 0) {
-        spanRow.addLong(column_span_parent_id_low, 0);
-        spanRow.addLong(column_span_parent_id_high, 0);
         spanRow.addBoolean(column_span_parent, true);
       } else if (span.getParents().length > 0) {
-        spanRow.addLong(column_span_parent_id_low, span.getParents()[0].getLow());
-        spanRow.addLong(column_span_parent_id_high, span.getParents()[0].getHigh());
+        for (int i = 0; i < span.getParents().length; i++) {
+          Insert parentInsert = tableParent.newInsert();
+          PartialRow parentRow = parentInsert.getRow();
+          parentRow.addLong(column_parent_id_low, span.getParents()[i].getLow());
+          parentRow.addLong(column_parent_id_high, span.getParents()[i].getHigh());
+          parentRow.addLong(column_parent_child_span_id, span.getSpanId().getLow());
+          session.apply(parentInsert);
+        }
         spanRow.addBoolean(column_span_parent, false);
       }
       spanRow.addString(column_span_description, span.getDescription());
@@ -174,7 +196,6 @@ public class KuduSpanReceiver extends SpanReceiver {
       long annotationCounter = 0;
       for (TimelineAnnotation ta : span.getTimelineAnnotations()) {
         annotationCounter++;
-        KuduTable tableTimeline = client.openTable(table_timeline);
         Insert timelineInsert = tableTimeline.newInsert();
         PartialRow timelineRow = timelineInsert.getRow();
         timelineRow.addLong(column_timeline_timeline_id, span.getSpanId().getLow() + annotationCounter);

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/641d05bf/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java b/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java
index c13970d..4ac3657 100644
--- a/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java
+++ b/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java
@@ -83,12 +83,6 @@ public class TestKuduSpanReceiver extends BaseKuduTest {
     span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_SPAN_ID,
             Type.INT64)
             .build());
-    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_HIGH,
-            Type.INT64)
-            .build());
-    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_LOW,
-            Type.INT64)
-            .build());
     span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT,
             Type.BOOL)
             .build());
@@ -121,6 +115,25 @@ public class TestKuduSpanReceiver extends BaseKuduTest {
     Schema timelineSchema = new Schema(timeline_columns);
     client.createTable(KuduReceiverConstants.DEFAULT_KUDU_SPAN_TIMELINE_ANNOTATION_TABLE, timelineSchema,
             new CreateTableOptions().setRangePartitionColumns(rangeKeysTimeline));
+
+    List<ColumnSchema> parent_columns = new ArrayList();
+    parent_columns.add(new ColumnSchema.ColumnSchemaBuilder
+            (KuduReceiverConstants.DEFAULT_KUDU_COLUMN_PARENT_ID_LOW, Type.INT64)
+            .key(true)
+            .build());
+    parent_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_PARENT_ID_HIGH,
+            Type.INT64)
+            .build());
+    parent_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_PARENT_CHILD_SPANID,
+            Type.INT64)
+            .build());
+    List<String> rangeKeysParent= new ArrayList<>();
+    rangeKeysParent.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_PARENT_ID_LOW);
+    Schema parentSchema = new Schema(parent_columns);
+    client.createTable(KuduReceiverConstants.DEFAULT_KUDU_SPAN_PARENT_TABLE, parentSchema,
+            new CreateTableOptions().setRangePartitionColumns(rangeKeysParent));
+
+
   }
 
   @Ignore
@@ -139,6 +152,9 @@ public class TestKuduSpanReceiver extends BaseKuduTest {
     TraceScope scope = tracer.newScope("testKuduScope");
     scope.addTimelineAnnotation("test");
     Span testSpan = scope.getSpan();
+    TraceScope childScope = tracer.newScope("testKuduChildScope", new SpanId(100,200));
+    Span childScopeSpan = childScope.getSpan();
+    childScope.close();
     scope.close();
     tracer.close();
     KuduClient client = BaseKuduTest.syncClient;
@@ -148,8 +164,6 @@ public class TestKuduSpanReceiver extends BaseKuduTest {
     spanColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_DESCRIPTION);
     spanColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_START_TIME);
     spanColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_STOP_TIME);
-    spanColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_HIGH);
-    spanColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_LOW);
     KuduScanner scanner = client.newScannerBuilder(client.openTable(KuduReceiverConstants.DEFAULT_KUDU_SPAN_TABLE))
             .setProjectedColumnNames(spanColumns)
             .build();
@@ -165,13 +179,32 @@ public class TestKuduSpanReceiver extends BaseKuduTest {
                 .description(result.getString(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_DESCRIPTION))
                 .begin(result.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_START_TIME))
                 .end(result.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_STOP_TIME));
-        if (!(result.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_HIGH) == 0 &&
-                result.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_LOW) == 0)) {
-          SpanId[] parents = new SpanId[1];
-          parents[0] = new SpanId(result.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_HIGH),
-                  result.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_LOW));
-          builder.parents(parents);
+
+        List<String> parentColumns = new ArrayList<>();
+        parentColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_PARENT_ID_LOW);
+        parentColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_PARENT_ID_HIGH);
+        parentColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_PARENT_CHILD_SPANID);
+        KuduScanner parentScanner = client
+                .newScannerBuilder(client.openTable(KuduReceiverConstants.DEFAULT_KUDU_SPAN_PARENT_TABLE))
+                .setProjectedColumnNames(parentColumns)
+                .addPredicate(KuduPredicate
+                        .newComparisonPredicate(new ColumnSchema.ColumnSchemaBuilder
+                                (KuduReceiverConstants.DEFAULT_KUDU_COLUMN_PARENT_CHILD_SPANID, Type.INT64)
+                                .build(), KuduPredicate.ComparisonOp.EQUAL, traceId))
+                .build();
+        List<SpanId> parentList = new LinkedList<SpanId>();
+        while (parentScanner.hasMoreRows()) {
+          RowResultIterator parentResults = parentScanner.nextRows();
+          while (parentResults.hasNext()) {
+            RowResult parentRow = parentResults.next();
+            parentList.add(new SpanId(
+                    parentRow.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_PARENT_ID_HIGH),
+                    parentRow.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_PARENT_ID_LOW)));
+          }
         }
+        SpanId[] array = new SpanId[parentList.size()];
+        parentList.toArray(array);
+        builder.parents(array);
         List<String> timelineColumns = new ArrayList<>();
         timelineColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_TIME);
         timelineColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_MESSAGE);

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/641d05bf/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanViewer.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanViewer.java b/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanViewer.java
index 7dd2807..c32a3bd 100644
--- a/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanViewer.java
+++ b/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanViewer.java
@@ -76,12 +76,6 @@ public class TestKuduSpanViewer extends BaseKuduTest {
     span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_SPAN_ID,
             Type.INT64)
             .build());
-    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_LOW,
-            Type.INT64)
-            .build());
-    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_HIGH,
-            Type.INT64)
-            .build());
     span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT,
             Type.BOOL)
             .build());


[05/12] incubator-htrace git commit: adding colin review changes to span receiver

Posted by le...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/a6ca3ccf/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java b/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java
index e045eba..8b446e2 100644
--- a/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java
+++ b/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java
@@ -18,16 +18,18 @@
 package org.apache.htrace.impl;
 
 import org.apache.htrace.core.Tracer;
-import org.apache.htrace.core.Span;
 import org.apache.htrace.core.TracerPool;
+import org.apache.htrace.core.Span;
+import org.apache.htrace.core.SpanId;
+import org.apache.htrace.core.MilliSpan;
 import org.apache.htrace.core.TraceScope;
 import org.apache.htrace.core.HTraceConfiguration;
-import org.apache.htrace.protobuf.generated.SpanProtos;
-import org.junit.Assert;
+import org.apache.htrace.core.TimelineAnnotation;
 import org.junit.BeforeClass;
-import org.junit.AfterClass;
 import org.junit.Ignore;
 import org.junit.Test;
+import org.junit.Assert;
+import org.junit.AfterClass;
 import org.kududb.Schema;
 import org.kududb.Type;
 import org.kududb.ColumnSchema;
@@ -37,50 +39,88 @@ import org.kududb.client.CreateTableOptions;
 import org.kududb.client.KuduScanner;
 import org.kududb.client.RowResultIterator;
 import org.kududb.client.RowResult;
+import org.kududb.client.KuduPredicate;
 
-
-import java.io.ByteArrayInputStream;
 import java.util.ArrayList;
+import java.util.LinkedList;
 import java.util.List;
 
 public class TestKuduSpanReceiver extends BaseKuduTest {
 
   private static final String BIN_DIR_PROP = "binDir";
-  private static final String BIN_DIR_PROP_DEFAULT = "../build/release/bin";
+  private static final String BIN_DIR_PROP_DEFAULT = "./build/release/bin";
+  //set kudu binary location and enable test execution from here
+  private static final boolean TEST_ENABLE = false;
 
   @BeforeClass
   public static void setUpBeforeClass() throws Exception {
-    System.setProperty(BIN_DIR_PROP, BIN_DIR_PROP_DEFAULT);
-    BaseKuduTest.setUpBeforeClass();
+    if (TEST_ENABLE) {
+      System.setProperty(BIN_DIR_PROP, BIN_DIR_PROP_DEFAULT);
+      BaseKuduTest.setUpBeforeClass();
+    }
   }
 
   @AfterClass
   public static void tearDownAfterClass() throws Exception {
-    BaseKuduTest.tearDownAfterClass();
+    if(TEST_ENABLE) {
+      BaseKuduTest.tearDownAfterClass();
+    }
   }
 
   private void createTable() throws Exception {
     KuduClient client = BaseKuduTest.syncClient;
-    List<ColumnSchema> columns = new ArrayList(4);
-    columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_ID,
-            Type.BINARY)
+    List<ColumnSchema> span_columns = new ArrayList();
+    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID,
+            Type.INT64)
             .key(true)
             .build());
-    columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN,
-            Type.BINARY)
+    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_START_TIME,
+            Type.INT64)
             .build());
-    columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_ROOT_SPAN_START_TIME,
-            Type.BINARY)
+    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_STOP_TIME,
+            Type.INT64)
             .build());
-    columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_ROOT_SPAN,
-            Type.BINARY)
+    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_SPAN_ID,
+            Type.INT64)
+            .build());
+    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PROCESS_ID,
+            Type.STRING)
+            .build());
+    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID,
+            Type.INT64)
+            .build());
+    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT,
+            Type.BOOL)
+            .build());
+    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_DESCRIPTION,
+            Type.STRING)
             .build());
-    List<String> rangeKeys = new ArrayList<>();
-    rangeKeys.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_ID);
 
-    Schema schema = new Schema(columns);
-    client.createTable(KuduReceiverConstants.DEFAULT_KUDU_TABLE, schema,
+    List<String> rangeKeys = new ArrayList<>();
+    rangeKeys.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID);
+    Schema schema = new Schema(span_columns);
+    client.createTable(KuduReceiverConstants.DEFAULT_KUDU_SPAN_TABLE, schema,
             new CreateTableOptions().setRangePartitionColumns(rangeKeys));
+
+    List<ColumnSchema> timeline_columns = new ArrayList();
+    timeline_columns.add(new ColumnSchema.ColumnSchemaBuilder
+            (KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_TIMELINEID, Type.INT64)
+            .key(true)
+            .build());
+    timeline_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_TIME,
+            Type.INT64)
+            .build());
+    timeline_columns.add(new ColumnSchema.ColumnSchemaBuilder
+            (KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_MESSAGE, Type.STRING)
+            .build());
+    timeline_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_SPANID,
+            Type.INT64)
+            .build());
+    List<String> rangeKeysTimeline = new ArrayList<>();
+    rangeKeysTimeline.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_TIMELINEID);
+    Schema timelineSchema = new Schema(timeline_columns);
+    client.createTable(KuduReceiverConstants.DEFAULT_KUDU_SPAN_TIMELINE_ANNOTATION_TABLE, timelineSchema,
+            new CreateTableOptions().setRangePartitionColumns(rangeKeysTimeline));
   }
 
   @Ignore
@@ -98,31 +138,63 @@ public class TestKuduSpanReceiver extends BaseKuduTest {
             .build();
     TraceScope scope = tracer.newScope("testKuduScope");
     Span testSpan = scope.getSpan();
-    SpanProtos.Span dbSpan = null;
     scope.close();
     tracer.close();
     KuduClient client = BaseKuduTest.syncClient;
-    List<String> projectColumns = new ArrayList<>(1);
-    projectColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN);
-    KuduScanner scanner = client.newScannerBuilder(client.openTable(KuduReceiverConstants.DEFAULT_KUDU_TABLE))
-            .setProjectedColumnNames(projectColumns)
+    List<String> spanColumns = new ArrayList<>();
+    spanColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID);
+    spanColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_SPAN_ID);
+    spanColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_DESCRIPTION);
+    spanColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_START_TIME);
+    spanColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_STOP_TIME);
+    KuduScanner scanner = client.newScannerBuilder(client.openTable(KuduReceiverConstants.DEFAULT_KUDU_SPAN_TABLE))
+            .setProjectedColumnNames(spanColumns)
             .build();
+    MilliSpan dbSpan = null;
     while (scanner.hasMoreRows()) {
       RowResultIterator results = scanner.nextRows();
       while (results.hasNext()) {
         RowResult result = results.next();
-        ByteArrayInputStream in = new
-                ByteArrayInputStream(result.getBinaryCopy(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN));
-        dbSpan = SpanProtos.Span.parseFrom(in);
+        long traceId = result.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID);
+        MilliSpan.Builder builder = new MilliSpan.Builder()
+                .spanId(new SpanId(result.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID),
+                        result.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_SPAN_ID)))
+                .description(result.getString(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_DESCRIPTION))
+                .begin(result.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_START_TIME))
+                .end(result.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_STOP_TIME));
+        List<String> timelineColumns = new ArrayList<>();
+        timelineColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_TIME);
+        timelineColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_MESSAGE);
+        KuduScanner timelineScanner = client
+                .newScannerBuilder(client.openTable(KuduReceiverConstants.DEFAULT_KUDU_SPAN_TIMELINE_ANNOTATION_TABLE))
+                .setProjectedColumnNames(timelineColumns)
+                .addPredicate(KuduPredicate
+                        .newComparisonPredicate(new ColumnSchema.ColumnSchemaBuilder
+                                (KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_SPANID, Type.INT64)
+                                .build(), KuduPredicate.ComparisonOp.EQUAL, traceId))
+                .build();
+        List<TimelineAnnotation> timelineList = new LinkedList<TimelineAnnotation>();
+        while (timelineScanner.hasMoreRows()) {
+          RowResultIterator timelineResults = timelineScanner.nextRows();
+          while (timelineResults.hasNext()) {
+            RowResult timelineRow = results.next();
+            timelineList.add(new TimelineAnnotation
+                    (timelineRow.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_TIME),
+                            timelineRow.getString(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_MESSAGE)));
+          }
+        }
+        builder.timeline(timelineList);
+        dbSpan = builder.build();
         break;
       }
     }
-    Assert.assertEquals(testSpan.getSpanId().getHigh(), dbSpan.getTraceId());
-    Assert.assertEquals(testSpan.getSpanId().getLow(), dbSpan.getSpanId());
-    Assert.assertEquals(testSpan.getStartTimeMillis(), dbSpan.getStart());
-    Assert.assertEquals(testSpan.getStopTimeMillis(), dbSpan.getStop());
+    Assert.assertEquals(testSpan.getSpanId().getHigh(), dbSpan.getSpanId().getHigh());
+    Assert.assertEquals(testSpan.getSpanId().getLow(), dbSpan.getSpanId().getLow());
+    Assert.assertEquals(testSpan.getStartTimeMillis(), dbSpan.getStartTimeMillis());
+    Assert.assertEquals(testSpan.getStopTimeMillis(), dbSpan.getStopTimeMillis());
     Assert.assertEquals(testSpan.getDescription(), dbSpan.getDescription());
-    syncClient.deleteTable(KuduReceiverConstants.DEFAULT_KUDU_TABLE);
+    syncClient.deleteTable(KuduReceiverConstants.DEFAULT_KUDU_SPAN_TABLE);
+    syncClient.deleteTable(KuduReceiverConstants.DEFAULT_KUDU_SPAN_TIMELINE_ANNOTATION_TABLE);
   }
 
 }


[10/12] incubator-htrace git commit: adding rest endpoints for span viewer web app

Posted by le...@apache.org.
adding rest endpoints for span viewer web app


Project: http://git-wip-us.apache.org/repos/asf/incubator-htrace/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-htrace/commit/4b2e213e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-htrace/tree/4b2e213e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-htrace/diff/4b2e213e

Branch: refs/heads/master
Commit: 4b2e213ea007d3cadc4475ae5833c57ed3843665
Parents: 0cd394f
Author: Nisala Nirmana <ni...@gmail.com>
Authored: Sat Aug 20 00:08:58 2016 +0530
Committer: Nisala Nirmana <ni...@gmail.com>
Committed: Sat Aug 20 00:08:58 2016 +0530

----------------------------------------------------------------------
 htrace-kudu/pom.xml                             |  12 +
 .../htrace/viewer/KuduClientConstants.java      |  45 +++
 .../apache/htrace/viewer/KuduSpanViewer.java    | 300 +++++++++++++++++++
 .../htrace/viewer/KuduSpanViewerRunner.java     |  38 +++
 .../htrace/viewer/KuduSpanViewerServer.java     |  63 ++++
 .../viewer/KuduSpanViewerSpansServlet.java      |  96 ++++++
 .../viewer/KuduSpanViewerTracesServlet.java     |  88 ++++++
 7 files changed, 642 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/4b2e213e/htrace-kudu/pom.xml
----------------------------------------------------------------------
diff --git a/htrace-kudu/pom.xml b/htrace-kudu/pom.xml
index e977bd9..19195e5 100644
--- a/htrace-kudu/pom.xml
+++ b/htrace-kudu/pom.xml
@@ -33,6 +33,7 @@ language governing permissions and limitations under the License. -->
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <kudu.version>0.9.1</kudu.version>
     <commons.version>1.3.2</commons.version>
+    <jetty.version>9.2.13.v20150730</jetty.version>
     <createDependencyReducedPom>true</createDependencyReducedPom>
   </properties>
 
@@ -156,6 +157,17 @@ language governing permissions and limitations under the License. -->
       <artifactId>commons-io</artifactId>
       <version>${commons.version}</version>
     </dependency>
+
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-server</artifactId>
+      <version>${jetty.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-servlet</artifactId>
+      <version>${jetty.version}</version>
+    </dependency>
   </dependencies>
 
   <profiles>

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/4b2e213e/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduClientConstants.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduClientConstants.java b/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduClientConstants.java
new file mode 100644
index 0000000..5945ad6
--- /dev/null
+++ b/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduClientConstants.java
@@ -0,0 +1,45 @@
+/*
+ * 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.viewer;
+
+
+public class KuduClientConstants {
+  static final String KUDU_MASTER_HOST_KEY = "kudu.master.host";
+  static final String DEFAULT_KUDU_MASTER_HOST = "127.0.0.1";
+  static final String KUDU_MASTER_PORT_KEY = "kudu.master.port";
+  static final String DEFAULT_KUDU_MASTER_PORT = "7051";
+  static final String DEFAULT_KUDU_SPAN_TABLE = "span";
+  static final String DEFAULT_KUDU_SPAN_TIMELINE_ANNOTATION_TABLE = "span.timeline";
+  static final String DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID = "trace_id";
+  static final String DEFAULT_KUDU_COLUMN_SPAN_START_TIME = "start_time";
+  static final String DEFAULT_KUDU_COLUMN_SPAN_STOP_TIME = "stop_time";
+  static final String DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_LOW = "parent_id_low";
+  static final String DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_HIGH = "parent_id_high";
+  static final String DEFAULT_KUDU_COLUMN_SPAN_SPAN_ID = "span_id";
+  static final String DEFAULT_KUDU_COLUMN_SPAN_DESCRIPTION = "description";
+  static final String DEFAULT_KUDU_COLUMN_SPAN_PARENT = "parent";
+  static final String DEFAULT_KUDU_COLUMN_TIMELINE_TIME = "time";;
+  static final String DEFAULT_KUDU_COLUMN_TIMELINE_MESSAGE = "message";
+  static final String DEFAULT_KUDU_COLUMN_TIMELINE_SPANID = "spanid";
+  static final String KUDU_CLIENT_WORKER_COUNT_KEY = "kudu.client.worker.count";
+  static final String KUDU_CLIENT_BOSS_COUNT_KEY = "kudu.client.boss.count";
+  static final String KUDU_CLIENT_STATISTICS_ENABLED_KEY = "kudu.client.statistics.enabled";
+  static final String KUDU_CLIENT_TIMEOUT_ADMIN_OPERATION_KEY = "kudu.client.timeout.admin.operation";
+  static final String KUDU_CLIENT_TIMEOUT_OPERATION_KEY = "kudu.client.timeout.operation";
+  static final String KUDU_CLIENT_TIMEOUT_SOCKET_READ_KEY = "kudu.client.timeout.socket.read";
+}

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/4b2e213e/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduSpanViewer.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduSpanViewer.java b/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduSpanViewer.java
new file mode 100644
index 0000000..d3f82d9
--- /dev/null
+++ b/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduSpanViewer.java
@@ -0,0 +1,300 @@
+/*
+ * 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.viewer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.htrace.core.HTraceConfiguration;
+import org.apache.htrace.core.MilliSpan;
+import org.apache.htrace.core.TimelineAnnotation;
+import org.apache.htrace.core.Span;
+import org.apache.htrace.core.SpanId;
+import org.apache.htrace.impl.KuduClientConfiguration;
+import org.kududb.ColumnSchema;
+import org.kududb.Type;
+import org.kududb.client.KuduClient;
+import org.kududb.client.KuduPredicate;
+import org.kududb.client.KuduScanner;
+import org.kududb.client.RowResult;
+import org.kududb.client.RowResultIterator;
+
+import java.io.OutputStreamWriter;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.LinkedList;
+
+public class KuduSpanViewer {
+
+  private static final Log LOG = LogFactory.getLog(KuduSpanViewer.class);
+  private static final String JSON_FIELD_TRACE_ID = "trace_id";
+  private static final String JSON_FIELD_PARENT_ID = "parent_id";
+  private static final String JSON_FIELD_START = "start";
+  private static final String JSON_FIELD_STOP = "stop";
+  private static final String JSON_FIELD_SPAN_ID = "span_id";
+  private static final String JSON_FIELD_DESCRIPTION = "description";
+  private static final String JSON_FIELD_TIMELINE = "timeline";
+  private static final String JSON_FIELD_TIMELINE_TIME = "time";
+  private static final String JSON_FIELD_TIMELINE_MESSEGE = "message";
+  private KuduClient client;
+  private KuduClientConfiguration clientConf;
+
+
+  public KuduSpanViewer(HTraceConfiguration conf) {
+    String masterHost;
+    Integer masterPort;
+    Integer workerCount;
+    Integer bossCount;
+    Boolean isStatisticsEnabled;
+    Long adminOperationTimeout;
+    Long operationTimeout;
+    Long socketReadTimeout;
+    masterHost = conf.get(KuduClientConstants.KUDU_MASTER_HOST_KEY,
+            KuduClientConstants.DEFAULT_KUDU_MASTER_HOST);
+    masterPort = Integer.valueOf(conf.get(KuduClientConstants.KUDU_MASTER_PORT_KEY,
+            KuduClientConstants.DEFAULT_KUDU_MASTER_PORT));
+
+    if (conf.get(KuduClientConstants.KUDU_CLIENT_BOSS_COUNT_KEY) != null) {
+      bossCount = Integer.valueOf(conf.get(KuduClientConstants.KUDU_CLIENT_BOSS_COUNT_KEY));
+    } else {
+      bossCount = null;
+    }
+    if (conf.get(KuduClientConstants.KUDU_CLIENT_WORKER_COUNT_KEY) != null) {
+      workerCount = Integer.valueOf(conf.get(KuduClientConstants.KUDU_CLIENT_WORKER_COUNT_KEY));
+    } else {
+      workerCount = null;
+    }
+    if (conf.get(KuduClientConstants.KUDU_CLIENT_STATISTICS_ENABLED_KEY) != null) {
+      isStatisticsEnabled = Boolean.valueOf(conf.get(KuduClientConstants.KUDU_CLIENT_STATISTICS_ENABLED_KEY));
+    } else {
+      isStatisticsEnabled = null;
+    }
+    if (conf.get(KuduClientConstants.KUDU_CLIENT_TIMEOUT_ADMIN_OPERATION_KEY) != null) {
+      adminOperationTimeout = Long.valueOf(conf.get(KuduClientConstants.KUDU_CLIENT_TIMEOUT_ADMIN_OPERATION_KEY));
+    } else {
+      adminOperationTimeout = null;
+    }
+    if (conf.get(KuduClientConstants.KUDU_CLIENT_TIMEOUT_OPERATION_KEY) != null) {
+      operationTimeout = Long.valueOf(conf.get(KuduClientConstants.KUDU_CLIENT_TIMEOUT_OPERATION_KEY));
+    } else {
+      operationTimeout = null;
+    }
+    if (conf.get(KuduClientConstants.KUDU_CLIENT_TIMEOUT_SOCKET_READ_KEY) != null) {
+      socketReadTimeout = Long.valueOf(conf.get(KuduClientConstants.KUDU_CLIENT_TIMEOUT_SOCKET_READ_KEY));
+    } else {
+      socketReadTimeout = null;
+    }
+    this.clientConf = new KuduClientConfiguration(masterHost,
+            masterPort,
+            workerCount,
+            bossCount,
+            isStatisticsEnabled,
+            adminOperationTimeout,
+            operationTimeout,
+            socketReadTimeout);
+    this.client = clientConf.buildClient();
+  }
+
+  public List<Span> getSpans(long spanId) throws Exception {
+    List<Span> spans = new ArrayList<Span>();
+    List<String> spanColumns = new ArrayList<>();
+    spanColumns.add(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID);
+    spanColumns.add(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_SPAN_ID);
+    spanColumns.add(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_DESCRIPTION);
+    spanColumns.add(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_START_TIME);
+    spanColumns.add(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_STOP_TIME);
+    spanColumns.add(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_HIGH);
+    spanColumns.add(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_LOW);
+    KuduScanner scanner = client.newScannerBuilder(client.openTable(KuduClientConstants.DEFAULT_KUDU_SPAN_TABLE))
+            .setProjectedColumnNames(spanColumns)
+            .addPredicate(KuduPredicate
+                    .newComparisonPredicate(new ColumnSchema.ColumnSchemaBuilder
+                            (KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_SPAN_ID, Type.INT64)
+                            .build(), KuduPredicate.ComparisonOp.EQUAL, spanId))
+            .build();
+    MilliSpan dbSpan;
+    while (scanner.hasMoreRows()) {
+      RowResultIterator results = scanner.nextRows();
+      while (results.hasNext()) {
+        RowResult result = results.next();
+        long traceId = result.getLong(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID);
+        MilliSpan.Builder builder = new MilliSpan.Builder()
+                .spanId(new SpanId(result.getLong(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_SPAN_ID),
+                        result.getLong(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID)))
+                .description(result.getString(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_DESCRIPTION))
+                .begin(result.getLong(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_START_TIME))
+                .end(result.getLong(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_STOP_TIME));
+        if (!(result.getLong(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_HIGH) == 0 &&
+                result.getLong(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_LOW) == 0)) {
+          SpanId[] parents = new SpanId[1];
+          parents[0] = new SpanId(result.getLong(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_HIGH),
+                  result.getLong(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_LOW));
+          builder.parents(parents);
+        }
+        List<String> timelineColumns = new ArrayList<>();
+        timelineColumns.add(KuduClientConstants.DEFAULT_KUDU_COLUMN_TIMELINE_TIME);
+        timelineColumns.add(KuduClientConstants.DEFAULT_KUDU_COLUMN_TIMELINE_MESSAGE);
+        KuduScanner timelineScanner = client
+                .newScannerBuilder(client.openTable(KuduClientConstants.DEFAULT_KUDU_SPAN_TIMELINE_ANNOTATION_TABLE))
+                .setProjectedColumnNames(timelineColumns)
+                .addPredicate(KuduPredicate
+                        .newComparisonPredicate(new ColumnSchema.ColumnSchemaBuilder
+                                (KuduClientConstants.DEFAULT_KUDU_COLUMN_TIMELINE_SPANID, Type.INT64)
+                                .build(), KuduPredicate.ComparisonOp.EQUAL, traceId))
+                .build();
+        List<TimelineAnnotation> timelineList = new LinkedList<TimelineAnnotation>();
+        while (timelineScanner.hasMoreRows()) {
+          RowResultIterator timelineResults = timelineScanner.nextRows();
+          while (timelineResults.hasNext()) {
+            RowResult timelineRow = timelineResults.next();
+            timelineList.add(new TimelineAnnotation
+                    (timelineRow.getLong(KuduClientConstants.DEFAULT_KUDU_COLUMN_TIMELINE_TIME),
+                            timelineRow.getString(KuduClientConstants.DEFAULT_KUDU_COLUMN_TIMELINE_MESSAGE)));
+          }
+        }
+        builder.timeline(timelineList);
+        dbSpan = builder.build();
+        spans.add(dbSpan);
+      }
+    }
+    return spans;
+  }
+
+  public List<Span> getRootSpans() throws Exception {
+    List<Span> spans = new ArrayList<Span>();
+    List<String> spanColumns = new ArrayList<>();
+    spanColumns.add(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID);
+    spanColumns.add(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_SPAN_ID);
+    spanColumns.add(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_DESCRIPTION);
+    spanColumns.add(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_START_TIME);
+    spanColumns.add(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_STOP_TIME);
+    KuduScanner scanner = client.newScannerBuilder(client.openTable(KuduClientConstants.DEFAULT_KUDU_SPAN_TABLE))
+            .setProjectedColumnNames(spanColumns)
+            .addPredicate(KuduPredicate
+                    .newComparisonPredicate(new ColumnSchema.ColumnSchemaBuilder
+                            (KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT, Type.BOOL)
+                            .build(), KuduPredicate.ComparisonOp.EQUAL, true))
+            .build();
+    MilliSpan dbSpan;
+    while (scanner.hasMoreRows()) {
+      RowResultIterator results = scanner.nextRows();
+      while (results.hasNext()) {
+        RowResult result = results.next();
+        long traceId = result.getLong(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID);
+        MilliSpan.Builder builder = new MilliSpan.Builder()
+                .spanId(new SpanId(result.getLong(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_SPAN_ID),
+                        result.getLong(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID)))
+                .description(result.getString(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_DESCRIPTION))
+                .begin(result.getLong(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_START_TIME))
+                .end(result.getLong(KuduClientConstants.DEFAULT_KUDU_COLUMN_SPAN_STOP_TIME));
+        List<String> timelineColumns = new ArrayList<>();
+        timelineColumns.add(KuduClientConstants.DEFAULT_KUDU_COLUMN_TIMELINE_TIME);
+        timelineColumns.add(KuduClientConstants.DEFAULT_KUDU_COLUMN_TIMELINE_MESSAGE);
+        KuduScanner timelineScanner = client
+                .newScannerBuilder(client.openTable(KuduClientConstants.DEFAULT_KUDU_SPAN_TIMELINE_ANNOTATION_TABLE))
+                .setProjectedColumnNames(timelineColumns)
+                .addPredicate(KuduPredicate
+                        .newComparisonPredicate(new ColumnSchema.ColumnSchemaBuilder
+                                (KuduClientConstants.DEFAULT_KUDU_COLUMN_TIMELINE_SPANID, Type.INT64)
+                                .build(), KuduPredicate.ComparisonOp.EQUAL, traceId))
+                .build();
+        List<TimelineAnnotation> timelineList = new LinkedList<TimelineAnnotation>();
+        while (timelineScanner.hasMoreRows()) {
+          RowResultIterator timelineResults = timelineScanner.nextRows();
+          while (timelineResults.hasNext()) {
+            RowResult timelineRow = timelineResults.next();
+            timelineList.add(new TimelineAnnotation
+                    (timelineRow.getLong(KuduClientConstants.DEFAULT_KUDU_COLUMN_TIMELINE_TIME),
+                            timelineRow.getString(KuduClientConstants.DEFAULT_KUDU_COLUMN_TIMELINE_MESSAGE)));
+          }
+        }
+        builder.timeline(timelineList);
+        dbSpan = builder.build();
+        spans.add(dbSpan);
+      }
+    }
+    return spans;
+  }
+
+  public void close() {
+    try {
+      this.client.close();
+    } catch (java.lang.Exception ex) {
+      LOG.error("Couln't close the Kudu DB client connection.", ex);
+    }
+  }
+
+
+  public static String toJsonString(final Span span) throws IOException {
+    ByteArrayOutputStream out = new ByteArrayOutputStream();
+    OutputStreamWriter writer =
+            new OutputStreamWriter(out, Charset.defaultCharset());
+    appendJsonString(span, writer);
+    writer.flush();
+    out.flush();
+    return out.toString();
+  }
+
+  public static void appendJsonString(Span span, OutputStreamWriter writer) throws IOException {
+    writer.append("{");
+    appendField(JSON_FIELD_TRACE_ID, span.getSpanId().getLow(), writer);
+    appendField(JSON_FIELD_SPAN_ID, span.getSpanId().getHigh(), writer);
+    appendField(JSON_FIELD_DESCRIPTION, span.getDescription(), writer);
+    if (span.getParents().length != 0) {
+      appendField(JSON_FIELD_PARENT_ID, span.getParents()[0].getLow(), writer);
+    }
+    appendField(JSON_FIELD_START, span.getStartTimeMillis(), writer);
+    appendField(JSON_FIELD_STOP, span.getStopTimeMillis(), writer);
+    if (!span.getTimelineAnnotations().isEmpty()) {
+      writer.append("\"");
+      writer.append(JSON_FIELD_TIMELINE);
+      writer.append("\"");
+      writer.append(":");
+      writer.append("[");
+      for (TimelineAnnotation annotation : span.getTimelineAnnotations()) {
+        writer.append("{");
+        appendField(JSON_FIELD_TIMELINE_TIME, annotation.getTime(), writer);
+        appendField(JSON_FIELD_TIMELINE_MESSEGE, annotation.getMessage(), writer);
+        writer.append("}");
+      }
+      writer.append("]");
+    }
+    writer.append("}");
+  }
+
+  private static void appendField(String field,
+                                  Object value,
+                                  OutputStreamWriter writer) throws IOException {
+    writer.append("\"");
+    writer.append(field);
+    writer.append("\"");
+    writer.append(":");
+    appendStringValue(value.toString(), writer);
+    writer.append(",");
+  }
+
+  private static void appendStringValue(String value,
+                                        OutputStreamWriter writer) throws IOException {
+    writer.append("\"");
+    writer.append(value.toString());
+    writer.append("\"");
+  }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/4b2e213e/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduSpanViewerRunner.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduSpanViewerRunner.java b/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduSpanViewerRunner.java
new file mode 100644
index 0000000..e530c8a
--- /dev/null
+++ b/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduSpanViewerRunner.java
@@ -0,0 +1,38 @@
+/*
+ * 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.viewer;
+
+
+import org.apache.htrace.core.HTraceConfiguration;
+
+public class KuduSpanViewerRunner extends Thread {
+  private HTraceConfiguration conf;
+
+  public KuduSpanViewerRunner(HTraceConfiguration conf){
+    this.conf = conf;
+  }
+
+  public void run(){
+    try {
+      new KuduSpanViewerServer().run(conf);
+    }catch (java.lang.Exception ex){
+      //Ignore
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/4b2e213e/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduSpanViewerServer.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduSpanViewerServer.java b/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduSpanViewerServer.java
new file mode 100644
index 0000000..d9b6c6a
--- /dev/null
+++ b/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduSpanViewerServer.java
@@ -0,0 +1,63 @@
+/*
+ * 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.viewer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.htrace.core.HTraceConfiguration;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.servlet.DefaultServlet;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+
+import java.net.InetSocketAddress;
+import java.net.URI;
+
+public class KuduSpanViewerServer {
+
+  private static final Log LOG = LogFactory.getLog(KuduSpanViewerServer.class);
+  public static final String HTRACE_VIEWER_HTTP_ADDRESS_DEFAULT = "0.0.0.0:17000";
+  private Server server;
+
+  public void stop() throws Exception {
+    if (server != null) {
+      server.stop();
+    }
+    LOG.info("Embedded jetty server stopped successfully.");
+  }
+
+  public int run(HTraceConfiguration conf) throws Exception {
+    URI uri = new URI("http://" + HTRACE_VIEWER_HTTP_ADDRESS_DEFAULT);
+    InetSocketAddress addr = new InetSocketAddress(uri.getHost(), uri.getPort());
+    server = new Server(addr);
+    ServletContextHandler root =
+            new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS);
+    server.setHandler(root);
+    root.addServlet(new ServletHolder(new DefaultServlet()),
+            "/");
+    root.addServlet(new ServletHolder(new KuduSpanViewerTracesServlet(conf)),
+            "/gettraces");
+    root.addServlet(new ServletHolder(new KuduSpanViewerSpansServlet(conf)),
+            "/getspans/*");
+
+    server.start();
+    server.join();
+    return 0;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/4b2e213e/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduSpanViewerSpansServlet.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduSpanViewerSpansServlet.java b/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduSpanViewerSpansServlet.java
new file mode 100644
index 0000000..662c21b
--- /dev/null
+++ b/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduSpanViewerSpansServlet.java
@@ -0,0 +1,96 @@
+/*
+ * 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.viewer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.htrace.core.HTraceConfiguration;
+import org.apache.htrace.core.Span;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+public class KuduSpanViewerSpansServlet extends HttpServlet {
+
+  private static final Log LOG = LogFactory.getLog(KuduSpanViewerSpansServlet.class);
+  public static final String PREFIX = "/getspans";
+  private static final ThreadLocal<KuduSpanViewer> kuduSpanViewer =
+          new ThreadLocal<KuduSpanViewer>() {
+            @Override
+            protected KuduSpanViewer initialValue() {
+              return null;
+            }
+          };
+  private HTraceConfiguration conf;
+
+  public KuduSpanViewerSpansServlet(HTraceConfiguration conf) {
+    this.conf = conf;
+  }
+
+  @Override
+  @SuppressWarnings("unchecked")
+  public void doGet(HttpServletRequest request, HttpServletResponse response)
+          throws ServletException, IOException {
+    final String path = request.getRequestURI().substring(PREFIX.length());
+    if (path == null || path.length() == 0) {
+      response.setContentType("text/plain");
+      response.getWriter().print("Invalid input");
+      return;
+    }
+    KuduSpanViewer viewer = kuduSpanViewer.get();
+
+    if (viewer == null) {
+      viewer = new KuduSpanViewer(conf);
+      kuduSpanViewer.set(viewer);
+    }
+    Long traceid = Long.parseLong(path.substring(1));
+    response.setContentType("application/javascript");
+    PrintWriter out = response.getWriter();
+    out.print("[");
+    boolean first = true;
+    try {
+      for (Span span : viewer.getSpans(traceid)) {
+        if (first) {
+          first = false;
+        } else {
+          out.print(",");
+        }
+        out.print(KuduSpanViewer.toJsonString(span));
+      }
+    } catch (java.lang.Exception ex) {
+      LOG.error("Exception occured while retrieving spans from Kudu Backend.");
+    }
+    out.print("]");
+  }
+
+  @Override
+  public void init() throws ServletException {
+  }
+
+  @Override
+  public void destroy() {
+    KuduSpanViewer viewer = kuduSpanViewer.get();
+    if (viewer != null) {
+      viewer.close();
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/4b2e213e/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduSpanViewerTracesServlet.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduSpanViewerTracesServlet.java b/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduSpanViewerTracesServlet.java
new file mode 100644
index 0000000..b296c28
--- /dev/null
+++ b/htrace-kudu/src/main/java/org/apache/htrace/viewer/KuduSpanViewerTracesServlet.java
@@ -0,0 +1,88 @@
+/*
+ * 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.viewer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.htrace.core.HTraceConfiguration;
+import org.apache.htrace.core.Span;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+
+public class KuduSpanViewerTracesServlet extends HttpServlet {
+  private static final Log LOG = LogFactory.getLog(KuduSpanViewerTracesServlet.class);
+  public static final String PREFIX = "/gettraces";
+  private static final ThreadLocal<KuduSpanViewer> kuduSpanViewer =
+          new ThreadLocal<KuduSpanViewer>() {
+            @Override
+            protected KuduSpanViewer initialValue() {
+              return null;
+            }
+          };
+  private HTraceConfiguration conf;
+
+  public KuduSpanViewerTracesServlet(HTraceConfiguration conf) {
+    this.conf = conf;
+  }
+
+  @Override
+  @SuppressWarnings("unchecked")
+  public void doGet(HttpServletRequest request, HttpServletResponse response)
+          throws ServletException, IOException {
+    KuduSpanViewer viewer = kuduSpanViewer.get();
+    if (viewer == null) {
+      viewer = new KuduSpanViewer(conf);
+      kuduSpanViewer.set(viewer);
+    }
+    response.setContentType("application/javascript");
+    PrintWriter out = response.getWriter();
+    out.print("[");
+    boolean first = true;
+    try {
+      for (Span span : viewer.getRootSpans()) {
+        if (first) {
+          first = false;
+        } else {
+          out.print(",");
+        }
+        out.print(KuduSpanViewer.toJsonString(span));
+      }
+    } catch (java.lang.Exception ex) {
+      LOG.error("Exception occured while retrieving spans from Kudu Backend.");
+    }
+    out.print("]");
+  }
+
+  @Override
+  public void init() throws ServletException {
+  }
+
+  @Override
+  public void destroy() {
+    KuduSpanViewer viewer = kuduSpanViewer.get();
+    if (viewer != null) {
+    viewer.close();
+    }
+  }
+}


[07/12] incubator-htrace git commit: adding colin review changes to span receiver

Posted by le...@apache.org.
adding colin review changes to span receiver


Project: http://git-wip-us.apache.org/repos/asf/incubator-htrace/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-htrace/commit/a6ca3ccf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-htrace/tree/a6ca3ccf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-htrace/diff/a6ca3ccf

Branch: refs/heads/master
Commit: a6ca3ccf8007f41a112baf98328b9311b7148e7b
Parents: 5d38e87
Author: Nisala Nirmana <ni...@gmail.com>
Authored: Mon Aug 8 02:55:35 2016 +0530
Committer: Nisala Nirmana <ni...@gmail.com>
Committed: Mon Aug 8 02:55:35 2016 +0530

----------------------------------------------------------------------
 htrace-kudu/pom.xml                             |   51 -
 .../htrace/impl/KuduClientConfiguration.java    |   35 +-
 .../htrace/impl/KuduReceiverConstants.java      |   73 +-
 .../apache/htrace/impl/KuduSpanReceiver.java    |  171 +-
 .../htrace/protobuf/generated/SpanProtos.java   | 2241 ------------------
 htrace-kudu/src/main/protobuf/Span.proto        |   38 -
 .../htrace/impl/TestKuduSpanReceiver.java       |  144 +-
 7 files changed, 295 insertions(+), 2458 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/a6ca3ccf/htrace-kudu/pom.xml
----------------------------------------------------------------------
diff --git a/htrace-kudu/pom.xml b/htrace-kudu/pom.xml
index 58140a6..e977bd9 100644
--- a/htrace-kudu/pom.xml
+++ b/htrace-kudu/pom.xml
@@ -91,10 +91,6 @@ language governing permissions and limitations under the License. -->
                   <pattern>org.apache.commons.logging</pattern>
                   <shadedPattern>org.apache.htrace.shaded.commons.logging</shadedPattern>
                 </relocation>
-                <relocation>
-                  <pattern>com.google.protobuf</pattern>
-                  <shadedPattern>org.apache.htrace.shaded.com.google.protobuf</shadedPattern>
-                </relocation>
               </relocations>
             </configuration>
             <goals>
@@ -132,11 +128,6 @@ language governing permissions and limitations under the License. -->
       <classifier>tests</classifier>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>com.google.protobuf</groupId>
-      <artifactId>protobuf-java</artifactId>
-      <version>2.5.0</version>
-    </dependency>
     <!-- Global deps. -->
     <dependency>
       <groupId>commons-logging</groupId>
@@ -169,48 +160,6 @@ language governing permissions and limitations under the License. -->
 
   <profiles>
     <profile>
-      <id>compile-protobuf</id>
-      <activation>
-        <property>
-          <name>compile-protobuf</name>
-        </property>
-      </activation>
-      <build>
-        <plugins>
-          <plugin>
-            <groupId>org.apache.hadoop</groupId>
-            <artifactId>hadoop-maven-plugins</artifactId>
-            <version>2.7.1</version>
-            <configuration>
-              <protocVersion>${protobuf.version}</protocVersion>
-              <protocCommand>${protoc.path}</protocCommand>
-            </configuration>
-            <executions>
-              <execution>
-                <id>compile-protoc</id>
-                <phase>generate-sources</phase>
-                <goals>
-                  <goal>protoc</goal>
-                </goals>
-                <configuration>
-                  <imports>
-                    <param>${basedir}/src/main/protobuf</param>
-                  </imports>
-                  <source>
-                    <directory>${basedir}/src/main/protobuf</directory>
-                    <includes>
-                      <include>Span.proto</include>
-                    </includes>
-                  </source>
-                  <output>${basedir}/src/main/java/</output>
-                </configuration>
-              </execution>
-            </executions>
-          </plugin>
-        </plugins>
-      </build>
-    </profile>
-    <profile>
       <id>dist</id>
       <build>
         <plugins>

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/a6ca3ccf/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java
index c58dbb2..742f0ef 100644
--- a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java
+++ b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java
@@ -22,20 +22,35 @@ import org.kududb.client.KuduClient.KuduClientBuilder;
 
 public class KuduClientConfiguration {
 
-  private String host;
-  private String port;
-  private Integer workerCount;
-  private Integer bossCount;
-  private Boolean isStatisticsEnabled;
-  private Long adminOperationTimeout;
-  private Long operationTimeout;
-  private Long socketReadTimeout;
+  private final String host;
+  private final String port;
+  private final Integer workerCount;
+  private final Integer bossCount;
+  private final Boolean isStatisticsEnabled;
+  private final Long adminOperationTimeout;
+  private final Long operationTimeout;
+  private final Long socketReadTimeout;
+
+  public KuduClientConfiguration(String host,
+                                 String port,
+                                 Integer workerCount,
+                                 Integer bossCount,
+                                 Boolean isStatisticsEnabled,
+                                 Long adminOperationTimeout,
+                                 Long operationTimeout,
+                                 Long socketReadTimeout) {
 
-  public KuduClientConfiguration(String host, String port) {
     this.host = host;
     this.port = port;
+    this.workerCount = workerCount;
+    this.bossCount = bossCount;
+    this.isStatisticsEnabled = isStatisticsEnabled;
+    this.adminOperationTimeout = adminOperationTimeout;
+    this.operationTimeout = operationTimeout;
+    this.socketReadTimeout = socketReadTimeout;
   }
 
+  /*
   public void setWorkerCount(int workerCount) {
     this.workerCount = workerCount;
   }
@@ -60,6 +75,8 @@ public class KuduClientConfiguration {
     this.socketReadTimeout = socketReadTimeout;
   }
 
+  */
+
   public KuduClient buildClient() {
     KuduClientBuilder builder = new KuduClient
             .KuduClientBuilder(host.concat(":").concat(port));

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/a6ca3ccf/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduReceiverConstants.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduReceiverConstants.java b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduReceiverConstants.java
index a605dfe..be98311 100644
--- a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduReceiverConstants.java
+++ b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduReceiverConstants.java
@@ -19,31 +19,52 @@ package org.apache.htrace.impl;
 
 public class KuduReceiverConstants {
 
-  public static final String KUDU_MASTER_HOST_KEY = "htrace.kudu.master.host";
-  public static final String DEFAULT_KUDU_MASTER_HOST = "127.0.0.1";
-  public static final String KUDU_MASTER_PORT_KEY = "htrace.kudu.master.port";
-  public static final String DEFAULT_KUDU_MASTER_PORT = "7051";
-  public static final String SPAN_BLOCKING_QUEUE_SIZE_KEY = "htrace.kudu.span.queue.size";
-  public static final int DEFAULT_SPAN_BLOCKING_QUEUE_SIZE = 1000;
-  public static final String KUDU_TABLE_KEY = "htrace.kudu.table";
-  public static final String DEFAULT_KUDU_TABLE = "htrace";
-  public static final String MAX_SPAN_BATCH_SIZE_KEY = "htrace.kudu.batch.size";
-  public static final int DEFAULT_MAX_SPAN_BATCH_SIZE = 100;
-  public static final String NUM_PARALLEL_THREADS_KEY = "htrace.kudu.num.threads";
-  public static final int DEFAULT_NUM_PARALLEL_THREADS = 1;
-  public static final String KUDU_COLUMN_SPAN_ID_KEY = "htrace.kudu.column.spanid";
-  public static final String DEFAULT_KUDU_COLUMN_SPAN_ID = "span_id";
-  public static final String KUDU_COLUMN_SPAN_KEY = "htrace.kudu.column.span";
-  public static final String DEFAULT_KUDU_COLUMN_SPAN = "span";
-  public static final String KUDU_COLUMN_ROOT_SPAN_KEY = "htrace.kudu.column.rootspan";
-  public static final String DEFAULT_KUDU_COLUMN_ROOT_SPAN = "root_span";
-  public static final String KUDU_COLUMN_ROOT_SPAN_START_TIME_KEY = "htrace.kudu.column.rootspan.starttime";
-  public static final String DEFAULT_KUDU_COLUMN_ROOT_SPAN_START_TIME = "root_span_start_time";
-  public static final String KUDU_CLIENT_WORKER_COUNT_KEY = "htrace.kudu.client.worker.count";
-  public static final String KUDU_CLIENT_BOSS_COUNT_KEY = "htrace.kudu.client.boss.count";
-  public static final String KUDU_CLIENT_STATISTICS_ENABLED_KEY = "htrace.kudu.client.statistics.enabled";
-  public static final String KUDU_CLIENT_TIMEOUT_ADMIN_OPERATION_KEY = "htrace.kudu.client.timeout.admin.operation";
-  public static final String KUDU_CLIENT_TIMEOUT_OPERATION_KEY = "htrace.kudu.client.timeout.operation";
-  public static final String KUDU_CLIENT_TIMEOUT_SOCKET_READ_KEY = "htrace.kudu.client.timeout.socket.read";
+  static final String KUDU_MASTER_HOST_KEY = "kudu.master.host";
+  static final String DEFAULT_KUDU_MASTER_HOST = "127.0.0.1";
+  static final String KUDU_MASTER_PORT_KEY = "kudu.master.port";
+  static final String DEFAULT_KUDU_MASTER_PORT = "7051";
+  static final String SPAN_BLOCKING_QUEUE_SIZE_KEY = "kudu.span.queue.size";
+  static final int DEFAULT_SPAN_BLOCKING_QUEUE_SIZE = 1000;
+  static final String KUDU_SPAN_TABLE_KEY = "kudu.span.table";
+  static final String DEFAULT_KUDU_SPAN_TABLE = "span";
+  static final String KUDU_SPAN_TIMELINE_ANNOTATION_TABLE_KEY = "kudu.span.timeline.annotation.table";
+  static final String DEFAULT_KUDU_SPAN_TIMELINE_ANNOTATION_TABLE = "span.timeline";
+  static final String MAX_SPAN_BATCH_SIZE_KEY = "kudu.batch.size";
+  static final int DEFAULT_MAX_SPAN_BATCH_SIZE = 100;
+  static final String NUM_PARALLEL_THREADS_KEY = "kudu.num.threads";
+  static final int DEFAULT_NUM_PARALLEL_THREADS = 1;
+  static final String KUDU_COLUMN_SPAN_TRACE_ID_KEY = "kudu.column.span.traceid";
+  static final String DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID = "trace_id";
+  static final String KUDU_COLUMN_SPAN_START_TIME_KEY = "kudu.column.span.starttime";
+  static final String DEFAULT_KUDU_COLUMN_SPAN_START_TIME = "start_time";
+  static final String KUDU_COLUMN_SPAN_STOP_TIME_KEY = "kudu.column.span.stoptime";
+  static final String DEFAULT_KUDU_COLUMN_SPAN_STOP_TIME = "stop_time";
+  static final String KUDU_COLUMN_SPAN_SPAN_ID_KEY = "kudu.column.span.spanid";
+  static final String DEFAULT_KUDU_COLUMN_SPAN_SPAN_ID = "span_id";
+  static final String KUDU_COLUMN_SPAN_PROCESS_ID_KEY = "kudu.column.span.processid";
+  static final String DEFAULT_KUDU_COLUMN_SPAN_PROCESS_ID = "process_id";
+  static final String KUDU_COLUMN_SPAN_PARENT_ID_KEY = "kudu.column.span.parentid";
+  static final String DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID = "parent_id";
+  static final String KUDU_COLUMN_SPAN_DESCRIPTION_KEY = "kudu.column.span.description";
+  static final String DEFAULT_KUDU_COLUMN_SPAN_DESCRIPTION = "description";
+  static final String KUDU_COLUMN_SPAN_PARENT_KEY = "kudu.column.span.parent";
+  static final String DEFAULT_KUDU_COLUMN_SPAN_PARENT = "parent";
+  static final String KUDU_COLUMN_TIMELINE_TIME_KEY = "kudu.column.timeline.time";
+  static final String DEFAULT_KUDU_COLUMN_TIMELINE_TIME = "time";
+  static final String KUDU_COLUMN_TIMELINE_MESSAGE_KEY = "kudu.column.timeline.message";
+  static final String DEFAULT_KUDU_COLUMN_TIMELINE_MESSAGE = "message";
+  static final String KUDU_COLUMN_TIMELINE_SPANID_KEY = "kudu.column.timeline.spanid";
+  static final String DEFAULT_KUDU_COLUMN_TIMELINE_SPANID = "spanid";
+  static final String KUDU_COLUMN_TIMELINE_TIMELINEID_KEY = "kudu.column.timeline.timelineid";
+  static final String DEFAULT_KUDU_COLUMN_TIMELINE_TIMELINEID = "timelineid";
+  static final String KUDU_CLIENT_WORKER_COUNT_KEY = "kudu.client.worker.count";
+  static final String KUDU_CLIENT_BOSS_COUNT_KEY = "kudu.client.boss.count";
+  static final String KUDU_CLIENT_STATISTICS_ENABLED_KEY = "kudu.client.statistics.enabled";
+  static final String KUDU_CLIENT_TIMEOUT_ADMIN_OPERATION_KEY = "kudu.client.timeout.admin.operation";
+  static final String KUDU_CLIENT_TIMEOUT_OPERATION_KEY = "kudu.client.timeout.operation";
+  static final String KUDU_CLIENT_TIMEOUT_SOCKET_READ_KEY = "kudu.client.timeout.socket.read";
 
 }
+
+
+

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/a6ca3ccf/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java
index ed3e093..46c324a 100644
--- a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java
+++ b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java
@@ -23,8 +23,6 @@ import org.apache.htrace.core.HTraceConfiguration;
 import org.apache.htrace.core.Span;
 import org.apache.htrace.core.SpanReceiver;
 import org.apache.htrace.core.TimelineAnnotation;
-import org.apache.htrace.protobuf.generated.SpanProtos;
-import org.kududb.client.Bytes;
 import org.kududb.client.KuduClient;
 import org.kududb.client.KuduSession;
 import org.kududb.client.KuduTable;
@@ -65,51 +63,113 @@ public class KuduSpanReceiver extends SpanReceiver {
       return thread;
     }
   };
+
   private ExecutorService service;
-  private String table;
-  private String column_span_id;
-  private String column_span;
-  private String column_root_span;
-  private String column_root_span_start_time;
+
+  private String table_span;
+  private String column_span_trace_id;
+  private String column_span_start_time;
+  private String column_span_stop_time;
+  private String column_span_span_id;
+  private String column_span_process_id;
+  private String column_span_parent_id;
+  private String column_span_description;
+  private String column_span_parent;
+
+  private String table_timeline;
+  private String column_timeline_timeline_id;
+  private String column_timeline_time;
+  private String column_timeline_message;
+  private String column_timeline_span_id;
 
   public KuduSpanReceiver(HTraceConfiguration conf) {
-    this.clientConf =
-            new KuduClientConfiguration(conf.get(KuduReceiverConstants.KUDU_MASTER_HOST_KEY,
-                    KuduReceiverConstants.DEFAULT_KUDU_MASTER_HOST),
-                    conf.get(KuduReceiverConstants.KUDU_MASTER_PORT_KEY,
-                            KuduReceiverConstants.DEFAULT_KUDU_MASTER_PORT));
+
+    String masterHost;
+    String masterPort;
+    Integer workerCount;
+    Integer bossCount;
+    Boolean isStatisticsEnabled;
+    Long adminOperationTimeout;
+    Long operationTimeout;
+    Long socketReadTimeout;
+
+    masterHost = conf.get(KuduReceiverConstants.KUDU_MASTER_HOST_KEY,
+            KuduReceiverConstants.DEFAULT_KUDU_MASTER_HOST);
+    masterPort = conf.get(KuduReceiverConstants.KUDU_MASTER_PORT_KEY,
+            KuduReceiverConstants.DEFAULT_KUDU_MASTER_PORT);
+
     if (conf.get(KuduReceiverConstants.KUDU_CLIENT_BOSS_COUNT_KEY) != null) {
-      this.clientConf.setBossCount(Integer.valueOf(conf.get(KuduReceiverConstants.KUDU_CLIENT_BOSS_COUNT_KEY)));
+      bossCount = Integer.valueOf(conf.get(KuduReceiverConstants.KUDU_CLIENT_BOSS_COUNT_KEY));
+    } else {
+      bossCount = null;
     }
     if (conf.get(KuduReceiverConstants.KUDU_CLIENT_WORKER_COUNT_KEY) != null) {
-      this.clientConf.setWorkerCount(Integer.valueOf(conf.get(KuduReceiverConstants.KUDU_CLIENT_WORKER_COUNT_KEY)));
+      workerCount = Integer.valueOf(conf.get(KuduReceiverConstants.KUDU_CLIENT_WORKER_COUNT_KEY));
+    } else {
+      workerCount = null;
     }
     if (conf.get(KuduReceiverConstants.KUDU_CLIENT_STATISTICS_ENABLED_KEY) != null) {
-      this.clientConf.setIsStatisticsEnabled(Boolean.valueOf(conf.get(KuduReceiverConstants.KUDU_CLIENT_STATISTICS_ENABLED_KEY)));
+      isStatisticsEnabled = Boolean.valueOf(conf.get(KuduReceiverConstants.KUDU_CLIENT_STATISTICS_ENABLED_KEY));
+    } else {
+      isStatisticsEnabled = null;
     }
     if (conf.get(KuduReceiverConstants.KUDU_CLIENT_TIMEOUT_ADMIN_OPERATION_KEY) != null) {
-      this.clientConf
-              .setAdminOperationTimeout(Long.valueOf(conf.get(KuduReceiverConstants.KUDU_CLIENT_TIMEOUT_ADMIN_OPERATION_KEY)));
+      adminOperationTimeout = Long.valueOf(conf.get(KuduReceiverConstants.KUDU_CLIENT_TIMEOUT_ADMIN_OPERATION_KEY));
+    } else {
+      adminOperationTimeout = null;
     }
     if (conf.get(KuduReceiverConstants.KUDU_CLIENT_TIMEOUT_OPERATION_KEY) != null) {
-      this.clientConf
-              .setOperationTimeout(Long.valueOf(conf.get(KuduReceiverConstants.KUDU_CLIENT_TIMEOUT_OPERATION_KEY)));
+      operationTimeout = Long.valueOf(conf.get(KuduReceiverConstants.KUDU_CLIENT_TIMEOUT_OPERATION_KEY));
+    } else {
+      operationTimeout = null;
     }
     if (conf.get(KuduReceiverConstants.KUDU_CLIENT_TIMEOUT_SOCKET_READ_KEY) != null) {
-      this.clientConf
-              .setSocketReadTimeout(Long.valueOf(conf.get(KuduReceiverConstants.KUDU_CLIENT_TIMEOUT_SOCKET_READ_KEY)));
+      socketReadTimeout = Long.valueOf(conf.get(KuduReceiverConstants.KUDU_CLIENT_TIMEOUT_SOCKET_READ_KEY));
+    } else {
+      socketReadTimeout = null;
     }
+
+    this.clientConf = new KuduClientConfiguration(masterHost,
+            masterPort,
+            workerCount,
+            bossCount,
+            isStatisticsEnabled,
+            adminOperationTimeout,
+            operationTimeout,
+            socketReadTimeout);
+
     this.queue = new ArrayBlockingQueue<Span>(conf.getInt(KuduReceiverConstants.SPAN_BLOCKING_QUEUE_SIZE_KEY,
             KuduReceiverConstants.DEFAULT_SPAN_BLOCKING_QUEUE_SIZE));
-    this.table = conf.get(KuduReceiverConstants.KUDU_TABLE_KEY, KuduReceiverConstants.DEFAULT_KUDU_TABLE);
-    this.column_span_id = conf.get(KuduReceiverConstants.KUDU_COLUMN_SPAN_ID_KEY,
-            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_ID);
-    this.column_span = conf.get(KuduReceiverConstants.KUDU_COLUMN_SPAN_KEY,
-            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN);
-    this.column_root_span = conf.get(KuduReceiverConstants.KUDU_COLUMN_ROOT_SPAN_KEY,
-            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_ROOT_SPAN);
-    this.column_root_span_start_time = conf.get(KuduReceiverConstants.KUDU_COLUMN_ROOT_SPAN_START_TIME_KEY,
-            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_ROOT_SPAN_START_TIME);
+
+    this.table_span = conf.get(KuduReceiverConstants.KUDU_SPAN_TABLE_KEY, KuduReceiverConstants.DEFAULT_KUDU_SPAN_TABLE);
+    this.table_timeline= conf.get(KuduReceiverConstants.KUDU_SPAN_TIMELINE_ANNOTATION_TABLE_KEY,
+            KuduReceiverConstants.DEFAULT_KUDU_SPAN_TIMELINE_ANNOTATION_TABLE);
+
+    this.column_span_trace_id = conf.get(KuduReceiverConstants.KUDU_COLUMN_SPAN_TRACE_ID_KEY,
+            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID);
+    this.column_span_start_time = conf.get(KuduReceiverConstants.KUDU_COLUMN_SPAN_START_TIME_KEY,
+            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_START_TIME);
+    this.column_span_stop_time = conf.get(KuduReceiverConstants.KUDU_COLUMN_SPAN_STOP_TIME_KEY,
+            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_STOP_TIME);
+    this.column_span_span_id = conf.get(KuduReceiverConstants.KUDU_COLUMN_SPAN_SPAN_ID_KEY,
+            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_SPAN_ID);
+    this.column_span_process_id = conf.get(KuduReceiverConstants.KUDU_COLUMN_SPAN_PROCESS_ID_KEY,
+            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PROCESS_ID);
+    this.column_span_parent_id = conf.get(KuduReceiverConstants.KUDU_COLUMN_SPAN_PARENT_ID_KEY,
+            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID);
+    this.column_span_description = conf.get(KuduReceiverConstants.KUDU_COLUMN_SPAN_DESCRIPTION_KEY,
+            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_DESCRIPTION);
+    this.column_span_parent = conf.get(KuduReceiverConstants.KUDU_COLUMN_SPAN_PARENT_KEY,
+            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT);
+    this.column_timeline_time = conf.get(KuduReceiverConstants.KUDU_COLUMN_TIMELINE_TIME_KEY,
+            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_TIME);
+    this.column_timeline_message = conf.get(KuduReceiverConstants.KUDU_COLUMN_TIMELINE_MESSAGE_KEY,
+            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_MESSAGE);
+    this.column_timeline_span_id = conf.get(KuduReceiverConstants.KUDU_COLUMN_TIMELINE_SPANID_KEY,
+            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_SPANID);
+    this.column_timeline_timeline_id = conf.get(KuduReceiverConstants.KUDU_COLUMN_TIMELINE_TIMELINEID_KEY,
+            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_TIMELINEID);
+
     this.maxSpanBatchSize = conf.getInt(KuduReceiverConstants.MAX_SPAN_BATCH_SIZE_KEY,
             KuduReceiverConstants.DEFAULT_MAX_SPAN_BATCH_SIZE);
     if (this.service != null) {
@@ -159,9 +219,6 @@ public class KuduSpanReceiver extends SpanReceiver {
 
     @Override
     public void run() {
-      SpanProtos.Span.Builder sbuilder = SpanProtos.Span.newBuilder();
-      SpanProtos.TimelineAnnotation.Builder tlbuilder =
-              SpanProtos.TimelineAnnotation.newBuilder();
       List<Span> dequeuedSpans = new ArrayList<Span>(maxSpanBatchSize);
       long errorCount = 0;
       while (running.get() || queue.size() > 0) {
@@ -188,35 +245,35 @@ public class KuduSpanReceiver extends SpanReceiver {
         }
         try {
           for (Span span : dequeuedSpans) {
-            sbuilder.clear()
-                    .setTraceId(span.getSpanId().getHigh())
-                    .setStart(span.getStartTimeMillis())
-                    .setStop(span.getStopTimeMillis())
-                    .setSpanId(span.getSpanId().getLow())
-                    .setProcessId(span.getTracerId())
-                    .setDescription(span.getDescription());
-
+            KuduTable tableSpan = client.openTable(table_span);
+            Insert spanInsert = tableSpan.newInsert();
+            PartialRow spanRow = spanInsert.getRow();
+            spanRow.addLong(column_span_trace_id,span.getSpanId().getHigh());
+            spanRow.addLong(column_span_start_time,span.getStartTimeMillis());
+            spanRow.addLong(column_span_stop_time,span.getStopTimeMillis());
+            spanRow.addLong(column_span_span_id,span.getSpanId().getLow());
+            spanRow.addString(column_span_process_id,span.getTracerId());
             if (span.getParents().length == 0) {
-              sbuilder.setParentId(0);
+              spanRow.addLong(column_span_parent_id,0);
+              spanRow.addBoolean(column_span_parent,false);
             } else if (span.getParents().length > 0) {
-              sbuilder.setParentId(span.getParents()[0].getLow());
+              spanRow.addLong(column_span_parent_id,span.getParents()[0].getLow());
+              spanRow.addBoolean(column_span_parent,true);
             }
+            spanRow.addString(column_span_description,span.getDescription());
+            this.session.apply(spanInsert);
+            long annotationCounter = 0;
             for (TimelineAnnotation ta : span.getTimelineAnnotations()) {
-              sbuilder.addTimeline(tlbuilder.clear()
-                      .setTime(ta.getTime())
-                      .setMessage(ta.getMessage())
-                      .build());
-            }
-            KuduTable tableRef = client.openTable(table);
-            Insert insert = tableRef.newInsert();
-            PartialRow row = insert.getRow();
-            row.addBinary(column_span_id, Bytes.fromLong(span.getSpanId().getHigh()));
-            row.addBinary(column_span, sbuilder.build().toByteArray());
-            if (span.getParents().length == 0) {
-              row.addBinary(column_root_span_start_time, Bytes.fromLong(span.getStartTimeMillis()));
-              row.addBinary(column_root_span, sbuilder.build().toByteArray());
+              annotationCounter++;
+              KuduTable tableTimeline = client.openTable(table_timeline);
+              Insert timelineInsert = tableTimeline.newInsert();
+              PartialRow timelineRow = timelineInsert.getRow();
+              timelineRow.addLong(column_timeline_timeline_id,span.getSpanId().getHigh()+annotationCounter);
+              timelineRow.addLong(column_timeline_time,ta.getTime());
+              timelineRow.addString(column_timeline_message,ta.getMessage());
+              timelineRow.addLong(column_timeline_span_id,span.getSpanId().getHigh());
+              this.session.apply(timelineInsert);
             }
-            this.session.apply(insert);
           }
           dequeuedSpans.clear();
           errorCount = 0;


[02/12] incubator-htrace git commit: initial span receiver for kudu poc commit

Posted by le...@apache.org.
initial span receiver for kudu poc commit


Project: http://git-wip-us.apache.org/repos/asf/incubator-htrace/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-htrace/commit/6752709e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-htrace/tree/6752709e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-htrace/diff/6752709e

Branch: refs/heads/master
Commit: 6752709e6d078465f55f88233ec3357328aa6d1e
Parents: 1a11d6c
Author: nisalanirmana <ni...@gmail.com>
Authored: Mon Jun 13 16:45:01 2016 +0530
Committer: nisalanirmana <ni...@gmail.com>
Committed: Mon Jun 13 16:45:01 2016 +0530

----------------------------------------------------------------------
 htrace-kudu/pom.xml                             |  229 ++
 .../apache/htrace/KuduHTraceConfiguration.java  |   52 +
 .../htrace/impl/KuduClientConfiguration.java    |   87 +
 .../org/apache/htrace/impl/KuduConstants.java   |   49 +
 .../apache/htrace/impl/KuduSpanReceiver.java    |  261 ++
 .../htrace/protobuf/generated/SpanProtos.java   | 2241 ++++++++++++++++++
 htrace-kudu/src/main/protobuf/Span.proto        |   38 +
 htrace-kudu/src/test/resources/log4j.properties |   25 +
 pom.xml                                         |    1 +
 9 files changed, 2983 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6752709e/htrace-kudu/pom.xml
----------------------------------------------------------------------
diff --git a/htrace-kudu/pom.xml b/htrace-kudu/pom.xml
new file mode 100644
index 0000000..60db72d
--- /dev/null
+++ b/htrace-kudu/pom.xml
@@ -0,0 +1,229 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 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. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>htrace-kudu</artifactId>
+  <packaging>jar</packaging>
+
+  <parent>
+    <artifactId>htrace</artifactId>
+    <groupId>org.apache.htrace</groupId>
+    <version>4.1.0-incubating-SNAPSHOT</version>
+    <relativePath>..</relativePath>
+  </parent>
+
+  <name>htrace-kudu</name>
+  <description>
+    htrace-kudu is the tools to send tracing information
+    to an kudu database for analysis later.
+  </description>
+  <url>http://incubator.apache.org/projects/htrace.html</url>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <kudu.version>1.0.0-SNAPSHOT</kudu.version>
+    <hadoop.version>2.6.0-cdh5.4.7</hadoop.version>
+    <createDependencyReducedPom>true</createDependencyReducedPom>
+  </properties>
+
+  <repositories>
+    <repository>
+      <id>cdh.repo</id>
+      <name>Cloudera Repositories</name>
+      <url>https://repository.cloudera.com/artifactory/cloudera-repos</url>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
+    </repository>
+  </repositories>
+
+  <build>
+    <resources>
+      <resource>
+        <directory>${basedir}/src/main</directory>
+        <includes>
+          <include>webapps/**</include>
+        </includes>
+      </resource>
+    </resources>
+    <plugins>
+      <plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <configuration>
+          <descriptorRefs>
+            <descriptorRef>jar-with-dependencies</descriptorRef>
+          </descriptorRefs>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.rat</groupId>
+        <artifactId>apache-rat-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-source-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <configuration>
+          <createDependencyReducedPom>${createDependencyReducedPom}</createDependencyReducedPom>
+        </configuration>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <configuration>
+              <relocations>
+                <relocation>
+                  <pattern>org.apache.commons.logging</pattern>
+                  <shadedPattern>org.apache.htrace.shaded.commons.logging</shadedPattern>
+                </relocation>
+                <relocation>
+                  <pattern>com.google.protobuf</pattern>
+                  <shadedPattern>org.apache.htrace.shaded.com.google.protobuf</shadedPattern>
+                </relocation>
+              </relocations>
+            </configuration>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <artifactId>maven-javadoc-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-gpg-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <!-- explicitly define maven-deploy-plugin after other to force exec order -->
+        <artifactId>maven-deploy-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <!-- Module deps. -->
+    <dependency>
+      <groupId>org.apache.htrace</groupId>
+      <artifactId>htrace-core4</artifactId>
+      <version>${project.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.htrace</groupId>
+      <artifactId>htrace-core4</artifactId>
+      <version>${project.version}</version>
+      <classifier>tests</classifier>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>com.google.protobuf</groupId>
+      <artifactId>protobuf-java</artifactId>
+      <version>2.5.0</version>
+    </dependency>
+    <!-- Global deps. -->
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- KUDU specific deps. -->
+    <dependency>
+      <groupId>org.kududb</groupId>
+      <artifactId>kudu-client</artifactId>
+      <version>${kudu.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hadoop</groupId>
+      <artifactId>hadoop-client</artifactId>
+      <version>${hadoop.version}</version>
+    </dependency>
+  </dependencies>
+
+  <profiles>
+    <profile>
+      <id>compile-protobuf</id>
+      <activation>
+        <property>
+          <name>compile-protobuf</name>
+        </property>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.hadoop</groupId>
+            <artifactId>hadoop-maven-plugins</artifactId>
+            <version>2.7.1</version>
+            <configuration>
+              <protocVersion>${protobuf.version}</protocVersion>
+              <protocCommand>${protoc.path}</protocCommand>
+            </configuration>
+            <executions>
+              <execution>
+                <id>compile-protoc</id>
+                <phase>generate-sources</phase>
+                <goals>
+                  <goal>protoc</goal>
+                </goals>
+                <configuration>
+                  <imports>
+                    <param>${basedir}/src/main/protobuf</param>
+                  </imports>
+                  <source>
+                    <directory>${basedir}/src/main/protobuf</directory>
+                    <includes>
+                      <include>Span.proto</include>
+                    </includes>
+                  </source>
+                  <output>${basedir}/src/main/java/</output>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+    <profile>
+      <id>dist</id>
+      <build>
+        <plugins>
+          <plugin>
+            <!--Make it so assembly:single does nothing in here-->
+            <artifactId>maven-assembly-plugin</artifactId>
+            <configuration>
+              <skipAssembly>true</skipAssembly>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+    <profile>
+      <id>doclint-disable</id>
+      <activation><jdk>[1.8,)</jdk></activation>
+      <properties>
+         <additionalparam>-Xdoclint:none</additionalparam>
+      </properties>
+    </profile>
+  </profiles>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6752709e/htrace-kudu/src/main/java/org/apache/htrace/KuduHTraceConfiguration.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/KuduHTraceConfiguration.java b/htrace-kudu/src/main/java/org/apache/htrace/KuduHTraceConfiguration.java
new file mode 100644
index 0000000..4a5e740
--- /dev/null
+++ b/htrace-kudu/src/main/java/org/apache/htrace/KuduHTraceConfiguration.java
@@ -0,0 +1,52 @@
+/*
+ * 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;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.htrace.core.HTraceConfiguration;
+
+public class KuduHTraceConfiguration extends HTraceConfiguration {
+
+  public static final String KEY_PREFIX = "kudu.";
+  private final Configuration conf;
+
+  public KuduHTraceConfiguration(Configuration conf) {
+    this.conf = conf;
+  }
+
+  @Override
+  public String get(String key) {
+    return conf.get(KEY_PREFIX + key);
+  }
+
+  @Override
+  public String get(String key, String defaultValue) {
+    return conf.get(KEY_PREFIX + key, defaultValue);
+
+  }
+
+  @Override
+  public boolean getBoolean(String key, boolean defaultValue) {
+    return conf.getBoolean(KEY_PREFIX + key, defaultValue);
+  }
+
+  @Override
+  public int getInt(String key, int defaultValue) {
+    return conf.getInt(KEY_PREFIX + key, defaultValue);
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6752709e/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java
new file mode 100644
index 0000000..4e99efc
--- /dev/null
+++ b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java
@@ -0,0 +1,87 @@
+/*
+ * 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.impl;
+
+import org.kududb.client.KuduClient;
+import org.kududb.client.KuduClient.KuduClientBuilder;
+
+public class KuduClientConfiguration {
+
+  private String host;
+  private String port;
+  private int workerCount;
+  private int bossCount;
+  private boolean isStatisticsEnabled;
+  private long adminOperationTimeout;
+  private long operationTimeout;
+  private long socketReadTimeout;
+
+  public KuduClientConfiguration(String host, String port) {
+    this.host = host;
+    this.port = port;
+  }
+
+  public void setWorkerCount(int workerCount) {
+    this.workerCount = workerCount;
+  }
+
+  public void setBossCount(int bossCount) {
+    this.bossCount = bossCount;
+  }
+
+  public void setIsStatisticsEnabled(boolean isStatisticsEnabled) {
+    this.isStatisticsEnabled = isStatisticsEnabled;
+  }
+
+  public void setAdminOperationTimeout(long adminOperationTimeout) {
+    this.adminOperationTimeout = adminOperationTimeout;
+  }
+
+  public void setOperationTimeout(long operationTimeout) {
+    this.operationTimeout = operationTimeout;
+  }
+
+  public void setSocketReadTimeout(long socketReadTimeout) {
+    this.socketReadTimeout = socketReadTimeout;
+  }
+
+  public KuduClient buildClient() {
+    KuduClientBuilder builder = new KuduClient
+            .KuduClientBuilder(host.concat(":").concat(port));
+    if (Integer.valueOf(workerCount) != null) {
+      builder.workerCount(workerCount);
+    }
+    if (Integer.valueOf(bossCount) != null) {
+      builder.bossCount(bossCount);
+    }
+    if (!Boolean.valueOf(isStatisticsEnabled)) {
+      builder.disableStatistics();
+    }
+    if (Long.valueOf(adminOperationTimeout) != null) {
+      builder.defaultAdminOperationTimeoutMs(adminOperationTimeout);
+    }
+    if (Long.valueOf(operationTimeout) != null) {
+      builder.defaultOperationTimeoutMs(operationTimeout);
+    }
+    if (Long.valueOf(socketReadTimeout) != null) {
+      builder.defaultSocketReadTimeoutMs(socketReadTimeout);
+    }
+    return builder.build();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6752709e/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduConstants.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduConstants.java b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduConstants.java
new file mode 100644
index 0000000..4092b8b
--- /dev/null
+++ b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduConstants.java
@@ -0,0 +1,49 @@
+/*
+ * 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.impl;
+
+public class KuduConstants {
+
+  public static final String KUDU_MASTER_HOST_KEY = "htrace.kudu.master.host";
+  public static final String DEFAULT_KUDU_MASTER_HOST = "127.0.0.1";
+  public static final String KUDU_MASTER_PORT_KEY = "htrace.kudu.master.port";
+  public static final String DEFAULT_KUDU_MASTER_PORT = "7051";
+  public static final String SPAN_BLOCKING_QUEUE_SIZE_KEY = "htrace.kudu.span.queue.size";
+  public static final int DEFAULT_SPAN_BLOCKING_QUEUE_SIZE = 1000;
+  public static final String KUDU_TABLE_KEY = "htrace.kudu.table";
+  public static final String DEFAULT_KUDU_TABLE = "htrace";
+  public static final String MAX_SPAN_BATCH_SIZE_KEY = "htrace.kudu.batch.size";
+  public static final int DEFAULT_MAX_SPAN_BATCH_SIZE = 100;
+  public static final String NUM_PARALLEL_THREADS_KEY = "htrace.kudu.num.threads";
+  public static final int DEFAULT_NUM_PARALLEL_THREADS = 1;
+  public static final String KUDU_COLUMN_SPAN_ID_KEY = "htrace.kudu.column.spanid";
+  public static final String DEFAULT_KUDU_COLUMN_SPAN_ID = "span_id";
+  public static final String KUDU_COLUMN_SPAN_KEY = "htrace.kudu.column.span";
+  public static final String DEFAULT_KUDU_COLUMN_SPAN = "span";
+  public static final String KUDU_COLUMN_ROOT_SPAN_KEY = "htrace.kudu.column.rootspan";
+  public static final String DEFAULT_KUDU_COLUMN_ROOT_SPAN = "root_span";
+  public static final String KUDU_COLUMN_ROOT_SPAN_START_TIME_KEY = "htrace.kudu.column.rootspan.starttime";
+  public static final String DEFAULT_KUDU_COLUMN_ROOT_SPAN_START_TIME = "root_span_start_time";
+  public static final String KUDU_CLIENT_WORKER_COUNT_KEY = "htrace.kudu.client.worker.count";
+  public static final String KUDU_CLIENT_BOSS_COUNT_KEY = "htrace.kudu.client.boss.count";
+  public static final String KUDU_CLIENT_STATISTICS_ENABLED_KEY = "htrace.kudu.client.statistics.enabled";
+  public static final String KUDU_CLIENT_TIMEOUT_ADMIN_OPERATION_KEY = "htrace.kudu.client.timeout.admin.operation";
+  public static final String KUDU_CLIENT_TIMEOUT_OPERATION_KEY = "htrace.kudu.client.timeout.operation";
+  public static final String KUDU_CLIENT_TIMEOUT_SOCKET_READ_KEY = "htrace.kudu.client.timeout.socket.read";
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/6752709e/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java
new file mode 100644
index 0000000..da7aca3
--- /dev/null
+++ b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java
@@ -0,0 +1,261 @@
+/*
+ * 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.impl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.htrace.core.HTraceConfiguration;
+import org.apache.htrace.core.Span;
+import org.apache.htrace.core.SpanReceiver;
+import org.apache.htrace.core.TimelineAnnotation;
+import org.apache.htrace.protobuf.generated.SpanProtos;
+import org.kududb.client.Bytes;
+import org.kududb.client.KuduClient;
+import org.kududb.client.KuduSession;
+import org.kududb.client.KuduTable;
+import org.kududb.client.Insert;
+import org.kududb.client.PartialRow;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
+
+public class KuduSpanReceiver extends SpanReceiver {
+
+  private static final Log LOG = LogFactory.getLog(KuduSpanReceiver.class);
+
+  private static final int SHUTDOWN_TIMEOUT = 30;
+  private static final int MAX_ERRORS = 10;
+  private final BlockingQueue<Span> queue;
+  private final AtomicBoolean running = new AtomicBoolean(true);
+  private final KuduClientConfiguration clientConf;
+  private final int maxSpanBatchSize;
+  private final ThreadFactory threadFactory = new ThreadFactory() {
+    private final AtomicLong receiverIndex = new AtomicLong(0);
+
+    @Override
+    public Thread newThread(Runnable runnable) {
+      Thread thread = new Thread(runnable);
+      thread.setDaemon(true);
+      thread.setName(String.format("kuduSpanReceiver-%d",
+              receiverIndex.getAndIncrement()));
+      return thread;
+    }
+  };
+  private ExecutorService service;
+  private String table;
+  private String column_span_id;
+  private String column_span;
+  private String column_root_span;
+  private String column_root_span_start_time;
+
+  public KuduSpanReceiver(HTraceConfiguration conf) {
+    this.clientConf =
+            new KuduClientConfiguration(conf.get(KuduConstants.KUDU_MASTER_HOST_KEY,
+                    KuduConstants.DEFAULT_KUDU_MASTER_HOST),
+                    conf.get(KuduConstants.KUDU_MASTER_PORT_KEY,
+                            KuduConstants.DEFAULT_KUDU_MASTER_PORT));
+    this.clientConf.setBossCount(conf.getInt(KuduConstants.KUDU_CLIENT_BOSS_COUNT_KEY,
+            Integer.valueOf(null)));
+    this.clientConf.setWorkerCount(conf.getInt(KuduConstants.KUDU_CLIENT_WORKER_COUNT_KEY,
+            Integer.valueOf(null)));
+    this.clientConf.setIsStatisticsEnabled(conf.getBoolean(KuduConstants.KUDU_CLIENT_STATISTICS_ENABLED_KEY,
+            Boolean.valueOf(null)));
+    this.clientConf
+            .setAdminOperationTimeout(Long.valueOf(conf.get(KuduConstants.KUDU_CLIENT_TIMEOUT_ADMIN_OPERATION_KEY,
+                    String.valueOf(null))));
+    this.clientConf
+            .setOperationTimeout(Long.valueOf(conf.get(KuduConstants.KUDU_CLIENT_TIMEOUT_OPERATION_KEY,
+                    String.valueOf(null))));
+    this.clientConf
+            .setSocketReadTimeout(Long.valueOf(conf.get(KuduConstants.KUDU_CLIENT_TIMEOUT_SOCKET_READ_KEY,
+                    String.valueOf(null))));
+    this.queue = new ArrayBlockingQueue<Span>(conf.getInt(KuduConstants.SPAN_BLOCKING_QUEUE_SIZE_KEY,
+            KuduConstants.DEFAULT_SPAN_BLOCKING_QUEUE_SIZE));
+    this.table = conf.get(KuduConstants.KUDU_TABLE_KEY, KuduConstants.DEFAULT_KUDU_TABLE);
+    this.column_span_id = conf.get(KuduConstants.KUDU_COLUMN_SPAN_ID_KEY,
+            KuduConstants.DEFAULT_KUDU_COLUMN_SPAN_ID);
+    this.column_span = conf.get(KuduConstants.KUDU_COLUMN_SPAN_KEY,
+            KuduConstants.DEFAULT_KUDU_COLUMN_SPAN);
+    this.column_root_span = conf.get(KuduConstants.KUDU_COLUMN_ROOT_SPAN_KEY,
+            KuduConstants.DEFAULT_KUDU_COLUMN_ROOT_SPAN);
+    this.column_root_span_start_time = conf.get(KuduConstants.KUDU_COLUMN_ROOT_SPAN_START_TIME_KEY,
+            KuduConstants.DEFAULT_KUDU_COLUMN_ROOT_SPAN_START_TIME);
+    this.maxSpanBatchSize = conf.getInt(KuduConstants.MAX_SPAN_BATCH_SIZE_KEY,
+            KuduConstants.DEFAULT_MAX_SPAN_BATCH_SIZE);
+    if (this.service != null) {
+      this.service.shutdownNow();
+      this.service = null;
+    }
+    int numThreads = conf.getInt(KuduConstants.NUM_PARALLEL_THREADS_KEY,
+            KuduConstants.DEFAULT_NUM_PARALLEL_THREADS);
+    this.service = Executors.newFixedThreadPool(numThreads, threadFactory);
+    for (int i = 0; i < numThreads; i++) {
+      this.service.submit(new KuduSpanReceiver.WriteSpanRunnable());
+    }
+  }
+
+  @Override
+  public void close() throws IOException {
+    running.set(false);
+    service.shutdown();
+    try {
+      if (!service.awaitTermination(SHUTDOWN_TIMEOUT, TimeUnit.SECONDS)) {
+        LOG.error("Timeout " + SHUTDOWN_TIMEOUT + " " + TimeUnit.SECONDS +
+                " reached while shutting worker threads which process enqued spans." +
+                " Enqueued spans which are left in blocking queue is dropped.");
+      }
+    } catch (InterruptedException e) {
+      LOG.warn("Interrupted exception occured while terminating thread service executor.", e);
+    }
+  }
+
+  @Override
+  public void receiveSpan(Span span) {
+    if (running.get()) {
+      try {
+        this.queue.add(span);
+      } catch (IllegalStateException e) {
+        LOG.error("Error trying to enqueue span ("
+                + span.getDescription()
+                + ") to the queue. Blocking Queue is currently reached its capacity.");
+      }
+    }
+  }
+
+  private class WriteSpanRunnable implements Runnable {
+
+    private KuduSession session;
+    private KuduClient client;
+
+    @Override
+    public void run() {
+      SpanProtos.Span.Builder sbuilder = SpanProtos.Span.newBuilder();
+      SpanProtos.TimelineAnnotation.Builder tlbuilder =
+              SpanProtos.TimelineAnnotation.newBuilder();
+      List<Span> dequeuedSpans = new ArrayList<Span>(maxSpanBatchSize);
+      long errorCount = 0;
+      while (running.get() || queue.size() > 0) {
+        Span firstSpan = null;
+        try {
+          firstSpan = queue.poll(1, TimeUnit.SECONDS);
+          if (firstSpan != null) {
+            dequeuedSpans.add(firstSpan);
+            queue.drainTo(dequeuedSpans, maxSpanBatchSize - 1);
+          }
+        } catch (InterruptedException ie) {
+          LOG.error("Interrupted Exception occurred while polling to " +
+                  "retrieve first span from blocking queue");
+        }
+        startSession();
+        if (dequeuedSpans.isEmpty()) {
+          try {
+            this.session.flush();
+          } catch (java.lang.Exception e) {
+            LOG.error("Failed to flush writes to Kudu.");
+            closeSession();
+          }
+          continue;
+        }
+        try {
+          for (Span span : dequeuedSpans) {
+            sbuilder.clear()
+                    .setTraceId(span.getSpanId().getHigh())
+                    .setStart(span.getStartTimeMillis())
+                    .setStop(span.getStopTimeMillis())
+                    .setSpanId(span.getSpanId().getLow())
+                    .setProcessId(span.getTracerId())
+                    .setDescription(span.getDescription());
+
+            if (span.getParents().length == 0) {
+              sbuilder.setParentId(0);
+            } else if (span.getParents().length > 0) {
+              sbuilder.setParentId(span.getParents()[0].getLow());
+            }
+            for (TimelineAnnotation ta : span.getTimelineAnnotations()) {
+              sbuilder.addTimeline(tlbuilder.clear()
+                      .setTime(ta.getTime())
+                      .setMessage(ta.getMessage())
+                      .build());
+            }
+            KuduTable tableRef = client.openTable(table);
+            Insert insert = tableRef.newInsert();
+            PartialRow row = insert.getRow();
+            row.addBinary(column_span_id, Bytes.fromLong(span.getSpanId().getHigh()));
+            row.addBinary(column_span, sbuilder.build().toByteArray());
+            if (span.getParents().length == 0) {
+              row.addBinary(column_root_span_start_time, Bytes.fromLong(span.getStartTimeMillis()));
+              row.addBinary(column_root_span, sbuilder.build().toByteArray());
+            }
+            this.session.apply(insert);
+          }
+          dequeuedSpans.clear();
+          errorCount = 0;
+        } catch (Exception e) {
+          errorCount += 1;
+          if (errorCount < MAX_ERRORS) {
+            try {
+              queue.addAll(dequeuedSpans);
+            } catch (IllegalStateException ex) {
+              LOG.error("Exception occured while writing spans kudu datastore. " +
+                      "Trying to re-enqueue de-queued spans to blocking queue for writing but failed. " +
+                      "Dropped " + dequeuedSpans.size() + " dequeued span(s) which were due written" +
+                      "into kudu datastore");
+            }
+          }
+          closeSession();
+          try {
+            Thread.sleep(500);
+          } catch (InterruptedException e1) {
+            LOG.error("Interrupted Exception occurred while allowing kudu to re-stabilized");
+          }
+        }
+      }
+      closeSession();
+    }
+
+    private void closeSession() {
+      try {
+        if (this.session != null) {
+          this.session.close();
+          this.session = null;
+        }
+      } catch (java.lang.Exception e) {
+        LOG.warn("Failed to close Kudu session. " + e.getMessage());
+      }
+    }
+
+    private void startSession() {
+      if (this.session == null) {
+        if (this.client == null) {
+          client = clientConf.buildClient();
+        }
+        session = client.newSession();
+      }
+    }
+  }
+
+}


[09/12] incubator-htrace git commit: adding review changes according to Colin

Posted by le...@apache.org.
adding review changes according to Colin


Project: http://git-wip-us.apache.org/repos/asf/incubator-htrace/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-htrace/commit/0cd394f5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-htrace/tree/0cd394f5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-htrace/diff/0cd394f5

Branch: refs/heads/master
Commit: 0cd394f5788b5738dde7169f62e94ab2c8e2b31e
Parents: 8ccbb89
Author: Nisala Nirmana <ni...@gmail.com>
Authored: Sat Aug 20 00:04:01 2016 +0530
Committer: Nisala Nirmana <ni...@gmail.com>
Committed: Sat Aug 20 00:04:01 2016 +0530

----------------------------------------------------------------------
 .../htrace/impl/KuduClientConfiguration.java    |   6 +-
 .../htrace/impl/KuduReceiverConstants.java      |  22 +-
 .../apache/htrace/impl/KuduSpanReceiver.java    | 267 +++++--------------
 .../htrace/impl/TestKuduSpanReceiver.java       |  28 +-
 .../apache/htrace/impl/TestKuduSpanViewer.java  | 237 ++++++++++++++++
 5 files changed, 333 insertions(+), 227 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/0cd394f5/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java
index 25d6fc4..c13e7b4 100644
--- a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java
+++ b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java
@@ -23,7 +23,7 @@ import org.kududb.client.KuduClient.KuduClientBuilder;
 public class KuduClientConfiguration {
 
   private final String host;
-  private final String port;
+  private final Integer port;
   private final Integer workerCount;
   private final Integer bossCount;
   private final Boolean isStatisticsEnabled;
@@ -32,7 +32,7 @@ public class KuduClientConfiguration {
   private final Long socketReadTimeout;
 
   public KuduClientConfiguration(String host,
-                                 String port,
+                                 Integer port,
                                  Integer workerCount,
                                  Integer bossCount,
                                  Boolean isStatisticsEnabled,
@@ -52,7 +52,7 @@ public class KuduClientConfiguration {
 
   public KuduClient buildClient() {
     KuduClientBuilder builder = new KuduClient
-            .KuduClientBuilder(host.concat(":").concat(port));
+            .KuduClientBuilder(host.concat(":").concat(port.toString()));
     if (workerCount != null) {
       builder.workerCount(workerCount);
     }

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/0cd394f5/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduReceiverConstants.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduReceiverConstants.java b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduReceiverConstants.java
index be98311..805ec80 100644
--- a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduReceiverConstants.java
+++ b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduReceiverConstants.java
@@ -23,39 +23,21 @@ public class KuduReceiverConstants {
   static final String DEFAULT_KUDU_MASTER_HOST = "127.0.0.1";
   static final String KUDU_MASTER_PORT_KEY = "kudu.master.port";
   static final String DEFAULT_KUDU_MASTER_PORT = "7051";
-  static final String SPAN_BLOCKING_QUEUE_SIZE_KEY = "kudu.span.queue.size";
-  static final int DEFAULT_SPAN_BLOCKING_QUEUE_SIZE = 1000;
   static final String KUDU_SPAN_TABLE_KEY = "kudu.span.table";
   static final String DEFAULT_KUDU_SPAN_TABLE = "span";
   static final String KUDU_SPAN_TIMELINE_ANNOTATION_TABLE_KEY = "kudu.span.timeline.annotation.table";
   static final String DEFAULT_KUDU_SPAN_TIMELINE_ANNOTATION_TABLE = "span.timeline";
-  static final String MAX_SPAN_BATCH_SIZE_KEY = "kudu.batch.size";
-  static final int DEFAULT_MAX_SPAN_BATCH_SIZE = 100;
-  static final String NUM_PARALLEL_THREADS_KEY = "kudu.num.threads";
-  static final int DEFAULT_NUM_PARALLEL_THREADS = 1;
-  static final String KUDU_COLUMN_SPAN_TRACE_ID_KEY = "kudu.column.span.traceid";
   static final String DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID = "trace_id";
-  static final String KUDU_COLUMN_SPAN_START_TIME_KEY = "kudu.column.span.starttime";
   static final String DEFAULT_KUDU_COLUMN_SPAN_START_TIME = "start_time";
-  static final String KUDU_COLUMN_SPAN_STOP_TIME_KEY = "kudu.column.span.stoptime";
   static final String DEFAULT_KUDU_COLUMN_SPAN_STOP_TIME = "stop_time";
-  static final String KUDU_COLUMN_SPAN_SPAN_ID_KEY = "kudu.column.span.spanid";
   static final String DEFAULT_KUDU_COLUMN_SPAN_SPAN_ID = "span_id";
-  static final String KUDU_COLUMN_SPAN_PROCESS_ID_KEY = "kudu.column.span.processid";
-  static final String DEFAULT_KUDU_COLUMN_SPAN_PROCESS_ID = "process_id";
-  static final String KUDU_COLUMN_SPAN_PARENT_ID_KEY = "kudu.column.span.parentid";
-  static final String DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID = "parent_id";
-  static final String KUDU_COLUMN_SPAN_DESCRIPTION_KEY = "kudu.column.span.description";
+  static final String DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_LOW = "parent_id_low";
+  static final String DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_HIGH = "parent_id_high";
   static final String DEFAULT_KUDU_COLUMN_SPAN_DESCRIPTION = "description";
-  static final String KUDU_COLUMN_SPAN_PARENT_KEY = "kudu.column.span.parent";
   static final String DEFAULT_KUDU_COLUMN_SPAN_PARENT = "parent";
-  static final String KUDU_COLUMN_TIMELINE_TIME_KEY = "kudu.column.timeline.time";
   static final String DEFAULT_KUDU_COLUMN_TIMELINE_TIME = "time";
-  static final String KUDU_COLUMN_TIMELINE_MESSAGE_KEY = "kudu.column.timeline.message";
   static final String DEFAULT_KUDU_COLUMN_TIMELINE_MESSAGE = "message";
-  static final String KUDU_COLUMN_TIMELINE_SPANID_KEY = "kudu.column.timeline.spanid";
   static final String DEFAULT_KUDU_COLUMN_TIMELINE_SPANID = "spanid";
-  static final String KUDU_COLUMN_TIMELINE_TIMELINEID_KEY = "kudu.column.timeline.timelineid";
   static final String DEFAULT_KUDU_COLUMN_TIMELINE_TIMELINEID = "timelineid";
   static final String KUDU_CLIENT_WORKER_COUNT_KEY = "kudu.client.worker.count";
   static final String KUDU_CLIENT_BOSS_COUNT_KEY = "kudu.client.boss.count";

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/0cd394f5/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java
index 46c324a..745f24d 100644
--- a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java
+++ b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java
@@ -30,49 +30,22 @@ import org.kududb.client.Insert;
 import org.kududb.client.PartialRow;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicLong;
 
 public class KuduSpanReceiver extends SpanReceiver {
 
   private static final Log LOG = LogFactory.getLog(KuduSpanReceiver.class);
 
-  private static final int SHUTDOWN_TIMEOUT = 30;
-  private static final int MAX_ERRORS = 10;
-  private final BlockingQueue<Span> queue;
-  private final AtomicBoolean running = new AtomicBoolean(true);
   private final KuduClientConfiguration clientConf;
-  private final int maxSpanBatchSize;
-  private final ThreadFactory threadFactory = new ThreadFactory() {
-    private final AtomicLong receiverIndex = new AtomicLong(0);
-
-    @Override
-    public Thread newThread(Runnable runnable) {
-      Thread thread = new Thread(runnable);
-      thread.setDaemon(true);
-      thread.setName(String.format("kuduSpanReceiver-%d",
-              receiverIndex.getAndIncrement()));
-      return thread;
-    }
-  };
-
-  private ExecutorService service;
+  private KuduSession session;
+  private KuduClient client;
 
   private String table_span;
   private String column_span_trace_id;
   private String column_span_start_time;
   private String column_span_stop_time;
   private String column_span_span_id;
-  private String column_span_process_id;
-  private String column_span_parent_id;
+  private String column_span_parent_id_low;
+  private String column_span_parent_id_high;
   private String column_span_description;
   private String column_span_parent;
 
@@ -85,7 +58,7 @@ public class KuduSpanReceiver extends SpanReceiver {
   public KuduSpanReceiver(HTraceConfiguration conf) {
 
     String masterHost;
-    String masterPort;
+    Integer masterPort;
     Integer workerCount;
     Integer bossCount;
     Boolean isStatisticsEnabled;
@@ -95,8 +68,8 @@ public class KuduSpanReceiver extends SpanReceiver {
 
     masterHost = conf.get(KuduReceiverConstants.KUDU_MASTER_HOST_KEY,
             KuduReceiverConstants.DEFAULT_KUDU_MASTER_HOST);
-    masterPort = conf.get(KuduReceiverConstants.KUDU_MASTER_PORT_KEY,
-            KuduReceiverConstants.DEFAULT_KUDU_MASTER_PORT);
+    masterPort = Integer.valueOf(conf.get(KuduReceiverConstants.KUDU_MASTER_PORT_KEY,
+            KuduReceiverConstants.DEFAULT_KUDU_MASTER_PORT));
 
     if (conf.get(KuduReceiverConstants.KUDU_CLIENT_BOSS_COUNT_KEY) != null) {
       bossCount = Integer.valueOf(conf.get(KuduReceiverConstants.KUDU_CLIENT_BOSS_COUNT_KEY));
@@ -137,186 +110,86 @@ public class KuduSpanReceiver extends SpanReceiver {
             adminOperationTimeout,
             operationTimeout,
             socketReadTimeout);
-
-    this.queue = new ArrayBlockingQueue<Span>(conf.getInt(KuduReceiverConstants.SPAN_BLOCKING_QUEUE_SIZE_KEY,
-            KuduReceiverConstants.DEFAULT_SPAN_BLOCKING_QUEUE_SIZE));
-
+    //table names made configurable
     this.table_span = conf.get(KuduReceiverConstants.KUDU_SPAN_TABLE_KEY, KuduReceiverConstants.DEFAULT_KUDU_SPAN_TABLE);
-    this.table_timeline= conf.get(KuduReceiverConstants.KUDU_SPAN_TIMELINE_ANNOTATION_TABLE_KEY,
+    this.table_timeline = conf.get(KuduReceiverConstants.KUDU_SPAN_TIMELINE_ANNOTATION_TABLE_KEY,
             KuduReceiverConstants.DEFAULT_KUDU_SPAN_TIMELINE_ANNOTATION_TABLE);
-
-    this.column_span_trace_id = conf.get(KuduReceiverConstants.KUDU_COLUMN_SPAN_TRACE_ID_KEY,
-            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID);
-    this.column_span_start_time = conf.get(KuduReceiverConstants.KUDU_COLUMN_SPAN_START_TIME_KEY,
-            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_START_TIME);
-    this.column_span_stop_time = conf.get(KuduReceiverConstants.KUDU_COLUMN_SPAN_STOP_TIME_KEY,
-            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_STOP_TIME);
-    this.column_span_span_id = conf.get(KuduReceiverConstants.KUDU_COLUMN_SPAN_SPAN_ID_KEY,
-            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_SPAN_ID);
-    this.column_span_process_id = conf.get(KuduReceiverConstants.KUDU_COLUMN_SPAN_PROCESS_ID_KEY,
-            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PROCESS_ID);
-    this.column_span_parent_id = conf.get(KuduReceiverConstants.KUDU_COLUMN_SPAN_PARENT_ID_KEY,
-            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID);
-    this.column_span_description = conf.get(KuduReceiverConstants.KUDU_COLUMN_SPAN_DESCRIPTION_KEY,
-            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_DESCRIPTION);
-    this.column_span_parent = conf.get(KuduReceiverConstants.KUDU_COLUMN_SPAN_PARENT_KEY,
-            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT);
-    this.column_timeline_time = conf.get(KuduReceiverConstants.KUDU_COLUMN_TIMELINE_TIME_KEY,
-            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_TIME);
-    this.column_timeline_message = conf.get(KuduReceiverConstants.KUDU_COLUMN_TIMELINE_MESSAGE_KEY,
-            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_MESSAGE);
-    this.column_timeline_span_id = conf.get(KuduReceiverConstants.KUDU_COLUMN_TIMELINE_SPANID_KEY,
-            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_SPANID);
-    this.column_timeline_timeline_id = conf.get(KuduReceiverConstants.KUDU_COLUMN_TIMELINE_TIMELINEID_KEY,
-            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_TIMELINEID);
-
-    this.maxSpanBatchSize = conf.getInt(KuduReceiverConstants.MAX_SPAN_BATCH_SIZE_KEY,
-            KuduReceiverConstants.DEFAULT_MAX_SPAN_BATCH_SIZE);
-    if (this.service != null) {
-      this.service.shutdownNow();
-      this.service = null;
-    }
-    int numThreads = conf.getInt(KuduReceiverConstants.NUM_PARALLEL_THREADS_KEY,
-            KuduReceiverConstants.DEFAULT_NUM_PARALLEL_THREADS);
-    this.service = Executors.newFixedThreadPool(numThreads, threadFactory);
-    for (int i = 0; i < numThreads; i++) {
-      this.service.submit(new KuduSpanReceiver.WriteSpanRunnable());
+    //default column names have used
+    this.column_span_trace_id = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID;
+    this.column_span_start_time = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_START_TIME;
+    this.column_span_stop_time = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_STOP_TIME;
+    this.column_span_span_id = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_SPAN_ID;
+    this.column_span_parent_id_low = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_LOW;
+    this.column_span_parent_id_high = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_HIGH;
+    this.column_span_description = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_DESCRIPTION;
+    this.column_span_parent = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT;
+    this.column_timeline_time = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_TIME;
+    this.column_timeline_message = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_MESSAGE;
+    this.column_timeline_span_id = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_SPANID;
+    this.column_timeline_timeline_id = KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_TIMELINEID;
+    //kudu backend session initialization
+    if (this.session == null) {
+      if (this.client == null) {
+        client = clientConf.buildClient();
+      }
+      session = client.newSession();
     }
   }
 
   @Override
   public void close() throws IOException {
-    running.set(false);
-    service.shutdown();
     try {
-      if (!service.awaitTermination(SHUTDOWN_TIMEOUT, TimeUnit.SECONDS)) {
-        LOG.error("Timeout " + SHUTDOWN_TIMEOUT + " " + TimeUnit.SECONDS +
-                " reached while shutting worker threads which process enqued spans." +
-                " Enqueued spans which are left in blocking queue is dropped.");
+      if (this.session != null) {
+        if (this.session.isClosed()) {
+          this.session.close();
+        }
+        this.client.close();
       }
-    } catch (InterruptedException e) {
-      LOG.warn("Interrupted exception occured while terminating thread service executor.", e);
+    } catch (java.lang.Exception e) {
+      LOG.warn("Failed to close Kudu session. " + e.getMessage());
     }
   }
 
   @Override
   public void receiveSpan(Span span) {
-    if (running.get()) {
-      try {
-        this.queue.add(span);
-      } catch (IllegalStateException e) {
-        LOG.error("Error trying to enqueue span ("
-                + span.getDescription()
-                + ") to the queue. Blocking Queue is currently reached its capacity.");
+   try {
+      KuduTable tableSpan = client.openTable(table_span);
+      Insert spanInsert = tableSpan.newInsert();
+      PartialRow spanRow = spanInsert.getRow();
+      spanRow.addLong(column_span_trace_id, span.getSpanId().getLow());
+      spanRow.addLong(column_span_start_time, span.getStartTimeMillis());
+      spanRow.addLong(column_span_stop_time, span.getStopTimeMillis());
+      spanRow.addLong(column_span_span_id, span.getSpanId().getHigh());
+      if (span.getParents().length == 0) {
+        spanRow.addLong(column_span_parent_id_low, 0);
+        spanRow.addLong(column_span_parent_id_high, 0);
+        spanRow.addBoolean(column_span_parent, true);
+      } else if (span.getParents().length > 0) {
+        spanRow.addLong(column_span_parent_id_low, span.getParents()[0].getLow());
+        spanRow.addLong(column_span_parent_id_high, span.getParents()[0].getHigh());
+        spanRow.addBoolean(column_span_parent, false);
       }
-    }
-  }
-
-  private class WriteSpanRunnable implements Runnable {
-
-    private KuduSession session;
-    private KuduClient client;
-
-    @Override
-    public void run() {
-      List<Span> dequeuedSpans = new ArrayList<Span>(maxSpanBatchSize);
-      long errorCount = 0;
-      while (running.get() || queue.size() > 0) {
-        Span firstSpan = null;
-        try {
-          firstSpan = queue.poll(1, TimeUnit.SECONDS);
-          if (firstSpan != null) {
-            dequeuedSpans.add(firstSpan);
-            queue.drainTo(dequeuedSpans, maxSpanBatchSize - 1);
-          }
-        } catch (InterruptedException ie) {
-          LOG.error("Interrupted Exception occurred while polling to " +
-                  "retrieve first span from blocking queue");
-        }
-        startSession();
-        if (dequeuedSpans.isEmpty()) {
-          try {
-            this.session.flush();
-          } catch (java.lang.Exception e) {
-            LOG.error("Failed to flush writes to Kudu.");
-            closeSession();
-          }
-          continue;
-        }
-        try {
-          for (Span span : dequeuedSpans) {
-            KuduTable tableSpan = client.openTable(table_span);
-            Insert spanInsert = tableSpan.newInsert();
-            PartialRow spanRow = spanInsert.getRow();
-            spanRow.addLong(column_span_trace_id,span.getSpanId().getHigh());
-            spanRow.addLong(column_span_start_time,span.getStartTimeMillis());
-            spanRow.addLong(column_span_stop_time,span.getStopTimeMillis());
-            spanRow.addLong(column_span_span_id,span.getSpanId().getLow());
-            spanRow.addString(column_span_process_id,span.getTracerId());
-            if (span.getParents().length == 0) {
-              spanRow.addLong(column_span_parent_id,0);
-              spanRow.addBoolean(column_span_parent,false);
-            } else if (span.getParents().length > 0) {
-              spanRow.addLong(column_span_parent_id,span.getParents()[0].getLow());
-              spanRow.addBoolean(column_span_parent,true);
-            }
-            spanRow.addString(column_span_description,span.getDescription());
-            this.session.apply(spanInsert);
-            long annotationCounter = 0;
-            for (TimelineAnnotation ta : span.getTimelineAnnotations()) {
-              annotationCounter++;
-              KuduTable tableTimeline = client.openTable(table_timeline);
-              Insert timelineInsert = tableTimeline.newInsert();
-              PartialRow timelineRow = timelineInsert.getRow();
-              timelineRow.addLong(column_timeline_timeline_id,span.getSpanId().getHigh()+annotationCounter);
-              timelineRow.addLong(column_timeline_time,ta.getTime());
-              timelineRow.addString(column_timeline_message,ta.getMessage());
-              timelineRow.addLong(column_timeline_span_id,span.getSpanId().getHigh());
-              this.session.apply(timelineInsert);
-            }
-          }
-          dequeuedSpans.clear();
-          errorCount = 0;
-        } catch (Exception e) {
-          errorCount += 1;
-          if (errorCount < MAX_ERRORS) {
-            try {
-              queue.addAll(dequeuedSpans);
-            } catch (IllegalStateException ex) {
-              LOG.error("Exception occured while writing spans kudu datastore. " +
-                      "Trying to re-enqueue de-queued spans to blocking queue for writing but failed. " +
-                      "Dropped " + dequeuedSpans.size() + " dequeued span(s) which were due written" +
-                      "into kudu datastore");
-            }
-          }
-          closeSession();
-          try {
-            Thread.sleep(500);
-          } catch (InterruptedException e1) {
-            LOG.error("Interrupted Exception occurred while allowing kudu to re-stabilized");
-          }
-        }
+      spanRow.addString(column_span_description, span.getDescription());
+      session.apply(spanInsert);
+      long annotationCounter = 0;
+      for (TimelineAnnotation ta : span.getTimelineAnnotations()) {
+        annotationCounter++;
+        KuduTable tableTimeline = client.openTable(table_timeline);
+        Insert timelineInsert = tableTimeline.newInsert();
+        PartialRow timelineRow = timelineInsert.getRow();
+        timelineRow.addLong(column_timeline_timeline_id, span.getSpanId().getLow() + annotationCounter);
+        timelineRow.addLong(column_timeline_time, ta.getTime());
+        timelineRow.addString(column_timeline_message, ta.getMessage());
+        timelineRow.addLong(column_timeline_span_id, span.getSpanId().getLow());
+        session.apply(timelineInsert);
       }
-      closeSession();
-    }
-
-    private void closeSession() {
+    } catch (java.lang.Exception ex) {
+      LOG.error("Failed to write span to Kudu backend", ex);
+    } finally {
       try {
-        if (this.session != null) {
-          this.session.close();
-          this.session = null;
-        }
-      } catch (java.lang.Exception e) {
-        LOG.warn("Failed to close Kudu session. " + e.getMessage());
-      }
-    }
-
-    private void startSession() {
-      if (this.session == null) {
-        if (this.client == null) {
-          client = clientConf.buildClient();
-        }
-        session = client.newSession();
+        session.flush();
+      } catch (java.lang.Exception ex) {
+        //Ignore
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/0cd394f5/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java b/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java
index 8b446e2..c13970d 100644
--- a/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java
+++ b/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java
@@ -48,7 +48,7 @@ import java.util.List;
 public class TestKuduSpanReceiver extends BaseKuduTest {
 
   private static final String BIN_DIR_PROP = "binDir";
-  private static final String BIN_DIR_PROP_DEFAULT = "./build/release/bin";
+  private static final String BIN_DIR_PROP_DEFAULT = "../build/release/bin";
   //set kudu binary location and enable test execution from here
   private static final boolean TEST_ENABLE = false;
 
@@ -83,10 +83,10 @@ public class TestKuduSpanReceiver extends BaseKuduTest {
     span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_SPAN_ID,
             Type.INT64)
             .build());
-    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PROCESS_ID,
-            Type.STRING)
+    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_HIGH,
+            Type.INT64)
             .build());
-    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID,
+    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_LOW,
             Type.INT64)
             .build());
     span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT,
@@ -137,6 +137,7 @@ public class TestKuduSpanReceiver extends BaseKuduTest {
                     KuduReceiverConstants.KUDU_MASTER_PORT_KEY, BaseKuduTest.getMasterAddresses().split(":")[1]))
             .build();
     TraceScope scope = tracer.newScope("testKuduScope");
+    scope.addTimelineAnnotation("test");
     Span testSpan = scope.getSpan();
     scope.close();
     tracer.close();
@@ -147,6 +148,8 @@ public class TestKuduSpanReceiver extends BaseKuduTest {
     spanColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_DESCRIPTION);
     spanColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_START_TIME);
     spanColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_STOP_TIME);
+    spanColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_HIGH);
+    spanColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_LOW);
     KuduScanner scanner = client.newScannerBuilder(client.openTable(KuduReceiverConstants.DEFAULT_KUDU_SPAN_TABLE))
             .setProjectedColumnNames(spanColumns)
             .build();
@@ -157,11 +160,18 @@ public class TestKuduSpanReceiver extends BaseKuduTest {
         RowResult result = results.next();
         long traceId = result.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID);
         MilliSpan.Builder builder = new MilliSpan.Builder()
-                .spanId(new SpanId(result.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID),
-                        result.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_SPAN_ID)))
+                .spanId(new SpanId(result.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_SPAN_ID),
+                        result.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID)))
                 .description(result.getString(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_DESCRIPTION))
                 .begin(result.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_START_TIME))
                 .end(result.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_STOP_TIME));
+        if (!(result.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_HIGH) == 0 &&
+                result.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_LOW) == 0)) {
+          SpanId[] parents = new SpanId[1];
+          parents[0] = new SpanId(result.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_HIGH),
+                  result.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_LOW));
+          builder.parents(parents);
+        }
         List<String> timelineColumns = new ArrayList<>();
         timelineColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_TIME);
         timelineColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_MESSAGE);
@@ -177,7 +187,7 @@ public class TestKuduSpanReceiver extends BaseKuduTest {
         while (timelineScanner.hasMoreRows()) {
           RowResultIterator timelineResults = timelineScanner.nextRows();
           while (timelineResults.hasNext()) {
-            RowResult timelineRow = results.next();
+            RowResult timelineRow = timelineResults.next();
             timelineList.add(new TimelineAnnotation
                     (timelineRow.getLong(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_TIME),
                             timelineRow.getString(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_MESSAGE)));
@@ -193,6 +203,10 @@ public class TestKuduSpanReceiver extends BaseKuduTest {
     Assert.assertEquals(testSpan.getStartTimeMillis(), dbSpan.getStartTimeMillis());
     Assert.assertEquals(testSpan.getStopTimeMillis(), dbSpan.getStopTimeMillis());
     Assert.assertEquals(testSpan.getDescription(), dbSpan.getDescription());
+    Assert.assertEquals(testSpan.getTimelineAnnotations().get(0).getMessage(),
+            dbSpan.getTimelineAnnotations().get(0).getMessage());
+    Assert.assertEquals(testSpan.getTimelineAnnotations().get(0).getTime(),
+            dbSpan.getTimelineAnnotations().get(0).getTime());
     syncClient.deleteTable(KuduReceiverConstants.DEFAULT_KUDU_SPAN_TABLE);
     syncClient.deleteTable(KuduReceiverConstants.DEFAULT_KUDU_SPAN_TIMELINE_ANNOTATION_TABLE);
   }

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/0cd394f5/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanViewer.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanViewer.java b/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanViewer.java
new file mode 100644
index 0000000..7dd2807
--- /dev/null
+++ b/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanViewer.java
@@ -0,0 +1,237 @@
+/*
+ * 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.impl;
+
+import org.apache.htrace.core.HTraceConfiguration;
+import org.apache.htrace.core.Span;
+import org.apache.htrace.core.SpanId;
+import org.apache.htrace.core.Tracer;
+import org.apache.htrace.core.TraceScope;
+import org.apache.htrace.core.MilliSpan;
+import org.apache.htrace.core.TracerPool;
+import org.apache.htrace.core.TimelineAnnotation;
+import org.apache.htrace.viewer.KuduSpanViewer;
+import org.junit.*;
+import org.kududb.ColumnSchema;
+import org.kududb.Schema;
+import org.kududb.Type;
+import org.kududb.client.BaseKuduTest;
+import org.kududb.client.KuduClient;
+import org.kududb.client.CreateTableOptions;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+public class TestKuduSpanViewer extends BaseKuduTest {
+
+  private static final String BIN_DIR_PROP = "binDir";
+  private static final String BIN_DIR_PROP_DEFAULT = "../build/release/bin";
+  //set kudu binary location and enable test execution from here
+  private static final boolean TEST_ENABLE = false;
+
+  @BeforeClass
+  public static void setUpBeforeClass() throws Exception {
+    if (TEST_ENABLE) {
+      System.setProperty(BIN_DIR_PROP, BIN_DIR_PROP_DEFAULT);
+      BaseKuduTest.setUpBeforeClass();
+    }
+  }
+
+  @AfterClass
+  public static void tearDownAfterClass() throws Exception {
+    if(TEST_ENABLE) {
+      BaseKuduTest.tearDownAfterClass();
+    }
+  }
+
+  private void createTable() throws Exception {
+    KuduClient client = BaseKuduTest.syncClient;
+    List<ColumnSchema> span_columns = new ArrayList();
+    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID,
+            Type.INT64)
+            .key(true)
+            .build());
+    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_START_TIME,
+            Type.INT64)
+            .build());
+    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_STOP_TIME,
+            Type.INT64)
+            .build());
+    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_SPAN_ID,
+            Type.INT64)
+            .build());
+    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_LOW,
+            Type.INT64)
+            .build());
+    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT_ID_HIGH,
+            Type.INT64)
+            .build());
+    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_PARENT,
+            Type.BOOL)
+            .build());
+    span_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_DESCRIPTION,
+            Type.STRING)
+            .build());
+
+    List<String> rangeKeys = new ArrayList<>();
+    rangeKeys.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_TRACE_ID);
+    Schema schema = new Schema(span_columns);
+    client.createTable(KuduReceiverConstants.DEFAULT_KUDU_SPAN_TABLE, schema,
+            new CreateTableOptions().setRangePartitionColumns(rangeKeys));
+
+    List<ColumnSchema> timeline_columns = new ArrayList();
+    timeline_columns.add(new ColumnSchema.ColumnSchemaBuilder
+            (KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_TIMELINEID, Type.INT64)
+            .key(true)
+            .build());
+    timeline_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_TIME,
+            Type.INT64)
+            .build());
+    timeline_columns.add(new ColumnSchema.ColumnSchemaBuilder
+            (KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_MESSAGE, Type.STRING)
+            .build());
+    timeline_columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_SPANID,
+            Type.INT64)
+            .build());
+    List<String> rangeKeysTimeline = new ArrayList<>();
+    rangeKeysTimeline.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_TIMELINE_TIMELINEID);
+    Schema timelineSchema = new Schema(timeline_columns);
+    client.createTable(KuduReceiverConstants.DEFAULT_KUDU_SPAN_TIMELINE_ANNOTATION_TABLE, timelineSchema,
+            new CreateTableOptions().setRangePartitionColumns(rangeKeysTimeline));
+  }
+
+
+  @Test
+  public void testSpanToJson() {
+    SpanId[] parent = new SpanId[1];
+    parent[0] = new SpanId(1,1);
+    MilliSpan.Builder builder = new MilliSpan.Builder()
+            .parents(parent)
+            .begin(1)
+            .end(2)
+            .spanId(new SpanId(10,20))
+            .description("description");
+    List<TimelineAnnotation> timelineList = new LinkedList<TimelineAnnotation>();
+    for (int i = 0; i < 3; i++) {
+      timelineList.add(new TimelineAnnotation(i,"message" + i));
+    }
+    builder.timeline(timelineList);
+    Span span = builder.build();
+    try {
+      String json = KuduSpanViewer.toJsonString(span);
+      String expected =
+              "{\"trace_id\":\"20\",\"span_id\":\"10\",\"description\":\"description\",\"parent_id\":\"1\"," +
+                      "\"start\":\"1\",\"stop\":\"2\",\"timeline\":[{\"time\":\"0\",\"message\":\"message0\",}{\"time\":\"1\"," +
+                      "\"message\":\"message1\",}{\"time\":\"2\",\"message\":\"message2\",}]}";
+      Assert.assertEquals(json, expected);
+    } catch (IOException e) {
+      Assert.fail("failed to get json from span. " + e.getMessage());
+    }
+  }
+
+  @Test
+  public void testSpanWithoutTimelineToJson() {
+    SpanId[] parent = new SpanId[1];
+    parent[0] = new SpanId(200,111);
+    MilliSpan.Builder builder = new MilliSpan.Builder()
+            .parents(parent)
+            .begin(1)
+            .end(2)
+            .spanId(new SpanId(10,20))
+            .tracerId("pid")
+            .description("description");
+    Span span = builder.build();
+    try {
+      String json = KuduSpanViewer.toJsonString(span);
+      String expected =
+              "{\"trace_id\":\"20\",\"span_id\":\"10\",\"description\":\"description\"," +
+                      "\"parent_id\":\"111\",\"start\":\"1\",\"stop\":\"2\",}";
+      Assert.assertEquals(json, expected);
+    } catch (IOException e) {
+      Assert.fail("failed to get json from span. " + e.getMessage());
+    }
+  }
+
+  @Ignore
+  @Test
+  public void TestKuduSpanViewer() throws Exception {
+    createTable();
+    Tracer tracer = new Tracer.Builder().
+            name("testKuduSpanReceiver").
+            tracerPool(new TracerPool("testKuduSpanReceiver")).
+            conf(HTraceConfiguration.fromKeyValuePairs(
+                    "sampler.classes", "AlwaysSampler",
+                    "span.receiver.classes", "org.apache.htrace.impl.KuduSpanReceiver",
+                    KuduReceiverConstants.KUDU_MASTER_HOST_KEY, BaseKuduTest.getMasterAddresses().split(":")[0],
+                    KuduReceiverConstants.KUDU_MASTER_PORT_KEY, BaseKuduTest.getMasterAddresses().split(":")[1]))
+            .build();
+    TraceScope scope = tracer.newScope("testKuduScope");
+    scope.addTimelineAnnotation("test");
+    Span testSpan = scope.getSpan();
+    TraceScope childScope = tracer.newScope("testKuduChildScope", new SpanId(100,200));
+    Span childScopeSpan = childScope.getSpan();
+    childScope.addTimelineAnnotation("testChild");
+    childScope.close();
+    scope.close();
+    tracer.close();
+    HTraceConfiguration conf = HTraceConfiguration
+            .fromKeyValuePairs(KuduReceiverConstants.KUDU_MASTER_HOST_KEY,
+                    BaseKuduTest.getMasterAddresses().split(":")[0],
+            KuduReceiverConstants.KUDU_MASTER_PORT_KEY, BaseKuduTest.getMasterAddresses().split(":")[1]);
+    KuduSpanViewer viewer = new KuduSpanViewer(conf);
+    List<Span> list = viewer.getRootSpans();
+    Assert.assertEquals(list.size(), 1);
+    Span span = viewer.getRootSpans().get(0);
+    try {
+      String json = KuduSpanViewer.toJsonString(span);
+      String expected = KuduSpanViewer.toJsonString(testSpan);
+      Assert.assertEquals(json, expected);
+    } catch (IOException e) {
+      Assert.fail("failed to get json from span. " + e.getMessage());
+    }
+    List<Span> list2 = viewer.getSpans(span.getSpanId().getHigh());
+    Assert.assertEquals(list2.size(), 2);
+    Span span2 = list2.get(0);
+    try {
+      String json = KuduSpanViewer.toJsonString(span2);
+      String expected = null;
+      if(span2.getParents().length != 0) {
+        expected = KuduSpanViewer.toJsonString(childScopeSpan);
+      } else {
+        expected = KuduSpanViewer.toJsonString(testSpan);
+      }
+      Assert.assertEquals(json, expected);
+    } catch (IOException e) {
+      Assert.fail("failed to get json from span. " + e.getMessage());
+    }
+    Span span3 = list2.get(1);
+    try {
+      String json = KuduSpanViewer.toJsonString(span3);
+      String expected = null;
+      if(span3.getParents().length != 0) {
+        expected = KuduSpanViewer.toJsonString(childScopeSpan);
+      } else {
+        expected = KuduSpanViewer.toJsonString(testSpan);
+      }
+      Assert.assertEquals(json, expected);
+    } catch (IOException e) {
+      Assert.fail("failed to get json from span. " + e.getMessage());
+    }
+  }
+}



[03/12] incubator-htrace git commit: refactored and added unit test cases

Posted by le...@apache.org.
refactored and added unit test cases


Project: http://git-wip-us.apache.org/repos/asf/incubator-htrace/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-htrace/commit/be4f53cc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-htrace/tree/be4f53cc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-htrace/diff/be4f53cc

Branch: refs/heads/master
Commit: be4f53cc35dda6ee76a73d8087a036bc6c18cf7b
Parents: 6752709
Author: Nisala Nirmana <ni...@gmail.com>
Authored: Mon Jul 18 02:17:14 2016 +0530
Committer: Nisala Nirmana <ni...@gmail.com>
Committed: Mon Jul 18 02:17:14 2016 +0530

----------------------------------------------------------------------
 htrace-kudu/pom.xml                             |  20 ++-
 .../apache/htrace/KuduHTraceConfiguration.java  |  52 --------
 .../htrace/impl/KuduClientConfiguration.java    |  24 ++--
 .../org/apache/htrace/impl/KuduConstants.java   |  49 -------
 .../htrace/impl/KuduReceiverConstants.java      |  49 +++++++
 .../apache/htrace/impl/KuduSpanReceiver.java    |  74 ++++++-----
 .../htrace/impl/TestKuduSpanReceiver.java       | 128 +++++++++++++++++++
 7 files changed, 242 insertions(+), 154 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/be4f53cc/htrace-kudu/pom.xml
----------------------------------------------------------------------
diff --git a/htrace-kudu/pom.xml b/htrace-kudu/pom.xml
index 60db72d..58140a6 100644
--- a/htrace-kudu/pom.xml
+++ b/htrace-kudu/pom.xml
@@ -18,7 +18,7 @@ language governing permissions and limitations under the License. -->
   <parent>
     <artifactId>htrace</artifactId>
     <groupId>org.apache.htrace</groupId>
-    <version>4.1.0-incubating-SNAPSHOT</version>
+    <version>4.2.0-incubating-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
@@ -31,8 +31,8 @@ language governing permissions and limitations under the License. -->
 
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-    <kudu.version>1.0.0-SNAPSHOT</kudu.version>
-    <hadoop.version>2.6.0-cdh5.4.7</hadoop.version>
+    <kudu.version>0.9.1</kudu.version>
+    <commons.version>1.3.2</commons.version>
     <createDependencyReducedPom>true</createDependencyReducedPom>
   </properties>
 
@@ -147,7 +147,6 @@ language governing permissions and limitations under the License. -->
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
-
     <!-- KUDU specific deps. -->
     <dependency>
       <groupId>org.kududb</groupId>
@@ -155,9 +154,16 @@ language governing permissions and limitations under the License. -->
       <version>${kudu.version}</version>
     </dependency>
     <dependency>
-      <groupId>org.apache.hadoop</groupId>
-      <artifactId>hadoop-client</artifactId>
-      <version>${hadoop.version}</version>
+      <groupId>org.kududb</groupId>
+      <artifactId>kudu-client</artifactId>
+      <version>${kudu.version}</version>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-io</artifactId>
+      <version>${commons.version}</version>
     </dependency>
   </dependencies>
 

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/be4f53cc/htrace-kudu/src/main/java/org/apache/htrace/KuduHTraceConfiguration.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/KuduHTraceConfiguration.java b/htrace-kudu/src/main/java/org/apache/htrace/KuduHTraceConfiguration.java
deleted file mode 100644
index 4a5e740..0000000
--- a/htrace-kudu/src/main/java/org/apache/htrace/KuduHTraceConfiguration.java
+++ /dev/null
@@ -1,52 +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.htrace;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.htrace.core.HTraceConfiguration;
-
-public class KuduHTraceConfiguration extends HTraceConfiguration {
-
-  public static final String KEY_PREFIX = "kudu.";
-  private final Configuration conf;
-
-  public KuduHTraceConfiguration(Configuration conf) {
-    this.conf = conf;
-  }
-
-  @Override
-  public String get(String key) {
-    return conf.get(KEY_PREFIX + key);
-  }
-
-  @Override
-  public String get(String key, String defaultValue) {
-    return conf.get(KEY_PREFIX + key, defaultValue);
-
-  }
-
-  @Override
-  public boolean getBoolean(String key, boolean defaultValue) {
-    return conf.getBoolean(KEY_PREFIX + key, defaultValue);
-  }
-
-  @Override
-  public int getInt(String key, int defaultValue) {
-    return conf.getInt(KEY_PREFIX + key, defaultValue);
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/be4f53cc/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java
index 4e99efc..c58dbb2 100644
--- a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java
+++ b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduClientConfiguration.java
@@ -24,12 +24,12 @@ public class KuduClientConfiguration {
 
   private String host;
   private String port;
-  private int workerCount;
-  private int bossCount;
-  private boolean isStatisticsEnabled;
-  private long adminOperationTimeout;
-  private long operationTimeout;
-  private long socketReadTimeout;
+  private Integer workerCount;
+  private Integer bossCount;
+  private Boolean isStatisticsEnabled;
+  private Long adminOperationTimeout;
+  private Long operationTimeout;
+  private Long socketReadTimeout;
 
   public KuduClientConfiguration(String host, String port) {
     this.host = host;
@@ -63,22 +63,22 @@ public class KuduClientConfiguration {
   public KuduClient buildClient() {
     KuduClientBuilder builder = new KuduClient
             .KuduClientBuilder(host.concat(":").concat(port));
-    if (Integer.valueOf(workerCount) != null) {
+    if (workerCount != null) {
       builder.workerCount(workerCount);
     }
-    if (Integer.valueOf(bossCount) != null) {
+    if (bossCount != null) {
       builder.bossCount(bossCount);
     }
-    if (!Boolean.valueOf(isStatisticsEnabled)) {
+    if (isStatisticsEnabled != null && isStatisticsEnabled == false) {
       builder.disableStatistics();
     }
-    if (Long.valueOf(adminOperationTimeout) != null) {
+    if (adminOperationTimeout != null) {
       builder.defaultAdminOperationTimeoutMs(adminOperationTimeout);
     }
-    if (Long.valueOf(operationTimeout) != null) {
+    if (operationTimeout != null) {
       builder.defaultOperationTimeoutMs(operationTimeout);
     }
-    if (Long.valueOf(socketReadTimeout) != null) {
+    if (socketReadTimeout != null) {
       builder.defaultSocketReadTimeoutMs(socketReadTimeout);
     }
     return builder.build();

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/be4f53cc/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduConstants.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduConstants.java b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduConstants.java
deleted file mode 100644
index 4092b8b..0000000
--- a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduConstants.java
+++ /dev/null
@@ -1,49 +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.htrace.impl;
-
-public class KuduConstants {
-
-  public static final String KUDU_MASTER_HOST_KEY = "htrace.kudu.master.host";
-  public static final String DEFAULT_KUDU_MASTER_HOST = "127.0.0.1";
-  public static final String KUDU_MASTER_PORT_KEY = "htrace.kudu.master.port";
-  public static final String DEFAULT_KUDU_MASTER_PORT = "7051";
-  public static final String SPAN_BLOCKING_QUEUE_SIZE_KEY = "htrace.kudu.span.queue.size";
-  public static final int DEFAULT_SPAN_BLOCKING_QUEUE_SIZE = 1000;
-  public static final String KUDU_TABLE_KEY = "htrace.kudu.table";
-  public static final String DEFAULT_KUDU_TABLE = "htrace";
-  public static final String MAX_SPAN_BATCH_SIZE_KEY = "htrace.kudu.batch.size";
-  public static final int DEFAULT_MAX_SPAN_BATCH_SIZE = 100;
-  public static final String NUM_PARALLEL_THREADS_KEY = "htrace.kudu.num.threads";
-  public static final int DEFAULT_NUM_PARALLEL_THREADS = 1;
-  public static final String KUDU_COLUMN_SPAN_ID_KEY = "htrace.kudu.column.spanid";
-  public static final String DEFAULT_KUDU_COLUMN_SPAN_ID = "span_id";
-  public static final String KUDU_COLUMN_SPAN_KEY = "htrace.kudu.column.span";
-  public static final String DEFAULT_KUDU_COLUMN_SPAN = "span";
-  public static final String KUDU_COLUMN_ROOT_SPAN_KEY = "htrace.kudu.column.rootspan";
-  public static final String DEFAULT_KUDU_COLUMN_ROOT_SPAN = "root_span";
-  public static final String KUDU_COLUMN_ROOT_SPAN_START_TIME_KEY = "htrace.kudu.column.rootspan.starttime";
-  public static final String DEFAULT_KUDU_COLUMN_ROOT_SPAN_START_TIME = "root_span_start_time";
-  public static final String KUDU_CLIENT_WORKER_COUNT_KEY = "htrace.kudu.client.worker.count";
-  public static final String KUDU_CLIENT_BOSS_COUNT_KEY = "htrace.kudu.client.boss.count";
-  public static final String KUDU_CLIENT_STATISTICS_ENABLED_KEY = "htrace.kudu.client.statistics.enabled";
-  public static final String KUDU_CLIENT_TIMEOUT_ADMIN_OPERATION_KEY = "htrace.kudu.client.timeout.admin.operation";
-  public static final String KUDU_CLIENT_TIMEOUT_OPERATION_KEY = "htrace.kudu.client.timeout.operation";
-  public static final String KUDU_CLIENT_TIMEOUT_SOCKET_READ_KEY = "htrace.kudu.client.timeout.socket.read";
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/be4f53cc/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduReceiverConstants.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduReceiverConstants.java b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduReceiverConstants.java
new file mode 100644
index 0000000..a605dfe
--- /dev/null
+++ b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduReceiverConstants.java
@@ -0,0 +1,49 @@
+/*
+ * 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.impl;
+
+public class KuduReceiverConstants {
+
+  public static final String KUDU_MASTER_HOST_KEY = "htrace.kudu.master.host";
+  public static final String DEFAULT_KUDU_MASTER_HOST = "127.0.0.1";
+  public static final String KUDU_MASTER_PORT_KEY = "htrace.kudu.master.port";
+  public static final String DEFAULT_KUDU_MASTER_PORT = "7051";
+  public static final String SPAN_BLOCKING_QUEUE_SIZE_KEY = "htrace.kudu.span.queue.size";
+  public static final int DEFAULT_SPAN_BLOCKING_QUEUE_SIZE = 1000;
+  public static final String KUDU_TABLE_KEY = "htrace.kudu.table";
+  public static final String DEFAULT_KUDU_TABLE = "htrace";
+  public static final String MAX_SPAN_BATCH_SIZE_KEY = "htrace.kudu.batch.size";
+  public static final int DEFAULT_MAX_SPAN_BATCH_SIZE = 100;
+  public static final String NUM_PARALLEL_THREADS_KEY = "htrace.kudu.num.threads";
+  public static final int DEFAULT_NUM_PARALLEL_THREADS = 1;
+  public static final String KUDU_COLUMN_SPAN_ID_KEY = "htrace.kudu.column.spanid";
+  public static final String DEFAULT_KUDU_COLUMN_SPAN_ID = "span_id";
+  public static final String KUDU_COLUMN_SPAN_KEY = "htrace.kudu.column.span";
+  public static final String DEFAULT_KUDU_COLUMN_SPAN = "span";
+  public static final String KUDU_COLUMN_ROOT_SPAN_KEY = "htrace.kudu.column.rootspan";
+  public static final String DEFAULT_KUDU_COLUMN_ROOT_SPAN = "root_span";
+  public static final String KUDU_COLUMN_ROOT_SPAN_START_TIME_KEY = "htrace.kudu.column.rootspan.starttime";
+  public static final String DEFAULT_KUDU_COLUMN_ROOT_SPAN_START_TIME = "root_span_start_time";
+  public static final String KUDU_CLIENT_WORKER_COUNT_KEY = "htrace.kudu.client.worker.count";
+  public static final String KUDU_CLIENT_BOSS_COUNT_KEY = "htrace.kudu.client.boss.count";
+  public static final String KUDU_CLIENT_STATISTICS_ENABLED_KEY = "htrace.kudu.client.statistics.enabled";
+  public static final String KUDU_CLIENT_TIMEOUT_ADMIN_OPERATION_KEY = "htrace.kudu.client.timeout.admin.operation";
+  public static final String KUDU_CLIENT_TIMEOUT_OPERATION_KEY = "htrace.kudu.client.timeout.operation";
+  public static final String KUDU_CLIENT_TIMEOUT_SOCKET_READ_KEY = "htrace.kudu.client.timeout.socket.read";
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/be4f53cc/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java
index da7aca3..ed3e093 100644
--- a/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java
+++ b/htrace-kudu/src/main/java/org/apache/htrace/impl/KuduSpanReceiver.java
@@ -74,44 +74,50 @@ public class KuduSpanReceiver extends SpanReceiver {
 
   public KuduSpanReceiver(HTraceConfiguration conf) {
     this.clientConf =
-            new KuduClientConfiguration(conf.get(KuduConstants.KUDU_MASTER_HOST_KEY,
-                    KuduConstants.DEFAULT_KUDU_MASTER_HOST),
-                    conf.get(KuduConstants.KUDU_MASTER_PORT_KEY,
-                            KuduConstants.DEFAULT_KUDU_MASTER_PORT));
-    this.clientConf.setBossCount(conf.getInt(KuduConstants.KUDU_CLIENT_BOSS_COUNT_KEY,
-            Integer.valueOf(null)));
-    this.clientConf.setWorkerCount(conf.getInt(KuduConstants.KUDU_CLIENT_WORKER_COUNT_KEY,
-            Integer.valueOf(null)));
-    this.clientConf.setIsStatisticsEnabled(conf.getBoolean(KuduConstants.KUDU_CLIENT_STATISTICS_ENABLED_KEY,
-            Boolean.valueOf(null)));
-    this.clientConf
-            .setAdminOperationTimeout(Long.valueOf(conf.get(KuduConstants.KUDU_CLIENT_TIMEOUT_ADMIN_OPERATION_KEY,
-                    String.valueOf(null))));
-    this.clientConf
-            .setOperationTimeout(Long.valueOf(conf.get(KuduConstants.KUDU_CLIENT_TIMEOUT_OPERATION_KEY,
-                    String.valueOf(null))));
-    this.clientConf
-            .setSocketReadTimeout(Long.valueOf(conf.get(KuduConstants.KUDU_CLIENT_TIMEOUT_SOCKET_READ_KEY,
-                    String.valueOf(null))));
-    this.queue = new ArrayBlockingQueue<Span>(conf.getInt(KuduConstants.SPAN_BLOCKING_QUEUE_SIZE_KEY,
-            KuduConstants.DEFAULT_SPAN_BLOCKING_QUEUE_SIZE));
-    this.table = conf.get(KuduConstants.KUDU_TABLE_KEY, KuduConstants.DEFAULT_KUDU_TABLE);
-    this.column_span_id = conf.get(KuduConstants.KUDU_COLUMN_SPAN_ID_KEY,
-            KuduConstants.DEFAULT_KUDU_COLUMN_SPAN_ID);
-    this.column_span = conf.get(KuduConstants.KUDU_COLUMN_SPAN_KEY,
-            KuduConstants.DEFAULT_KUDU_COLUMN_SPAN);
-    this.column_root_span = conf.get(KuduConstants.KUDU_COLUMN_ROOT_SPAN_KEY,
-            KuduConstants.DEFAULT_KUDU_COLUMN_ROOT_SPAN);
-    this.column_root_span_start_time = conf.get(KuduConstants.KUDU_COLUMN_ROOT_SPAN_START_TIME_KEY,
-            KuduConstants.DEFAULT_KUDU_COLUMN_ROOT_SPAN_START_TIME);
-    this.maxSpanBatchSize = conf.getInt(KuduConstants.MAX_SPAN_BATCH_SIZE_KEY,
-            KuduConstants.DEFAULT_MAX_SPAN_BATCH_SIZE);
+            new KuduClientConfiguration(conf.get(KuduReceiverConstants.KUDU_MASTER_HOST_KEY,
+                    KuduReceiverConstants.DEFAULT_KUDU_MASTER_HOST),
+                    conf.get(KuduReceiverConstants.KUDU_MASTER_PORT_KEY,
+                            KuduReceiverConstants.DEFAULT_KUDU_MASTER_PORT));
+    if (conf.get(KuduReceiverConstants.KUDU_CLIENT_BOSS_COUNT_KEY) != null) {
+      this.clientConf.setBossCount(Integer.valueOf(conf.get(KuduReceiverConstants.KUDU_CLIENT_BOSS_COUNT_KEY)));
+    }
+    if (conf.get(KuduReceiverConstants.KUDU_CLIENT_WORKER_COUNT_KEY) != null) {
+      this.clientConf.setWorkerCount(Integer.valueOf(conf.get(KuduReceiverConstants.KUDU_CLIENT_WORKER_COUNT_KEY)));
+    }
+    if (conf.get(KuduReceiverConstants.KUDU_CLIENT_STATISTICS_ENABLED_KEY) != null) {
+      this.clientConf.setIsStatisticsEnabled(Boolean.valueOf(conf.get(KuduReceiverConstants.KUDU_CLIENT_STATISTICS_ENABLED_KEY)));
+    }
+    if (conf.get(KuduReceiverConstants.KUDU_CLIENT_TIMEOUT_ADMIN_OPERATION_KEY) != null) {
+      this.clientConf
+              .setAdminOperationTimeout(Long.valueOf(conf.get(KuduReceiverConstants.KUDU_CLIENT_TIMEOUT_ADMIN_OPERATION_KEY)));
+    }
+    if (conf.get(KuduReceiverConstants.KUDU_CLIENT_TIMEOUT_OPERATION_KEY) != null) {
+      this.clientConf
+              .setOperationTimeout(Long.valueOf(conf.get(KuduReceiverConstants.KUDU_CLIENT_TIMEOUT_OPERATION_KEY)));
+    }
+    if (conf.get(KuduReceiverConstants.KUDU_CLIENT_TIMEOUT_SOCKET_READ_KEY) != null) {
+      this.clientConf
+              .setSocketReadTimeout(Long.valueOf(conf.get(KuduReceiverConstants.KUDU_CLIENT_TIMEOUT_SOCKET_READ_KEY)));
+    }
+    this.queue = new ArrayBlockingQueue<Span>(conf.getInt(KuduReceiverConstants.SPAN_BLOCKING_QUEUE_SIZE_KEY,
+            KuduReceiverConstants.DEFAULT_SPAN_BLOCKING_QUEUE_SIZE));
+    this.table = conf.get(KuduReceiverConstants.KUDU_TABLE_KEY, KuduReceiverConstants.DEFAULT_KUDU_TABLE);
+    this.column_span_id = conf.get(KuduReceiverConstants.KUDU_COLUMN_SPAN_ID_KEY,
+            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_ID);
+    this.column_span = conf.get(KuduReceiverConstants.KUDU_COLUMN_SPAN_KEY,
+            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN);
+    this.column_root_span = conf.get(KuduReceiverConstants.KUDU_COLUMN_ROOT_SPAN_KEY,
+            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_ROOT_SPAN);
+    this.column_root_span_start_time = conf.get(KuduReceiverConstants.KUDU_COLUMN_ROOT_SPAN_START_TIME_KEY,
+            KuduReceiverConstants.DEFAULT_KUDU_COLUMN_ROOT_SPAN_START_TIME);
+    this.maxSpanBatchSize = conf.getInt(KuduReceiverConstants.MAX_SPAN_BATCH_SIZE_KEY,
+            KuduReceiverConstants.DEFAULT_MAX_SPAN_BATCH_SIZE);
     if (this.service != null) {
       this.service.shutdownNow();
       this.service = null;
     }
-    int numThreads = conf.getInt(KuduConstants.NUM_PARALLEL_THREADS_KEY,
-            KuduConstants.DEFAULT_NUM_PARALLEL_THREADS);
+    int numThreads = conf.getInt(KuduReceiverConstants.NUM_PARALLEL_THREADS_KEY,
+            KuduReceiverConstants.DEFAULT_NUM_PARALLEL_THREADS);
     this.service = Executors.newFixedThreadPool(numThreads, threadFactory);
     for (int i = 0; i < numThreads; i++) {
       this.service.submit(new KuduSpanReceiver.WriteSpanRunnable());

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/be4f53cc/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java
----------------------------------------------------------------------
diff --git a/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java b/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java
new file mode 100644
index 0000000..99a2839
--- /dev/null
+++ b/htrace-kudu/src/test/java/org/apache/htrace/impl/TestKuduSpanReceiver.java
@@ -0,0 +1,128 @@
+/*
+ * 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.impl;
+
+import org.apache.htrace.core.Tracer;
+import org.apache.htrace.core.Span;
+import org.apache.htrace.core.TracerPool;
+import org.apache.htrace.core.TraceScope;
+import org.apache.htrace.core.HTraceConfiguration;
+import org.apache.htrace.protobuf.generated.SpanProtos;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.AfterClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.kududb.Schema;
+import org.kududb.Type;
+import org.kududb.ColumnSchema;
+import org.kududb.client.BaseKuduTest;
+import org.kududb.client.KuduClient;
+import org.kududb.client.CreateTableOptions;
+import org.kududb.client.KuduScanner;
+import org.kududb.client.RowResultIterator;
+import org.kududb.client.RowResult;
+
+
+import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestKuduSpanReceiver extends BaseKuduTest {
+
+  private static final String BIN_DIR_PROP = "binDir";
+  private static final String BIN_DIR_PROP_DEFAULT = "/home/djkevincr/poc/incubator-kudu/build/release/bin";
+
+  @BeforeClass
+  public static void setUpBeforeClass() throws Exception {
+    System.setProperty(BIN_DIR_PROP, BIN_DIR_PROP_DEFAULT);
+    BaseKuduTest.setUpBeforeClass();
+  }
+
+  @AfterClass
+  public static void tearDownAfterClass() throws Exception {
+    BaseKuduTest.tearDownAfterClass();
+  }
+
+  private void createTable() throws Exception {
+    KuduClient client = BaseKuduTest.syncClient;
+    List<ColumnSchema> columns = new ArrayList(4);
+    columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_ID,
+            Type.BINARY)
+            .key(true)
+            .build());
+    columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN,
+            Type.BINARY)
+            .build());
+    columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_ROOT_SPAN_START_TIME,
+            Type.BINARY)
+            .build());
+    columns.add(new ColumnSchema.ColumnSchemaBuilder(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_ROOT_SPAN,
+            Type.BINARY)
+            .build());
+    List<String> rangeKeys = new ArrayList<>();
+    rangeKeys.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN_ID);
+
+    Schema schema = new Schema(columns);
+    client.createTable(KuduReceiverConstants.DEFAULT_KUDU_TABLE, schema,
+            new CreateTableOptions().setRangePartitionColumns(rangeKeys));
+  }
+
+  @Ignore
+  @Test
+  public void TestKuduSpanReceiver() throws Exception {
+    createTable();
+    Tracer tracer = new Tracer.Builder().
+            name("testKuduSpanReceiver").
+            tracerPool(new TracerPool("testKuduSpanReceiver")).
+            conf(HTraceConfiguration.fromKeyValuePairs(
+                    "sampler.classes", "AlwaysSampler",
+                    "span.receiver.classes", "org.apache.htrace.impl.KuduSpanReceiver",
+                    KuduReceiverConstants.KUDU_MASTER_HOST_KEY, BaseKuduTest.getMasterAddresses().split(":")[0],
+                    KuduReceiverConstants.KUDU_MASTER_PORT_KEY, BaseKuduTest.getMasterAddresses().split(":")[1]))
+            .build();
+    TraceScope scope = tracer.newScope("testKuduScope");
+    Span testSpan = scope.getSpan();
+    SpanProtos.Span dbSpan = null;
+    scope.close();
+    tracer.close();
+    KuduClient client = BaseKuduTest.syncClient;
+    List<String> projectColumns = new ArrayList<>(1);
+    projectColumns.add(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN);
+    KuduScanner scanner = client.newScannerBuilder(client.openTable(KuduReceiverConstants.DEFAULT_KUDU_TABLE))
+            .setProjectedColumnNames(projectColumns)
+            .build();
+    while (scanner.hasMoreRows()) {
+      RowResultIterator results = scanner.nextRows();
+      while (results.hasNext()) {
+        RowResult result = results.next();
+        ByteArrayInputStream in = new
+                ByteArrayInputStream(result.getBinaryCopy(KuduReceiverConstants.DEFAULT_KUDU_COLUMN_SPAN));
+        dbSpan = SpanProtos.Span.parseFrom(in);
+        break;
+      }
+    }
+    Assert.assertEquals(testSpan.getSpanId().getHigh(), dbSpan.getTraceId());
+    Assert.assertEquals(testSpan.getSpanId().getLow(), dbSpan.getSpanId());
+    Assert.assertEquals(testSpan.getStartTimeMillis(), dbSpan.getStart());
+    Assert.assertEquals(testSpan.getStopTimeMillis(), dbSpan.getStop());
+    Assert.assertEquals(testSpan.getDescription(), dbSpan.getDescription());
+    syncClient.deleteTable(KuduReceiverConstants.DEFAULT_KUDU_TABLE);
+  }
+
+}


[12/12] incubator-htrace git commit: Merge branch 'GSOC_HTRACE' of https://github.com/nisalanirmana/incubator-htrace

Posted by le...@apache.org.
Merge branch 'GSOC_HTRACE' of https://github.com/nisalanirmana/incubator-htrace


Project: http://git-wip-us.apache.org/repos/asf/incubator-htrace/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-htrace/commit/a3b503d7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-htrace/tree/a3b503d7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-htrace/diff/a3b503d7

Branch: refs/heads/master
Commit: a3b503d7da4bd151bba2978ce7720ba38aa4d332
Parents: 4508cd5 641d05b
Author: Lewis John McGibbney <le...@gmail.com>
Authored: Wed Apr 11 13:25:45 2018 -0700
Committer: Lewis John McGibbney <le...@gmail.com>
Committed: Wed Apr 11 13:25:45 2018 -0700

----------------------------------------------------------------------
 htrace-kudu/pom.xml                             | 196 ++++++++++++
 .../htrace/impl/KuduClientConfiguration.java    |  77 +++++
 .../htrace/impl/KuduReceiverConstants.java      |  55 ++++
 .../apache/htrace/impl/KuduSpanReceiver.java    | 218 ++++++++++++++
 .../htrace/viewer/KuduClientConstants.java      |  45 +++
 .../apache/htrace/viewer/KuduSpanViewer.java    | 300 +++++++++++++++++++
 .../htrace/viewer/KuduSpanViewerRunner.java     |  38 +++
 .../htrace/viewer/KuduSpanViewerServer.java     |  63 ++++
 .../viewer/KuduSpanViewerSpansServlet.java      |  96 ++++++
 .../viewer/KuduSpanViewerTracesServlet.java     |  88 ++++++
 .../htrace/impl/TestKuduSpanReceiver.java       | 247 +++++++++++++++
 .../apache/htrace/impl/TestKuduSpanViewer.java  | 231 ++++++++++++++
 htrace-kudu/src/test/resources/log4j.properties |  25 ++
 pom.xml                                         |   1 +
 14 files changed, 1680 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/a3b503d7/pom.xml
----------------------------------------------------------------------
diff --cc pom.xml
index 44e850a,879c8f1..86eab9a
--- a/pom.xml
+++ b/pom.xml
@@@ -35,8 -35,17 +35,9 @@@ language governing permissions and limi
      <module>htrace-hbase</module>
      <module>htrace-flume</module>
      <module>htrace-htraced</module>
+     <module>htrace-kudu</module>
    </modules>
  
 -  <licenses>
 -    <license>
 -      <name>The Apache Software License, Version 2.0</name>
 -      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
 -      <distribution>repo</distribution>
 -      <comments>A business-friendly OSS license</comments>
 -    </license>
 -  </licenses>
    <scm>
      <connection>scm:git:http://git-wip-us.apache.org/repos/asf/incubator-htrace.git</connection>
      <developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/incubator-htrace.git</developerConnection>