com.twitter.common.thrift
Class TTransportConnection

java.lang.Object
  extended by com.twitter.common.thrift.TTransportConnection
All Implemented Interfaces:
Supplier<org.apache.thrift.transport.TTransport>, Connection<org.apache.thrift.transport.TTransport,InetSocketAddress>, Closeable

public class TTransportConnection
extends Object
implements Connection<org.apache.thrift.transport.TTransport,InetSocketAddress>

A ConnectionPool compatible thrift connection that can work with any valid thrift transport.


Constructor Summary
TTransportConnection(org.apache.thrift.transport.TTransport transport, InetSocketAddress endpoint)
           
 
Method Summary
 void close()
          Closes this connection.
 org.apache.thrift.transport.TTransport get()
          This will always be the same underlying connection for the lifetime of this object.
 InetSocketAddress getEndpoint()
           
 boolean isValid()
          Returns true if the underlying transport is still open.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TTransportConnection

public TTransportConnection(org.apache.thrift.transport.TTransport transport,
                            InetSocketAddress endpoint)
Method Detail

isValid

public boolean isValid()
Returns true if the underlying transport is still open. To invalidate a transport it should be closed.

TODO(John Sirois): it seems like an improper soc to have validity testing here and not also an invalidation method - correct or accept

Specified by:
isValid in interface Connection<org.apache.thrift.transport.TTransport,InetSocketAddress>
Returns:
true if the supplied connection is valid for use.

get

public org.apache.thrift.transport.TTransport get()
Description copied from interface: Connection
This will always be the same underlying connection for the lifetime of this object.

Specified by:
get in interface Supplier<org.apache.thrift.transport.TTransport>
Specified by:
get in interface Connection<org.apache.thrift.transport.TTransport,InetSocketAddress>
Returns:
the connection

close

public void close()
Description copied from interface: Connection
Closes this connection.

Specified by:
close in interface Connection<org.apache.thrift.transport.TTransport,InetSocketAddress>
Specified by:
close in interface Closeable

getEndpoint

public InetSocketAddress getEndpoint()
Specified by:
getEndpoint in interface Connection<org.apache.thrift.transport.TTransport,InetSocketAddress>
Returns:
the endpoint this connection is connected to.

toString

public String toString()
Overrides:
toString in class Object