|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.opennms.bb.dp.capsd.components.CapsWriter
The CapsWriter class is designed to use the information collected by the CapsReadere and write the information to persistant storage. The data is store into the distributed poller database using SQL statements defined in the properties for the system.
The class is designed to be created using an instance of the CapsReader class and then run later as a database runnable. The run of the instance will be passed an SQL connection where the persistant information will be stored.
Inner Class Summary | |
private static class |
CapsWriter.AddressToSoapDocument
This static class is used to build an compliant SOAP document that is sent to the discover daemon. |
Field Summary | |
private static String |
IF_ADMIN_STATUS
The lookup string for looking up the value of ifAdminStatus |
private static String |
IF_DESCR
The lookup string for looking up the value of ifDescr |
private static String |
IF_INDEX
The lookup string for looking up the value of ifIndex |
private static String |
IF_OPER_STATUS
The lookup string for looking up the value of ifOperStatus |
private static String |
IF_PHYS_ADDR
The lookup string for looking up the value of ifPhysAddr |
private static String |
IF_SPEED
The lookup string for looking up the value of ifSpeed |
private static String |
IF_TYPE
The lookup string for looking up the value of ifType |
private static String |
IP_ADDR_ENT_ADDR
The lookup string for looking up the value of ipAdEntAddr |
private static String |
IP_ADDR_ENT_NETMASK
The lookup string for looking up the value of ipAdEntNetMask |
private static String |
IP_ADDR_IF_INDEX
The lookup string for looking up the value of ipAdEntIfIndex |
private com.sun.media.jsdt.Channel |
m_channel
The JSDT Communication channel. |
private com.sun.media.jsdt.Client |
m_client
The JSDT Client. |
private String |
m_createDate
Creation date of the node. |
private Set |
m_dupNodes
Set of nodes (ip addresses) already known to Capsd. |
private static char[] |
m_hexDigit
|
private List |
m_ifEntries
The list of IfEntry objects from the MIB on the remote host. |
private List |
m_ipAddrEntries
The list of IP Address entries corresponding to the interfaces on the remote host. |
private IPv4Address |
m_nodeAddress
The original address that was sent by the discovery process to capsd. |
private Dictionary |
m_services
The dictionary of services that are index via the interface address. |
private SystemGroup |
m_sysGroup
The SNMP System Group information collected from the node. |
private static String |
SYS_CONTACT
The lookup string for looking up the value of sysContact |
private static String |
SYS_DESCR
The lookup string for looking up the value of sysDescr |
private static String |
SYS_LOCATION
The lookup string for looking up the value of sysLocation |
private static String |
SYS_NAME
The lookup string for looking up the value of sysName |
private static String |
SYS_OBJECTID
The lookup string for looking up the value of sysObjectID |
Constructor Summary | |
private |
CapsWriter()
The class' default constructor. |
|
CapsWriter(CapsReader capsReader,
com.sun.media.jsdt.Channel channel,
com.sun.media.jsdt.Client client)
The class' constructor that is used to create an instance of a writer object. |
Method Summary | |
private void |
dbInsertInterface(PreparedStatement stmt,
IfTableEntry ifEntry,
IPv4Address ifAddress,
int nodeKey)
This method is used to add a specific interface into the database. |
private void |
dbInsertInterfaces(Connection dbcomm,
int nodeKey)
This method is used to insert the information about the interface into the database. |
private int |
dbInsertNode(Connection dbcomm)
This method is designed to insert the currently known information about the queried node(interface) into the distributed poller database. |
private void |
dbInsertServices(PreparedStatement stmt,
IPv4Address ifAddress,
int ifIndex,
int nodeKey)
This method is used to insert the supported services for the interface into the datastore. |
private void |
dbInsertSnmp(PreparedStatement stmt,
IfTableEntry ifEntry,
IPv4Address ifAddress,
int nodeKey)
This method is used to insert the SNMP information gathered about an interface into the database. |
void |
dbRun(Connection connection)
This method of the CapsWriter class does the bulk of the work for the instance. |
private String |
getIpAddress(int ifIndex)
This method is used to find the corresponding IP Address for the indexed interface. |
private String |
getNetmask(int ifIndex)
This method is used to find the corresponding netmask for the indexed interface. |
private String |
toHexString(byte[] physAddr)
This method converts the physical address, normally six bytes, into a hexidecimal string. |
Methods inherited from class java.lang.Object |
|
Field Detail |
private static final char[] m_hexDigit
private IPv4Address m_nodeAddress
The original address that was sent by the discovery process to capsd.
private SystemGroup m_sysGroup
The SNMP System Group information collected from the node.
private List m_ifEntries
The list of IfEntry objects from the MIB on the remote host. This is a list of IfTableEntry objects.
private List m_ipAddrEntries
The list of IP Address entries corresponding to the interfaces on the remote host. This information is also collected via SNMP.
private Set m_dupNodes
Set of nodes (ip addresses) already known to Capsd.
private Dictionary m_services
The dictionary of services that are index via the interface address.
private String m_createDate
Creation date of the node.
private com.sun.media.jsdt.Channel m_channel
The JSDT Communication channel.
private com.sun.media.jsdt.Client m_client
The JSDT Client.
private static final String SYS_OBJECTID
private static final String SYS_NAME
private static final String SYS_DESCR
private static final String SYS_LOCATION
private static final String SYS_CONTACT
private static final String IF_INDEX
private static final String IF_DESCR
private static final String IF_TYPE
private static final String IF_SPEED
private static final String IF_PHYS_ADDR
private static final String IF_ADMIN_STATUS
private static final String IF_OPER_STATUS
private static final String IP_ADDR_IF_INDEX
private static final String IP_ADDR_ENT_ADDR
private static final String IP_ADDR_ENT_NETMASK
Constructor Detail |
private CapsWriter() throws UnsupportedOperationException
The class' default constructor. The constructor will always throw an exception and not designed to be instantianted without a CapsReader object to interogate information from.
UnsupportedOperationException
- Always thrown
by the constructor.public CapsWriter(CapsReader capsReader, com.sun.media.jsdt.Channel channel, com.sun.media.jsdt.Client client)
The class' constructor that is used to create an instance of a writer object. The object is always paired with a reader object that has all the information gleaned about then node.
Once an instance of the object is initialized the dbRun method must be called to actually store the information to the database.
capsReader
- the CapsReader object that has all the datachannel
- the JSDT channel to which nodes are added
after being added to the DB - discovery then
reads off this channel to update the
'knownNodes'client
- the JSDT client identification for this objectMethod Detail |
private int dbInsertNode(Connection dbcomm) throws SQLException
This method is designed to insert the currently known information about the queried node(interface) into the distributed poller database.
See the create.sql script from the sql module in CVS on OpenNMS for more information about the layout of the database.
dbcomm
- The JDBC database connection.SQLException
- Thrown if an error occurs
inserting the node into the database.java.lang.NullPointerException
- Thrown if the
sql statement could not be loaded from the system
properties.private void dbInsertInterfaces(Connection dbcomm, int nodeKey) throws SQLException
This method is used to insert the information about the interface into the database. The information includes all the known information queried by the CapsReader object.
dbcomm
- The connection to the databse.nodeKey
- The node id for the interfacesSQLException
- Thrown if an error occurs
committing the information to the database.java.lang.NullPointerException
- Thrown if the method
is unable to load the SQL statements from the properties.private void dbInsertInterface(PreparedStatement stmt, IfTableEntry ifEntry, IPv4Address ifAddress, int nodeKey) throws SQLException
This method is used to add a specific interface into the database. The interface addition includes information discovered by the SNMP agent such as it's operational status. If the insert fails then an exception is thrown by the method. The method also attempts to lookup the hostname for the specified IP Address. If the lookup fails then a null record is written to the hostname field.
stmt
- The SQL prepared statment used to insert the informationifEntry
- The SNMP Information collected about the interfaceifAddress
- The Interface IP Address.nodeKey
- The node identification keySQLException
- Thrown if the insertion into the
database fails.private void dbInsertSnmp(PreparedStatement stmt, IfTableEntry ifEntry, IPv4Address ifAddress, int nodeKey) throws SQLException
This method is used to insert the SNMP information gathered about an interface into the database. The information includes the network maks, interface index, physical address, and interace status along with other fields.
stmt
- The prepared SQL statement.ifEntry
- The SNMP interface information.ifAddress
- The IP Address of the interfacenodeKey
- The foreign key node identifierSQLException
- Thrown if an error occurs
adding the information to the datastore.private void dbInsertServices(PreparedStatement stmt, IPv4Address ifAddress, int ifIndex, int nodeKey) throws SQLException
This method is used to insert the supported services for the interface into the datastore. Each service that was supported on the interface is written as a row in the ifServices table.
stmt
- The SQL statement for inserting rows.ifAddress
- The IP Address of the interface.ifIndex
- The index of the lan card.nodeKey
- The node's foreign key constraintSQLException
- Thrown if an error occurs
setting up the bindings or executing the statement.private String getIpAddress(int ifIndex)
This method is used to find the corresponding IP Address for the indexed interface. The list of IP Address entries are searched until the first IP Address is found for the interface. The IP Address is then returned as a string. If there is no interface corresponding to the index then a null is returned to the caller.
ifIndex
- The interface index for.private String getNetmask(int ifIndex)
This method is used to find the corresponding netmask for the indexed interface. The list of IP Address table entries are searched until the first netmask address is found for the interface. The netmask is then returned as a string. If there is no interface corresponding to the index then a null is returned.
ifIndex
- The interface index to search for.private String toHexString(byte[] physAddr)
This method converts the physical address, normally six bytes, into a hexidecimal string. The string is not prefixed with the traditional "0x", but is the raw hexidecimal string in upper case.
NOTICE: The string is converted based on the starndard US-ASCII table. Each NIBBLE is converted to an integer and added to the character '0' (Zero).
physAddr
- The physical address to convert to a string.public void dbRun(Connection connection)
This method of the CapsWriter class does the bulk of the work for the instance. The information that was grabbed by the constructor is written to the persistant store by the run method. The run method can be called multiple times with different connections if necessary.
dbRun
in interface DBRunnable
connection
- the database connection to be used by this
object to add data to the DB
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |