Package com.github.ambry.network
Interface ConnectionPool
-
public interface ConnectionPool
A Connection pool interface that pools a list of connections, does connection management and connection cleanup. A checkoutConnection should be followed by a checkInConnection or destroyConnection. The pool is also responsible to close and delete connections on shutdown. This includes connection that are live and idle.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
checkInConnection(ConnectedChannel connectedChannel)
The connected channel that needs to be put back into the pool after a successful usageConnectedChannel
checkOutConnection(java.lang.String host, Port port, long timeout)
Returns a connected channel that represents the give host and port.void
destroyConnection(ConnectedChannel connectedChannel)
The connected channel that needs to be destroyed/disconnected after an errorvoid
shutdown()
Shutsdown the connection pool.void
start()
Starts the connection pool.
-
-
-
Method Detail
-
start
void start()
Starts the connection pool.
-
shutdown
void shutdown()
Shutsdown the connection pool. This also includes cleaning up all idle and active connections
-
checkOutConnection
ConnectedChannel checkOutConnection(java.lang.String host, Port port, long timeout) throws java.io.IOException, java.lang.InterruptedException, ConnectionPoolTimeoutException
Returns a connected channel that represents the give host and port. If no connection is available, this method blocks for the timeout specified- Parameters:
host
- The remote host to which a connection is requiredport
- The remote to which a connection is requiredtimeout
- The time up to which to wait to get a connection- Returns:
- The connected channel that represents the given host and port.
- Throws:
java.io.IOException
java.lang.InterruptedException
ConnectionPoolTimeoutException
-
checkInConnection
void checkInConnection(ConnectedChannel connectedChannel)
The connected channel that needs to be put back into the pool after a successful usage- Parameters:
connectedChannel
- The channel to check in
-
destroyConnection
void destroyConnection(ConnectedChannel connectedChannel)
The connected channel that needs to be destroyed/disconnected after an error- Parameters:
connectedChannel
- The channel to destroy/disconnect
-
-