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 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 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 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()
           
 CollectdConfigFactory getCollectdConfig()
           
 int getInterfaceDbNodeId(Connection dbConn, InetAddress ifAddress, int ifIndex)
           
 String getNextSvcIdSql()
           
 OpennmsServerConfigFactory getOpennmsServerConfig()
           
 PollerConfig getPollerConfig()
           
 Integer getServiceId(String name)
          Returns the service ID from the service table that was loaded during class initialization for the specified name.
 String getServiceName(Integer id)
          Returns the service name from the service table that was loaded during class initialization for the specified ID.
 boolean isInterfaceInDB(Connection dbConn, InetAddress ifAddress)
           
 boolean isInterfaceInDB(InetAddress ifAddress)
           
 void setCapsdConfig(CapsdConfig capsdConfig)
           
 void setCollectdConfig(CollectdConfigFactory collectdConfigFactory)
           
 void setJdbcTemplate(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)
           
 void setNextSvcIdSql(String nextSvcIdSql)
           
 void setOpennmsServerConfig(OpennmsServerConfigFactory serverConfigFactory)
           
 void setPollerConfig(PollerConfig pollerConfig)
           
 void syncManagementState()
          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 syncManagementState(Connection conn)
           
 void syncServices()
          This method is responsible for sync'ing the content of the 'service' table with the protocols listed in the caspd-configuration.xml file.
 void syncServices(Connection conn)
           
 List<String> syncServicesTable()
          Synchronize configured services list with the database.
 List<String> syncServicesTable(Connection conn)
           
 void syncSnmpPrimaryState()
          Responsible for syncing up the 'isPrimarySnmp' field of the ipInterface table based on the capsd and collectd configurations.
 void syncSnmpPrimaryState(Connection conn)
           
 
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 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 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 Integer getServiceId(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 String getServiceName(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()
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

syncServices

public void syncServices(Connection conn)
                  throws SQLException
Throws:
SQLException

syncServicesTable

public List<String> syncServicesTable()
Description copied from interface: CapsdDbSyncer
Synchronize configured services list with the database.

Specified by:
syncServicesTable in interface CapsdDbSyncer

syncServicesTable

public List<String> syncServicesTable(Connection conn)
                               throws SQLException
Throws:
SQLException

syncManagementState

public void syncManagementState()
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

syncManagementState

public void syncManagementState(Connection conn)
                         throws SQLException
Throws:
SQLException

syncSnmpPrimaryState

public void syncSnmpPrimaryState()
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

syncSnmpPrimaryState

public void syncSnmpPrimaryState(Connection conn)
                          throws SQLException
Throws:
SQLException

getCapsdConfig

public CapsdConfig getCapsdConfig()

setCapsdConfig

public void setCapsdConfig(CapsdConfig capsdConfig)

getOpennmsServerConfig

public OpennmsServerConfigFactory getOpennmsServerConfig()

setOpennmsServerConfig

public void setOpennmsServerConfig(OpennmsServerConfigFactory serverConfigFactory)

getPollerConfig

public PollerConfig getPollerConfig()

setPollerConfig

public void setPollerConfig(PollerConfig pollerConfig)

getCollectdConfig

public CollectdConfigFactory getCollectdConfig()

setCollectdConfig

public void setCollectdConfig(CollectdConfigFactory collectdConfigFactory)

afterPropertiesSet

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

getInterfaceDbNodeId

public int getInterfaceDbNodeId(Connection dbConn,
                                InetAddress ifAddress,
                                int ifIndex)
                         throws SQLException
Throws:
SQLException

isInterfaceInDB

public boolean isInterfaceInDB(InetAddress ifAddress)
Specified by:
isInterfaceInDB in interface CapsdDbSyncer

isInterfaceInDB

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

setNextSvcIdSql

public void setNextSvcIdSql(String nextSvcIdSql)

getNextSvcIdSql

public String getNextSvcIdSql()

setJdbcTemplate

public void setJdbcTemplate(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)


Copyright © 2009. All Rights Reserved.