@Override public Number ping(final InetAddress host, final long timeout, final int retries, final int packetsize) throws Exception { initialize(); return m_pinger.ping(host, timeout, retries, packetsize); }
@Override public boolean isV4Available() { initialize(); return m_pinger.isV4Available(); }
@Override public boolean isV6Available() { initialize(); return m_pinger.isV6Available(); }
if (pinger.isV4Available()) { pinger.initialize4(); v4 = true; if (pinger.isV6Available()) { pinger.initialize6(); v6 = true; final Number result = pinger.ping(tryme, timeout, 0); if (result == null) { throw new IllegalStateException("No result pinging localhost.");
@Override public List<Number> parallelPing(final InetAddress host, final int count, final long timeout, final long pingInterval) throws Exception { initialize(); return m_pinger.parallelPing(host, count, timeout, pingInterval); }
private void initialize() { if (m_pinger == null) { final Class<? extends Pinger> pinger = BestMatchPingerFactory.findPinger(); try { m_pinger = pinger.newInstance(); } catch (final Throwable t) { LOG.error("Failed to initialize best match pinger ({}): {} Falling back to the null pinger.", pinger, t.getMessage()); LOG.trace("Failed to initialize best match pinger ({}). Falling back to the null pinger.", pinger, t); m_pinger = new NullPinger(); } try { if (m_allowFragmentation != null) { m_pinger.setAllowFragmentation(m_allowFragmentation); } } catch (final Throwable t) { LOG.debug("Failed to set 'allow fragmentation' flag on pinger {}: {}", pinger, t.getMessage()); LOG.trace("Failed to set 'allow fragmentation' flag on pinger {}.", pinger, t); } try { if (m_trafficClass != null) { m_pinger.setTrafficClass(m_trafficClass); } } catch (final Throwable t) { LOG.debug("Failed to set traffic class on pinger {}", pinger, t); } } } }
@Override public void setTrafficClass(final int tc) throws Exception { if (m_pinger != null) { m_pinger.setTrafficClass(tc); } m_trafficClass = tc; }
if (pinger.isV4Available()) { pinger.initialize4(); v4 = true; if (pinger.isV6Available()) { pinger.initialize6(); v6 = true; final Number result = pinger.ping(tryme, timeout, 0); if (result == null) { throw new IllegalStateException("No result pinging localhost.");
@Override public List<Number> parallelPing(final InetAddress host, final int count, final long timeout, final long pingInterval, final int size) throws Exception { initialize(); return m_pinger.parallelPing(host, count, timeout, pingInterval, size); }
private void initialize() { if (m_pinger == null) { final Class<? extends Pinger> pinger = BestMatchPingerFactory.findPinger(); try { m_pinger = pinger.newInstance(); } catch (final Throwable t) { LOG.error("Failed to initialize best match pinger ({}): {} Falling back to the null pinger.", pinger, t.getMessage()); LOG.trace("Failed to initialize best match pinger ({}). Falling back to the null pinger.", pinger, t); m_pinger = new NullPinger(); } try { if (m_allowFragmentation != null) { m_pinger.setAllowFragmentation(m_allowFragmentation); } } catch (final Throwable t) { LOG.debug("Failed to set 'allow fragmentation' flag on pinger {}: {}", pinger, t.getMessage()); LOG.trace("Failed to set 'allow fragmentation' flag on pinger {}.", pinger, t); } try { if (m_trafficClass != null) { m_pinger.setTrafficClass(m_trafficClass); } } catch (final Throwable t) { LOG.debug("Failed to set traffic class on pinger {}", pinger, t); } } } }
@Override public void setTrafficClass(final int tc) throws Exception { if (m_pinger != null) { m_pinger.setTrafficClass(tc); } m_trafficClass = tc; }
final Pinger pinger = pingerFactory.getInstance(); boolean hasV4 = pinger.isV4Available(); boolean hasV6 = pinger.isV6Available(); pinger.initialize4(); hasV4 = true; } catch (final Exception e) { pinger.initialize6(); hasV6 = true; } catch (final Exception e) {
@Override public Number ping(final InetAddress host) throws Exception { initialize(); return m_pinger.ping(host); }
@Override public List<Number> parallelPing(final InetAddress host, final int count, final long timeout, final long pingInterval) throws Exception { initialize(); return m_pinger.parallelPing(host, count, timeout, pingInterval); }
@Override public boolean isV6Available() { initialize(); return m_pinger.isV6Available(); }
@Override public boolean isV4Available() { initialize(); return m_pinger.isV4Available(); }
@Override public Pinger call() throws Exception { final Pinger pinger = clazz.newInstance(); pinger.setTrafficClass(tc); return pinger; } });
private void testPinger() { final Pinger pinger = PingerFactory.getInstance(); final boolean hasV4 = pinger.isV4Available(); final boolean hasV6 = pinger.isV6Available(); pinger.initialize4(); } catch (final Exception e) { log().warn("Failed to initialize IPv4 stack.", e); pinger.initialize6(); } catch (final Exception e) { log().warn("Failed to initialize IPv6 stack.", e);
@Override public void ping(final InetAddress host, final long timeout, final int retries, final int packetsize, final int sequenceId, final PingResponseCallback cb) throws Exception { initialize(); m_pinger.ping(host, timeout, retries, packetsize, sequenceId, cb); }
@Override public List<Number> parallelPing(final InetAddress host, final int count, final long timeout, final long pingInterval, final int size) throws Exception { initialize(); return m_pinger.parallelPing(host, count, timeout, pingInterval, size); }