Class TftpServerImpl
- java.lang.Object
-
- org.opennms.features.deviceconfig.tftp.impl.TftpServerImpl
-
- All Implemented Interfaces:
AutoCloseable,Runnable,TftpServer
public class TftpServerImpl extends Object implements TftpServer, Runnable, AutoCloseable
-
-
Constructor Summary
Constructors Constructor Description TftpServerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Stop the tftp server (and any currently running transfers) and release all opened network resources.protected voidfinalize()TftpStatisticsgetAndResetStatistics()intgetMaxTimeoutRetries()Get the current value for maxTimeoutRetriesintgetPort()intgetSocketTimeout()The current socket timeout used during transfers in milliseconds.TftpStatisticsgetStatistics()booleanisRunning()check if the server thread is still running.voidlaunch()voidregister(TftpFileReceiver receiver)voidrun()voidsetAddress(String addr)voidsetMaximumReceiveSize(long maximumReceiveSize)voidsetMaxTimeoutRetries(int retries)Set the max number of retries in response to a timeout.voidsetPort(int port)voidsetSocketTimeout(int timeout)Set the socket timeout in milliseconds used in transfers.voidunregister(TftpFileReceiver receiver)
-
-
-
Method Detail
-
finalize
protected void finalize() throws Throwable
-
getPort
public int getPort()
- Specified by:
getPortin interfaceTftpServer
-
getMaxTimeoutRetries
public int getMaxTimeoutRetries()
Get the current value for maxTimeoutRetries- Returns:
- the max allowed number of retries
-
getSocketTimeout
public int getSocketTimeout()
The current socket timeout used during transfers in milliseconds.- Returns:
- the timeout value
-
isRunning
public boolean isRunning() throws Exceptioncheck if the server thread is still running.- Returns:
- true if running, false if stopped.
- Throws:
Exception- throws the exception that stopped the server if the server is stopped from an exception.
-
launch
public void launch() throws IOException- Throws:
IOException
-
setMaxTimeoutRetries
public void setMaxTimeoutRetries(int retries)
Set the max number of retries in response to a timeout. Default 3. Min 0.- Parameters:
retries- number of retries, must be > 0
-
setSocketTimeout
public void setSocketTimeout(int timeout)
Set the socket timeout in milliseconds used in transfers. Defaults to the value here: https://commons.apache.org/net/apidocs/org/apache/commons/net/tftp/TFTP.html#DEFAULT_TIMEOUT (5000 at the time I write this) Min value of 10.- Parameters:
timeout- the timeout; must be larger than 10
-
setAddress
public void setAddress(String addr) throws UnknownHostException
- Throws:
UnknownHostException
-
setPort
public void setPort(int port)
-
setMaximumReceiveSize
public void setMaximumReceiveSize(long maximumReceiveSize)
-
close
public void close()
Stop the tftp server (and any currently running transfers) and release all opened network resources.- Specified by:
closein interfaceAutoCloseable
-
register
public void register(TftpFileReceiver receiver) throws IOException
- Specified by:
registerin interfaceTftpServer- Throws:
IOException
-
unregister
public void unregister(TftpFileReceiver receiver)
- Specified by:
unregisterin interfaceTftpServer
-
getStatistics
public TftpStatistics getStatistics()
- Specified by:
getStatisticsin interfaceTftpServer
-
getAndResetStatistics
public TftpStatistics getAndResetStatistics()
- Specified by:
getAndResetStatisticsin interfaceTftpServer
-
-