OpenNMS API 1.2.3

org.opennms.netmgt.config
Class DataCollectionConfigFactory

java.lang.Object
  extended byorg.opennms.netmgt.config.DataCollectionConfigFactory

public final class DataCollectionConfigFactory
extends java.lang.Object

This class is the main respository for SNMP data collection configuration information used by the SNMP service monitor. When this class is loaded it reads the snmp data collection configuration into memory. 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:
Weave , OpenNMS

Field Summary
private  java.util.Map m_collectionGroupMap
          Map of group maps indexed by SNMP collection name.
private  java.util.Map m_collectionMap
          Map of SnmpCollection objects indexed by data collection name
private  DatacollectionConfig 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 DataCollectionConfigFactory m_singleton
          The singleton instance of this factory
 
Constructor Summary
private DataCollectionConfigFactory(java.lang.String configFile)
          Private constructor
 
Method Summary
static DataCollectionConfigFactory getInstance()
          Return the singleton instance of this factory.
 int getMaxVarsPerPdu(java.lang.String cName)
          Retrieves the configured value for the maximum number of variables (oids) which can be encoded into a single outgoing SNMP PDU request..
 java.util.List getMibObjectList(java.lang.String cName, java.lang.String aSysoid, java.lang.String anAddress, int ifType)
          This method returns the list of MIB objects associated with a particular system object id, IP address, and ifType for the specified collection.
 java.util.List getRRAList(java.lang.String cName)
          Retrieves configured list of RoundRobin Archive statements.
 java.lang.String getRrdRepository()
          Retrieves the configured path to the RRD file repository.
 java.lang.String getSnmpStorageFlag(java.lang.String cName)
          Retrieves the configured value of the SNMP storage flag.
 int getStep(java.lang.String cName)
          Retrieves configured RRD step size.
static void init()
          Load the config from the default config file and create the singleton instance of this factory.
private  void processGroupName(java.lang.String cName, java.lang.String groupName, int ifType, java.util.List mibObjectList)
          Private utility method used by the getMibObjectList() method.
(package private) static void processObjectList(java.util.List objectList, java.util.List mibObjectList)
          Takes a list of castor generated MibObj objects iterates over them creating corresponding MibObject objects and adding them to the supplied MibObject list.
static void reload()
          Reload the config from the default config file
private static long toLong(java.net.InetAddress addr)
          Converts the internet address to a long value so that it can be compared using simple opertions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_singleton

private static DataCollectionConfigFactory m_singleton
The singleton instance of this factory


m_config

private DatacollectionConfig m_config
The config class loaded from the config file


m_loaded

private static boolean m_loaded
This member is set to true if the configuration file has been loaded.


m_collectionGroupMap

private java.util.Map m_collectionGroupMap
Map of group maps indexed by SNMP collection name.


m_collectionMap

private java.util.Map m_collectionMap
Map of SnmpCollection objects indexed by data collection name

Constructor Detail

DataCollectionConfigFactory

private DataCollectionConfigFactory(java.lang.String configFile)
                             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

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.

getInstance

public static DataCollectionConfigFactory 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.

toLong

private static long toLong(java.net.InetAddress addr)
Converts the internet address to a long value so that it can be compared using simple opertions. The address is converted in network byte order (big endin) and allows for comparisions like <, >, <=, >=, ==, and !=.

Parameters:
addr - The address to convert to a long
Returns:
The address as a long value.

getMibObjectList

public java.util.List getMibObjectList(java.lang.String cName,
                                       java.lang.String aSysoid,
                                       java.lang.String anAddress,
                                       int ifType)
This method returns the list of MIB objects associated with a particular system object id, IP address, and ifType for the specified collection.

Parameters:
cName - name of the data collection from which to retrieve oid information.
aSysoid - system object id to look up in the collection
anAddress - IP address to look up in the collection
ifType - Interface type (-1 indicates that only node-level objects should be retrieved.
Returns:
a list of MIB objects

processGroupName

private void processGroupName(java.lang.String cName,
                              java.lang.String groupName,
                              int ifType,
                              java.util.List mibObjectList)
Private utility method used by the getMibObjectList() method. This method takes a group name and a list of MibObject objects as arguments and adds all of the MibObjects associated with the group to the object list. If the passed group consists of any additional sub-groups, then this method will be called recursively for each sub-group until the entire log.debug("processGroupName: adding MIB objects from group: " + groupName); group is processed.

Parameters:
cName - Collection name
groupName - Name of the group to process
ifType - Interface type
mibObjectList - List of MibObject objects being built.

processObjectList

static void processObjectList(java.util.List objectList,
                              java.util.List mibObjectList)
Takes a list of castor generated MibObj objects iterates over them creating corresponding MibObject objects and adding them to the supplied MibObject list.

Parameters:
objectList - List of MibObject objects parsed from 'datacollection-config.xml'
mibObjectList - List of MibObject objects currently being built

getStep

public int getStep(java.lang.String cName)
Retrieves configured RRD step size.

Parameters:
cName - Name of the data collection
Returns:
RRD step size for the specified collection

getRRAList

public java.util.List getRRAList(java.lang.String cName)
Retrieves configured list of RoundRobin Archive statements.

Parameters:
cName - Name of the data collection
Returns:
list of RRA strings.

getSnmpStorageFlag

public java.lang.String getSnmpStorageFlag(java.lang.String cName)
Retrieves the configured value of the SNMP storage flag.

Parameters:
cName - Name of the data collection
Returns:
SNMP storage flag

getMaxVarsPerPdu

public int getMaxVarsPerPdu(java.lang.String cName)
Retrieves the configured value for the maximum number of variables (oids) which can be encoded into a single outgoing SNMP PDU request..

Parameters:
cName - Name of the data collection
Returns:
max number of variables per pdu or -1 upon error

getRrdRepository

public java.lang.String getRrdRepository()
Retrieves the configured path to the RRD file repository.

Returns:
RRD repository path.

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.