@Test public void testAddToSpecificsFromURLViaStream() throws Exception { final List<IPPollAddress> specifics = new ArrayList<IPPollAddress>(); final InputStream in = this.getClass().getResourceAsStream("validDiscoveryIncludeFile.txt"); final long timeout = 100; final int retries = 1; DiscoveryConfigFactory.addToSpecificsFromURL(specifics, in, 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())); }
public static boolean addToSpecificsFromURL(final List<IPPollAddress> specifics, final String url, final long timeout, final int retries) { InputStream is = null; try { final URL fileURL = new URL(url); is = fileURL.openStream(); if (is == null) { LogUtils.warnf(DiscoveryConfigFactory.class, "URL does not exist: %s", url); return true; } else { return addToSpecificsFromURL(specifics, fileURL.openStream(), timeout, retries); } } catch (final IOException e) { LogUtils.errorf(DiscoveryConfigFactory.class, "Error reading URL: %s", url); return false; } finally { IOUtils.closeQuietly(is); } }
DiscoveryConfigFactory { public static boolean addToSpecificsFromURL(final List<IPPollAddress> specifics, final String url, final long timeout, final int retries) { InputStream is = null; try { final URL fileURL = new URL(url); is = fileURL.openStream(); if (is == null) { LogUtils.warnf(DiscoveryConfigFactory.class, "URL does not exist: %s", url); return true; } else { return addToSpecificsFromURL(specifics, fileURL.openStream(), timeout, retries); } } catch (final IOException e) { LogUtils.errorf(DiscoveryConfigFactory.class, "Error reading URL: %s", url); return false; } finally { IOUtils.closeQuietly(is); } } }
DiscoveryConfigFactory { public static boolean addToSpecificsFromURL(final List<IPPollAddress> specifics, final String url, final long timeout, final int retries) { InputStream is = null; try { final URL fileURL = new URL(url); is = fileURL.openStream(); if (is == null) { LogUtils.warnf(DiscoveryConfigFactory.class, "URL does not exist: %s", url); return true; } else { return addToSpecificsFromURL(specifics, fileURL.openStream(), timeout, retries); } } catch (final IOException e) { LogUtils.errorf(DiscoveryConfigFactory.class, "Error reading URL: %s", url); return false; } finally { IOUtils.closeQuietly(is); } } private  DiscoveryConfigFactory(final String configFile); protected  DiscoveryConfigFactory(); }
DiscoveryConfigFactory { public static boolean addToSpecificsFromURL(final List<IPPollAddress> specifics, final String url, final long timeout, final int retries) { InputStream is = null; try { final URL fileURL = new URL(url); is = fileURL.openStream(); if (is == null) { LogUtils.warnf(DiscoveryConfigFactory.class, "URL does not exist: %s", url); return true; } else { return addToSpecificsFromURL(specifics, fileURL.openStream(), timeout, retries); } } catch (final IOException e) { LogUtils.errorf(DiscoveryConfigFactory.class, "Error reading URL: %s", url); return false; } finally { IOUtils.closeQuietly(is); } } private  DiscoveryConfigFactory(final String configFile); protected  DiscoveryConfigFactory(); Lock getReadLock(); Lock getWriteLock(); static synchronized void init(); static synchronized void reload(); static synchronized DiscoveryConfigFactory getInstance(); static synchronized void setInstance(final DiscoveryConfigFactory factory); synchronized DiscoveryConfiguration getConfiguration(); void saveConfiguration(final DiscoveryConfiguration configuration); static boolean addToSpecificsFromURL(final List<IPPollAddress> specifics, final String url, final long timeout, final int retries); static boolean addToSpecificsFromURL(final List<IPPollAddress> specifics, final InputStream is, final long timeout, final int retries); List<IPPollAddress> getURLSpecifics(); List<IPPollRange> getRanges(); List<IPPollAddress> getSpecifics(); boolean isExcluded(final InetAddress address); int getIntraPacketDelay(); Iterator<IPPollAddress> getExcludingInterator(final Iterator<IPPollAddress> it); Iterable<IPPollAddress> getConfiguredAddresses(); long getRestartSleepTime(); long getInitialSleepTime(); }
DiscoveryConfigFactory { public static boolean addToSpecificsFromURL(final List<IPPollAddress> specifics, final String url, final long timeout, final int retries) { InputStream is = null; try { final URL fileURL = new URL(url); is = fileURL.openStream(); if (is == null) { LogUtils.warnf(DiscoveryConfigFactory.class, "URL does not exist: %s", url); return true; } else { return addToSpecificsFromURL(specifics, fileURL.openStream(), timeout, retries); } } catch (final IOException e) { LogUtils.errorf(DiscoveryConfigFactory.class, "Error reading URL: %s", url); return false; } finally { IOUtils.closeQuietly(is); } } private  DiscoveryConfigFactory(final String configFile); protected  DiscoveryConfigFactory(); Lock getReadLock(); Lock getWriteLock(); static synchronized void init(); static synchronized void reload(); static synchronized DiscoveryConfigFactory getInstance(); static synchronized void setInstance(final DiscoveryConfigFactory factory); synchronized DiscoveryConfiguration getConfiguration(); void saveConfiguration(final DiscoveryConfiguration configuration); static boolean addToSpecificsFromURL(final List<IPPollAddress> specifics, final String url, final long timeout, final int retries); static boolean addToSpecificsFromURL(final List<IPPollAddress> specifics, final InputStream is, final long timeout, final int retries); List<IPPollAddress> getURLSpecifics(); List<IPPollRange> getRanges(); List<IPPollAddress> getSpecifics(); boolean isExcluded(final InetAddress address); int getIntraPacketDelay(); Iterator<IPPollAddress> getExcludingInterator(final Iterator<IPPollAddress> it); Iterable<IPPollAddress> getConfiguredAddresses(); long getRestartSleepTime(); long getInitialSleepTime(); static final String COMMENT_STR; static final char COMMENT_CHAR; }