OpenNMS API 1.2.3

org.opennms.netmgt.capsd
Class RescanProcessor

java.lang.Object
  extended byorg.opennms.netmgt.capsd.RescanProcessor
All Implemented Interfaces:
java.lang.Runnable

final class RescanProcessor
extends java.lang.Object
implements java.lang.Runnable

This class is designed to rescan all the managed interfaces for a specified node, update the database based on the information collected, and generate events necessary to notify the other OpenNMS services. The constructor takes an integer which is the node identifier of the node to be rescanned. .

Author:
James Zuo , Mike Davidson , Brian Weaver , OpenNMS

Field Summary
private  CapsdConfigFactory m_cFactory
          Capsd configuration factory
private  java.util.List m_eventList
          Event list...during the rescan significant database changes cause events (interfaceReparented, nodeGainedService, and others) to be created and added to the event list.
private  boolean m_forceRescan
          Indicates if the rescan is in response to a forceRescan event.
private  boolean m_ifIndexOnNodeChangedFlag
          Set during the rescan to true if any of the ifIndex values associated with a node's interface's were modified as a result of the scan.
private  Scheduler.NodeInfo m_scheduledNode
          Information necessary to schedule the node.
(package private) static java.util.Map m_serviceNames
           
private  boolean m_snmpIfTableChangedFlag
          Set during the rescan to true if a new interface is added to the snmpInterfaces table or if any key fields of the node's snmpIntefaces table were modified (such as ifIndex or ifType)
private static java.lang.String SELECT_METHOD_MAX
           
private static java.lang.String SELECT_METHOD_MIN
           
(package private) static java.lang.String SQL_DB_DELETE_DUP_INTERFACE
          SQL statements used to clear up ipinterface table, ifservices table and snmpinterface table when delete a duplicate node.
(package private) static java.lang.String SQL_DB_DELETE_DUP_SERVICES
           
(package private) static java.lang.String SQL_DB_DELETE_DUP_SNMPINTERFACE
           
(package private) static java.lang.String SQL_DB_REPARENT_IF_SERVICES
           
(package private) static java.lang.String SQL_DB_REPARENT_IF_SERVICES_DELETE
           
(package private) static java.lang.String SQL_DB_REPARENT_IF_SERVICES_LOOKUP
           
(package private) static java.lang.String SQL_DB_REPARENT_IP_INTERFACE
           
(package private) static java.lang.String SQL_DB_REPARENT_IP_INTERFACE_DELETE
           
(package private) static java.lang.String SQL_DB_REPARENT_IP_INTERFACE_LOOKUP
          SQL statements used to reparent an interface and its associated services under a new parent nodeid
(package private) static java.lang.String SQL_DB_REPARENT_SNMP_IF_DELETE
           
(package private) static java.lang.String SQL_DB_REPARENT_SNMP_IF_LOOKUP
           
(package private) static java.lang.String SQL_DB_REPARENT_SNMP_INTERFACE
           
(package private) static java.lang.String SQL_DB_RETRIEVE_DUPLICATE_NODEIDS
          SQL statement for retrieving the nodeids that have the same ipaddr as the updating node no matter what ifindex they have.
(package private) static java.lang.String SQL_DB_RETRIEVE_NODE_TYPE
          SQL statement for retrieving the 'nodetype' field of the node table for the specified nodeid.
(package private) static java.lang.String SQL_DB_RETRIEVE_OTHER_NODES
          SQL statement used to retrieve other nodeIds that have the same ipinterface as the updating node.
private static java.lang.String SQL_RETRIEVE_SERVICE_IDS
          SQL statement used to retrieve service IDs so that service name can be determined from ID, and map of service names
 
Constructor Summary
(package private) RescanProcessor(Scheduler.NodeInfo nodeInfo, boolean forceRescan)
          Constructor.
 
Method Summary
private  void addSupportedProtocols(DbNodeEntry node, DbIpInterfaceEntry ipIfEntry, java.util.List protocols, boolean addrUnmanaged, int ifIndex, Package ipPkg)
          Responsible for iterating inserting an entry into the ifServices table for each protocol supported by the interface.
private  boolean areDbInterfacesInSnmpCollection(DbIpInterfaceEntry[] dbInterfaces, IfSnmpCollector snmpc)
          This method is used to verify if each interface on a node stored in the database is in the specified SNMP data collection.
private static java.util.List buildLBSnmpAddressList(java.util.Map collectorMap, IfSnmpCollector snmpc)
          Builds a list of InetAddress objects representing each of the interfaces from the collector map object which support SNMP and have a valid ifIndex and have an IfType of loopback.
