From 7e009eedd633aaba4fdc542029d5cc7fb3415b02 Mon Sep 17 00:00:00 2001 From: Chisu Yu Date: Tue, 25 Sep 2012 09:51:05 +0000 Subject: [PATCH] =?UTF-8?q?[=EC=9C=A0=EC=B9=98=EC=88=98]=20[NOBTS]=20add?= =?UTF-8?q?=20serviceName=20to=20thrift.Span?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-commons/trunk@703 84d0f5b1-2673-498c-a247-62c4ff18d310 --- .../com/profiler/common/dto/thrift/Span.java | 161 ++++++++++++++---- src/main/thrift/Trace.thrift | 11 +- 2 files changed, 136 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/profiler/common/dto/thrift/Span.java b/src/main/java/com/profiler/common/dto/thrift/Span.java index e06620074..6b36bfbb5 100644 --- a/src/main/java/com/profiler/common/dto/thrift/Span.java +++ b/src/main/java/com/profiler/common/dto/thrift/Span.java @@ -35,11 +35,12 @@ public class Span implements org.apache.thrift.TBase, java.i private static final org.apache.thrift.protocol.TField MOST_TRACE_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("mostTraceID", org.apache.thrift.protocol.TType.I64, (short)3); private static final org.apache.thrift.protocol.TField LEAST_TRACE_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("leastTraceID", org.apache.thrift.protocol.TType.I64, (short)4); private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)5); - private static final org.apache.thrift.protocol.TField SPAN_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("spanID", org.apache.thrift.protocol.TType.I64, (short)6); - private static final org.apache.thrift.protocol.TField PARENT_SPAN_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("parentSpanId", org.apache.thrift.protocol.TType.I64, (short)7); - private static final org.apache.thrift.protocol.TField ANNOTATIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("annotations", org.apache.thrift.protocol.TType.LIST, (short)8); - private static final org.apache.thrift.protocol.TField BINARY_ANNOTATIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("binaryAnnotations", org.apache.thrift.protocol.TType.LIST, (short)9); - private static final org.apache.thrift.protocol.TField FLAG_FIELD_DESC = new org.apache.thrift.protocol.TField("flag", org.apache.thrift.protocol.TType.I32, (short)10); + private static final org.apache.thrift.protocol.TField SERVICE_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("serviceName", org.apache.thrift.protocol.TType.STRING, (short)6); + private static final org.apache.thrift.protocol.TField SPAN_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("spanID", org.apache.thrift.protocol.TType.I64, (short)7); + private static final org.apache.thrift.protocol.TField PARENT_SPAN_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("parentSpanId", org.apache.thrift.protocol.TType.I64, (short)8); + private static final org.apache.thrift.protocol.TField ANNOTATIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("annotations", org.apache.thrift.protocol.TType.LIST, (short)9); + private static final org.apache.thrift.protocol.TField BINARY_ANNOTATIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("binaryAnnotations", org.apache.thrift.protocol.TType.LIST, (short)10); + private static final org.apache.thrift.protocol.TField FLAG_FIELD_DESC = new org.apache.thrift.protocol.TField("flag", org.apache.thrift.protocol.TType.I32, (short)11); private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { @@ -52,6 +53,7 @@ public class Span implements org.apache.thrift.TBase, java.i private long mostTraceID; // required private long leastTraceID; // required private String name; // required + private String serviceName; // required private long spanID; // required private long parentSpanId; // optional private List annotations; // required @@ -65,11 +67,12 @@ public class Span implements org.apache.thrift.TBase, java.i MOST_TRACE_ID((short)3, "mostTraceID"), LEAST_TRACE_ID((short)4, "leastTraceID"), NAME((short)5, "name"), - SPAN_ID((short)6, "spanID"), - PARENT_SPAN_ID((short)7, "parentSpanId"), - ANNOTATIONS((short)8, "annotations"), - BINARY_ANNOTATIONS((short)9, "binaryAnnotations"), - FLAG((short)10, "flag"); + SERVICE_NAME((short)6, "serviceName"), + SPAN_ID((short)7, "spanID"), + PARENT_SPAN_ID((short)8, "parentSpanId"), + ANNOTATIONS((short)9, "annotations"), + BINARY_ANNOTATIONS((short)10, "binaryAnnotations"), + FLAG((short)11, "flag"); private static final Map byName = new HashMap(); @@ -94,15 +97,17 @@ public class Span implements org.apache.thrift.TBase, java.i return LEAST_TRACE_ID; case 5: // NAME return NAME; - case 6: // SPAN_ID + case 6: // SERVICE_NAME + return SERVICE_NAME; + case 7: // SPAN_ID return SPAN_ID; - case 7: // PARENT_SPAN_ID + case 8: // PARENT_SPAN_ID return PARENT_SPAN_ID; - case 8: // ANNOTATIONS + case 9: // ANNOTATIONS return ANNOTATIONS; - case 9: // BINARY_ANNOTATIONS + case 10: // BINARY_ANNOTATIONS return BINARY_ANNOTATIONS; - case 10: // FLAG + case 11: // FLAG return FLAG; default: return null; @@ -165,6 +170,8 @@ public class Span implements org.apache.thrift.TBase, java.i new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); tmpMap.put(_Fields.NAME, new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.SERVICE_NAME, new org.apache.thrift.meta_data.FieldMetaData("serviceName", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.SPAN_ID, new org.apache.thrift.meta_data.FieldMetaData("spanID", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); tmpMap.put(_Fields.PARENT_SPAN_ID, new org.apache.thrift.meta_data.FieldMetaData("parentSpanId", org.apache.thrift.TFieldRequirementType.OPTIONAL, @@ -192,6 +199,7 @@ public class Span implements org.apache.thrift.TBase, java.i long mostTraceID, long leastTraceID, String name, + String serviceName, long spanID, List annotations, List binaryAnnotations) @@ -205,6 +213,7 @@ public class Span implements org.apache.thrift.TBase, java.i this.leastTraceID = leastTraceID; setLeastTraceIDIsSet(true); this.name = name; + this.serviceName = serviceName; this.spanID = spanID; setSpanIDIsSet(true); this.annotations = annotations; @@ -226,6 +235,9 @@ public class Span implements org.apache.thrift.TBase, java.i if (other.isSetName()) { this.name = other.name; } + if (other.isSetServiceName()) { + this.serviceName = other.serviceName; + } this.spanID = other.spanID; this.parentSpanId = other.parentSpanId; if (other.isSetAnnotations()) { @@ -259,6 +271,7 @@ public class Span implements org.apache.thrift.TBase, java.i setLeastTraceIDIsSet(false); this.leastTraceID = 0; this.name = null; + this.serviceName = null; setSpanIDIsSet(false); this.spanID = 0; setParentSpanIdIsSet(false); @@ -381,6 +394,29 @@ public class Span implements org.apache.thrift.TBase, java.i } } + public String getServiceName() { + return this.serviceName; + } + + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + } + + public void unsetServiceName() { + this.serviceName = null; + } + + /** Returns true if field serviceName is set (has been assigned a value) and false otherwise */ + public boolean isSetServiceName() { + return this.serviceName != null; + } + + public void setServiceNameIsSet(boolean value) { + if (!value) { + this.serviceName = null; + } + } + public long getSpanID() { return this.spanID; } @@ -565,6 +601,14 @@ public class Span implements org.apache.thrift.TBase, java.i } break; + case SERVICE_NAME: + if (value == null) { + unsetServiceName(); + } else { + setServiceName((String)value); + } + break; + case SPAN_ID: if (value == null) { unsetSpanID(); @@ -625,6 +669,9 @@ public class Span implements org.apache.thrift.TBase, java.i case NAME: return getName(); + case SERVICE_NAME: + return getServiceName(); + case SPAN_ID: return Long.valueOf(getSpanID()); @@ -661,6 +708,8 @@ public class Span implements org.apache.thrift.TBase, java.i return isSetLeastTraceID(); case NAME: return isSetName(); + case SERVICE_NAME: + return isSetServiceName(); case SPAN_ID: return isSetSpanID(); case PARENT_SPAN_ID: @@ -733,6 +782,15 @@ public class Span implements org.apache.thrift.TBase, java.i return false; } + boolean this_present_serviceName = true && this.isSetServiceName(); + boolean that_present_serviceName = true && that.isSetServiceName(); + if (this_present_serviceName || that_present_serviceName) { + if (!(this_present_serviceName && that_present_serviceName)) + return false; + if (!this.serviceName.equals(that.serviceName)) + return false; + } + boolean this_present_spanID = true; boolean that_present_spanID = true; if (this_present_spanID || that_present_spanID) { @@ -844,6 +902,16 @@ public class Span implements org.apache.thrift.TBase, java.i return lastComparison; } } + lastComparison = Boolean.valueOf(isSetServiceName()).compareTo(typedOther.isSetServiceName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetServiceName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.serviceName, typedOther.serviceName); + if (lastComparison != 0) { + return lastComparison; + } + } lastComparison = Boolean.valueOf(isSetSpanID()).compareTo(typedOther.isSetSpanID()); if (lastComparison != 0) { return lastComparison; @@ -942,6 +1010,14 @@ public class Span implements org.apache.thrift.TBase, java.i } first = false; if (!first) sb.append(", "); + sb.append("serviceName:"); + if (this.serviceName == null) { + sb.append("null"); + } else { + sb.append(this.serviceName); + } + first = false; + if (!first) sb.append(", "); sb.append("spanID:"); sb.append(this.spanID); first = false; @@ -1057,7 +1133,15 @@ public class Span implements org.apache.thrift.TBase, java.i org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case 6: // SPAN_ID + case 6: // SERVICE_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.serviceName = iprot.readString(); + struct.setServiceNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 7: // SPAN_ID if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.spanID = iprot.readI64(); struct.setSpanIDIsSet(true); @@ -1065,7 +1149,7 @@ public class Span implements org.apache.thrift.TBase, java.i org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case 7: // PARENT_SPAN_ID + case 8: // PARENT_SPAN_ID if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.parentSpanId = iprot.readI64(); struct.setParentSpanIdIsSet(true); @@ -1073,7 +1157,7 @@ public class Span implements org.apache.thrift.TBase, java.i org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case 8: // ANNOTATIONS + case 9: // ANNOTATIONS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { org.apache.thrift.protocol.TList _list0 = iprot.readListBegin(); @@ -1092,7 +1176,7 @@ public class Span implements org.apache.thrift.TBase, java.i org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case 9: // BINARY_ANNOTATIONS + case 10: // BINARY_ANNOTATIONS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { org.apache.thrift.protocol.TList _list3 = iprot.readListBegin(); @@ -1111,7 +1195,7 @@ public class Span implements org.apache.thrift.TBase, java.i org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case 10: // FLAG + case 11: // FLAG if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.flag = iprot.readI32(); struct.setFlagIsSet(true); @@ -1151,6 +1235,11 @@ public class Span implements org.apache.thrift.TBase, java.i oprot.writeString(struct.name); oprot.writeFieldEnd(); } + if (struct.serviceName != null) { + oprot.writeFieldBegin(SERVICE_NAME_FIELD_DESC); + oprot.writeString(struct.serviceName); + oprot.writeFieldEnd(); + } oprot.writeFieldBegin(SPAN_ID_FIELD_DESC); oprot.writeI64(struct.spanID); oprot.writeFieldEnd(); @@ -1221,22 +1310,25 @@ public class Span implements org.apache.thrift.TBase, java.i if (struct.isSetName()) { optionals.set(4); } - if (struct.isSetSpanID()) { + if (struct.isSetServiceName()) { optionals.set(5); } - if (struct.isSetParentSpanId()) { + if (struct.isSetSpanID()) { optionals.set(6); } - if (struct.isSetAnnotations()) { + if (struct.isSetParentSpanId()) { optionals.set(7); } - if (struct.isSetBinaryAnnotations()) { + if (struct.isSetAnnotations()) { optionals.set(8); } - if (struct.isSetFlag()) { + if (struct.isSetBinaryAnnotations()) { optionals.set(9); } - oprot.writeBitSet(optionals, 10); + if (struct.isSetFlag()) { + optionals.set(10); + } + oprot.writeBitSet(optionals, 11); if (struct.isSetAgentID()) { oprot.writeString(struct.agentID); } @@ -1252,6 +1344,9 @@ public class Span implements org.apache.thrift.TBase, java.i if (struct.isSetName()) { oprot.writeString(struct.name); } + if (struct.isSetServiceName()) { + oprot.writeString(struct.serviceName); + } if (struct.isSetSpanID()) { oprot.writeI64(struct.spanID); } @@ -1284,7 +1379,7 @@ public class Span implements org.apache.thrift.TBase, java.i @Override public void read(org.apache.thrift.protocol.TProtocol prot, Span struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(10); + BitSet incoming = iprot.readBitSet(11); if (incoming.get(0)) { struct.agentID = iprot.readString(); struct.setAgentIDIsSet(true); @@ -1306,14 +1401,18 @@ public class Span implements org.apache.thrift.TBase, java.i struct.setNameIsSet(true); } if (incoming.get(5)) { + struct.serviceName = iprot.readString(); + struct.setServiceNameIsSet(true); + } + if (incoming.get(6)) { struct.spanID = iprot.readI64(); struct.setSpanIDIsSet(true); } - if (incoming.get(6)) { + if (incoming.get(7)) { struct.parentSpanId = iprot.readI64(); struct.setParentSpanIdIsSet(true); } - if (incoming.get(7)) { + if (incoming.get(8)) { { org.apache.thrift.protocol.TList _list10 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.annotations = new ArrayList(_list10.size); @@ -1327,7 +1426,7 @@ public class Span implements org.apache.thrift.TBase, java.i } struct.setAnnotationsIsSet(true); } - if (incoming.get(8)) { + if (incoming.get(9)) { { org.apache.thrift.protocol.TList _list13 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.binaryAnnotations = new ArrayList(_list13.size); @@ -1341,7 +1440,7 @@ public class Span implements org.apache.thrift.TBase, java.i } struct.setBinaryAnnotationsIsSet(true); } - if (incoming.get(9)) { + if (incoming.get(10)) { struct.flag = iprot.readI32(); struct.setFlagIsSet(true); } diff --git a/src/main/thrift/Trace.thrift b/src/main/thrift/Trace.thrift index 1c0c9a721..146aecba4 100644 --- a/src/main/thrift/Trace.thrift +++ b/src/main/thrift/Trace.thrift @@ -29,9 +29,10 @@ struct Span { 3: i64 mostTraceID 4: i64 leastTraceID 5: string name, - 6: i64 spanID, - 7: optional i64 parentSpanId, - 8: list annotations, - 9: list binaryAnnotations - 10: optional i32 flag = 0 + 6: string serviceName + 7: i64 spanID, + 8: optional i64 parentSpanId, + 9: list annotations, + 10: list binaryAnnotations + 11: optional i32 flag = 0 } \ No newline at end of file