本文整理汇总了Java中org.apache.thrift.protocol.TProtocol.getTransport方法的典型用法代码示例。如果您正苦于以下问题:Java TProtocol.getTransport方法的具体用法?Java TProtocol.getTransport怎么用?Java TProtocol.getTransport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.thrift.protocol.TProtocol
的用法示例。
在下文中一共展示了TProtocol.getTransport方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createContext
import org.apache.thrift.protocol.TProtocol; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public ServerContext createContext(final TProtocol input, final TProtocol output) {
final String userName = "metacat-thrift-interface";
String clientHost = null; //requestContext.getHeaderString("X-Forwarded-For");
final long requestThreadId = Thread.currentThread().getId();
final TTransport transport = input.getTransport();
if (transport instanceof TSocket) {
final TSocket thriftSocket = (TSocket) transport;
clientHost = thriftSocket.getSocket().getInetAddress().getHostAddress();
}
final CatalogServerRequestContext context = new CatalogServerRequestContext(
userName,
null,
clientHost,
null,
"hive",
requestThreadId
);
MetacatContextManager.setContext(context);
return context;
}
示例2: getInetAddress
import org.apache.thrift.protocol.TProtocol; //导入方法依赖的package包/类
private String getInetAddress(TProtocol in) {
TTransport transport = in.getTransport();
if (transport != null && transport instanceof TSocket) {
Socket socket = ((TSocket) in.getTransport()).getSocket();
return socket.getInetAddress().getHostAddress().replace('.', ':');
} else {
return UN_KNOWN_IP;
}
}
示例3: open
import org.apache.thrift.protocol.TProtocol; //导入方法依赖的package包/类
private void open( TProtocol protocol ) throws TTransportException {
if ( protocol != null ) {
TTransport transport = protocol.getTransport();
if ( transport != null && ! transport.isOpen() ) {
transport.open();
}
}
}
示例4: close
import org.apache.thrift.protocol.TProtocol; //导入方法依赖的package包/类
private void close( TProtocol protocol ) {
if ( protocol != null ) {
TTransport transport = protocol.getTransport();
if ( transport != null && transport.isOpen() ) {
transport.close();
}
}
}