private static java.util.List buildSnmpAddressList(java.util.Map collectorMap, IfSnmpCollector snmpc)
          Builds a list of InetAddress objects representing each of the interfaces from the collector map object which support SNMP and have a valid ifIndex.
private  void createDuplicateIpAddressEvent(DbIpInterfaceEntry ifEntry)
          This method is responsible for generating a duplicateIpAddress event and adding it to the event list.
private  void createDuplicateNodeDeletedEvent(DbNodeEntry deletedNode)
          This method is responsible for generating a duplicateNodeDeleted event and adding it to the event list.
private  void createInterfaceIndexChangedEvent(DbIpInterfaceEntry updatedEntry, DbIpInterfaceEntry originalEntry)
          This method is responsible for generating a interfaceIndexChanged event and adding it to the event list.
private  void createInterfaceReparentedEvent(DbNodeEntry newNode, int oldNodeId, java.net.InetAddress reparentedIf)
          This method is responsible for generating a interfaceReparented event and adding it to the event list.
private  void createInterfaceSupportsSNMPEvent(DbIpInterfaceEntry ifEntry)
          This method is responsible for generating a interfaceSupportsSNMPEvent event and adding it to the event list.
private  void createIpHostNameChangedEvent(DbIpInterfaceEntry updatedEntry, DbIpInterfaceEntry originalEntry)
          This method is responsible for generating an ipHostNameChanged event and adding it to the event list.
private  void createNodeGainedInterfaceEvent(DbIpInterfaceEntry ifEntry)
          This method is responsible for generating a nodeGainedInterface event and adding it to the event list.
private  void createNodeGainedServiceEvent(DbNodeEntry nodeEntry, DbIpInterfaceEntry ifEntry, java.lang.String svcName)
          This method is responsible for generating a nodeGainedService event and adding it to the event list.
private  void createNodeInfoChangedEvent(DbNodeEntry updatedEntry, DbNodeEntry originalEntry)
          This method is responsible for generating a nodeInfoChanged event and adding it to the event list.
private  void createNodeLabelChangedEvent(DbNodeEntry updatedEntry, DbNodeEntry originalEntry)
          This method is responsible for generating a nodeLabelChanged event and adding it to the event list.
private  void createPrimarySnmpInterfaceChangedEvent(int nodeId, java.net.InetAddress newPrimaryIf, java.net.InetAddress oldPrimaryIf)
          This method is responsible for generating a primarySnmpInterfaceChanged event and adding it to the event list.
private  void createReinitializePrimarySnmpInterfaceEvent(int nodeId, java.net.InetAddress primarySnmpIf)
          This method is responsible for generating a reinitializePrimarySnmpInterface event and adding it to the event list.
private  void createResumePollingServiceEvent(DbNodeEntry nodeEntry, DbIpInterfaceEntry ifEntry, java.lang.String svcName)
          This method is responsible for generating a resumePollingService event and adding it to the event list.
private  void createSnmpConflictsWithDbEvent(DbNodeEntry nodeEntry)
          This method is responsible for generating a snmpConflictsWithDb event and adding it to the event list.
private  void createSuspendPollingServiceEvent(DbNodeEntry nodeEntry, DbIpInterfaceEntry ifEntry, java.lang.String svcName)
          This method is responsible for generating a suspendPollingService event and adding it to the event list.
private  void deleteDuplicateNode(java.sql.Connection dbc, DbNodeEntry duplicateNode)
          This method is responsible to delete any interface associated with the duplicate node, delete any entry left in ifservices table and snmpinterface table for the duplicate node, and make the node as 'deleted'.
private  java.net.InetAddress determinePrimaryIpInterface(java.util.Map collectorMap)
          This method is responsible for determining the primary IP interface for the node being rescanned.
private  IfSnmpCollector findSnmpCollector(java.util.Map collectorMap)
           
private  void generateSnmpDataCollectionEvents(DbNodeEntry nodeEntry, java.util.List oldPriIfs, java.net.InetAddress primarySnmpIf)
          Determines if any SNMP data collection related events need to be generated based upon the results of the current rescan.
private  DbIpInterfaceEntry[] getInterfaces(DbNodeEntry dbNodeEntry)
           
private  DbNodeEntry getNode()
           
private  boolean isDuplicateInterface(java.sql.Connection dbc, java.net.InetAddress ifaddr, int nodeId)
          This method verify if an ipaddress is existing in other node except in the updating node.
