org.opennms.netmgt.capsd
Class JdbcCapsdDbSyncer

java.lang.Object
  extended by org.opennms.netmgt.capsd.JdbcCapsdDbSyncer
All Implemented Interfaces:
CapsdDbSyncer, org.springframework.beans.factory.InitializingBean

public class JdbcCapsdDbSyncer
extends java.lang.Object
implements org.springframework.beans.factory.InitializingBean, CapsdDbSyncer


Nested Class Summary
protected static class JdbcCapsdDbSyncer.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.
 
Field Summary
static java.lang.String RETRIEVE_IPADDR_NODEID_SQL
          The SQL statement used to determine if an IP address is already in the ipInterface table and if so what its parent nodeid is.
static java.lang.String RETRIEVE_IPADDR_SQL
          The SQL statement used to determine if an IP address is already in the ipInterface table and there is known.
 
Constructor Summary
JdbcCapsdDbSyncer()
           
 
Method Summary
 void afterPropertiesSet()
           
 CapsdConfig getCapsdConfig()
           
 org.opennms.netmgt.config.CollectdConfigFactory getCollectdConfig()
           
 int getInterfaceDbNodeId(java.sql.Connection dbConn, java.net.InetAddress ifAddress, int ifIndex)
           
 java.lang.String getNextSvcIdSql()
           
 org.opennms.netmgt.config.OpennmsServerConfigFactory getOpennmsServerConfig()
           
 PollerConfig getPollerConfig()
           
 java.lang.Integer getServiceId(java.lang.String name)
          Returns the service ID from the service table that was loaded during class initialization for the specified name.
 java.lang.String getServiceName(java.lang.Integer id)
          Returns the service name from the service table that was loaded during class initialization for the specified ID.
 void init()
           
 boolean isInterfaceInDB(java.sql.Connection dbConn, java.net.InetAddress ifAddress)
           
 void setCapsdConfig(CapsdConfig capsdConfig)
           
 void setCollectdConfig(org.opennms.netmgt.config.CollectdConfigFactory collectdConfigFactory)
           
 void setNextSvcIdSql(java.lang.String nextSvcIdSql)
           
 void setOpennmsServerConfig(org.opennms.netmgt.config.OpennmsServerConfigFactory serverConfigFactory)
           
 void setPollerConfig(PollerConfig pollerConfig)
           
 void syncManagementState(java.sql.Connection conn)
          Responsible for syncing up the 'isManaged' field of the ipInterface table and the 'status' field of the ifServices table based on the capsd and poller configurations.
 void syncServices(java.sql.Connection conn)
          This method is responsible for sync'ing the content of the 'service' table with the protocols listed in the caspd-configuration.xml file.
 java.util.List<java.lang.String> syncServicesTable(java.sql.Connection conn)
          Synchronize configured services list with the database.
 void syncSnmpPrimaryState(java.sql.Connection conn)
          Responsible for syncing up the 'isPrimarySnmp' field of the ipInterface table based on the capsd and collectd configurations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RETRIEVE_IPADDR_NODEID_SQL

public static final java.lang.String RETRIEVE_IPADDR_NODEID_SQL
The SQL statement used to determine if an IP address is already in the ipInterface table and if so what its parent nodeid is.

See Also:
Constant Field Values

RETRIEVE_IPADDR_SQL

public static final java.lang.String RETRIEVE_IPADDR_SQL
The SQL statement used to determine if an IP address is already in the ipInterface table and there is known.

See Also:
Constant Field Values
Constructor Detail

JdbcCapsdDbSyncer

public JdbcCapsdDbSyncer()
Method Detail

getServiceId

public java.lang.Integer getServiceId(java.lang.String name)
Returns the service ID from the service table that was loaded during class initialization for the specified name.

Specified by:
getServiceId in interface CapsdDbSyncer
Parameters:
name - the name of the service to look up
Returns:
The result of the lookup, or null if a matching service name wasn't found

getServiceName

public java.lang.String getServiceName(java.lang.Integer id)
Returns the service name from the service table that was loaded during class initialization for the specified ID.

Specified by:
getServiceName in interface CapsdDbSyncer
Parameters:
name - the ID of the service to look up
Returns:
The result of the lookup, or null if a matching service ID wasn't found

syncServices

public void syncServices(java.sql.Connection conn)
                  throws java.sql.SQLException
