Class BestMatchPinger

  • All Implemented Interfaces:
    Pinger

    public class BestMatchPinger
    extends java.lang.Object
    implements Pinger
    • Constructor Summary

      Constructors 
      Constructor Description
      BestMatchPinger()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void initialize4()
      Initialize IPv4 in this Pinger implementation.
      void initialize6()
      Initialize IPv6 in this Pinger implementation.
      boolean isV4Available()
      Whether or not IPv4 is initialized and available for this implementation.
      boolean isV6Available()
      Whether or not IPv6 is initialized and available for this implementation.
      java.util.List<java.lang.Number> parallelPing​(java.net.InetAddress host, int count, long timeout, long pingInterval)
      Ping a remote host, sending 1 or more packets at the given interval, and then return the response times as a list.
      java.util.List<java.lang.Number> parallelPing​(java.net.InetAddress host, int count, long timeout, long pingInterval, int size)
      Ping a remote host, sending 1 or more packets at the given interval, and then return the response times as a list.
      java.lang.Number ping​(java.net.InetAddress host)
      Ping a remote host, using the default number of retries and timeouts.
      java.lang.Number ping​(java.net.InetAddress host, long timeout, int retries)
      This method is used to ping a remote host to test for ICMP support.
      java.lang.Number ping​(java.net.InetAddress host, long timeout, int retries, int packetsize)
      This method is used to ping a remote host to test for ICMP support.
      void ping​(java.net.InetAddress host, long timeout, int retries, int packetsize, int sequenceId, PingResponseCallback cb)
      This method is used to ping a remote host to test for ICMP support.
      void ping​(java.net.InetAddress host, long timeout, int retries, int sequenceId, PingResponseCallback cb)
      This method is used to ping a remote host to test for ICMP support.
      void setAllowFragmentation​(boolean allow)  
      void setTrafficClass​(int tc)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BestMatchPinger

        public BestMatchPinger()
    • Method Detail

      • ping

        public void ping​(java.net.InetAddress host,
                         long timeout,
                         int retries,
                         int packetsize,
                         int sequenceId,
                         PingResponseCallback cb)
                  throws java.lang.Exception
        Description copied from interface: Pinger
        This method is used to ping a remote host to test for ICMP support. Calls the callback method upon success or error.
        Specified by:
        ping in interface Pinger
        Parameters:
        host - The InetAddress address to poll.
        timeout - The time to wait between each retry.
        retries - The number of times to retry.
        packetsize - The size in byte of the ICMP packet.
        sequenceId - an ID representing the ping
        cb - the org.opennms.netmgt.ping.PingResponseCallback callback to call upon success or error
        Throws:
        java.lang.Exception
      • ping

        public void ping​(java.net.InetAddress host,
                         long timeout,
                         int retries,
                         int sequenceId,
                         PingResponseCallback cb)
                  throws java.lang.Exception
        Description copied from interface: Pinger
        This method is used to ping a remote host to test for ICMP support. Calls the callback method upon success or error.
        Specified by:
        ping in interface Pinger
        Parameters:
        host - The InetAddress address to poll.
        timeout - The time to wait between each retry.
        retries - The number of times to retry.
        sequenceId - an ID representing the ping
        cb - the org.opennms.netmgt.ping.PingResponseCallback callback to call upon success or error
        Throws:
        java.lang.Exception
      • ping

        public java.lang.Number ping​(java.net.InetAddress host,
                                     long timeout,
                                     int retries,
                                     int packetsize)
                              throws java.lang.Exception
        Description copied from interface: Pinger
        This method is used to ping a remote host to test for ICMP support. If the remote host responds within the specified period, defined by retries and timeouts, then the response time is returned.
        Specified by:
        ping in interface Pinger
        Parameters:
        host - The InetAddress address to poll.
        timeout - The time to wait between each retry.
        retries - The number of times to retry.
        packetsize - The size in byte of the ICMP packet.
        Returns:
        The response time in microseconds if the host is reachable and has responded with an echo reply, otherwise a null value.
        Throws:
        java.lang.Exception
      • ping

        public java.lang.Number ping​(java.net.InetAddress host,
                                     long timeout,
                                     int retries)
                              throws java.lang.Exception
        Description copied from interface: Pinger
        This method is used to ping a remote host to test for ICMP support. If the remote host responds within the specified period, defined by retries and timeouts, then the response time is returned.
        Specified by:
        ping in interface Pinger
        Parameters:
        host - The InetAddress address to poll.
        timeout - The time to wait between each retry.
        retries - The number of times to retry.
        Returns:
        The response time in microseconds if the host is reachable and has responded with an echo reply, otherwise a null value.
        Throws:
        java.lang.Exception
      • ping

        public java.lang.Number ping​(java.net.InetAddress host)
                              throws java.lang.Exception
        Description copied from interface: Pinger
        Ping a remote host, using the default number of retries and timeouts.
        Specified by:
        ping in interface Pinger
        Parameters:
        host - The InetAddress address to poll.
        Returns:
        The response time in microseconds if the host is reachable and has responded with an echo reply, otherwise a null value.
        Throws:
        java.io.IOException - if any.
        java.lang.InterruptedException - if any.
        java.lang.Exception - if any.
      • parallelPing

        public java.util.List<java.lang.Number> parallelPing​(java.net.InetAddress host,
                                                             int count,
                                                             long timeout,
                                                             long pingInterval)
                                                      throws java.lang.Exception
        Description copied from interface: Pinger
        Ping a remote host, sending 1 or more packets at the given interval, and then return the response times as a list.
        Specified by:
        parallelPing in interface Pinger
        Parameters:
        host - The InetAddress address to poll.
        count - The number of packets to send.
        timeout - The time to wait between each retry.
        pingInterval - The interval at which packets will be sent.
        Returns:
        a List of response times in microseconds. If, for a given ping request, the host is reachable and has responded with an echo reply, it will contain a number, otherwise a null value.
        Throws:
        java.lang.Exception
      • parallelPing

        public java.util.List<java.lang.Number> parallelPing​(java.net.InetAddress host,
                                                             int count,
                                                             long timeout,
                                                             long pingInterval,
                                                             int size)
                                                      throws java.lang.Exception
        Description copied from interface: Pinger
        Ping a remote host, sending 1 or more packets at the given interval, and then return the response times as a list.
        Specified by:
        parallelPing in interface Pinger
        Parameters:
        host - The InetAddress address to poll.
        count - The number of packets to send.
        timeout - The time to wait between each retry.
        pingInterval - The interval at which packets will be sent.
        size - The size of the packet to send.
        Returns:
        a List of response times in microseconds. If, for a given ping request, the host is reachable and has responded with an echo reply, it will contain a number, otherwise a null value.
        Throws:
        java.lang.Exception
      • initialize4

        public void initialize4()
                         throws java.lang.Exception
        Description copied from interface: Pinger
        Initialize IPv4 in this Pinger implementation. If unable to do so, implementations should throw an exception.
        Specified by:
        initialize4 in interface Pinger
        Throws:
        java.lang.Exception
      • initialize6

        public void initialize6()
                         throws java.lang.Exception
        Description copied from interface: Pinger
        Initialize IPv6 in this Pinger implementation. If unable to do so, implementations should throw an exception.
        Specified by:
        initialize6 in interface Pinger
        Throws:
        java.lang.Exception
      • isV4Available

        public boolean isV4Available()
        Description copied from interface: Pinger
        Whether or not IPv4 is initialized and available for this implementation.
        Specified by:
        isV4Available in interface Pinger
      • isV6Available

        public boolean isV6Available()
        Description copied from interface: Pinger
        Whether or not IPv6 is initialized and available for this implementation.
        Specified by:
        isV6Available in interface Pinger
        Returns:
      • setAllowFragmentation

        public void setAllowFragmentation​(boolean allow)
                                   throws java.lang.Exception
        Specified by:
        setAllowFragmentation in interface Pinger
        Throws:
        java.lang.Exception
      • setTrafficClass

        public void setTrafficClass​(int tc)
                             throws java.lang.Exception
        Specified by:
        setTrafficClass in interface Pinger
        Throws:
        java.lang.Exception