private  boolean isDuplicateNode(java.sql.Connection dbc, DbNodeEntry suspectNode, IfSnmpCollector snmpc)
          This method checks if a suspect node entry is a duplicate node to the updating node by verify if each interface in the suspect node is contained in the ipAddrTable of the updating node.
private  boolean isInterfaceAlias(java.net.InetAddress ipAddr, IfSnmpCollector snmpc)
          Determines if the passed InetAddress object represents an interface alias.
private  boolean isNodeDeleted(java.sql.Connection dbc, int nodeId)
          Utility method used to determine if the specified node has been marked as deleted in the node table.
private  void reparentInterface(java.sql.Connection dbc, java.net.InetAddress ifAddr, int ifIndex, int newNodeId, int oldNodeId)
          This method is responsible for reparenting an interface's database table entries under its new node identifier.
 void run()
          This is where all the work of the class is done.
private  boolean scanPrimarySnmpInterface(org.apache.log4j.Category log, DbIpInterfaceEntry[] dbInterfaces, java.util.Map collectorMap, java.util.Set probedAddrs)
           
private  void setNodeLabelAndSmbInfo(java.util.Map collectorMap, DbNodeEntry dbNodeEntry, DbNodeEntry currNodeEntry, java.net.InetAddress currPrimarySnmpIf)
          Primarily, this method is responsible for assigning the node's nodeLabel value using information collected from the node's various interfaces.
private  void updateInterface(java.sql.Connection dbc, java.util.Date now, DbNodeEntry node, java.net.InetAddress target, java.net.InetAddress ifaddr, java.util.List protocols, IfSnmpCollector snmpc, boolean doesSnmp)
          This method is responsible for updating the ipInterface table entry for a specific interface.
private  void updateInterfaceInfo(java.sql.Connection dbc, java.util.Date now, DbNodeEntry node, DbIpInterfaceEntry dbIpIfEntry, IfSnmpCollector snmpc, boolean isNewIpEntry, boolean isReparented, boolean doesSnmp)
          This method is responsible for updating the ipinterface table entry for a specific interface.
private  void updateInterfaces(java.sql.Connection dbc, java.util.Date now, DbNodeEntry node, java.util.Map collectorMap, boolean doesSnmp)
          This method is responsible for updating all of the interface's associated with a node.
private  DbNodeEntry updateNode(java.sql.Connection dbc, java.util.Date now, DbNodeEntry dbNodeEntry, java.net.InetAddress currPrimarySnmpIf, DbIpInterfaceEntry[] dbIpInterfaces, java.util.Map collectorMap)
          This method is responsible for updating the node table using the most recent data collected from the node's managed interfaces.
private  void updateNonIpInterface(java.sql.Connection dbc, java.util.Date now, DbNodeEntry node, int ifIndex, IfSnmpCollector snmpc)
          This method is responsible for updating the ipInterface table entry for a specific interface.
private  java.net.InetAddress updatePrimarySnmpInterface(java.sql.Connection dbc, DbNodeEntry dbNodeEntry, java.util.Map collectorMap)
           
private  void updateServiceInfo(java.sql.Connection dbc, DbNodeEntry node, DbIpInterfaceEntry dbIpIfEntry, boolean isNewIpEntry, java.util.List protocols)
          This method is responsible for updating the ifservices table entry for a specific interface.
private  void updateServicesOnForcedRescan(DbNodeEntry node, DbIpInterfaceEntry dbIpIfEntry, DbIfServiceEntry[] dbSupportedServices)
          This method is responsible for updating the status of services for an interface during a forced rescan
private  void updateSnmpInfo(java.sql.Connection dbc, DbNodeEntry node, DbIpInterfaceEntry dbIpIfEntry, IfSnmpCollector snmpc)
          This method is responsible for updating the snmpInterface table entry for a specific interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SQL_DB_RETRIEVE_NODE_TYPE

static final java.lang.String SQL_DB_RETRIEVE_NODE_TYPE
SQL statement for retrieving the 'nodetype' field of the node table for the specified nodeid. Used to determine if the node is active ('A') or been marked as deleted ('D')..

See Also:
Constant Field Values

SQL_DB_RETRIEVE_OTHER_NODES

static final java.lang.String SQL_DB_RETRIEVE_OTHER_NODES
SQL statement used to retrieve other nodeIds that have the same ipinterface as the updating node.

See Also:
Constant Field Values

