OpenNMS API 1.2.9

## org.opennms.netmgt.config
Class PollerConfigFactory

    java.lang.Object
      org.opennms.netmgt.config.PollerConfigFactory

All Implemented Interfaces:
  PollerConfig

public final class PollerConfigFactory
extends java.lang.Object
implements PollerConfig

This is the singleton class used to load the configuration for the OpenNMS Poller service from the poller-configuration xml file. A mapping of the configured URLs to the iplist they contain is built at init() time so as to avoid numerous file reads. 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:
  James Zuo , Mike Davidson , Sowmya Nataraj , OpenNMS

Field Summary
`private PollerConfiguration` `m_config` The config class loaded from the config file
`private static boolean` `m_loaded` This member is set to true if the configuration file has been loaded.
`private static java.lang.String` `m_localServer` The name of the local OpenNMS server
`private java.util.Map` `m_pkgIpMap` A mapping of the configured package to a list of IPs selected via filter rules, so as to avoid repetetive database access.
`private static PollerConfigFactory` `m_singleton` The singleton instance of this factory
`private java.util.Map` `m_svcMonitors` A mapp of service names to service monitors.
`private java.util.Map` `m_urlIPMap` A mapping of the configured URLs to a list of the specific IPs configured in each - so as to avoid file reads
`private static boolean` `m_verifyServer` A boolean flag to indicate If a filter rule agaist the local OpenNMS server has to be used.

Constructor Summary
`private` `PollerConfigFactory(OpennmsServerConfigFactory serverConfig, java.io.Reader reader)` Private constructor

