public static Endpoint create(String serviceName, int ipv4, int port) { return new Endpoint(serviceName, ipv4, (short) (port & 0xffff)); }
@Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof Endpoint) return this.equals((Endpoint)that); return false; }
@Override public Endpoint getClientEndPoint() { if(currentClientServiceName == null){ return endPoint; } else { Endpoint newEndPoint = new Endpoint(endPoint); newEndPoint.setService_name(currentClientServiceName); return newEndPoint; } }
public Object getFieldValue(_Fields field) { switch (field) { case IPV4: return Integer.valueOf(getIpv4()); case PORT: return Short.valueOf(getPort()); case SERVICE_NAME: return getService_name(); } throw new IllegalStateException(); }
public void setFieldValue(_Fields field, Object value) { switch (field) { case IPV4: if (value == null) { unsetIpv4(); } else { setIpv4((Integer)value); } break; case PORT: if (value == null) { unsetPort(); } else { setPort((Short)value); } break; case SERVICE_NAME: if (value == null) { unsetService_name(); } else { setService_name((String)value); } break; } }
@Override public void read(org.apache.thrift.protocol.TProtocol prot, Annotation struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(4); if (incoming.get(0)) { struct.timestamp = iprot.readI64(); struct.setTimestampIsSet(true); } if (incoming.get(1)) { struct.value = iprot.readString(); struct.setValueIsSet(true); } if (incoming.get(2)) { struct.host = new Endpoint(); struct.host.read(iprot); struct.setHostIsSet(true); } } }
/** 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 IPV4: return isSetIpv4(); case PORT: return isSetPort(); case SERVICE_NAME: return isSetService_name(); } throw new IllegalStateException(); }
/** * Builder. * * @param ip ipv4 host address as int. Ex for the ip 1.2.3.4, it would be (1 << 24) | (2 << 16) | (3 << 8) | 4 * @param port Port for service * @param serviceName Name of the local service being traced. Should be lowercase and not <code>null</code> or empty. */ public Builder(int ip, int port, String serviceName) { this(Endpoint.builder().serviceName(serviceName).ipv4(ip).port(port).build()); }
@Override public int hashCode() { int h = 1; h *= 1000003; h ^= (timestamp >>> 32) ^ timestamp; h *= 1000003; h ^= value.hashCode(); h *= 1000003; h ^= (host == null) ? 0 : host.hashCode(); return h; } }
@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 void read(org.apache.thrift.protocol.TProtocol prot, Annotation struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(4); if (incoming.get(0)) { struct.timestamp = iprot.readI64(); struct.setTimestampIsSet(true); } if (incoming.get(1)) { struct.value = iprot.readString(); struct.setValueIsSet(true); } if (incoming.get(2)) { struct.host = new Endpoint(); struct.host.read(iprot); struct.setHostIsSet(true); } } }
public void setFieldValue(_Fields field, Object value) { switch (field) { case IPV4: if (value == null) { unsetIpv4(); } else { setIpv4((Integer)value); } break; case PORT: if (value == null) { unsetPort(); } else { setPort((Short)value); } break; case SERVICE_NAME: if (value == null) { unsetService_name(); } else { setService_name((String)value); } break; } }
/** 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 IPV4: return isSetIpv4(); case PORT: return isSetPort(); case SERVICE_NAME: return isSetService_name(); } throw new IllegalStateException(); }
public Object getFieldValue(_Fields field) { switch (field) { case IPV4: return Integer.valueOf(getIpv4()); case PORT: return Short.valueOf(getPort()); case SERVICE_NAME: return getService_name(); } throw new IllegalStateException(); }
/** * {@inheritDoc} */ @Override public Endpoint getClientEndPoint() { final String serviceName = currentClientServiceName.get(); if (serviceName == null) { return endPoint; } else { final Endpoint ep = new Endpoint(endPoint); ep.setService_name(serviceName); return ep; } }
/** * Constructor * * @param ip Int representation of ipv4 address. * @param port port on which current process is listening. * @param serviceName Name of the local service being traced. Should be lowercase and not <code>null</code> or empty. */ public ThreadLocalServerClientAndLocalSpanState(int ip, int port, String serviceName) { this(Endpoint.builder().ipv4(ip).port(port).serviceName(serviceName).build()); }
@Override public int hashCode() { int h = 1; h *= 1000003; h ^= (timestamp >>> 32) ^ timestamp; h *= 1000003; h ^= value.hashCode(); h *= 1000003; h ^= (host == null) ? 0 : host.hashCode(); return h; } }
@Override public void read(org.apache.thrift.protocol.TProtocol prot, Annotation struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(4); if (incoming.get(0)) { struct.timestamp = iprot.readI64(); struct.setTimestampIsSet(true); } if (incoming.get(1)) { struct.value = iprot.readString(); struct.setValueIsSet(true); } if (incoming.get(2)) { struct.host = new Endpoint(); struct.host.read(iprot); struct.setHostIsSet(true); } if (incoming.get(3)) { struct.duration = iprot.readI32(); struct.setDurationIsSet(true); } } }
public void setFieldValue(_Fields field, Object value) { switch (field) { case IPV4: if (value == null) { unsetIpv4(); } else { setIpv4((Integer)value); } break; case PORT: if (value == null) { unsetPort(); } else { setPort((Short)value); } break; case SERVICE_NAME: if (value == null) { unsetService_name(); } else { setService_name((String)value); } break; } }