SQL_DB_RETRIEVE_DUPLICATE_NODEIDS

static final java.lang.String SQL_DB_RETRIEVE_DUPLICATE_NODEIDS
SQL statement for retrieving the nodeids that have the same ipaddr as the updating node no matter what ifindex they have.

See Also:
Constant Field Values

SQL_DB_REPARENT_IP_INTERFACE_LOOKUP

static final java.lang.String SQL_DB_REPARENT_IP_INTERFACE_LOOKUP
SQL statements used to reparent an interface and its associated services under a new parent nodeid

See Also:
Constant Field Values

SQL_DB_REPARENT_IP_INTERFACE_DELETE

static final java.lang.String SQL_DB_REPARENT_IP_INTERFACE_DELETE
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_IF_LOOKUP

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

SQL_DB_REPARENT_SNMP_IF_DELETE

static final java.lang.String SQL_DB_REPARENT_SNMP_IF_DELETE
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_LOOKUP

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

SQL_DB_REPARENT_IF_SERVICES_DELETE

static final java.lang.String SQL_DB_REPARENT_IF_SERVICES_DELETE
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_DUP_INTERFACE

static final java.lang.String SQL_DB_DELETE_DUP_INTERFACE
SQL statements used to clear up ipinterface table, ifservices table and snmpinterface table when delete a duplicate node.

See Also:
Constant Field Values

SQL_DB_DELETE_DUP_SERVICES

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

SQL_DB_DELETE_DUP_SNMPINTERFACE

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

SELECT_METHOD_MIN

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

SELECT_METHOD_MAX

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

SQL_RETRIEVE_SERVICE_IDS

private static final java.lang.String SQL_RETRIEVE_SERVICE_IDS
SQL statement used to retrieve service IDs so that service name can be determined from ID, and map of service names

See Also:
Constant Field Values

m_serviceNames

static final java.util.Map m_serviceNames

m_scheduledNode

private Scheduler.NodeInfo m_scheduledNode
Information necessary to schedule the node.


m_forceRescan

private boolean m_forceRescan
Indicates if the rescan is in response to a forceRescan event.


m_eventList

private java.util.List m_eventList
Event list...during the rescan significant database changes cause events (interfaceReparented, nodeGainedService, and others) to be created and added to the event list. The last thing the rescan process does is send the events out.


m_cFactory

private CapsdConfigFactory m_cFactory
Capsd configuration factory


m_ifIndexOnNodeChangedFlag

private boolean m_ifIndexOnNodeChangedFlag
Set during the rescan to true if any of the ifIndex values associated with a node's interface's were modified as a result of the scan.


m_snmpIfTableChangedFlag

private boolean m_snmpIfTableChangedFlag
Set during the rescan to true if a new interface is added to the snmpInterfaces table or if any key fields of the node's snmpIntefaces table were modified (such as ifIndex or ifType)

Constructor Detail

RescanProcessor

RescanProcessor(Scheduler.NodeInfo nodeInfo,
                boolean forceRescan)
Constructor.

Parameters:
nodeInfo - Scheduler.NodeInfo object containing the nodeid of the node to be rescanned.
forceRescan - True if a forced rescan is to be performed (all interfaces not just managed interfaces scanned), false otherwise.
Method Detail

updateNode

private DbNodeEntry updateNode(java.sql.Connection dbc,
                               java.util.Date now,
                               DbNodeEntry dbNodeEntry,
                               java.net.InetAddress currPrimarySnmpIf,
                               DbIpInterfaceEntry[] dbIpInterfaces,
                               java.util.Map collectorMap)
                        throws java.sql.SQLException
This method is responsible for updating the node table using the most recent data collected from the node's managed interfaces.

Parameters:
dbc - Database connection
now - Date object representing the time of the rescan.
dbNodeEntry - DbNodeEntry object representing existing values in the database
currPrimarySnmpIf - Primary SNMP interface address based on latest collection
dbIpInterfaces - Array of DbIpInterfaceEntry objects representing all the interfaces retrieved from the database for this node.
collectorMap - Map of IfCollector objects...one per managed interface.
Returns:
DbNodeEntry object representing the updated values from the node table in the database.
Throws:
java.sql.SQLException - if there is a problem updating the node table.

updateInterfaces

private void updateInterfaces(java.sql.Connection dbc,
                              java.util.Date now,
                              DbNodeEntry node,
                              java.util.Map collectorMap,
                              boolean doesSnmp)
                       throws java.sql.SQLException
This method is responsible for updating all of the interface's associated with a node.

