|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.go.trove.net.PlainSocketFactory
Allows client socket connections to be established with a timeout. Calling getSocket will always return a new socket, and recycle will always close the socket. Sessions are ignored on all requests.
| Constructor Summary | |
PlainSocketFactory(java.net.InetAddress addr,
int port,
long timeout)
|
|
| Method Summary | |
void |
clear()
Closes all recycled connections, but does not prevent new connections from being created and recycled. |
CheckedSocket |
createSocket()
Must always return a new socket connection. |
CheckedSocket |
createSocket(long timeout)
Returns a new socket connection. |
CheckedSocket |
createSocket(java.lang.Object session)
Returns a new socket connection. |
CheckedSocket |
createSocket(java.lang.Object session,
long timeout)
Returns a new socket connection. |
int |
getAvailableCount()
Returns the number of recycled sockets currently available. |
long |
getDefaultTimeout()
Returns the default timeout for creating or getting sockets or -1 if infinite. |
InetAddressAndPort |
getInetAddressAndPort()
Returns the InetAddress and port that this factory will most likely connect to. |
InetAddressAndPort |
getInetAddressAndPort(java.lang.Object session)
Returns the InetAddress and port that this factory will most likely connect to. |
CheckedSocket |
getSocket()
Returns a new or recycled socket connection. |
CheckedSocket |
getSocket(long timeout)
Returns a new or recycled socket connection. |
CheckedSocket |
getSocket(java.lang.Object session)
Returns a new or recycled socket connection. |
CheckedSocket |
getSocket(java.lang.Object session,
long timeout)
Returns a new or recycled socket connection. |
void |
recycleSocket(CheckedSocket socket)
Recycle a socket connection that was returned from the getSocket
or createSocket methods. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public PlainSocketFactory(java.net.InetAddress addr,
int port,
long timeout)
addr - Address to connect new sockets to.port - Port to connect new sockets to.timeout - Maximum time to wait (in milliseconds) for new
connections to be established before throwing an exception| Method Detail |
public InetAddressAndPort getInetAddressAndPort()
SocketFactorygetInetAddressAndPort in interface SocketFactorypublic InetAddressAndPort getInetAddressAndPort(java.lang.Object session)
SocketFactorygetInetAddressAndPort in interface SocketFactorycom.go.trove.net.SocketFactorysession - Object whose hashcode might be used to select a specific
connection if factory is distributed. If null, then no session is used.public long getDefaultTimeout()
SocketFactorygetDefaultTimeout in interface SocketFactory
public CheckedSocket createSocket()
throws java.net.ConnectException,
java.net.SocketException
SocketFactoryrecycleSocket so that it be used again.createSocket in interface SocketFactorycom.go.trove.net.SocketFactoryjava.net.ConnectException - if timeout has elapsed and no socket is
available or factory is closed
public CheckedSocket createSocket(java.lang.Object session)
throws java.net.ConnectException,
java.net.SocketException
SocketFactoryrecycleSocket so that it be used again.createSocket in interface SocketFactorycom.go.trove.net.SocketFactorysession - Object whose hashcode might be used to select a specific
connection if factory is distributed. If null, then no session is used.java.net.ConnectException - if timeout has elapsed and no socket is
available or factory is closed
public CheckedSocket createSocket(long timeout)
throws java.net.ConnectException,
java.net.SocketException
SocketFactoryrecycleSocket so that it be used again.createSocket in interface SocketFactorycom.go.trove.net.SocketFactorytimeout - Maximum time to wait (in milliseconds) for a connection
to be created before throwing a ConnectExceptionjava.net.ConnectException - if timeout has elapsed and no socket is
available or factory is closed
public CheckedSocket createSocket(java.lang.Object session,
long timeout)
throws java.net.ConnectException,
java.net.SocketException
SocketFactoryrecycleSocket so that it be used again.createSocket in interface SocketFactorycom.go.trove.net.SocketFactorysession - Object whose hashcode might be used to select a specific
connection if factory is distributed. If null, then no session is used.timeout - Maximum time to wait (in milliseconds) for a connection
to become available before throwing an exceptionjava.net.ConnectException - if timeout has elapsed and no socket is
available or factory is closed
public CheckedSocket getSocket()
throws java.net.ConnectException,
java.net.SocketException
SocketFactoryrecycleSocket so that it be used again.getSocket in interface SocketFactorycom.go.trove.net.SocketFactoryjava.net.ConnectException - if timeout has elapsed and no socket is
available or factory is closed
public CheckedSocket getSocket(java.lang.Object session)
throws java.net.ConnectException,
java.net.SocketException
SocketFactoryrecycleSocket so that it be used again.getSocket in interface SocketFactorycom.go.trove.net.SocketFactorysession - Object whose hashcode might be used to select a specific
connection if factory is distributed. If null, then no session is used.java.net.ConnectException - if timeout has elapsed and no socket is
available or factory is closed
public CheckedSocket getSocket(long timeout)
throws java.net.ConnectException,
java.net.SocketException
SocketFactoryrecycleSocket so that it be used again.getSocket in interface SocketFactorycom.go.trove.net.SocketFactorytimeout - Maximum time to wait (in milliseconds) for a connection
to be returned before throwing a ConnectExceptionjava.net.ConnectException - if timeout has elapsed and no socket is
available or factory is closed
public CheckedSocket getSocket(java.lang.Object session,
long timeout)
throws java.net.ConnectException,
java.net.SocketException
SocketFactoryrecycleSocket so that it be used again.getSocket in interface SocketFactorycom.go.trove.net.SocketFactorysession - Object whose hashcode might be used to select a specific
connection if factory is distributed. If null, then no session is used.timeout - Maximum time to wait (in milliseconds) for a connection
to be returned before throwing a ConnectExceptionjava.net.ConnectException - if timeout has elapsed and no socket is
available or factory is closed
public void recycleSocket(CheckedSocket socket)
throws java.net.SocketException,
java.lang.IllegalArgumentException
SocketFactorygetSocket
or createSocket methods. Since SocketFactory has no knowledge of
any protocol being used on the socket, it is the responsibility of the
caller to ensure the socket is in a "clean" state. Depending on
implementation, the recycled socket may simply be closed.recycleSocket in interface SocketFactorycom.go.trove.net.SocketFactorysocket - Socket which must have come from this factory. Passing in
null is ignored.public void clear()
SocketFactoryclear in interface SocketFactorypublic int getAvailableCount()
SocketFactorygetAvailableCount in interface SocketFactory
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||