Class DefaultTcpPortMonitor
java.lang.Object
com.aoindustries.noc.monitor.portmon.PortMonitor
com.aoindustries.noc.monitor.portmon.DefaultTcpPortMonitor
- Direct Known Subclasses:
DefaultSslPortMonitor
,FtpPortMonitor
,ImapPortMonitor
,Pop3PortMonitor
,SmtpPortMonitor
,SshPortMonitor
Monitors any TCP port by simply connecting and disconnecting. Additional
protocol-specific checks are performed by subclasses overriding the checkPort
method.
- Author:
- AO Industries, Inc.
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
protected static final String
protected final boolean
protected static final int
Fields inherited from class com.aoindustries.noc.monitor.portmon.PortMonitor
canceled, CRLF, ipAddress, port
-
Constructor Summary
ConstructorDescriptionDefaultTcpPortMonitor
(InetAddress ipAddress, Port port, boolean ssl) Creates a new default TCP monitor.DefaultTcpPortMonitor
(InetAddress ipAddress, Port port, URIParameters monitoringParameters) Creates a new default TCP monitor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
Cancels this port method on a best effort basis.final String
Checks the port.protected String
checkPort
(Socket socket, InputStream in, OutputStream out) Performs any protocol-specific monitoring.protected Socket
connect()
Gets the socket to use for this port connection.Methods inherited from class com.aoindustries.noc.monitor.portmon.PortMonitor
getPortMonitor, readLine
-
Field Details
-
TIMEOUT
protected static final int TIMEOUT- See Also:
-
ssl
protected final boolean ssl -
CONNECTED_SUCCESSFULLY
- See Also:
-
CONNECTED_SUCCESSFULLY_SSL
- See Also:
-
-
Constructor Details
-
DefaultTcpPortMonitor
Creates a new default TCP monitor. -
DefaultTcpPortMonitor
Creates a new default TCP monitor.
-
-
Method Details
-
cancel
public void cancel()Description copied from class:PortMonitor
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.
- Overrides:
cancel
in classPortMonitor
- See Also:
-
connect
Gets the socket to use for this port connection.- Throws:
Exception
-
checkPort
Description copied from class:PortMonitor
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.- Specified by:
checkPort
in classPortMonitor
- Returns:
- the message indicating success
- Throws:
Exception
- See Also:
-
checkPort
Performs any protocol-specific monitoring. This default implementation does nothing.- Throws:
Exception
-