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); }
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(); }
/** * Construct a {@link DiscoveryJob}. All ranges must have the * same foreignSource and location for the message to be routed correctly. * * @param ranges * @param foreignSource * @param location * @param packetsPerSecond */ public DiscoveryJob(List<IPPollRange> ranges, String foreignSource, String location, double packetsPerSecond) { m_ranges = Preconditions.checkNotNull(ranges, "ranges argument"); // NMS-8767: Allow null foreignSources so that Provisiond will create non-provisioned nodes //m_foreignSource = Preconditions.checkNotNull(foreignSource, "foreignSource argument"); m_foreignSource = foreignSource; m_location = Preconditions.checkNotNull(location, "location argument"); m_packetsPerSecond = packetsPerSecond > 0.0 ? packetsPerSecond : DiscoveryConfigFactory.DEFAULT_PACKETS_PER_SECOND; // Verify that all ranges in this job have the same foreign source Preconditions.checkState(m_ranges.stream().allMatch(range -> range.getForeignSource() == null || m_foreignSource.equals(range.getForeignSource()))); // Verify that all ranges in this job have the same location Preconditions.checkState(m_ranges.stream().allMatch(range -> range.getLocation() == null || m_location.equals(range.getLocation()))); }
return new IPPollRange( range.getForeignSource() == null ? foreignSourceFromConfig : range.getForeignSource(), range.getLocation() == null ? locationFromConfig : range.getLocation() ); }, LinkedHashMap::new, Collectors.toList())) previousRange.get().getAddressRange().incrementEnd(); return null;
includes.add(new IPPollRange(ir.getForeignSource().orElse(null), ir.getLocation().orElse(null), ir.getBegin(), ir.getEnd(), timeout, retries)); } catch (final UnknownHostException uhE) { LOG.warn("Failed to convert address range ({}, {})", ir.getBegin(), ir.getEnd(), uhE);
for(IPPollRange range : job.getRanges()) { try { InetAddress begin = InetAddress.getByAddress(range.getAddressRange().getBegin()); InetAddress end = InetAddress.getByAddress(range.getAddressRange().getEnd()); builder.withRange(begin, end, range.getRetries(), range.getTimeout(), TimeUnit.MILLISECONDS); } catch (UnknownHostException e) { LOG.error("Failed to retrieve addresses from range: {}. The range will be skipped.", e);
return new IPPollRange( range.getForeignSource() == null ? foreignSourceFromConfig : range.getForeignSource(), range.getLocation() == null ? locationFromConfig : range.getLocation() ); }, LinkedHashMap::new, Collectors.toList())) previousRange.get().getAddressRange().incrementEnd(); return null;
List<IPPollRange> ranges = new ArrayList<>(); for (IPRangeDTO dto : request.getIpRanges()) { IPPollRange pollRange = new IPPollRange(null, location, dto.getBegin(), dto.getEnd(), dto.getTimeout(), dto.getRetries()); ranges.add(pollRange);
for(IPPollRange range : job.getRanges()) { try { InetAddress begin = InetAddress.getByAddress(range.getAddressRange().getBegin()); InetAddress end = InetAddress.getByAddress(range.getAddressRange().getEnd()); builder.withRange(begin, end, range.getRetries(), range.getTimeout(), TimeUnit.MILLISECONDS); } catch (UnknownHostException e) { LOG.error("Failed to retrieve addresses from range: {}. The range will be skipped.", e);
/** * Construct a {@link DiscoveryJob}. All ranges must have the * same foreignSource and location for the message to be routed correctly. * * @param ranges * @param foreignSource * @param location * @param packetsPerSecond */ public DiscoveryJob(List<IPPollRange> ranges, String foreignSource, String location, double packetsPerSecond) { m_ranges = Preconditions.checkNotNull(ranges, "ranges argument"); // NMS-8767: Allow null foreignSources so that Provisiond will create non-provisioned nodes //m_foreignSource = Preconditions.checkNotNull(foreignSource, "foreignSource argument"); m_foreignSource = foreignSource; m_location = Preconditions.checkNotNull(location, "location argument"); m_packetsPerSecond = packetsPerSecond > 0.0 ? packetsPerSecond : DiscoveryConfigFactory.DEFAULT_PACKETS_PER_SECOND; // Verify that all ranges in this job have the same foreign source Preconditions.checkState(m_ranges.stream().allMatch(range -> range.getForeignSource() == null || m_foreignSource.equals(range.getForeignSource()))); // Verify that all ranges in this job have the same location Preconditions.checkState(m_ranges.stream().allMatch(range -> range.getLocation() == null || m_location.equals(range.getLocation()))); }
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); }
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>getConfiguredAddresses</p> * * TODO: This function is inefficient. It has O(n^2) complexity based on the * product of the include ranges and exclude ranges. This might cause problems * if users are using a large number of excluded ranges. * * @return a {@link java.lang.Iterable} object. */ @Override public Iterable<IPPollAddress> getConfiguredAddresses() { getReadLock().lock(); try { final List<IPPollAddress> specifics = getSpecifics(); final List<IPPollRange> ranges = getRanges(); specifics.addAll(getURLSpecifics()); final List<Iterator<IPPollAddress>> iters = new ArrayList<Iterator<IPPollAddress>>(); iters.add(specifics.iterator()); for(final IPPollRange range : ranges) { iters.add(getExcludingInterator(range.iterator())); } return IteratorUtils.concatIterators(iters); } finally { getReadLock().unlock(); } }