Parameters:
dbc - Database connection.
now - Date/time to be associated with the update.
node - Node entry for the node being rescanned
collectorMap - Map of IfCollector objects associated with the node.
doesSnmp - Indicates that the interface does support SNMP
Throws:
java.sql.SQLException - if there is a problem updating the ipInterface table.

updateNonIpInterface

private void updateNonIpInterface(java.sql.Connection dbc,
                                  java.util.Date now,
                                  DbNodeEntry node,
                                  int ifIndex,
                                  IfSnmpCollector snmpc)
                           throws java.sql.SQLException
This method is responsible for updating the ipInterface table entry for a specific interface.

Parameters:
dbc - Database Connection
now - Date/time to be associated with the update.
node - Node entry for the node being rescanned
ifIndex - Interface index of non-IP interface to update
snmpc - SNMP collector or null if SNMP not supported.
Throws:
java.sql.SQLException - if there is a problem updating the ipInterface table.

updateInterface

private void updateInterface(java.sql.Connection dbc,
                             java.util.Date now,
                             DbNodeEntry node,
                             java.net.InetAddress target,
                             java.net.InetAddress ifaddr,
                             java.util.List protocols,
                             IfSnmpCollector snmpc,
                             boolean doesSnmp)
                      throws java.sql.SQLException
This method is responsible for updating the ipInterface table entry for a specific interface.

Parameters:
dbc - Database Connection
now - Date/time to be associated with the update.
node - Node entry for the node being rescanned
target - Target interface (from IfCollector.getTarget())
ifaddr - Interface being updated.
protocols - Protocols supported by the interface.
snmpc - SNMP collector or null if SNMP not supported.
doesSnmp - Indicates that the interface supports SNMP
Throws:
java.sql.SQLException - if there is a problem updating the ipInterface table.

deleteDuplicateNode

private void deleteDuplicateNode(java.sql.Connection dbc,
                                 DbNodeEntry duplicateNode)
                          throws java.sql.SQLException
This method is responsible to delete any interface associated with the duplicate node, delete any entry left in ifservices table and snmpinterface table for the duplicate node, and make the node as 'deleted'.

Parameters:
dbc - Database Connection
duplicateNode - Duplicate node to delete.
Throws:
java.sql.SQLException

isDuplicateInterface

private boolean isDuplicateInterface(java.sql.Connection dbc,
                                     java.net.InetAddress ifaddr,
                                     int nodeId)
                              throws java.sql.SQLException
This method verify if an ipaddress is existing in other node except in the updating node.

Parameters:
dbc - Database Connection
ifaddr - Ip address being verified.
nodeId - Node Id of the node being rescanned
Throws:
java.sql.SQLException

updateInterfaceInfo

private void updateInterfaceInfo(java.sql.Connection dbc,
                                 java.util.Date now,
                                 DbNodeEntry node,
                                 DbIpInterfaceEntry dbIpIfEntry,
                                 IfSnmpCollector snmpc,
                                 boolean isNewIpEntry,
                                 boolean isReparented,
                                 boolean doesSnmp)
                          throws java.sql.SQLException
This method is responsible for updating the ipinterface table entry for a specific interface.

Parameters:
dbc - Database Connection.
now - Date/time to be associated with the update.
node - Node entry for the node being rescanned.
dbIpIfEntry - interface entry of the updating interface.
snmpc - SNMP collector or null if SNMP not supported.
isNewIpEntry - if dbIpIfEntry is a new entry.
isReparented - if dbIpIfentry is reparented.
doesSnmp - if node supports SNMP.
Throws:
java.sql.SQLException - if there is a problem updating the ipinterface table.

updateServiceInfo

private void updateServiceInfo(java.sql.Connection dbc,
                               DbNodeEntry node,
                               DbIpInterfaceEntry dbIpIfEntry,
                               boolean isNewIpEntry,
                               java.util.List protocols)
                        throws java.sql.SQLException
This method is responsible for updating the ifservices table entry for a specific interface.

Parameters:
dbc - Database Connection.
node - Node entry for the node being rescanned.
dbIpIfEntry - interface entry of the updating interface.
isNewIpEntry - if the dbIpIfEntry is a new entry.
protocols - Protocols supported by the interface.
Throws:
java.sql.SQLException - if there is a problem updating the ifservices table.

updateServicesOnForcedRescan

private void updateServicesOnForcedRescan(DbNodeEntry node,
                                          DbIpInterfaceEntry dbIpIfEntry,
                                          DbIfServiceEntry[] dbSupportedServices)
                                   throws java.sql.SQLException
