Class IRODSConnectionPool
java.lang.Object
org.irods.irods4j.high_level.connection.IRODSConnectionPool
- All Implemented Interfaces:
AutoCloseable
A class which manages a pool of iRODS connections.
- Since:
- 0.1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA class representing a connection within anIRODSConnectionPool. -
Constructor Summary
ConstructorsConstructorDescriptionIRODSConnectionPool(int poolSize) Initializes a newly created connection pool with defaultIRODSApi.ConnectionOptions, defaultConnectionPoolOptions, and space for the requested number of iRODS connections.IRODSConnectionPool(ConnectionPoolOptions poolOptions, int poolSize) Initializes a newly created connection pool with default aIRODSApi.ConnectionOptions, a user-definedConnectionPoolOptions, and space for the requested number of iRODS connections.IRODSConnectionPool(IRODSApi.ConnectionOptions connOptions, int poolSize) Initializes a newly created connection pool with a user-definedIRODSApi.ConnectionOptions, defaultConnectionPoolOptions, and space for the requested number of iRODS connections.IRODSConnectionPool(IRODSApi.ConnectionOptions connOptions, ConnectionPoolOptions poolOptions, int poolSize) Initializes a newly created connection pool. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Equivalent tostop().Returns a usable connection from the pool.intReturns the number of connections managed by the pool.voidsetConnectionOptions(IRODSApi.ConnectionOptions connOptions) Sets the options to use when connecting to the iRODS server.voidsetPoolSize(int poolSize) Sets the number of connections the pool should manage.voidstart(String host, int port, QualifiedUsername clientUser, Function<IRODSApi.RcComm, Boolean> authenticator) Synchronously establishes one or more connections to an iRODS server and authenticates each one using the provided authentication callback.voidstart(ExecutorService executor, String host, int port, QualifiedUsername clientUser, Function<IRODSApi.RcComm, Boolean> authenticator) Asynchronously establishes one or more connections to an iRODS server using the providedExecutorServiceand authenticates each one using the provided authentication callback.voidstop()Shuts down all pooled connections to the iRODS server.
-
Constructor Details
-
IRODSConnectionPool
public IRODSConnectionPool(int poolSize) Initializes a newly created connection pool with defaultIRODSApi.ConnectionOptions, defaultConnectionPoolOptions, and space for the requested number of iRODS connections.- Parameters:
poolSize- The number of connections the pool should manage.- Throws:
IllegalArgumentException- If pool size is less than or equal to 0.- Since:
- 0.1.0
-
IRODSConnectionPool
Initializes a newly created connection pool with default aIRODSApi.ConnectionOptions, a user-definedConnectionPoolOptions, and space for the requested number of iRODS connections.- Parameters:
poolOptions- Options which influence the behavior of connection pool.poolSize- The number of connections the pool should manage.- Throws:
IllegalArgumentException- If pool size is less than or equal to 0.- Since:
- 0.1.0
-
IRODSConnectionPool
Initializes a newly created connection pool with a user-definedIRODSApi.ConnectionOptions, defaultConnectionPoolOptions, and space for the requested number of iRODS connections.- Parameters:
connOptions- The connection options to use when establishing connections to the iRODS server.poolSize- The number of connections the pool should manage.- Throws:
IllegalArgumentException- If connection options is null or the pool size is less than or equal to 0.- Since:
- 0.1.0
-
IRODSConnectionPool
public IRODSConnectionPool(IRODSApi.ConnectionOptions connOptions, ConnectionPoolOptions poolOptions, int poolSize) Initializes a newly created connection pool.- Parameters:
connOptions- The connection options to use when establishing connections to the iRODS server.poolOptions- Options which influence the behavior of connection pool.poolSize- The number of connections the pool should manage.- Throws:
IllegalArgumentException- If any constructor argument is null or out of range.- Since:
- 0.1.0
-
-
Method Details
-
setConnectionOptions
Sets the options to use when connecting to the iRODS server. This only takes affect when starting the connection pool.- Parameters:
connOptions- The connection options to use when establishing connections to the iRODS server.- Throws:
IllegalArgumentException- If the connection options are null.- Since:
- 0.1.0
-
setPoolSize
public void setPoolSize(int poolSize) Sets the number of connections the pool should manage. This only takes affect when starting the connection pool.- Parameters:
poolSize- The number of connections the pool should manage.- Throws:
IllegalArgumentException- If the pool size is less than or equal to 0.- Since:
- 0.1.0
-
getPoolSize
public int getPoolSize()Returns the number of connections managed by the pool.- Since:
- 0.1.0
-
start
public void start(String host, int port, QualifiedUsername clientUser, Function<IRODSApi.RcComm, Boolean> authenticator) throws IOException, IRODSExceptionSynchronously establishes one or more connections to an iRODS server and authenticates each one using the provided authentication callback.- Parameters:
host- The hostname or IP of the iRODS server to connect to.port- The port number of the iRODS server to connect to.clientUser- The iRODS user to connect as.authenticator- The callback to use for authentication.- Throws:
IRODSExceptionIOExceptionIllegalArgumentException- If any of the construction arguments is null or empty.- Since:
- 0.1.0
-
start
public void start(ExecutorService executor, String host, int port, QualifiedUsername clientUser, Function<IRODSApi.RcComm, Boolean> authenticator) throws IOException, IRODSExceptionAsynchronously establishes one or more connections to an iRODS server using the providedExecutorServiceand authenticates each one using the provided authentication callback.- Parameters:
executor- TheExecutorServiceto improved connection startup performance.host- The hostname or IP of the iRODS server to connect to.port- The port number of the iRODS server to connect to.clientUser- The iRODS user to connect as.authenticator- The callback to use for authentication.- Throws:
IRODSExceptionIOExceptionIllegalArgumentException- If any of the construction arguments is null or empty.- Since:
- 0.1.0
-
stop
public void stop()Shuts down all pooled connections to the iRODS server. All pooled connections should be returned to the pool before invoking this function.- Since:
- 0.1.0
-
close
Equivalent tostop().- Specified by:
closein interfaceAutoCloseable- Throws:
Exception- Since:
- 0.1.0
-
getConnection
Returns a usable connection from the pool.- Since:
- 0.1.0
-