/** * <P> * Returns an Enumeration that can be used to cycle over the range of * pollable addresses. * </P> * * @return a {@link java.util.Enumeration} object. */ public Enumeration<IPPollAddress> elements() { return new IPPollRangeGenerator(m_range.elements()); }
/** * <P> * If there are more elements left in the iteration then a value of true * is returned. Else a false value is returned. * </P> */ @Override public boolean hasNext() { return hasMoreElements(); }
/** * <P> * Returns the next object in the iteration. If there are no objects * left in the iteration an exception will be thrown. * </P> * * @exception java.util.NoSuchElementException * Thrown if the collection is exhausted. */ @Override public InetAddress next() { return nextElement(); }
/** * <P> * Returns true if the passed object is equal to self. The objects must be * equal in address, timeout, and the number of retries. * </P> * * @return True if the objects are logically equal. False is returned otherwise. * @param pollAddr a {@link org.opennms.netmgt.model.discovery.IPPollAddress} object. */ @Override public boolean equals(final Object object) { if (object instanceof IPPollAddress) { IPPollAddress pollAddr = (IPPollAddress)object; if (pollAddr != null) { if (pollAddr == this) { return true; } else if (pollAddr.getAddress().equals(m_address) && pollAddr.getRetries() == m_retries && pollAddr.getTimeout() == m_timeout) { return true; } } } return false; }
protected static boolean isConsecutive(IPPollRange range, IPPollRange address) { Preconditions.checkState(BigInteger.ONE.equals(address.getAddressRange().size())); return range != null && new IPAddress(range.getAddressRange().getEnd()).isPredecessorOf(new IPAddress(address.getAddressRange().getEnd())) && Objects.equals(range.getForeignSource(), address.getForeignSource()) && Objects.equals(range.getLocation(), address.getLocation()) && range.getRetries() == address.getRetries() && range.getTimeout() == address.getTimeout(); }
/** * <p>getExcludingInterator</p> * * @param it a {@link java.util.Iterator} object. * @return a {@link java.util.Iterator} object. */ @Override public Iterator<IPPollAddress> getExcludingInterator(final Iterator<IPPollAddress> it) { return StreamSupport.stream( Spliterators.spliteratorUnknownSize(it, ORDERED | IMMUTABLE), false ) // Filter out excluded addresses .filter(item -> !isExcluded(item.getAddress())) .iterator(); }
public Iterable<IPPollAddress> getAddresses() { final List<Iterator<IPPollAddress>> iters = new ArrayList<>(); for(final IPPollRange range : m_ranges) { iters.add(range.iterator()); } return IteratorUtils.concatIterators(iters); }
/** * <P> * Returns the next IPPollAddress in the enumeration. * </P> * * @exception java.util.NoSuchElementException * Thrown if there are no more elements in the iteration. */ @Override public IPPollAddress nextElement() { return new IPPollAddress(m_foreignSource, m_location, (InetAddress) m_range.nextElement(), m_timeout, m_retries); }
/** * <P> * Returns the next element in the enumeration. If there is no element * left in the enumeration an exception will be thrown. * </P> * * @exception java.util.NoSuchElementException * Thrown if the collection is exhausted. */ @Override public InetAddress nextElement() { if (!hasMoreElements()) throw new NoSuchElementException("End of Range"); InetAddress element = make(m_next); m_next = m_next.add(BigInteger.ONE); return element; }
/** * <P> * Returns an Iterator object that can be used to step through all the * address encapsulated in the object. * </P> * * <P> * The iterator returns objects of type * {@link java.net.InetAddress InetAddress}or <code>null</code> if the * address is unknown. * </p> * * @see java.net.InetAddress * @return a {@link java.util.Iterator} object. */ @Override public Iterator<InetAddress> iterator() { return new IPAddressRangeGenerator(m_begin, m_end); }
/** * <P> * Creates an IPPollRange object that can be used to generate IPPollAddress * objects. The addresses are encapsulated by the range [start..end] and the * values of timeout and retry are set in each generated IPPollAddress * object. * </P> * * @param start * The start of the address range to cycle over. * @param end * The end of the address range to cycle over. * @param timeout * The timeout for each generated IPPollAddress. * @param retries * The number of retries for generated addresses. * * @see IPPollAddress * @see IPAddrRange * */ public IPPollRange(String foreignSource, String location, InetAddress start, InetAddress end, long timeout, int retries) { this(foreignSource, location, new IPAddrRange(start, end), timeout, retries); }
/** * <P> * Returns true if there are more elements in the iteration. * </P> */ @Override public boolean hasNext() { return hasMoreElements(); }
/** * <P> * Returns the next object in the iteration and increments the internal * pointer. * </P> * * @exception java.util.NoSuchElementException * Thrown if there are no more elements in the iteration. */ @Override public IPPollAddress next() { return nextElement(); }
private void ping(IPPollAddress pollAddress) { InetAddress address = pollAddress.getAddress(); if (address != null) { if (!isAlreadyDiscovered(address)) { try { m_pinger.ping(address, pollAddress.getTimeout(), pollAddress.getRetries(), (short) 1, cb); } catch (Throwable e) { LOG.debug("error pinging {}", address.getAddress(), e); } } else { LOG.debug("{} already discovered.", address.toString()); } } }
protected static boolean isConsecutive(IPPollRange range, IPPollRange address) { Preconditions.checkState(BigInteger.ONE.equals(address.getAddressRange().size())); return range != null && new IPAddress(range.getAddressRange().getEnd()).isPredecessorOf(new IPAddress(address.getAddressRange().getEnd())) && Objects.equals(range.getForeignSource(), address.getForeignSource()) && Objects.equals(range.getLocation(), address.getLocation()) && range.getRetries() == address.getRetries() && range.getTimeout() == address.getTimeout(); }
public Iterable<IPPollAddress> getAddresses() { final List<Iterator<IPPollAddress>> iters = new ArrayList<>(); for(final IPPollRange range : m_ranges) { iters.add(range.iterator()); } return IteratorUtils.concatIterators(iters); }
/** * <P> * Returns an Iterator object that can be used to cycle over the range of * pollable address information. * </P> * * @return a {@link java.util.Iterator} object. */ @Override public Iterator<IPPollAddress> iterator() { return new IPPollRangeGenerator(m_range.elements()); }
/** * <P> * Returns an Enumeration object that can be used to list out all the * address contained in the encapsulated range. * </P> * * <P> * The iterator returns objects of type * {@link java.net.InetAddress InetAddress}or <code>null</code> if the * address is unknown. * </p> * * @see java.net.InetAddress */ Enumeration<InetAddress> elements() { return new IPAddressRangeGenerator(m_begin, m_end); }
/** * <P> * Creates an IPPollRange object that can be used to generate IPPollAddress * objects. The addresses are encapsulated by the range object and the * values of timeout and retry are set in each generated IPPollAddress * object. * </P> * * @param fromIP * The start of the address range to cycle over. * @param toIP * The end of the address range to cycle over. * @param timeout * The timeout for each generated IPPollAddress. * @param retries * The number of retries for generated addresses. * @see IPPollAddress * @see IPAddrRange * @throws java.net.UnknownHostException if any. */ public IPPollRange(String foreignSource, String location, String fromIP, String toIP, long timeout, int retries) throws java.net.UnknownHostException { m_range = new IPAddrRange(fromIP, toIP); m_foreignSource = foreignSource; m_location = location; m_timeout = timeout; m_retries = retries; }
public Iterable<IPPollAddress> getAddresses(List<IPPollRange> ranges) { final List<Iterator<IPPollAddress>> iters = new ArrayList<>(); for(final IPPollRange range : ranges) { iters.add(range.iterator()); } return IteratorUtils.concatIterators(iters); }