OpenNMS API 1.2.3

org.opennms.netmgt.capsd
Class ReparentViaSmb

java.lang.Object
  extended byorg.opennms.netmgt.capsd.ReparentViaSmb

public final class ReparentViaSmb
extends java.lang.Object

This class is designed to reparent interfaces in the database based on the SMB protocol. Specifically, if two nodes in the 'node' table have identical NetBIOS names it is assumed that those two nodes actually represent different interfaces (physical or alias'd) on the same box. The node with the lowest nodeID becomes the "reparent node" and the other nodes are considered duplicates. All interfaces under each duplicate node are then reparented under the "reparent node" and the duplicate node(s) are flagged in the database as deleted (nodeType='D').

Version:
1.1.1.1
Author:
Mike , OpenNMS

Nested Class Summary
private static class ReparentViaSmb.LightWeightIfEntry
           LightWeightIfEntry is designed to hold specific information about an IP interface in the database such as its IP address, its parent node id, and its managed status and represents a lighter weight version of the DbIpInterfaceEntry class.
private static class ReparentViaSmb.LightWeightNodeEntry
          This class is a lighter weight version of the DbNodeEntry class for use in SMB reparenting.
 
Field Summary
private  java.sql.Connection m_connection
          Database connection
private  java.util.List m_existingNodeList
          List of LightWeightNodeEntry objects intialized from the content of the 'node' table.
private static java.util.List m_netbiosNamesToSkip
          Contains hard-coded list of NetBIOS names which are not subject to reparenting via SMB.
private  java.util.Map m_reparentedIfMap
          Contains a mapping of reparent nodes and the list of interfaces which were reparented under them.
private  java.util.Map m_reparentNodeMap
          Contains of mapping of reparent nodes and the list of duplicate nodes associated with them.
(package private) static java.lang.String SQL_DB_DELETE_NODE
           
(package private) static java.lang.String SQL_DB_REPARENT_IF_SERVICES
           
(package private) static java.lang.String SQL_DB_REPARENT_IP_INTERFACE
           
(package private) static java.lang.String SQL_DB_REPARENT_SNMP_INTERFACE
           
(package private) static java.lang.String SQL_DB_RETRIEVE_INTERFACES
           
(package private) static java.lang.String SQL_DB_RETRIEVE_NODE
           
(package private) static java.lang.String SQL_DB_RETRIEVE_NODES
          SQL Statements
 
Constructor Summary
private ReparentViaSmb()
          The class' default constructor.
  ReparentViaSmb(java.sql.Connection connection)
          Class constructor.
 
Method Summary
private  void buildNodeLists()
          This method is responsible for building a list of existing nodes from the 'node' table and then processing that list of nodes in order to determine if there are any nodes which must be reparented because they share the same NetBIOS name with another node.
private  void generateEvents()
          Generates appropriate events to inform other OpenNMS processes of the database changes.
private  void reparentInterfaces()
          This method is responsible for reparenting interfaces belonging to duplicate nodes under the appropriate reparent node id.
private  void sendInterfaceReparentedEvent(java.lang.String ipAddr, java.lang.String ipHostName, int newNodeId, int oldNodeId, DbNodeEntry reparentNodeEntry)
          This method is responsible for generating a interfaceReparented event and sending it to Eventd.
 void sync()
          Performs reparenting if necessary and generates appropriate events to inform other OpenNMS processes of any database changes..
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SQL_DB_RETRIEVE_NODES

static final java.lang.String SQL_DB_RETRIEVE_NODES
SQL Statements

See Also:
Constant Field Values

SQL_DB_RETRIEVE_NODE

static final java.lang.String SQL_DB_RETRIEVE_NODE
See Also:
Constant Field Values

SQL_DB_RETRIEVE_INTERFACES

static final java.lang.String SQL_DB_RETRIEVE_INTERFACES
See Also:
Constant Field Values

SQL_DB_REPARENT_IP_INTERFACE

static final java.lang.String SQL_DB_REPARENT_IP_INTERFACE
See Also:
Constant Field Values

SQL_DB_REPARENT_SNMP_INTERFACE

static final java.lang.String SQL_DB_REPARENT_SNMP_INTERFACE
See Also:
Constant Field Values

SQL_DB_REPARENT_IF_SERVICES

static final java.lang.String SQL_DB_REPARENT_IF_SERVICES
See Also:
Constant Field Values

SQL_DB_DELETE_NODE

static final java.lang.String SQL_DB_DELETE_NODE
See Also:
Constant Field Values

m_connection

private java.sql.Connection m_connection
Database connection


m_existingNodeList

private java.util.List m_existingNodeList
List of LightWeightNodeEntry objects intialized from the content of the 'node' table.


m_reparentedIfMap

private java.util.Map m_reparentedIfMap
Contains a mapping of reparent nodes and the list of interfaces which were reparented under them.


m_reparentNodeMap

private java.util.Map m_reparentNodeMap
Contains of mapping of reparent nodes and the list of duplicate nodes associated with them.


m_netbiosNamesToSkip

private static java.util.List m_netbiosNamesToSkip
Contains hard-coded list of NetBIOS names which are not subject to reparenting via SMB.

Constructor Detail

ReparentViaSmb

private ReparentViaSmb()
                throws java.lang.UnsupportedOperationException
The class' default constructor. The constructor will always throw an exception and not designed to be instantianted without a database connection and CapsReader object.

Throws:
java.lang.UnsupportedOperationException - Always thrown by the constructor.

ReparentViaSmb

public ReparentViaSmb(java.sql.Connection connection)
Class constructor.

Parameters:
connection - Database connection
Method Detail

buildNodeLists

private void buildNodeLists()
                     throws java.sql.SQLException
This method is responsible for building a list of existing nodes from the 'node' table and then processing that list of nodes in order to determine if there are any nodes which must be reparented because they share the same NetBIOS name with another node. During this processing the reparent node map is built which contains a mapping of reparent nodes to their duplicate node lists.

Throws:
java.sql.SQLException - if an error occurs querying the database.

sync

public void sync()
          throws java.sql.SQLException
Performs reparenting if necessary and generates appropriate events to inform other OpenNMS processes of any database changes..

Throws:
java.sql.SQLException - if error occurs updating the database

reparentInterfaces

private void reparentInterfaces()
                         throws java.sql.SQLException
This method is responsible for reparenting interfaces belonging to duplicate nodes under the appropriate reparent node id. During this processing the reparented interface map is generated. This map contains a list of reparented interfaces associated with each reparent node. This list will make it possible to generate 'interfaceReparented' events for each reparented interface. During reparenting the 'ipInterface', 'snmpInterface', and 'ifServices' tables are all updated to reflect the new parent node id for the reparented interface.

Throws:
java.sql.SQLException - if error occurs updating the database

generateEvents

private void generateEvents()
Generates appropriate events to inform other OpenNMS processes of the database changes. Loops through the keys of the reparent interface and generates 'interfaceReparented' events for each reparented interface.


sendInterfaceReparentedEvent

private void sendInterfaceReparentedEvent(java.lang.String ipAddr,
                                          java.lang.String ipHostName,
                                          int newNodeId,
                                          int oldNodeId,
                                          DbNodeEntry reparentNodeEntry)
This method is responsible for generating a interfaceReparented event and sending it to Eventd.

Parameters:
ipAddr - IP address of interface which was reparented
ipHostName - IP Host Name for the interface
newNodeId - Interface's new nodeID
oldNodeId - Interface's old nodeID
reparentNodeEntry - DbNodeEntry object with all info associated with the reparent node

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.