Class ThriftUtil


  • public class ThriftUtil
    extends Object
    Factory methods for creating Thrift client objects
    • Constructor Detail

      • ThriftUtil

        public ThriftUtil()
    • Method Detail

      • protocolFactory

        public static org.apache.thrift.protocol.TProtocolFactory protocolFactory()
        An instance of TraceProtocolFactory
        Returns:
        The default Thrift TProtocolFactory for RPC
      • transportFactory

        public static org.apache.thrift.transport.TTransportFactory transportFactory()
        An instance of TFramedTransport.Factory
        Returns:
        The default Thrift TTransportFactory for RPC
      • createClient

        public static <T extends org.apache.thrift.TServiceClient> T createClient​(org.apache.thrift.TServiceClientFactory<T> factory,
                                                                                  org.apache.thrift.transport.TTransport transport)
        Create a Thrift client using the given factory and transport
      • getClientNoTimeout

        public static <T extends org.apache.thrift.TServiceClient> T getClientNoTimeout​(org.apache.thrift.TServiceClientFactory<T> factory,
                                                                                        HostAndPort address,
                                                                                        ClientContext context)
                                                                                 throws org.apache.thrift.transport.TTransportException
        Create a Thrift client using the given factory with a pooled transport (if available), the address, and client context with no timeout.
        Parameters:
        factory - Thrift client factory
        address - Server address for client to connect to
        context - RPC options
        Throws:
        org.apache.thrift.transport.TTransportException
      • getClient

        public static <T extends org.apache.thrift.TServiceClient> T getClient​(org.apache.thrift.TServiceClientFactory<T> factory,
                                                                               HostAndPort address,
                                                                               ClientContext context)
                                                                        throws org.apache.thrift.transport.TTransportException
        Create a Thrift client using the given factory with a pooled transport (if available), the address and client context. Client timeout is extracted from the ClientContext
        Parameters:
        factory - Thrift client factory
        address - Server address for client to connect to
        context - RPC options
        Throws:
        org.apache.thrift.transport.TTransportException
      • getClient

        public static <T extends org.apache.thrift.TServiceClient> T getClient​(org.apache.thrift.TServiceClientFactory<T> factory,
                                                                               HostAndPort address,
                                                                               ClientContext context,
                                                                               long timeout)
                                                                        throws org.apache.thrift.transport.TTransportException
        Create a Thrift client using the given factory with a pooled transport (if available) using the address, client context and timeout
        Parameters:
        factory - Thrift client factory
        address - Server address for client to connect to
        context - RPC options
        timeout - Socket timeout which overrides the ClientContext timeout
        Throws:
        org.apache.thrift.transport.TTransportException
      • returnClient

        public static void returnClient​(org.apache.thrift.TServiceClient iface)
        Return the transport used by the client to the shared pool.
        Parameters:
        iface - The Client being returned or null.
      • getTServerClient

        public static TabletClientService.Client getTServerClient​(HostAndPort address,
                                                                  ClientContext context)
                                                           throws org.apache.thrift.transport.TTransportException
        Create a TabletServer Thrift client
        Parameters:
        address - Server address for client to connect to
        context - RPC options
        Throws:
        org.apache.thrift.transport.TTransportException
      • getTServerClient

        public static TabletClientService.Client getTServerClient​(HostAndPort address,
                                                                  ClientContext context,
                                                                  long timeout)
                                                           throws org.apache.thrift.transport.TTransportException
        Create a TabletServer Thrift client
        Parameters:
        address - Server address for client to connect to
        context - Options for connecting to the server
        timeout - Socket timeout which overrides the ClientContext timeout
        Throws:
        org.apache.thrift.transport.TTransportException
      • createTransport

        public static org.apache.thrift.transport.TTransport createTransport​(HostAndPort address,
                                                                             ClientContext context)
                                                                      throws org.apache.thrift.TException
        Create a transport that is not pooled
        Parameters:
        address - Server address to open the transport to
        context - RPC options
        Throws:
        org.apache.thrift.TException
      • transportFactory

        public static org.apache.thrift.transport.TTransportFactory transportFactory​(int maxFrameSize)
        Get an instance of the TTransportFactory with the provided maximum frame size
        Parameters:
        maxFrameSize - Maximum Thrift message frame size
        Returns:
        A, possibly cached, TTransportFactory with the requested maximum frame size
      • transportFactory

        public static org.apache.thrift.transport.TTransportFactory transportFactory​(long maxFrameSize)
        See Also:
        transportFactory(int)
      • createClientTransport

        public static org.apache.thrift.transport.TTransport createClientTransport​(HostAndPort address,
                                                                                   int timeout,
                                                                                   SslConnectionParams sslParams,
                                                                                   SaslConnectionParams saslParams)
                                                                            throws org.apache.thrift.transport.TTransportException
        Create a TTransport for clients to the given address with the provided socket timeout and session-layer configuration
        Parameters:
        address - Server address to connect to
        timeout - Client socket timeout
        sslParams - RPC options for SSL servers
        saslParams - RPC options for SASL servers
        Returns:
        An open TTransport which must be closed when finished
        Throws:
        org.apache.thrift.transport.TTransportException