This method is responsible for updating the status of services for an interface during a forced rescan

Parameters:
node - Node entry for the node being rescanned
dbIpIfEntry - interface entry of the updating interface
dbSupportedServices - services on the updating interface
Throws:
java.sql.SQLException - if there is a problem updating the snmpInterface table.

updateSnmpInfo

private void updateSnmpInfo(java.sql.Connection dbc,
                            DbNodeEntry node,
                            DbIpInterfaceEntry dbIpIfEntry,
                            IfSnmpCollector snmpc)
                     throws java.sql.SQLException
This method is responsible for updating the snmpInterface table entry for a specific interface.

Parameters:
dbc - Database Connection
node - Node entry for the node being rescanned
dbIpIfEntry - interface entry of the updating interface
snmpc - SNMP collector or null if SNMP not supported.
Throws:
java.sql.SQLException - if there is a problem updating the snmpInterface table.

isDuplicateNode

private boolean isDuplicateNode(java.sql.Connection dbc,
                                DbNodeEntry suspectNode,
                                IfSnmpCollector snmpc)
This method checks if a suspect node entry is a duplicate node to the updating node by verify if each interface in the suspect node is contained in the ipAddrTable of the updating node.

Parameters:
dbc - Database connection
suspectNode - the suspect node to verify duplication.
snmpc - the SNMP collection of the updating node.

addSupportedProtocols

private void addSupportedProtocols(DbNodeEntry node,
                                   DbIpInterfaceEntry ipIfEntry,
                                   java.util.List protocols,
                                   boolean addrUnmanaged,
                                   int ifIndex,
                                   Package ipPkg)
                            throws java.sql.SQLException
Responsible for iterating inserting an entry into the ifServices table for each protocol supported by the interface.

Parameters:
node - Node entry
ipIfEntry - DbIpInterfaceEntry object
protocols - List of supported protocols
addrUnmanaged - Boolean flag indicating if interface is managed or unmanaged according to the Capsd configuration.
ifIndex - Interface index or -1 if index is not known
ipPkg - Poller package to which the interface belongs
Throws:
java.sql.SQLException - if an error occurs adding interfaces to the ipInterface table.

reparentInterface

private void reparentInterface(java.sql.Connection dbc,
                               java.net.InetAddress ifAddr,
                               int ifIndex,
                               int newNodeId,
                               int oldNodeId)
                        throws java.sql.SQLException
This method is responsible for reparenting an interface's database table entries under its new node identifier. The following tables are updated: ipInterface snmpInterface ifServices

Parameters:
dbc - Database connection
ifAddr - Interface to be reparented.
newNodeId - Interface's new node identifier
oldNodeId - Interfaces' old node identifier
Throws:
java.sql.SQLException - if a database error occurs during reparenting.

buildLBSnmpAddressList

private static java.util.List buildLBSnmpAddressList(java.util.Map collectorMap,
                                                     IfSnmpCollector snmpc)
Builds a list of InetAddress objects representing each of the interfaces from the collector map object which support SNMP and have a valid ifIndex and have an IfType of loopback. This is part of a feature to choose a non 127.*.*.* loopback address as the primary SNMP interface.

Parameters:
collectorMap - Map of IfCollector objects containing data collected from all of the node's interfaces.
snmpc - Reference to SNMP collection object
Returns:
List of InetAddress objects.

buildSnmpAddressList

private static java.util.List buildSnmpAddressList(java.util.Map collectorMap,
                                                   IfSnmpCollector snmpc)
Builds a list of InetAddress objects representing each of the interfaces from the collector map object which support SNMP and have a valid ifIndex.

Parameters:
collectorMap - Map of IfCollector objects containing data collected from all of the node's interfaces.
snmpc - Reference to SNMP collection object
Returns:
List of InetAddress objects.

determinePrimaryIpInterface

private java.net.InetAddress determinePrimaryIpInterface(java.util.Map collectorMap)
This method is responsible for determining the primary IP interface for the node being rescanned.

Parameters:
collectorMap - Map of IfCollector objects containing data collected from all of the node's interfaces.
Returns:
InetAddress The primary IP interface for the node or null if a primary interface for the node could not be determined.

setNodeLabelAndSmbInfo

private void setNodeLabelAndSmbInfo(java.util.Map collectorMap,
                                    DbNodeEntry dbNodeEntry,
                                    DbNodeEntry currNodeEntry,
                                    java.net.InetAddress currPrimarySnmpIf)
