Java Code Examples for org.apache.thrift.protocol.TProtocol#getTransport()
The following examples show how to use
org.apache.thrift.protocol.TProtocol#getTransport() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CatalogThriftEventHandler.java From metacat with Apache License 2.0 | 6 votes |
/** * {@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; }
Example 2
Source File: DBConn.java From Doradus with Apache License 2.0 | 6 votes |
/** * Close the database connection. This object can be reused after the connection has * been closed by calling {@link #open()} again. */ public void close() { // Get the connection's protocol (TBinaryProtocol), and the protocol's transport // (TSocket) and close it. if (m_client != null) { TProtocol protocol = m_client.getInputProtocol(); if (protocol != null) { TTransport transport = protocol.getTransport(); if (transport != null) { transport.close(); } } } m_client = null; m_bFailed = true; // Prevent reusing this connection until reconnected m_bDBOpen = false; }
Example 3
Source File: SaslTransportPlugin.java From jstorm with Apache License 2.0 | 6 votes |
public boolean process(final TProtocol inProt, final TProtocol outProt) throws TException { // populating request context ReqContext req_context = ReqContext.context(); TTransport trans = inProt.getTransport(); // Sasl transport TSaslServerTransport saslTrans = (TSaslServerTransport) trans; // remote address TSocket tsocket = (TSocket) saslTrans.getUnderlyingTransport(); Socket socket = tsocket.getSocket(); req_context.setRemoteAddress(socket.getInetAddress()); // remote subject SaslServer saslServer = saslTrans.getSaslServer(); String authId = saslServer.getAuthorizationID(); Subject remoteUser = new Subject(); remoteUser.getPrincipals().add(new User(authId)); req_context.setSubject(remoteUser); // invoke service handler return wrapped.process(inProt, outProt); }
Example 4
Source File: ThriftIDLSerializer.java From octo-rpc with Apache License 2.0 | 5 votes |
private boolean hasOldRequestHeader(TProtocol protocol) { TTransport trans = protocol.getTransport(); if (trans.getBytesRemainingInBuffer() >= 3) { byte type = trans.getBuffer()[trans.getBufferPosition()]; if (type == org.apache.thrift.protocol.TType.STRUCT) { short id = (short) (((trans.getBuffer()[trans.getBufferPosition() + 1] & 0xff) << 8) | ((trans.getBuffer()[trans.getBufferPosition() + 2] & 0xff))); if (id == MTRACE_FIELD_DESC.id) { return true; } } } return false; }
Example 5
Source File: TProtobufProcessor.java From jigsaw-payment with Apache License 2.0 | 5 votes |
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; } }
Example 6
Source File: ThriftUtil.java From incubator-sentry with Apache License 2.0 | 5 votes |
public static void setImpersonator(final TProtocol in) { try { TTransport transport = in.getTransport(); if (transport instanceof TSaslServerTransport) { String impersonator = ((TSaslServerTransport) transport).getSaslServer() .getAuthorizationID(); setImpersonator(impersonator); } } catch (Exception e) { // If there has exception when get impersonator info, log the error information. LOGGER.warn("There is an error when get the impersonator:" + e.getMessage()); } }
Example 7
Source File: ThriftUtil.java From incubator-sentry with Apache License 2.0 | 5 votes |
public static void setIpAddress(final TProtocol in) { try { TTransport transport = in.getTransport(); TSocket tSocket = getUnderlyingSocketFromTransport(transport); if (tSocket != null) { setIpAddress(tSocket.getSocket().getInetAddress().toString()); } else { LOGGER.warn("Unknown Transport, cannot determine ipAddress"); } } catch (Exception e) { // If there has exception when get impersonator info, log the error information. LOGGER.warn("There is an error when get the client's ip address:" + e.getMessage()); } }
Example 8
Source File: InterningProtocol.java From parquet-format with Apache License 2.0 | 4 votes |
public InterningProtocol(TProtocol delegate) { super(delegate.getTransport()); this.delegate = delegate; }
Example 9
Source File: InterningProtocol.java From parquet-mr with Apache License 2.0 | 4 votes |
public InterningProtocol(TProtocol delegate) { super(delegate.getTransport()); this.delegate = delegate; }
Example 10
Source File: TReplaceListProtocol.java From pinpoint with Apache License 2.0 | 4 votes |
public TReplaceListProtocol(final TProtocol protocol) { super(protocol.getTransport()); this.protocol = protocol; }