Package ubic.gemma.core.loader.util.ftp
Class FTPClientFactoryImpl
java.lang.Object
ubic.gemma.core.loader.util.ftp.FTPClientFactoryImpl
- All Implemented Interfaces:
AutoCloseable
,FTPClientFactory
This implementation maintains one pool of FTP clients per URL authority (i.e
URL.getAuthority()
).
Anonymous authentication is used by default.
- Author:
- poirigui
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
abandonClient
(URL url, org.apache.commons.net.ftp.FTPClient client) Abandon an FTP client.void
close()
void
destroyClient
(URL url, org.apache.commons.net.ftp.FTPClient client) Destroy an FTP client that is known to be no-longer valid.org.apache.commons.net.ftp.FTPClient
getFtpClient
(URL url) Create an FTP client for the given URL.openStream
(URL url) Open an input stream for the given FTP URL.void
recycleClient
(URL url, org.apache.commons.net.ftp.FTPClient client) Recycle the FTP client so that it might be reused in the future.void
setAuthenticator
(FTPClientAuthenticator authenticator) Set the authenticator to use to authenticate against FTP servers.void
setConnectTimeout
(Duration connectTimeout) void
setControlTimeout
(Duration controlTimeout) void
setDataTimeout
(Duration dataTimeout) void
setMaxIdleConnections
(int maxIdle) Set the maximum number of idle FTP connections to keep in the pool.void
setMaxTotalConnections
(int maxTotal) Set the maximum number of FTP connections.
-
Constructor Details
-
FTPClientFactoryImpl
public FTPClientFactoryImpl()
-
-
Method Details
-
setConnectTimeout
-
setControlTimeout
-
setDataTimeout
-
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
Set the authenticator to use to authenticate against FTP servers. -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
getFtpClient
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 withFTPClient.completePendingCommand()
.- Specified by:
getFtpClient
in interfaceFTPClientFactory
- Throws:
IOException
-
destroyClient
Description copied from interface:FTPClientFactory
Destroy an FTP client that is known to be no-longer valid.- Specified by:
destroyClient
in interfaceFTPClientFactory
-
abandonClient
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 interfaceFTPClientFactory
-
recycleClient
Description copied from interface:FTPClientFactory
Recycle the FTP client so that it might be reused in the future.- Specified by:
recycleClient
in interfaceFTPClientFactory
-
openStream
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 interfaceFTPClientFactory
- Throws:
IOException
-