/** * 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. * * @param host * The address to poll. * @param timeout * The time to wait between each retry. * @param retries * The number of times to retry * @return The response time in microseconds if the host is reachable and has responded with an echo reply, otherwise a null value. * @throws InterruptedException if any. * @throws IOException if any. * @throws java.lang.Exception if any. */ @Override public Number ping(final InetAddress host, final long timeout, final int retries, final int packetsize) throws Exception { final SinglePingResponseCallback cb = new SinglePingResponseCallback(host); ping(host, timeout, retries, packetsize,(short)1, cb); cb.waitFor(); cb.rethrowError(); return cb.getResponseTime(); }
/** * 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. * * @param host * The address to poll. * @param timeout * The time to wait between each retry. * @param retries * The number of times to retry * @return The response time in microseconds if the host is reachable and has responded with an echo reply, otherwise a null value. * @throws InterruptedException if any. * @throws IOException if any. * @throws java.lang.Exception if any. */ public Long ping(InetAddress host, long timeout, int retries) throws Exception { SinglePingResponseCallback cb = new SinglePingResponseCallback(host); ping(host, timeout, retries, (short)1, cb); cb.waitFor(); return cb.getResponseTime(); }
/** * 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. * * @param host * The address to poll. * @param timeout * The time to wait between each retry. * @param retries * The number of times to retry * @return The response time in microseconds if the host is reachable and has responded with an echo reply, otherwise a null value. * @throws InterruptedException if any. * @throws IOException if any. * @throws java.lang.Exception if any. */ @Override public Number ping(final InetAddress host, final long timeout, final int retries, final int packetsize) throws Exception { final SinglePingResponseCallback cb = new SinglePingResponseCallback(host); ping(host, timeout, retries, packetsize, (short)1, cb); cb.waitFor(); cb.rethrowError(); return cb.getResponseTime(); }
/** {@inheritDoc} */ @Override public void handleError(InetAddress address, EchoPacket request, Throwable t) { try { m_error = t; info("an error occurred pinging " + address, t); } finally { m_latch.countDown(); } }
/** * 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. * * @param host * The address to poll. * @param timeout * The time to wait between each retry. * @param retries * The number of times to retry * @return The response time in microseconds if the host is reachable and has responded with an echo reply, otherwise a null value. * @throws InterruptedException if any. * @throws IOException if any. * @throws java.lang.Exception if any. */ @Override public Number ping(final InetAddress host, final long timeout, final int retries, final int packetsize) throws Exception { final SinglePingResponseCallback cb = new SinglePingResponseCallback(host); ping(host, timeout, retries, packetsize, (short)1, cb); cb.waitFor(); cb.rethrowError(); return cb.getResponseTime(); }
/** {@inheritDoc} */ @Override public void handleTimeout(InetAddress address, EchoPacket request) { try { assert(request != null); info("timed out pinging address " + address + ", thread " + request.getIdentifier() + ", seq " + request.getSequenceNumber()); } finally { m_latch.countDown(); } }
/** * 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. * * @param host * The address to poll. * @param timeout * The time to wait between each retry. * @param retries * The number of times to retry * @return The response time in microseconds if the host is reachable and has responded with an echo reply, otherwise a null value. * @throws InterruptedException if any. * @throws IOException if any. * @throws java.lang.Exception if any. */ @Override public Number ping(final InetAddress host, final long timeout, final int retries, final int packetsize) throws Exception { final SinglePingResponseCallback cb = new SinglePingResponseCallback(host); ping(host, timeout, retries, packetsize, 1, cb); cb.waitFor(); cb.rethrowError(); return cb.getResponseTime(); }
/** {@inheritDoc} */ @Override public void handleResponse(InetAddress address, EchoPacket response) { try { info("got response for address " + address + ", thread " + response.getIdentifier() + ", seq " + response.getSequenceNumber() + " with a responseTime "+response.elapsedTime(TimeUnit.MILLISECONDS)+"ms"); m_responseTime = (long)Math.round(response.elapsedTime(TimeUnit.MICROSECONDS)); } finally { m_latch.countDown(); } }