Class FTPClientFactoryImpl

java.lang.Object
ubic.gemma.core.loader.util.ftp.FTPClientFactoryImpl
All Implemented Interfaces:
AutoCloseable, FTPClientFactory

public class FTPClientFactoryImpl extends Object implements FTPClientFactory, AutoCloseable
This implementation maintains one pool of FTP clients per URL authority (i.e URL.getAuthority()).

Anonymous authentication is used by default.

Author:
poirigui
  • Constructor Details

    • FTPClientFactoryImpl

      public FTPClientFactoryImpl()
  • Method Details

    • setConnectTimeout

      public void setConnectTimeout(Duration connectTimeout)
    • setControlTimeout

      public void setControlTimeout(Duration controlTimeout)
    • setDataTimeout

      public void setDataTimeout(Duration dataTimeout)
    • setMaxIdleConnections

      public void setMaxIdleConnections(int maxIdle)
      Set the maximum number of idle FTP connections to keep in the pool.
    • setMaxTotalConnections

      public void setMaxTotalConnections(int maxTotal)
      Set the maximum number of FTP connections.
    • setAuthenticator

      public void setAuthenticator(@Nullable FTPClientAuthenticator authenticator)
      Set the authenticator to use to authenticate against FTP servers.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • getFtpClient

      public org.apache.commons.net.ftp.FTPClient getFtpClient(URL url) throws IOException
      Description copied from interface: FTPClientFactory
      Create an FTP client for the given URL.

      Once you're done with the client, you should consider recycling it with FTPClientFactory.recycleClient(URL, FTPClient). However, if you do so, make sure that all pending commands have completed with FTPClient.completePendingCommand().

      Specified by:
      getFtpClient in interface FTPClientFactory
      Throws:
      IOException
    • destroyClient

      public void destroyClient(URL url, org.apache.commons.net.ftp.FTPClient client)
      Description copied from interface: FTPClientFactory
      Destroy an FTP client that is known to be no-longer valid.
      Specified by:
      destroyClient in interface FTPClientFactory
    • abandonClient

      public void abandonClient(URL url, org.apache.commons.net.ftp.FTPClient client)
      Description copied from interface: FTPClientFactory
      Abandon an FTP client.

      Unlike FTPClientFactory.destroyClient(URL, FTPClient), no attempt will be made to gracefully logout.

      Specified by:
      abandonClient in interface FTPClientFactory
    • recycleClient

      public void recycleClient(URL url, org.apache.commons.net.ftp.FTPClient client)
      Description copied from interface: FTPClientFactory
      Recycle the FTP client so that it might be reused in the future.
      Specified by:
      recycleClient in interface FTPClientFactory
    • openStream

      public InputStream openStream(URL url) throws IOException
      Description copied from interface: FTPClientFactory
      Open an input stream for the given FTP URL.

      The FTP client will be recycled once the stream is closed.

      Specified by:
      openStream in interface FTPClientFactory
      Throws:
      IOException