Class IRODSConnectionPool

java.lang.Object
org.irods.irods4j.high_level.connection.IRODSConnectionPool
All Implemented Interfaces:
AutoCloseable

public class IRODSConnectionPool extends Object implements AutoCloseable
A class which manages a pool of iRODS connections.
Since:
0.1.0
  • Constructor Details

    • IRODSConnectionPool

      public IRODSConnectionPool(int poolSize)
      Initializes a newly created connection pool with default IRODSApi.ConnectionOptions, default ConnectionPoolOptions, 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

      public IRODSConnectionPool(ConnectionPoolOptions poolOptions, int poolSize)
      Initializes a newly created connection pool with default a IRODSApi.ConnectionOptions, a user-defined ConnectionPoolOptions, 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

      public IRODSConnectionPool(IRODSApi.ConnectionOptions connOptions, int poolSize)
      Initializes a newly created connection pool with a user-defined IRODSApi.ConnectionOptions, default ConnectionPoolOptions, 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

      public void setConnectionOptions(IRODSApi.ConnectionOptions connOptions)
      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, IRODSException
      Synchronously 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:
      IRODSException
      IOException
      IllegalArgumentException - 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, IRODSException
      Asynchronously establishes one or more connections to an iRODS server using the provided ExecutorService and authenticates each one using the provided authentication callback.
      Parameters:
      executor - The ExecutorService to 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:
      IRODSException
      IOException
      IllegalArgumentException - 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

      public void close() throws Exception
      Equivalent to stop().
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception
      Since:
      0.1.0
    • getConnection

      public IRODSConnectionPool.PoolConnection getConnection()
      Returns a usable connection from the pool.
      Since:
      0.1.0