@Test public void testSingleIPExclude() throws Exception { final DiscoveryConfigFactory factory = new DiscoveryConfigFactory() { public void saveConfiguration(final DiscoveryConfiguration configuration) throws MarshalException, ValidationException, IOException {} public synchronized DiscoveryConfiguration getConfiguration() { final DiscoveryConfiguration conf = new DiscoveryConfiguration(); IncludeRange ir = new IncludeRange(); ir.setBegin("192.168.0.1"); ir.setEnd("192.168.0.254"); conf.addIncludeRange(ir); ExcludeRange er = new ExcludeRange(); er.setBegin("192.168.0.100"); er.setEnd("192.168.0.100"); conf.addExcludeRange(er); return conf; } }; assertFalse(factory.isExcluded(InetAddressUtils.addr("192.168.0.1"))); assertFalse(factory.isExcluded(InetAddressUtils.addr("192.168.0.2"))); assertFalse(factory.isExcluded(InetAddressUtils.addr("192.168.0.99"))); assertTrue(factory.isExcluded(InetAddressUtils.addr("192.168.0.100"))); assertFalse(factory.isExcluded(InetAddressUtils.addr("192.168.0.101"))); assertFalse(factory.isExcluded(InetAddressUtils.addr("192.168.0.151"))); }
public boolean isExcluded(final InetAddress address) { getReadLock().lock(); try { final List<ExcludeRange> excludeRange = getConfiguration().getExcludeRangeCollection(); if (excludeRange != null) { final byte[] laddr = address.getAddress(); for (final ExcludeRange range : excludeRange) { if (InetAddressUtils.isInetAddressInRange(laddr, range.getBegin(), range.getEnd())) { return true; } } } return false; } finally { getReadLock().unlock(); } }
DiscoveryConfigFactory { public boolean isExcluded(final InetAddress address) { getReadLock().lock(); try { final List<ExcludeRange> excludeRange = getConfiguration().getExcludeRangeCollection(); if (excludeRange != null) { final byte[] laddr = address.getAddress(); for (final ExcludeRange range : excludeRange) { if (InetAddressUtils.isInetAddressInRange(laddr, range.getBegin(), range.getEnd())) { return true; } } } return false; } finally { getReadLock().unlock(); } } }
DiscoveryConfigFactory { public boolean isExcluded(final InetAddress address) { getReadLock().lock(); try { final List<ExcludeRange> excludeRange = getConfiguration().getExcludeRangeCollection(); if (excludeRange != null) { final byte[] laddr = address.getAddress(); for (final ExcludeRange range : excludeRange) { if (InetAddressUtils.isInetAddressInRange(laddr, range.getBegin(), range.getEnd())) { return true; } } } return false; } finally { getReadLock().unlock(); } } private  DiscoveryConfigFactory(final String configFile); protected  DiscoveryConfigFactory(); }
DiscoveryConfigFactory { public boolean isExcluded(final InetAddress address) { getReadLock().lock(); try { final List<ExcludeRange> excludeRange = getConfiguration().getExcludeRangeCollection(); if (excludeRange != null) { final byte[] laddr = address.getAddress(); for (final ExcludeRange range : excludeRange) { if (InetAddressUtils.isInetAddressInRange(laddr, range.getBegin(), range.getEnd())) { return true; } } } return false; } finally { getReadLock().unlock(); } } 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 boolean isExcluded(final InetAddress address) { getReadLock().lock(); try { final List<ExcludeRange> excludeRange = getConfiguration().getExcludeRangeCollection(); if (excludeRange != null) { final byte[] laddr = address.getAddress(); for (final ExcludeRange range : excludeRange) { if (InetAddressUtils.isInetAddressInRange(laddr, range.getBegin(), range.getEnd())) { return true; } } } return false; } finally { getReadLock().unlock(); } } 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; }