use of org.apache.thrift.transport.TNonblockingTransport in project pinpoint by naver.
the class TAsyncMethodCallConstructInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args, result, throwable);
}
if (validate(target)) {
TNonblockingTransport transport = ((TNonblockingTransportFieldGetter) target)._$PINPOINT$_getTNonblockingTransport();
if (validateTransport(transport)) {
SocketAddress socketAddress = ((SocketAddressFieldAccessor) transport)._$PINPOINT$_getSocketAddress();
((SocketAddressFieldAccessor) target)._$PINPOINT$_setSocketAddress(socketAddress);
}
}
}
use of org.apache.thrift.transport.TNonblockingTransport in project commons by twitter.
the class ThriftFactory method createAsyncClientFactory.
private <T> Function<TTransport, T> createAsyncClientFactory(final Class<T> serviceInterface) throws IOException {
final TAsyncClientManager clientManager = new TAsyncClientManager();
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
clientManager.stop();
}
});
final Constructor<? extends T> implementationConstructor = findAsyncImplementationConstructor(serviceInterface);
return new Function<TTransport, T>() {
@Override
public T apply(TTransport transport) {
Preconditions.checkNotNull(transport);
Preconditions.checkArgument(transport instanceof TNonblockingTransport, "Invalid transport provided to client factory: " + transport.getClass());
try {
T client = implementationConstructor.newInstance(new TBinaryProtocol.Factory(), clientManager, transport);
if (socketTimeout != null) {
((TAsyncClient) client).setTimeout(socketTimeout.as(Time.MILLISECONDS));
}
return client;
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
}
}
};
}
Aggregations