Description copied from interface: CapsdDbSyncer
This method is responsible for sync'ing the content of the 'service' table with the protocols listed in the caspd-configuration.xml file. First a list of services currently contained in the 'service' table in the database is built. Next, the list of services defined in capsd-configuration.xml is iterated over and if any services are defined but do not yet exist in the 'service' table they are added to the table. Finally, the list of services in the database is iterated over and if any service exists in the database but is no longer listed in the capsd-configuration.xml file then that the following occurs: 1. All 'outage' table entries which refer to the service are deleted. 2. All 'ifServices' table entries which refer to the service are deleted. Note that the 'service' table entry will remain in the database since events most likely exist which refer to the service.

Specified by:
syncServices in interface CapsdDbSyncer
Throws:
java.sql.SQLException

syncServicesTable

public java.util.List<java.lang.String> syncServicesTable(java.sql.Connection conn)
                                                   throws java.sql.SQLException
Description copied from interface: CapsdDbSyncer
Synchronize configured services list with the database.

Specified by:
syncServicesTable in interface CapsdDbSyncer
Throws:
java.sql.SQLException

syncManagementState

public void syncManagementState(java.sql.Connection conn)
                         throws java.sql.SQLException
Description copied from interface: CapsdDbSyncer
Responsible for syncing up the 'isManaged' field of the ipInterface table and the 'status' field of the ifServices table based on the capsd and poller configurations. Note that the 'sync' only takes place for interfaces and services that are not deleted or force unmanaged.
 Here is how the statuses are set:
  If an interface is 'unmanaged' based on the capsd configuration,
      ipManaged='U' and status='U'
 
  If an interface is 'managed' based on the capsd configuration,
    1. If the interface is not in any pacakge, ipManaged='N' and status ='N'
    2. If the interface in atleast one package but the service is not polled by
       by any of the packages, ipManaged='M' and status='N'
    3. If the interface in atleast one package and the service is polled by a
       package that this interface belongs to, ipManaged='M' and status'=A'
 
 

Specified by:
syncManagementState in interface CapsdDbSyncer
Parameters:
conn - Connection to the database.
Throws:
java.sql.SQLException - Thrown if an error occurs while syncing the database.

syncSnmpPrimaryState

public void syncSnmpPrimaryState(java.sql.Connection conn)
                          throws java.sql.SQLException
Description copied from interface: CapsdDbSyncer
Responsible for syncing up the 'isPrimarySnmp' field of the ipInterface table based on the capsd and collectd configurations. Note that the 'sync' only takes place for interfaces that are not deleted. Also, it will prefer a loopback interface over other interfaces.

Specified by:
syncSnmpPrimaryState in interface CapsdDbSyncer
Parameters:
conn - Connection to the database.
Throws:
java.sql.SQLException - Thrown if an error occurs while syncing the database.

init

public void init()

getCapsdConfig

public CapsdConfig getCapsdConfig()

setCapsdConfig

public void setCapsdConfig(CapsdConfig capsdConfig)

getOpennmsServerConfig

public org.opennms.netmgt.config.OpennmsServerConfigFactory getOpennmsServerConfig()

setOpennmsServerConfig

public void setOpennmsServerConfig(org.opennms.netmgt.config.OpennmsServerConfigFactory serverConfigFactory)

getPollerConfig

public PollerConfig getPollerConfig()

setPollerConfig

public void setPollerConfig(PollerConfig pollerConfig)

getCollectdConfig

public org.opennms.netmgt.config.CollectdConfigFactory getCollectdConfig()

setCollectdConfig

public void setCollectdConfig(org.opennms.netmgt.config.CollectdConfigFactory collectdConfigFactory)

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean

getInterfaceDbNodeId

public int getInterfaceDbNodeId(java.sql.Connection dbConn,
                                java.net.InetAddress ifAddress,
                                int ifIndex)
                         throws java.sql.SQLException
Throws:
java.sql.SQLException

isInterfaceInDB

public boolean isInterfaceInDB(java.sql.Connection dbConn,
                               java.net.InetAddress ifAddress)
                        throws java.sql.SQLException
Specified by:
isInterfaceInDB in interface CapsdDbSyncer
Throws:
java.sql.SQLException

setNextSvcIdSql

public void setNextSvcIdSql(java.lang.String nextSvcIdSql)

getNextSvcIdSql

public java.lang.String getNextSvcIdSql()


Copyright © 2007. All Rights Reserved.