/** * 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()))); }
/** * 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(); }
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(); }
range.getForeignSource() == null ? foreignSourceFromConfig : range.getForeignSource(),
range.getForeignSource() == null ? foreignSourceFromConfig : range.getForeignSource(),