org.opennms.netmgt.dao.support
Class DefaultResourceDao

java.lang.Object
  extended by org.opennms.netmgt.dao.support.DefaultResourceDao
All Implemented Interfaces:
ResourceDao, org.springframework.beans.factory.InitializingBean

public class DefaultResourceDao
extends Object
implements ResourceDao, org.springframework.beans.factory.InitializingBean

Encapsulates all SNMP performance reporting for the web user interface.

Author:
Seth Leger , Lawrence Karnowski , OpenNMS , DJ Gregor

Field Summary
static String INTERFACE_GRAPH_TYPE
          Constant INTERFACE_GRAPH_TYPE="interface"
static String RESPONSE_DIRECTORY
          Constant RESPONSE_DIRECTORY="response"
static String SNMP_DIRECTORY
          Constant SNMP_DIRECTORY="snmp"
static String STRINGS_PROPERTIES_FILE_NAME
          File name to look for in a resource directory for string attributes.
 
Constructor Summary
DefaultResourceDao()
          Constructor for DefaultResourceDao.
 
Method Summary
 void afterPropertiesSet()
          afterPropertiesSet
static String decode(String string)
          Encapsulate the deprecated decode method to fix it in one place.
 List<OnmsResource> findDomainResources()
          Returns a list of resources for domains.
 List<OnmsResource> findNodeResources()
          Returns a list of resources for a node.
 List<OnmsResource> findTopLevelResources()
          findTopLevelResources
protected  OnmsResource getChildResource(OnmsResource parentResource, String resourceType, String resource)
          getChildResource
protected  List<OnmsResource> getChildResourceList(OnmsResource parentResource)
          getChildResourceList
 CollectdConfigFactory getCollectdConfig()
          getCollectdConfig
 DataCollectionConfig getDataCollectionConfig()
          getDataCollectionConfig
protected  OnmsResource getDomainEntityResource(String domain)
          getDomainEntityResource
protected  OnmsResource getForeignSourceNodeEntityResource(String resource)
          getForeignSourceNodeEntityResource
 LocationMonitorDao getLocationMonitorDao()
          getLocationMonitorDao
 NodeDao getNodeDao()
          getNodeDao
protected  OnmsResource getNodeEntityResource(String resource)
          getNodeEntityResource
 OnmsResource getResourceById(String id)
          Fetch a specific resource by string ID.
 OnmsResource getResourceForIpInterface(OnmsIpInterface ipInterface)
          getResourceForIpInterface
 OnmsResource getResourceForIpInterface(OnmsIpInterface ipInterface, OnmsLocationMonitor locMon)
          getResourceForIpInterface
 OnmsResource getResourceForNode(OnmsNode node)
          getResourceForNode
 List<OnmsResource> getResourceListById(String id)
          Fetch a specific list of resources by string ID.
 Collection<OnmsResourceType> getResourceTypes()
          getResourceTypes
 File getRrdDirectory()
          getRrdDirectory
 File getRrdDirectory(boolean verify)
          getRrdDirectory
protected  OnmsResource getTopLevelResource(String resourceType, String resource)
          getTopLevelResource
 void setCollectdConfig(CollectdConfigFactory collectdConfig)
          setCollectdConfig
 void setDataCollectionConfig(DataCollectionConfig dataCollectionConfig)
          setDataCollectionConfig
 void setLocationMonitorDao(LocationMonitorDao locationMonitorDao)
          setLocationMonitorDao
 void setNodeDao(NodeDao nodeDao)
          setNodeDao
 void setRrdDirectory(File rrdDirectory)
          setRrdDirectory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STRINGS_PROPERTIES_FILE_NAME

public static final String STRINGS_PROPERTIES_FILE_NAME
File name to look for in a resource directory for string attributes.

See Also:
Constant Field Values

INTERFACE_GRAPH_TYPE

public static final String INTERFACE_GRAPH_TYPE
Constant INTERFACE_GRAPH_TYPE="interface"

See Also:
Constant Field Values

RESPONSE_DIRECTORY

public static final String RESPONSE_DIRECTORY
Constant RESPONSE_DIRECTORY="response"

See Also:
Constant Field Values

SNMP_DIRECTORY

public static final String SNMP_DIRECTORY
Constant SNMP_DIRECTORY="snmp"

See Also:
Constant Field Values
Constructor Detail

DefaultResourceDao

public DefaultResourceDao()

Constructor for DefaultResourceDao.

Method Detail

setRrdDirectory

public void setRrdDirectory(File rrdDirectory)

setRrdDirectory

Parameters:
rrdDirectory - a File object.

getRrdDirectory

public File getRrdDirectory()

getRrdDirectory

Specified by:
getRrdDirectory in interface ResourceDao
Returns:
a File object.

getRrdDirectory

public File getRrdDirectory(boolean verify)

getRrdDirectory

Specified by:
getRrdDirectory in interface ResourceDao
Parameters:
verify - a boolean.
Returns:
a File object.

getDataCollectionConfig

public DataCollectionConfig getDataCollectionConfig()

getDataCollectionConfig

Returns:
a DataCollectionConfig object.

setDataCollectionConfig

public void setDataCollectionConfig(DataCollectionConfig dataCollectionConfig)

setDataCollectionConfig

Parameters:
dataCollectionConfig - a DataCollectionConfig object.

getNodeDao

public NodeDao getNodeDao()

getNodeDao

Returns:
a NodeDao object.

setNodeDao

public void setNodeDao(NodeDao nodeDao)

