use of org.opennms.netmgt.model.discovery.IPPollRange in project opennms by OpenNMS.
the class DiscoveryConfigFactory method getRanges.
/**
* <p>getRanges</p>
*
* @return a {@link java.util.List} object.
*/
@Override
public List<IPPollRange> getRanges() {
final List<IPPollRange> includes = new LinkedList<IPPollRange>();
getReadLock().lock();
try {
Long defaultTimeout = getConfiguration().getTimeout().orElse(DEFAULT_TIMEOUT);
Integer defaultRetries = getConfiguration().getRetries().orElse(DEFAULT_RETRIES);
for (final IncludeRange ir : getConfiguration().getIncludeRanges()) {
// Validate IP range; if invalid, then log and discard this range
try {
InetAddressUtils.toIpAddrBytes(ir.getBegin());
} catch (Throwable e) {
LOG.warn("Begin address of discovery range is invalid, discarding: {}", ir.getBegin());
continue;
}
try {
InetAddressUtils.toIpAddrBytes(ir.getEnd());
} catch (Throwable e) {
LOG.warn("End address of discovery range is invalid, discarding: {}", ir.getEnd());
continue;
}
long timeout = ir.getTimeout().orElse(defaultTimeout);
int retries = ir.getRetries().orElse(defaultRetries);
try {
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);
}
}
return includes;
} finally {
getReadLock().unlock();
}
}
Aggregations