Primarily, this method is responsible for assigning the node's nodeLabel value using information collected from the node's various interfaces. Additionally, if the node talks NetBIOS/SMB, then the node's NetBIOS name and operating system fields are assigned.

Parameters:
collectorMap - Map of IfCollector objects, one per interface.
dbNodeEntry - Node entry, as it exists in the database.
currNodeEntry - Current node entry, as collected during the current rescan.
currPrimarySnmpIf - Primary SNMP interface, as determined from the collection retrieved during the current rescan.

isNodeDeleted

private boolean isNodeDeleted(java.sql.Connection dbc,
                              int nodeId)
                       throws java.sql.SQLException
Utility method used to determine if the specified node has been marked as deleted in the node table.

Parameters:
dbc - Database connection.
nodeId - Node identifier to check
Returns:
TRUE if node has been marked as deleted, FALSE otherwise.
Throws:
java.sql.SQLException

isInterfaceAlias

private boolean isInterfaceAlias(java.net.InetAddress ipAddr,
                                 IfSnmpCollector snmpc)
Determines if the passed InetAddress object represents an interface alias. The interface is an alias if the IpAddrTable collected from it via SNMP does not contain itself.

Parameters:
ipAddr - Address of interface to be tested
snmpc - IfSnmpCollector object containing SNMP collected ifTable and ipAddrTable information.
Returns:
TRUE if the provided IP address is an alias, FALSE otherwise.

areDbInterfacesInSnmpCollection

private boolean areDbInterfacesInSnmpCollection(DbIpInterfaceEntry[] dbInterfaces,
                                                IfSnmpCollector snmpc)
This method is used to verify if each interface on a node stored in the database is in the specified SNMP data collection.

Parameters:
dbInterfaces - the ipInterfaces on a node stored in the database
snmpc - IfSnmpCollector object containing SNMP collected ipAddrTable information.
Returns:
True if each ipInterface is contained in the ipAddrTable of the specified SNMP collection.

run

public void run()
This is where all the work of the class is done.

Specified by:
run in interface java.lang.Runnable

scanPrimarySnmpInterface

private boolean scanPrimarySnmpInterface(org.apache.log4j.Category log,
                                         DbIpInterfaceEntry[] dbInterfaces,
                                         java.util.Map collectorMap,
                                         java.util.Set probedAddrs)

updatePrimarySnmpInterface

private java.net.InetAddress updatePrimarySnmpInterface(java.sql.Connection dbc,
                                                        DbNodeEntry dbNodeEntry,
                                                        java.util.Map collectorMap)
                                                 throws java.sql.SQLException
Throws:
java.sql.SQLException

findSnmpCollector

private IfSnmpCollector findSnmpCollector(java.util.Map collectorMap)
Parameters:
collectorMap -
Returns:

getInterfaces

private DbIpInterfaceEntry[] getInterfaces(DbNodeEntry dbNodeEntry)

getNode

private DbNodeEntry getNode()

generateSnmpDataCollectionEvents

private void generateSnmpDataCollectionEvents(DbNodeEntry nodeEntry,
                                              java.util.List oldPriIfs,
                                              java.net.InetAddress primarySnmpIf)
Determines if any SNMP data collection related events need to be generated based upon the results of the current rescan. If necessary will generate one of the following events: 'reinitializePrimarySnmpInterface' 'primarySnmpInterfaceChanged'

Parameters:
nodeEntry - DbNodeEntry object of the node being rescanned.
oldPriIfs - List of Previous primary SNMP interface(s) (from the DB).
primarySnmpIf - Primary SNMP interface as determined by the current rescan.

createNodeLabelChangedEvent

private void createNodeLabelChangedEvent(DbNodeEntry updatedEntry,
                                         DbNodeEntry originalEntry)
This method is responsible for generating a nodeLabelChanged event and adding it to the event list.

Parameters:
updatedEntry - Updated node entry object
originalEntry - Original node entry object

createNodeInfoChangedEvent

private void createNodeInfoChangedEvent(DbNodeEntry updatedEntry,
                                        DbNodeEntry originalEntry)
This method is responsible for generating a nodeInfoChanged event and adding it to the event list.

Parameters:
updatedEntry - Updated node entry object
originalEntry - Original node entry object

createPrimarySnmpInterfaceChangedEvent

private void createPrimarySnmpInterfaceChangedEvent(int nodeId,
                                                    java.net.InetAddress newPrimaryIf,
                                                    java.net.InetAddress oldPrimaryIf)
