use of org.apache.thrift.protocol.TProtocol in project pinpoint by naver.
the class AnnotationTranscoderTest method write.
private void write(int value) throws TException {
TCompactProtocol.Factory factory = new TCompactProtocol.Factory();
ByteArrayOutputStream baos = new ByteArrayOutputStream(16);
TIOStreamTransport transport = new TIOStreamTransport(baos);
TProtocol protocol = factory.getProtocol(transport);
protocol.writeI32(value);
byte[] buffer = baos.toByteArray();
logger.debug(Arrays.toString(buffer));
}
use of org.apache.thrift.protocol.TProtocol in project pinpoint by naver.
the class ByteSizeTest method test.
@Test
public void test() throws TException {
TCompactProtocol.Factory factory = new TCompactProtocol.Factory();
ByteArrayOutputStream baos = new ByteArrayOutputStream(16);
TIOStreamTransport transport = new TIOStreamTransport(baos);
TProtocol protocol = factory.getProtocol(transport);
long l = TimeUnit.DAYS.toMillis(1);
logger.debug("day:{}", l);
long currentTime = System.currentTimeMillis();
logger.debug("currentTime:{}" + currentTime);
protocol.writeI64(l);
byte[] buffer = baos.toByteArray();
logger.debug("{}", buffer.length);
}
use of org.apache.thrift.protocol.TProtocol in project pinpoint by naver.
the class TBaseProcessorProcessInterceptor method processTraceObject.
private void processTraceObject(final Trace trace, Object target, Object[] args, Throwable throwable) {
// end spanEvent
try {
SpanEventRecorder recorder = trace.currentSpanEventRecorder();
// TODO Might need a way to collect and record method arguments
// trace.recordAttribute(...);
recorder.recordException(throwable);
recorder.recordApi(this.descriptor);
} catch (Throwable t) {
logger.warn("Error processing trace object. Cause:{}", t.getMessage(), t);
} finally {
trace.traceBlockEnd();
}
// end root span
SpanRecorder recorder = trace.getSpanRecorder();
String methodUri = getMethodUri(target);
recorder.recordRpcName(methodUri);
// retrieve connection information
String localIpPort = ThriftConstants.UNKNOWN_ADDRESS;
String remoteAddress = ThriftConstants.UNKNOWN_ADDRESS;
if (args.length == 2 && args[0] instanceof TProtocol) {
TProtocol inputProtocol = (TProtocol) args[0];
TTransport inputTransport = inputProtocol.getTransport();
if (inputTransport instanceof SocketFieldAccessor) {
Socket socket = ((SocketFieldAccessor) inputTransport)._$PINPOINT$_getSocket();
if (socket != null) {
localIpPort = ThriftUtils.getHostPort(socket.getLocalSocketAddress());
remoteAddress = ThriftUtils.getHost(socket.getRemoteSocketAddress());
}
} else {
if (isDebug) {
logger.debug("Invalid target object. Need field accessor({}).", SocketFieldAccessor.class.getName());
}
}
}
if (localIpPort != ThriftConstants.UNKNOWN_ADDRESS) {
recorder.recordEndPoint(localIpPort);
}
if (remoteAddress != ThriftConstants.UNKNOWN_ADDRESS) {
recorder.recordRemoteAddress(remoteAddress);
}
}
use of org.apache.thrift.protocol.TProtocol in project commons by twitter.
the class PingPongClient method run.
@Override
public void run() {
TTransport transport = new TSocket("localhost", THRIFT_PORT.get());
try {
transport.open();
} catch (TTransportException e) {
throw new RuntimeException(e);
}
TProtocol protocol = new TBinaryProtocol(transport);
PingPong.Client client = new PingPong.Client(protocol);
try {
LOG.info("Pinging...");
LOG.info(client.ping());
} catch (TException e) {
throw new RuntimeException(e);
}
}
use of org.apache.thrift.protocol.TProtocol in project eiger by wlloyd.
the class EmbeddedCassandraServiceTest method getClient.
/**
* Gets a connection to the localhost client
*
* @return
* @throws TTransportException
*/
private Cassandra.Client getClient() throws TTransportException {
TTransport tr = new TFramedTransport(new TSocket("localhost", DatabaseDescriptor.getRpcPort()));
TProtocol proto = new TBinaryProtocol(tr);
Cassandra.Client client = new Cassandra.Client(proto);
tr.open();
return client;
}
Aggregations