Class DiscoveryConfigFactory

    • Constructor Detail

      • DiscoveryConfigFactory

        public DiscoveryConfigFactory()
                               throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • getInstance

        public static DiscoveryConfigFactory getInstance()
        Deprecated.
        Inject this value instead of using singleton access.
      • getReadLock

        public java.util.concurrent.locks.Lock getReadLock()
      • getWriteLock

        public java.util.concurrent.locks.Lock getWriteLock()
      • reload

        public void reload()
                    throws java.io.IOException
        Reload the config from the default config file.
        Throws:
        java.io.IOException
        java.io.IOException - Thrown if the specified config file cannot be read/loaded
        java.io.IOException - if any.
      • saveXml

        protected void saveXml​(java.lang.String xml)
                        throws java.io.IOException

        saveXml

        Parameters:
        xml - a String object.
        Throws:
        java.io.IOException - if any.
      • saveConfiguration

        public void saveConfiguration​(DiscoveryConfiguration configuration)
                               throws java.io.IOException

        saveConfiguration

        Parameters:
        configuration - a DiscoveryConfiguration object.
        Throws:
        java.io.IOException - if any.
      • addToSpecificsFromURL

        public static java.util.List<java.lang.String> addToSpecificsFromURL​(java.util.List<IPPollAddress> specifics,
                                                                             java.lang.String url,
                                                                             java.lang.String foreignSource,
                                                                             java.lang.String location,
                                                                             long timeout,
                                                                             int retries)
         The file URL is read and a 'specific IP' is added for each entry
          in this file. Each line in the URL file can be one of -
          <IP><space>#<comments>
          or
          <IP>
          or
          #<comments>
        
          Lines starting with a '#' are ignored and so are characters after
          a '<space>#' in a line.
         
        Parameters:
        specifics - the list to add to
        url - the URL file
        timeout - the timeout for all entries in this URL
        retries - the retries for all entries in this URL
        Returns:
        a list of IP Addresses retrieved from the URL.
      • addToSpecificsFromURL

        public static java.util.List<java.lang.String> addToSpecificsFromURL​(java.util.List<IPPollAddress> specifics,
                                                                             java.io.InputStream is,
                                                                             java.lang.String foreignSource,
                                                                             java.lang.String location,
                                                                             long timeout,
                                                                             int retries,
                                                                             java.lang.String url)
                                                                      throws java.io.IOException

        addToSpecificsFromURL

        Parameters:
        specifics - a List object.
        is - a InputStream object.
        timeout - a long.
        retries - a int.
        url -
        Returns:
        a List of IP Addresses retrieved from URL.
        Throws:
        java.io.IOException - if any.
      • isExcluded

        public boolean isExcluded​(java.net.InetAddress address,
                                  java.lang.String location)

        isExcluded

        Specified by:
        isExcluded in interface DiscoveryConfigurationFactory
        Parameters:
        address - a InetAddress object.
        location -
        Returns:
        a boolean.
      • getConfiguredAddresses

        public java.lang.Iterable<IPPollAddress> getConfiguredAddresses()

        getConfiguredAddresses

        TODO: This function is inefficient. It has O(n^2) complexity based on the product of the include ranges and exclude ranges. This might cause problems if users are using a large number of excluded ranges.
        Specified by:
        getConfiguredAddresses in interface DiscoveryConfigurationFactory
        Returns:
        a Iterable object.