java.lang.Object
com.aoindustries.noc.monitor.portmon.PortMonitor
Direct Known Subclasses:
DefaultTcpPortMonitor, DefaultUdpPortMonitor, JdbcPortMonitor

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

  • Constructor Details

    • PortMonitor

      protected PortMonitor(InetAddress ipAddress, Port port)
      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

      protected static String readLine(Reader in, StringBuilder buffer) throws IOException
      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

      public abstract String checkPort() throws Exception
      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.
      Returns:
      the message indicating success
      Throws:
      Exception
      See Also: