Package ubic.gemma.core.loader.util.ftp
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.eURL.getAuthority()
).Anonymous authentication is used by default.
- Author:
- poirigui
-
-
Constructor Summary
Constructors Constructor Description FTPClientFactoryImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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.InputStream
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.
-
-
-
Method Detail
-
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 interfaceAutoCloseable
-
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 withFTPClient.completePendingCommand()
.- Specified by:
getFtpClient
in interfaceFTPClientFactory
- 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 interfaceFTPClientFactory
-
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 interfaceFTPClientFactory
-
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 interfaceFTPClientFactory
-
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 interfaceFTPClientFactory
- Throws:
IOException
-
-