/** * Create an annotation with the correct times and endpoint. * * @param value Annotation value * @param time timestamp will be extracted * @param ep the endopint this annotation will be associated with. * @param sendRequest use the first or last timestamp. */ private static Annotation createZipkinAnnotation(String value, long time, Endpoint ep, boolean sendRequest) { Annotation annotation = new Annotation(); annotation.setHost(ep); // Zipkin is in microseconds if (sendRequest) { annotation.setTimestamp(time * 1000); } else { annotation.setTimestamp(time * 1000); } annotation.setValue(value); return annotation; }
public Object getFieldValue(_Fields field) { switch (field) { case TIMESTAMP: return Long.valueOf(getTimestamp()); case VALUE: return getValue(); case HOST: return getHost(); case DURATION: return Integer.valueOf(getDuration()); } throw new IllegalStateException(); }
@Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof Annotation) return this.equals((Annotation)that); return false; }
public Object getFieldValue(_Fields field) { switch (field) { case TIMESTAMP: return Long.valueOf(getTimestamp()); case VALUE: return getValue(); case HOST: return getHost(); } throw new IllegalStateException(); }
case TIMESTAMP: if (value == null) { unsetTimestamp(); } else { setTimestamp((Long)value); unsetValue(); } else { setValue((String)value); unsetHost(); } else { setHost((Endpoint)value); unsetDuration(); } else { setDuration((Integer)value);
public void setFieldValue(_Fields field, Object value) { switch (field) { case TIMESTAMP: if (value == null) { unsetTimestamp(); } else { setTimestamp((Long)value); } break; case VALUE: if (value == null) { unsetValue(); } else { setValue((String)value); } break; case HOST: if (value == null) { unsetHost(); } else { setHost((Endpoint)value); } break; } }
_elem2 = new Annotation(); _elem2.read(iprot); struct.annotations.add(_elem2);
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case TIMESTAMP: return isSetTimestamp(); case VALUE: return isSetValue(); case HOST: return isSetHost(); } throw new IllegalStateException(); }
public Annotation deepCopy() { return new Annotation(this); }
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case TIMESTAMP: return isSetTimestamp(); case VALUE: return isSetValue(); case HOST: return isSetHost(); case DURATION: return isSetDuration(); } throw new IllegalStateException(); }
@Override void annotate(Span span, long timestamp, String value) { Annotation annotation = Annotation.create(timestamp, value, localEndpoint()); synchronized (span) { span.addToAnnotations(annotation); } }
/** * Performs a deep copy on <i>other</i>. */ public Annotation(Annotation other) { __isset_bitfield = other.__isset_bitfield; this.timestamp = other.timestamp; if (other.isSetValue()) { this.value = other.value; } if (other.isSetHost()) { this.host = new Endpoint(other.host); } }
if (annotation.getValue().equals(zipkinCoreConstants.CLIENT_SEND) || annotation.getValue().equals(zipkinCoreConstants.SERVER_RECV)) { assertTrue(startTime <= annotation.getTimestamp()); assertTrue(annotation.getTimestamp() <= annoStartTime); } else if (annotation.getValue().equals(zipkinCoreConstants.CLIENT_RECV) || annotation.getValue().equals(zipkinCoreConstants.SERVER_SEND)) { assertTrue(annoEndTime <= annotation.getTimestamp()); assertTrue(annotation.getTimestamp() <= endTime); } else { assertTrue(annoStartTime <= annotation.getTimestamp()); assertTrue(annotation.getTimestamp() <= annoEndTime); assertTrue(annotation.getTimestamp() <= endTime);
boolean this_present_value = true && this.isSetValue(); boolean that_present_value = true && that.isSetValue(); if (this_present_value || that_present_value) { if (!(this_present_value && that_present_value)) boolean this_present_host = true && this.isSetHost(); boolean that_present_host = true && that.isSetHost(); if (this_present_host || that_present_host) { if (!(this_present_host && that_present_host)) boolean this_present_duration = true && this.isSetDuration(); boolean that_present_duration = true && that.isSetDuration(); if (this_present_duration || that_present_duration) { if (!(this_present_duration && that_present_duration))
public void write(org.apache.thrift.protocol.TProtocol oprot, Annotation struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldBegin(TIMESTAMP_FIELD_DESC); oprot.writeI64(struct.timestamp); oprot.writeFieldEnd(); if (struct.value != null) { oprot.writeFieldBegin(VALUE_FIELD_DESC); oprot.writeString(struct.value); oprot.writeFieldEnd(); } if (struct.host != null) { if (struct.isSetHost()) { oprot.writeFieldBegin(HOST_FIELD_DESC); struct.host.write(oprot); oprot.writeFieldEnd(); } } if (struct.isSetDuration()) { oprot.writeFieldBegin(DURATION_FIELD_DESC); oprot.writeI32(struct.duration); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); }
public void write(org.apache.thrift.protocol.TProtocol oprot, Annotation struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldBegin(TIMESTAMP_FIELD_DESC); oprot.writeI64(struct.timestamp); oprot.writeFieldEnd(); if (struct.value != null) { oprot.writeFieldBegin(VALUE_FIELD_DESC); oprot.writeString(struct.value); oprot.writeFieldEnd(); } if (struct.host != null) { if (struct.isSetHost()) { oprot.writeFieldBegin(HOST_FIELD_DESC); struct.host.write(oprot); oprot.writeFieldEnd(); } } oprot.writeFieldStop(); oprot.writeStructEnd(); }
public static <T> getFieldByColumnName(Object obj, String columnName) throws Exception { for (Field field : obj.getClass().getDeclaredFields()) { Annotation a = field.getAnnotation(Column.class); if (a != null && a.getValue().equals(columnName)) { return <T> field.get(obj); } } throw new IllegalArgumentException("No such column:" + columnName); }
if (isSetHost()) { if (!first) sb.append(", "); sb.append("host:"); if (isSetDuration()) { if (!first) sb.append(", "); sb.append("duration:");
@Test public void testHTraceDefaultPort() throws IOException { MilliSpan ms = new MilliSpan.Builder().description("test"). parents(new SpanId[] { new SpanId(2L, 2L) }). spanId(new SpanId(2L, 3L)). tracerId("hmaster"). begin(System.currentTimeMillis()). build(); com.twitter.zipkin.gen.Span zs = new HTraceToZipkinConverter(12345, (short) -1).convert(ms); for (com.twitter.zipkin.gen.Annotation annotation:zs.getAnnotations()) { assertEquals((short)60000, annotation.getHost().getPort()); } // make sure it's all lower cased ms = new MilliSpan.Builder().description("test"). parents(new SpanId[] {new SpanId(2, 2)}). spanId(new SpanId(2, 3)). tracerId("HregIonServer"). begin(System.currentTimeMillis()). build(); zs = new HTraceToZipkinConverter(12345, (short) -1).convert(ms); for (com.twitter.zipkin.gen.Annotation annotation:zs.getAnnotations()) { assertEquals((short)60020, annotation.getHost().getPort()); } }
@Override public String toString() { StringBuilder sb = new StringBuilder("Annotation("); boolean first = true; sb.append("timestamp:"); sb.append(this.timestamp); first = false; if (!first) sb.append(", "); sb.append("value:"); if (this.value == null) { sb.append("null"); } else { sb.append(this.value); } first = false; if (isSetHost()) { if (!first) sb.append(", "); sb.append("host:"); if (this.host == null) { sb.append("null"); } else { sb.append(this.host); } first = false; } sb.append(")"); return sb.toString(); }