Package org.apache.accumulo.core.rpc
Class ThriftUtil
- java.lang.Object
-
- org.apache.accumulo.core.rpc.ThriftUtil
-
public class ThriftUtil extends Object
Factory methods for creating Thrift client objects
-
-
Field Summary
Fields Modifier and Type Field Description static String
DIGEST_MD5
static String
GSSAPI
-
Constructor Summary
Constructors Constructor Description ThriftUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends org.apache.thrift.TServiceClient>
TcreateClient(org.apache.thrift.TServiceClientFactory<T> factory, org.apache.thrift.transport.TTransport transport)
Create a Thrift client using the given factory and transportstatic org.apache.thrift.transport.TTransport
createClientTransport(HostAndPort address, int timeout, SslConnectionParams sslParams, SaslConnectionParams saslParams)
Create a TTransport for clients to the given address with the provided socket timeout and session-layer configurationstatic org.apache.thrift.transport.TTransport
createTransport(HostAndPort address, ClientContext context)
Create a transport that is not pooledstatic <T extends org.apache.thrift.TServiceClient>
TgetClient(org.apache.thrift.TServiceClientFactory<T> factory, HostAndPort address, ClientContext context)
Create a Thrift client using the given factory with a pooled transport (if available), the address and client context.static <T extends org.apache.thrift.TServiceClient>
TgetClient(org.apache.thrift.TServiceClientFactory<T> factory, HostAndPort address, ClientContext context, long timeout)
Create a Thrift client using the given factory with a pooled transport (if available) using the address, client context and timeoustatic <T extends org.apache.thrift.TServiceClient>
TgetClientNoTimeout(org.apache.thrift.TServiceClientFactory<T> factory, HostAndPort address, ClientContext context)
Create a Thrift client using the given factory with a pooled transport (if available), the address, and client context with no timeout.static TabletClientService.Client
getTServerClient(HostAndPort address, ClientContext context)
Create a TabletServer Thrift clientstatic TabletClientService.Client
getTServerClient(HostAndPort address, ClientContext context, long timeout)
Create a TabletServer Thrift clientstatic org.apache.thrift.protocol.TProtocolFactory
protocolFactory()
An instance ofTraceProtocolFactory
static void
returnClient(org.apache.thrift.TServiceClient iface)
Return the transport used by the client to the shared pool.static org.apache.thrift.transport.TTransportFactory
transportFactory()
An instance ofTFramedTransport.Factory
static org.apache.thrift.transport.TTransportFactory
transportFactory(int maxFrameSize)
Get an instance of the TTransportFactory with the provided maximum frame sizestatic org.apache.thrift.transport.TTransportFactory
transportFactory(long maxFrameSize)
-
-
-
Field Detail
-
GSSAPI
public static final String GSSAPI
- See Also:
- Constant Field Values
-
DIGEST_MD5
public static final String DIGEST_MD5
- See Also:
- Constant Field Values
-
-
Method Detail
-
protocolFactory
public static org.apache.thrift.protocol.TProtocolFactory protocolFactory()
An instance ofTraceProtocolFactory
- Returns:
- The default Thrift TProtocolFactory for RPC
-
transportFactory
public static org.apache.thrift.transport.TTransportFactory transportFactory()
An instance ofTFramedTransport.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 factoryaddress
- Server address for client to connect tocontext
- 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 factoryaddress
- Server address for client to connect tocontext
- 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 timeou- Parameters:
factory
- Thrift client factoryaddress
- Server address for client to connect tocontext
- RPC optionstimeout
- 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 tocontext
- 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 tocontext
- Options for connecting to the servertimeout
- 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 tocontext
- 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 totimeout
- Client socket timeoutsslParams
- RPC options for SSL serverssaslParams
- RPC options for SASL servers- Returns:
- An open TTransport which must be closed when finished
- Throws:
org.apache.thrift.transport.TTransportException
-
-