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 void
close()
Stop the tftp server (and any currently running transfers) and release all opened network resources.protected void
finalize()
TftpStatistics
getAndResetStatistics()
int
getMaxTimeoutRetries()
Get the current value for maxTimeoutRetriesint
getPort()
int
getSocketTimeout()
The current socket timeout used during transfers in milliseconds.TftpStatistics
getStatistics()
boolean
isRunning()
check if the server thread is still running.void
launch()
void
register(TftpFileReceiver receiver)
void
run()
void
setAddress(String addr)
void
setMaximumReceiveSize(long maximumReceiveSize)
void
setMaxTimeoutRetries(int retries)
Set the max number of retries in response to a timeout.void
setPort(int port)
void
setSocketTimeout(int timeout)
Set the socket timeout in milliseconds used in transfers.void
unregister(TftpFileReceiver receiver)
-
-
-
Method Detail
-
finalize
protected void finalize() throws Throwable
-
getPort
public int getPort()
- Specified by:
getPort
in 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 Exception
check 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:
close
in interfaceAutoCloseable
-
register
public void register(TftpFileReceiver receiver) throws IOException
- Specified by:
register
in interfaceTftpServer
- Throws:
IOException
-
unregister
public void unregister(TftpFileReceiver receiver)
- Specified by:
unregister
in interfaceTftpServer
-
getStatistics
public TftpStatistics getStatistics()
- Specified by:
getStatistics
in interfaceTftpServer
-
getAndResetStatistics
public TftpStatistics getAndResetStatistics()
- Specified by:
getAndResetStatistics
in interfaceTftpServer
-
-