Class AmiPeerFactory


  • public class AmiPeerFactory
    extends Object
    This class is the main repository for AMI configuration information used by the capabilities daemon. When this class is loaded it reads the AMI configuration into memory, and uses the configuration to find the AmiAgentConfig objects for specific addresses. If an address cannot be located in the configuration then a default peer instance is returned to the caller. Note: Users of this class should make sure the init() is called before calling any other method to ensure the config is loaded before accessing other convenience methods.
    Author:
    Jeff Gehlbach, OpenNMS
    • Method Detail

      • getReadLock

        public Lock getReadLock()
      • getWriteLock

        public Lock getWriteLock()
      • init

        public static void init()
                         throws IOException
        Load the config from the default config file and create the singleton instance of this factory.
        Throws:
        IOException - Thrown if the specified config file cannot be read
        IOException - if any.
      • reload

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

        public static AmiPeerFactory getInstance()
        Return the singleton instance of this factory.
        Returns:
        The current factory instance.
        Throws:
        IllegalStateException - Thrown if the factory has not yet been initialized.
      • setAmiConfig

        public static void setAmiConfig​(AmiConfig m_config)

        setAmiConfig

        Parameters:
        m_config - a AmiConfig object.
      • saveCurrent

        public void saveCurrent()
                         throws Exception
        Saves the current settings to disk
        Throws:
        Exception - if saving settings to disk fails.
      • getAgentConfig

        public AmiAgentConfig getAgentConfig​(InetAddress agentInetAddress)

        getAgentConfig

        Parameters:
        agentInetAddress - a InetAddress object.
        Returns:
        a org.opennms.protocols.ami.AmiAgentConfig object.
      • getAmiConfig

        public static AmiConfig getAmiConfig()

        getAmiConfig

        Returns:
        a AmiConfig object.