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

public class DefaultTcpPortMonitor extends PortMonitor
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 Details

  • Constructor Details

    • DefaultTcpPortMonitor

      public DefaultTcpPortMonitor(InetAddress ipAddress, Port port, boolean ssl)
      Creates a new default TCP monitor.
    • DefaultTcpPortMonitor

      public DefaultTcpPortMonitor(InetAddress ipAddress, Port port, URIParameters monitoringParameters)
      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 class PortMonitor
      See Also:
    • connect

      protected Socket connect() throws Exception
      Gets the socket to use for this port connection.
      Throws:
      Exception
    • checkPort

      public final String checkPort() throws Exception
      Description copied from class: PortMonitor
      Checks the port. This may take arbitrarily long to complete, and any timeout should be provided externally and call the cancel method. If any error occurs, must throw an exception.
      Specified by:
      checkPort in class PortMonitor
      Returns:
      the message indicating success
      Throws:
      Exception
      See Also:
    • checkPort

      protected String checkPort(Socket socket, InputStream in, OutputStream out) throws Exception
      Performs any protocol-specific monitoring. This default implementation does nothing.
      Throws:
      Exception