Class PortMonitor
java.lang.Object
com.aoindustries.noc.monitor.portmon.PortMonitor
- Direct Known Subclasses:
DefaultTcpPortMonitor
,DefaultUdpPortMonitor
,JdbcPortMonitor
A
PortMonitor
connects to a service on a port and verifies it is
working correctly. The monitor will only be used at most once per instance.
TODO: Support chronyd protocol: chronyc tracking
- Author:
- AO Industries, Inc.
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
PortMonitor
(InetAddress ipAddress, Port port) Creates a new port monitor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
Cancels this port method on a best effort basis.abstract String
Checks the port.static PortMonitor
getPortMonitor
(InetAddress ipAddress, Port port, String appProtocol, URIParameters monitoringParameters) Factory method to get the best port monitor for the provided port details.protected static String
readLine
(Reader in, StringBuilder buffer) Reads a line into the given buffer.
-
Field Details
-
CRLF
- See Also:
-
ipAddress
-
port
-
canceled
protected volatile boolean canceled
-
-
Constructor Details
-
PortMonitor
Creates a new port monitor.
-
-
Method Details
-
getPortMonitor
public static PortMonitor getPortMonitor(InetAddress ipAddress, Port port, String appProtocol, URIParameters monitoringParameters) throws IllegalArgumentException Factory method to get the best port monitor for the provided port details. If can't find any monitor, will through IllegalArgumentException.- Throws:
IllegalArgumentException
-
readLine
Reads a line into the given buffer.- Throws:
IOException
-
cancel
public void cancel()Cancels this port method on a best effort basis. This will not necessarily cause the checkPort method to return immediately. This should only be used once the result of checkPort is no longer relevant, such as after a timeout. Some monitors may still perform their task arbitrarily long after cancel has been called.It is critical that subclass implementations of this method not block in any way.
- See Also:
-
checkPort
Checks the port. This may take arbitrarily long to complete, and any timeout should be provided externally and call thecancel
method. If any error occurs, must throw an exception.- Returns:
- the message indicating success
- Throws:
Exception
- See Also:
-