|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opennms.netmgt.config.SnmpPeerFactory
This class is the main respository for SNMP configuration information used by
the capabilities daemon. When this class is loaded it reads the snmp
configuration into memory, and uses the configuration to find the
SnmpPeer
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.
Field Summary | |
private static SnmpConfig |
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 SnmpPeerFactory |
m_singleton
The singleton instance of this factory |
Constructor Summary | |
private |
SnmpPeerFactory(java.lang.String configFile)
Private constructor |
Method Summary | |
private SnmpPeer |
create(java.net.InetAddress addr,
Definition def)
this method uses the passed address and definition to construct an appropriate SNMP peer object for use by an SnmpSession. |
private SnmpPeer |
create(java.net.InetAddress addr,
Definition def,
int supportedSnmpVersion)
this method uses the passed address and definition to construct an appropriate SNMP peer object for use by an SnmpSession. |
void |
define(java.net.InetAddress ip,
java.lang.String community)
Puts a specific IP address with associated read-community string into the currently loaded snmp-config.xml. |
static SnmpPeerFactory |
getInstance()
Return the singleton instance of this factory. |
SnmpPeer |
getPeer(java.net.InetAddress host)
This method is used by the Capabilities poller to lookup the SNMP peer information associated with the passed host. |
SnmpPeer |
getPeer(java.net.InetAddress host,
int supportedSnmpVersion)
This method is used by the Capabilities poller to lookup the SNMP peer information associated with the passed host. |
static void |
init()
Load the config from the default config file and create the singleton instance of this factory. |
private static void |
optimize()
Combine specific and range elements so that SnmpPeerFactory has to spend less time iterating all these elements. |
static void |
reload()
Reload the config from the default config file |
static void |
saveCurrent()
Saves the current settings to disk |
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 |
private static SnmpPeerFactory m_singleton
private static SnmpConfig m_config
private static boolean m_loaded
Constructor Detail |
private SnmpPeerFactory(java.lang.String configFile) throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
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 |
public static void init() throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
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.public static void reload() throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
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.public static void saveCurrent() throws java.lang.Exception
java.lang.Exception
private static void optimize() throws java.net.UnknownHostException
java.net.UnknownHostException
public static SnmpPeerFactory getInstance()
java.lang.IllegalStateException
- Thrown if the factory has not yet been initialized.private static long toLong(java.net.InetAddress addr)
addr
- The address to convert to a long
public void define(java.net.InetAddress ip, java.lang.String community) throws java.net.UnknownHostException
java.net.UnknownHostException
private SnmpPeer create(java.net.InetAddress addr, Definition def)
addr
- The address to construct the snmp peer instance.def
- The definition containing the appropriate information.
private SnmpPeer create(java.net.InetAddress addr, Definition def, int supportedSnmpVersion)
addr
- The address to construct the snmp peer instance.def
- The definition containing the appropriate information.supportedSnmpVersion
- SNMP version to associate with the peer object if SNMP version
has not been explicitly configured.
public SnmpPeer getPeer(java.net.InetAddress host)
host
- The host for locating the SnmpPeer information.
public SnmpPeer getPeer(java.net.InetAddress host, int supportedSnmpVersion)
host
- The host for locating the SnmpPeer information.supportedSnmpVersion
- SNMP version to associate with the peer object if SNMP version
has not been explicitly configured.
|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |