use of org.opennms.netmgt.model.discovery.IPPollAddress in project opennms by OpenNMS.
the class DiscoveryConfigFactory method getSpecifics.
/**
* <p>getSpecifics</p>
*
* @return a {@link java.util.List} object.
*/
@Override
public List<IPPollAddress> getSpecifics() {
final List<IPPollAddress> specifics = new LinkedList<IPPollAddress>();
getReadLock().lock();
try {
Long defaultTimeout = getConfiguration().getTimeout().orElse(DEFAULT_TIMEOUT);
Integer defaultRetries = getConfiguration().getRetries().orElse(DEFAULT_RETRIES);
for (final Specific s : getConfiguration().getSpecifics()) {
long timeout = s.getTimeout().orElse(defaultTimeout);
int retries = s.getRetries().orElse(defaultRetries);
final String address = s.getAddress();
try {
specifics.add(new IPPollAddress(s.getForeignSource().orElse(null), s.getLocation().orElse(null), InetAddressUtils.addr(address), timeout, retries));
} catch (final IllegalArgumentException e) {
LOG.warn("Failed to convert address {}", address, e);
}
}
return specifics;
} finally {
getReadLock().unlock();
}
}
use of org.opennms.netmgt.model.discovery.IPPollAddress in project opennms by OpenNMS.
the class DiscoveryConfigFactoryTest method testAddToSpecificsFromURLViaURL.
@Test
public void testAddToSpecificsFromURLViaURL() throws Exception {
final List<IPPollAddress> specifics = new ArrayList<>();
final URL in = this.getClass().getResource("validDiscoveryIncludeFile.txt");
final long timeout = 100;
final int retries = 1;
DiscoveryConfigFactory.addToSpecificsFromURL(specifics, in.toString(), null, null, timeout, retries);
assertEquals(8, specifics.size());
assertEquals("127.0.0.1", InetAddressUtils.str(specifics.get(0).getAddress()));
assertEquals("10.1.1.1", InetAddressUtils.str(specifics.get(1).getAddress()));
assertEquals("10.2.1.1", InetAddressUtils.str(specifics.get(2).getAddress()));
assertEquals("8.8.8.8", InetAddressUtils.str(specifics.get(3).getAddress()));
assertEquals("fe80:0000:0000:0000:ffff:eeee:dddd:cccc", InetAddressUtils.str(specifics.get(4).getAddress()));
assertEquals("0000:0000:0000:0000:0000:0000:0000:0001", InetAddressUtils.str(specifics.get(5).getAddress()));
assertEquals("fe80:0000:0000:0000:ffff:eeee:dddd:cccd", InetAddressUtils.str(specifics.get(6).getAddress()));
assertEquals("fe80:0000:0000:0000:ffff:eeee:dddd:cccc", InetAddressUtils.str(specifics.get(7).getAddress()));
}
Aggregations