This method is responsible for generating a primarySnmpInterfaceChanged event and adding it to the event list.

Parameters:
nodeId - Nodeid of node being rescanned.
newPrimaryIf - new primary SNMP interface address
oldPrimaryIf - old primary SNMP interface address

createInterfaceIndexChangedEvent

private void createInterfaceIndexChangedEvent(DbIpInterfaceEntry updatedEntry,
                                              DbIpInterfaceEntry originalEntry)
This method is responsible for generating a interfaceIndexChanged event and adding it to the event list.

Parameters:
updatedEntry - updated IP interface database entry
originalEntry - original IP interface database entry

createIpHostNameChangedEvent

private void createIpHostNameChangedEvent(DbIpInterfaceEntry updatedEntry,
                                          DbIpInterfaceEntry originalEntry)
This method is responsible for generating an ipHostNameChanged event and adding it to the event list.

Parameters:
updatedEntry - updated IP interface database entry
originalEntry - original IP interface database entry

createInterfaceReparentedEvent

private void createInterfaceReparentedEvent(DbNodeEntry newNode,
                                            int oldNodeId,
                                            java.net.InetAddress reparentedIf)
This method is responsible for generating a interfaceReparented event and adding it to the event list.

Parameters:
newNode - Entry of node under which the interface was added.
oldNodeId - Node identifier of node from which the interface was removed.
reparentedIf - Reparented interface

createDuplicateNodeDeletedEvent

private void createDuplicateNodeDeletedEvent(DbNodeEntry deletedNode)
This method is responsible for generating a duplicateNodeDeleted event and adding it to the event list.

Parameters:
deletedNode - Entry of duplciate node which was deleted.

createNodeGainedInterfaceEvent

private void createNodeGainedInterfaceEvent(DbIpInterfaceEntry ifEntry)
This method is responsible for generating a nodeGainedInterface event and adding it to the event list.

Parameters:
ifEntry - Entry of new interface.

createDuplicateIpAddressEvent

private void createDuplicateIpAddressEvent(DbIpInterfaceEntry ifEntry)
This method is responsible for generating a duplicateIpAddress event and adding it to the event list.

Parameters:
ifEntry - Entry of new interface.

createNodeGainedServiceEvent

private void createNodeGainedServiceEvent(DbNodeEntry nodeEntry,
                                          DbIpInterfaceEntry ifEntry,
                                          java.lang.String svcName)
This method is responsible for generating a nodeGainedService event and adding it to the event list.

Parameters:
nodeEntry - Entry of node which has gained a service
ifEntry - Entry of interface which has gained a service
svcName - Service name

createSuspendPollingServiceEvent

private void createSuspendPollingServiceEvent(DbNodeEntry nodeEntry,
                                              DbIpInterfaceEntry ifEntry,
                                              java.lang.String svcName)
This method is responsible for generating a suspendPollingService event and adding it to the event list.

Parameters:
nodeEntry - Entry of node for which a service is to be polled
ifEntry - Entry of interface which a service is to be polled
svcName - Service name

createResumePollingServiceEvent

private void createResumePollingServiceEvent(DbNodeEntry nodeEntry,
                                             DbIpInterfaceEntry ifEntry,
                                             java.lang.String svcName)
This method is responsible for generating a resumePollingService event and adding it to the event list.

Parameters:
nodeEntry - Entry of node for which a service is to be polled
ifEntry - Entry of interface which a service is to be polled
svcName - Service name

createSnmpConflictsWithDbEvent

private void createSnmpConflictsWithDbEvent(DbNodeEntry nodeEntry)
This method is responsible for generating a snmpConflictsWithDb event and adding it to the event list.

Parameters:
nodeEntry - Entry of node for which a conflict exits

createInterfaceSupportsSNMPEvent

private void createInterfaceSupportsSNMPEvent(DbIpInterfaceEntry ifEntry)
This method is responsible for generating a interfaceSupportsSNMPEvent event and adding it to the event list.

Parameters:
ifEntry - Entry of interface which has gained a service

createReinitializePrimarySnmpInterfaceEvent

private void createReinitializePrimarySnmpInterfaceEvent(int nodeId,
                                                         java.net.InetAddress primarySnmpIf)
This method is responsible for generating a reinitializePrimarySnmpInterface event and adding it to the event list.

Parameters:
nodeId - Nodeid of node being rescanned.
primarySnmpIf - Primary SNMP interface address.

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.