setNodeDao

Parameters:
nodeDao - a NodeDao object.

getCollectdConfig

public CollectdConfigFactory getCollectdConfig()

getCollectdConfig

Returns:
a CollectdConfigFactory object.

setCollectdConfig

public void setCollectdConfig(CollectdConfigFactory collectdConfig)

setCollectdConfig

Parameters:
collectdConfig - a CollectdConfigFactory object.

getLocationMonitorDao

public LocationMonitorDao getLocationMonitorDao()

getLocationMonitorDao

Returns:
a LocationMonitorDao object.

setLocationMonitorDao

public void setLocationMonitorDao(LocationMonitorDao locationMonitorDao)

setLocationMonitorDao

Parameters:
locationMonitorDao - a LocationMonitorDao object.

afterPropertiesSet

public void afterPropertiesSet()
                        throws IOException

afterPropertiesSet

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
IOException - if any.

getResourceTypes

public Collection<OnmsResourceType> getResourceTypes()

getResourceTypes

Specified by:
getResourceTypes in interface ResourceDao
Returns:
a Collection object.

getResourceById

public OnmsResource getResourceById(String id)
Fetch a specific resource by string ID.

Specified by:
getResourceById in interface ResourceDao
Parameters:
id - a String object.
Returns:
Resource or null if resource cannot be found.
Throws:
IllegalArgumentException - When the resource ID string does not match the expected regex pattern
org.springframework.orm.ObjectRetrievalFailureException - If any exceptions are thrown while searching for the resource

getResourceListById

public List<OnmsResource> getResourceListById(String id)
                                       throws IllegalArgumentException,
                                              org.springframework.orm.ObjectRetrievalFailureException
Fetch a specific list of resources by string ID.

Specified by:
getResourceListById in interface ResourceDao
Parameters:
id - a String object.
Returns:
Resources or null if resources cannot be found.
Throws:
IllegalArgumentException - When the resource ID string does not match the expected regex pattern
org.springframework.orm.ObjectRetrievalFailureException - If any exceptions are thrown while searching for the resource

getTopLevelResource

protected OnmsResource getTopLevelResource(String resourceType,
                                           String resource)
                                    throws org.springframework.orm.ObjectRetrievalFailureException

getTopLevelResource

Parameters:
resourceType - a String object.
resource - a String object.
Returns:
a OnmsResource object.
Throws:
org.springframework.orm.ObjectRetrievalFailureException

getChildResource

protected OnmsResource getChildResource(OnmsResource parentResource,
                                        String resourceType,
                                        String resource)

getChildResource

Parameters:
parentResource - a OnmsResource object.
resourceType - a String object.
resource - a String object.
Returns:
a OnmsResource object.

getChildResourceList

protected List<OnmsResource> getChildResourceList(OnmsResource parentResource)

getChildResourceList

Parameters:
parentResource - a OnmsResource object.
Returns:
a List object.

findNodeResources

public List<OnmsResource> findNodeResources()
Returns a list of resources for a node. XXX It does not currently fully check that an IP address that is found to have distributed response time data is in the database on the proper node so it can have false positives.

Specified by:
findNodeResources in interface ResourceDao
Returns:
a List object.

findDomainResources

public List<OnmsResource> findDomainResources()
Returns a list of resources for domains.

Specified by:
findDomainResources in interface ResourceDao
Returns:
a List object.

getNodeEntityResource

protected OnmsResource getNodeEntityResource(String resource)

getNodeEntityResource

Parameters:
resource - a String object.
Returns:
a OnmsResource object.

getForeignSourceNodeEntityResource

protected OnmsResource getForeignSourceNodeEntityResource(String resource)

getForeignSourceNodeEntityResource

Parameters:
resource - a String object.
Returns:
a OnmsResource object.

getDomainEntityResource

protected OnmsResource getDomainEntityResource(String domain)

getDomainEntityResource

Parameters:
domain - a String object.
Returns:
a OnmsResource object.

decode

public static String decode(String string)
Encapsulate the deprecated decode method to fix it in one place.

Parameters:
string - string to be decoded
Returns:
decoded string

getResourceForNode

public OnmsResource getResourceForNode(OnmsNode node)

getResourceForNode

Specified by:
getResourceForNode in interface ResourceDao
Parameters:
node - a OnmsNode object.
Returns:
a OnmsResource object.

getResourceForIpInterface

public OnmsResource getResourceForIpInterface(OnmsIpInterface ipInterface)
Description copied from interface: ResourceDao

getResourceForIpInterface

Specified by:
getResourceForIpInterface in interface ResourceDao
Parameters:
ipInterface - a OnmsIpInterface object.
Returns:
OnmsResource for the responseTime resource on the interface or null if the responseTime resource cannot be found for the given IP interface.

getResourceForIpInterface

public OnmsResource getResourceForIpInterface(OnmsIpInterface ipInterface,
                                              OnmsLocationMonitor locMon)
Description copied from interface: ResourceDao

getResourceForIpInterface

Specified by:
getResourceForIpInterface in interface ResourceDao
Parameters:
ipInterface - a OnmsIpInterface object.
locMon - a OnmsLocationMonitor object.
Returns:
OnmsResource for the distributedStatus resource on the interface or null if the distributedStatus resource cannot be found for the given IP interface.

findTopLevelResources

public List<OnmsResource> findTopLevelResources()

findTopLevelResources

Specified by:
findTopLevelResources in interface ResourceDao
Returns:
a List object.


Copyright © 2011. All Rights Reserved.