Method Summary
`private void` `createPackageIpListMap()` This method is used to establish package agaist iplist mapping, with which, the iplist is selected per package via the configured filter rules from the database.
`private void` `createServiceMonitors()`
`private void` `createUrlIpMap()` Go through the poller configuration and build a mapping of each configured URL to a list of IPs configured in that URL - done at init() time so that repeated file reads can be avoided
`java.util.Enumeration` `enumerateMonitor()`
`java.util.Enumeration` `enumeratePackage()`
`java.util.List` `getAllPackageMatches(java.lang.String ipaddr)` Returns a list of package names that the ip belongs to, null if none.
`PollerConfiguration` `getConfiguration()` Return the poller configuration object.
`java.lang.String` `getCriticalService()` This method returns the configured critical service name.
`Package` `getFirstPackageMatch(java.lang.String ipaddr)` Returns the first package that the ip belongs to, null if none.
`static PollerConfigFactory` `getInstance()` Return the singleton instance of this factory.
`java.lang.String` `getNextOutageIdSql()`
`Package` `getPackage(java.lang.String name)`
`java.util.List` `getRRAList(Package pkg)` Retrieves configured list of RoundRobin Archive statements.
`ServiceMonitor` `getServiceMonitor(java.lang.String svcName)`
`java.util.Map` `getServiceMonitors()`
`int` `getStep(Package pkg)` Retrieves configured RRD step size.
`int` `getThreads()`
`boolean` `getXmlrpc()` This method returns the boolean flag xmlrpc to indicate if notification to external xmlrpc server is needed.
`static void` `init()` Load the config from the default config file and create the singleton instance of this factory.
`boolean` `interfaceInPackage(java.lang.String iface, Package pkg)` This method is used to determine if the named interface is included in the passed package definition.
`private boolean` `interfaceInUrl(java.lang.String addr, java.lang.String url)` This method is used to determine if the named interface is included in the passed package's url includes.
`boolean` `isPolled(java.lang.String ipaddr)` Returns true if the ip is part of atleast one package.
`boolean` `isPolled(java.lang.String svcName, Package pkg)` Returns true if this package has the service enabled and if there is a monitor for this service.
`boolean` `isPolled(java.lang.String ipaddr, java.lang.String svcName)` Returns true if the ip is part of atleast one package and if this package has the service enabled and if there is a monitor for this service.
`boolean` `nodeOutageProcessingEnabled()` Returns true if node outage processing is enabled.
`boolean` `pollAllIfNoCriticalServiceDefined()` This method returns the configured value of the 'pollAllIfNoCriticalServiceDefined' flag.
`void` `rebuildPackageIpListMap()` This method is used to rebuild the package agaist iplist mapping when needed.
`static void` `reload()` Reload the config from the default config file
`private void` `reloadXML(OpennmsServerConfigFactory serverConfig, java.io.Reader reader)`
`void` `saveCurrent()` Saves the current in-memory configuration to disk and reloads
`boolean` `serviceInPackageAndEnabled(java.lang.String svcName, Package pkg)` Returns true if the service is part of the package and the status of the service is set to "on".
`boolean` `serviceMonitored(java.lang.String svcName)` Returns true if the service has a monitor configured, false otherwise.
`boolean` `serviceUnresponsiveEnabled()` Returns true if serviceUnresponsive behavior is enabled.
`void` `update()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### m_singleton

    private static PollerConfigFactory m_singleton

  The singleton instance of this factory

### m_loaded

    private static boolean m_loaded

  This member is set to true if the configuration file has been loaded.

### m_config

    private PollerConfiguration m_config

  The config class loaded from the config file

### m_urlIPMap

    private java.util.Map m_urlIPMap

  A mapping of the configured URLs to a list of the specific IPs configured in each - so as to avoid file reads

### m_pkgIpMap

    private java.util.Map m_pkgIpMap

  A mapping of the configured package to a list of IPs selected via filter rules, so as to avoid repetetive database access.

### m_svcMonitors

    private java.util.Map m_svcMonitors

  A mapp of service names to service monitors. Constructed based on data in the configuration file.

### m_verifyServer

    private static boolean m_verifyServer

  A boolean flag to indicate If a filter rule agaist the local OpenNMS server has to be used.

### m_localServer

    private static java.lang.String m_localServer

  The name of the local OpenNMS server

Constructor Detail

### PollerConfigFactory

    private PollerConfigFactory(OpennmsServerConfigFactory serverConfig,
                                java.io.Reader reader)
                         throws java.io.IOException,
                                org.exolab.castor.xml.MarshalException,
                                org.exolab.castor.xml.ValidationException

  Private constructor

Throws:
  `java.io.IOException` - Thrown if the specified config file cannot be read
  `org.exolab.castor.xml.MarshalException` - Thrown if the file does not conform to the schema.
  `org.exolab.castor.xml.ValidationException` - Thrown if the contents do not match the required schema.

Method Detail

### createUrlIpMap

    private void createUrlIpMap()

  Go through the poller configuration and build a mapping of each configured URL to a list of IPs configured in that URL - done at init() time so that repeated file reads can be avoided

### reloadXML

    private void reloadXML(OpennmsServerConfigFactory serverConfig,
                           java.io.Reader reader)
                    throws org.exolab.castor.xml.MarshalException,
                           org.exolab.castor.xml.ValidationException,
                           java.io.IOException

  Throws:
    `org.exolab.castor.xml.MarshalException`
    `org.exolab.castor.xml.ValidationException`
    `java.io.IOException`

### init

    public static void init()
                     throws java.io.IOException,
                            org.exolab.castor.xml.MarshalException,
                            org.exolab.castor.xml.ValidationException

  Load the config from the default config file and create the singleton instance of this factory.

  Throws:
    `java.io.IOException` - Thrown if the specified config file cannot be read
    `org.exolab.castor.xml.MarshalException` - Thrown if the file does not conform to the schema.
    `org.exolab.castor.xml.ValidationException` - Thrown if the contents do not match the required schema.

### reload

    public static void reload()
                       throws java.io.IOException,
                              org.exolab.castor.xml.MarshalException,
                              org.exolab.castor.xml.ValidationException

  Reload the config from the default config file

  Throws:
    `java.io.IOException` - Thrown if the specified config file cannot be read/loaded
    `org.exolab.castor.xml.MarshalException` - Thrown if the file does not conform to the schema.
    `org.exolab.castor.xml.ValidationException` - Thrown if the contents do not match the required schema.

### saveCurrent

    public void saveCurrent()
                     throws org.exolab.castor.xml.MarshalException,
                            java.io.IOException,
                            org.exolab.castor.xml.ValidationException

  Saves the current in-memory configuration to disk and reloads

  Throws:
    `org.exolab.castor.xml.MarshalException`
    `java.io.IOException`
    `org.exolab.castor.xml.ValidationException`

### getInstance

    public static PollerConfigFactory getInstance()

  Return the singleton instance of this factory.

  Returns:
    The current factory instance.
  Throws:
    `java.lang.IllegalStateException` - Thrown if the factory has not yet been initialized.

### getConfiguration

    public PollerConfiguration getConfiguration()

  Return the poller configuration object.

### getPackage

    public Package getPackage(java.lang.String name)

  Specified by:
    `getPackage` in interface `PollerConfig`

### interfaceInUrl

    private boolean interfaceInUrl(java.lang.String addr,
                                   java.lang.String url)

  This method is used to determine if the named interface is included in the passed package's url includes. If the interface is found in any of the URL files, then a value of true is returned, else a false value is returned.

        The file URL is read and each entry in this file checked. 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:
    `addr` - The interface to test against the package's URL
    `url` - The url file to read
  Returns:
    True if the interface is included in the url, false otherwise.

### getXmlrpc

    public boolean getXmlrpc()

  This method returns the boolean flag xmlrpc to indicate if notification to external xmlrpc server is needed.

  Specified by:
    `getXmlrpc` in interface `PollerConfig`
  Returns:
    true if need to notify an external xmlrpc server

### getCriticalService

    public java.lang.String getCriticalService()

  This method returns the configured critical service name.

  Specified by:
    `getCriticalService` in interface `PollerConfig`
  Returns:
    the name of the configured critical service, or null if none is present

### pollAllIfNoCriticalServiceDefined

    public boolean pollAllIfNoCriticalServiceDefined()

  This method returns the configured value of the 'pollAllIfNoCriticalServiceDefined' flag. A value of true causes the poller's node outage code to poll all the services on an interface if a status change has occurred and there is no critical service defined on the interface. A value of false causes the poller's node outage code to not poll all the services on an interface in this situation.

  Specified by:
    `pollAllIfNoCriticalServiceDefined` in interface `PollerConfig`
  Returns:
    true or false based on configured value

### nodeOutageProcessingEnabled

    public boolean nodeOutageProcessingEnabled()

  Returns true if node outage processing is enabled.

  Specified by:
    `nodeOutageProcessingEnabled` in interface `PollerConfig`

### serviceUnresponsiveEnabled

    public boolean serviceUnresponsiveEnabled()

  Returns true if serviceUnresponsive behavior is enabled. If enabled a serviceUnresponsive event is generated for TCP-based services if the service monitor is able to connect to the designated port but times out before receiving the expected response. If disabled, an outage will be generated in this scenario.

  Specified by:
    `serviceUnresponsiveEnabled` in interface `PollerConfig`

### createPackageIpListMap

    private void createPackageIpListMap()

  This method is used to establish package agaist iplist mapping, with which, the iplist is selected per package via the configured filter rules from the database.

### rebuildPackageIpListMap

    public void rebuildPackageIpListMap()

  This method is used to rebuild the package agaist iplist mapping when needed. When a node gained service event occurs, poller has to determine which package the ip/service combination is in, but if the interface is a newly added one, the package iplist should be rebuilt so that poller could know which package this ip/service pair is in.

  Specified by:
    `rebuildPackageIpListMap` in interface `PollerConfig`

### interfaceInPackage

    public boolean interfaceInPackage(java.lang.String iface,
                                      Package pkg)

  This method is used to determine if the named interface is included in the passed package definition. If the interface belongs to the package then a value of true is returned. If the interface does not belong to the package a false value is returned. Note: Evaluation of the interface against a package filter will only work if the IP is already in the database.

  Specified by:
    `interfaceInPackage` in interface `PollerConfig`
  Parameters:
    `iface` - The interface to test against the package.
    `pkg` - The package to check for the inclusion of the interface.
  Returns:
    True if the interface is included in the package, false otherwise.

### serviceInPackageAndEnabled

    public boolean serviceInPackageAndEnabled(java.lang.String svcName,
                                              Package pkg)

  Returns true if the service is part of the package and the status of the service is set to "on". Returns false if the service is not in the package or it is but the status of the service is set to "off".

  Specified by:
    `serviceInPackageAndEnabled` in interface `PollerConfig`
  Parameters:
    `svcName` - The service name to lookup.
    `pkg` - The package to lookup up service.

### serviceMonitored

    public boolean serviceMonitored(java.lang.String svcName)

  Returns true if the service has a monitor configured, false otherwise.

  Specified by:
    `serviceMonitored` in interface `PollerConfig`
  Parameters:
    `svcName` - The service name to lookup.

### getFirstPackageMatch

    public Package getFirstPackageMatch(java.lang.String ipaddr)

  Returns the first package that the ip belongs to, null if none. Note: Evaluation of the interface against a package filter will only work if the IP is alrady in the database.

  Specified by:
    `getFirstPackageMatch` in interface `PollerConfig`
  Parameters:
    `ipaddr` - the interface to check
  Returns:
    the first package that the ip belongs to, null if none

### getAllPackageMatches

    public java.util.List getAllPackageMatches(java.lang.String ipaddr)

  Returns a list of package names that the ip belongs to, null if none. Note: Evaluation of the interface against a package filter will only work if the IP is alrady in the database.

  Parameters:
    `ipaddr` - the interface to check
  Returns:
    a list of package names that the ip belongs to, null if none

### isPolled

    public boolean isPolled(java.lang.String ipaddr)

  Returns true if the ip is part of atleast one package. Note: Evaluation of the interface against a package filter will only work if the IP is alrady in the database.

  Specified by:
    `isPolled` in interface `PollerConfig`
  Parameters:
    `ipaddr` - the interface to check
  Returns:
    true if the ip is part of atleast one package, false otherwise

### isPolled

    public boolean isPolled(java.lang.String svcName,
                            Package pkg)

  Returns true if this package has the service enabled and if there is a monitor for this service. Note: Evaluation of the interface against a package filter will only work if the IP is alrady in the database.

  Specified by:
    `isPolled` in interface `PollerConfig`
  Parameters:
    `svcName` - the service to check
    `pkg` - the package to check
  Returns:
    true if the ip is part of atleast one package and the service is enabled in this package and monitored, false otherwise

### isPolled

    public boolean isPolled(java.lang.String ipaddr,
                            java.lang.String svcName)

  Returns true if the ip is part of atleast one package and if this package has the service enabled and if there is a monitor for this service. Note: Evaluation of the interface against a package filter will only work if the IP is alrady in the database.

  Specified by:
    `isPolled` in interface `PollerConfig`
  Parameters:
    `ipaddr` - the interface to check
    `svcName` - the service to check
  Returns:
    true if the ip is part of atleast one package and the service is enabled in this package and monitored, false otherwise

### getStep

    public int getStep(Package pkg)

  Retrieves configured RRD step size.

  Specified by:
    `getStep` in interface `PollerConfig`
  Parameters:
    `pkg` - Name of the data collection
  Returns:
    RRD step size for the specified collection

### getRRAList

    public java.util.List getRRAList(Package pkg)

  Retrieves configured list of RoundRobin Archive statements.

  Specified by:
    `getRRAList` in interface `PollerConfig`
  Parameters:
    `pkg` - Name of the data collection
  Returns:
    list of RRA strings.

### enumeratePackage

    public java.util.Enumeration enumeratePackage()

  Specified by:
    `enumeratePackage` in interface `PollerConfig`

### enumerateMonitor

    public java.util.Enumeration enumerateMonitor()

### getThreads

    public int getThreads()

  Specified by:
    `getThreads` in interface `PollerConfig`

### createServiceMonitors

    private void createServiceMonitors()

  Returns:

### getServiceMonitors

    public java.util.Map getServiceMonitors()

  Specified by:
    `getServiceMonitors` in interface `PollerConfig`

### getServiceMonitor

    public ServiceMonitor getServiceMonitor(java.lang.String svcName)

  Specified by:
    `getServiceMonitor` in interface `PollerConfig`

### getNextOutageIdSql

    public java.lang.String getNextOutageIdSql()

  Specified by:
    `getNextOutageIdSql` in interface `PollerConfig`

### update

    public void update()
                throws java.io.IOException,
                       org.exolab.castor.xml.MarshalException,
                       org.exolab.castor.xml.ValidationException

  Specified by:
    `update` in interface `PollerConfig`
  Throws:
    `java.io.IOException`
    `org.exolab.castor.xml.MarshalException`
    `org.exolab.castor.xml.ValidationException`

OpenNMS API 1.2.9

Generated by ranger on May 19 2007 2335.