Package org.opennms.netmgt.dao.hibernate
Class InterfaceToNodeCacheDaoImpl
- java.lang.Object
-
- org.opennms.netmgt.dao.api.AbstractInterfaceToNodeCache
-
- org.opennms.netmgt.dao.hibernate.InterfaceToNodeCacheDaoImpl
-
- All Implemented Interfaces:
InterfaceToNodeCache
public class InterfaceToNodeCacheDaoImpl extends AbstractInterfaceToNodeCache implements InterfaceToNodeCache
This class represents a singular instance that is used to map IP addresses to known nodes.- Author:
- Seth, Johan Edstrom, Brian Weaver , Tarus Balog , OpenNMS
-
-
Constructor Summary
Constructors Constructor Description InterfaceToNodeCacheDaoImpl()
InterfaceToNodeCacheDaoImpl(long refreshRate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Should only be used for testing.void
dataSourceSync()
Clears and synchronizes the internal known IP address cache with the current information contained in the database.void
destroy()
IpInterfaceDao
getIpInterfaceDao()
NodeDao
getNodeDao()
Iterable<Integer>
getNodeId(String location, InetAddress address)
Returns the nodeid for the IP Addressvoid
init()
void
removeInterfacesForNode(int nodeId)
boolean
removeNodeId(String location, InetAddress address, int nodeId)
Removes an address from the node ID map.void
setIpInterfaceDao(IpInterfaceDao ipInterfaceDao)
void
setNodeDao(NodeDao nodeDao)
boolean
setNodeId(String location, InetAddress addr, int nodeid)
Sets the IP Address and Node ID in the Map.int
size()
-
Methods inherited from class org.opennms.netmgt.dao.api.AbstractInterfaceToNodeCache
getFirstNodeId, getInstance, setInstance
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.opennms.netmgt.dao.api.InterfaceToNodeCache
getFirstNodeId
-
-
-
-
Method Detail
-
init
@PostConstruct public void init()
-
destroy
@PreDestroy public void destroy()
-
getNodeDao
public NodeDao getNodeDao()
-
setNodeDao
public void setNodeDao(NodeDao nodeDao)
-
getIpInterfaceDao
public IpInterfaceDao getIpInterfaceDao()
-
setIpInterfaceDao
public void setIpInterfaceDao(IpInterfaceDao ipInterfaceDao)
-
dataSourceSync
@Transactional public void dataSourceSync()
Clears and synchronizes the internal known IP address cache with the current information contained in the database. To synchronize the cache the method opens a new connection to the database, loads the address, and then closes it's connection.- Specified by:
dataSourceSync
in interfaceInterfaceToNodeCache
- Throws:
SQLException
- Thrown if the connection cannot be created or a database error occurs.
-
getNodeId
public Iterable<Integer> getNodeId(String location, InetAddress address)
Returns the nodeid for the IP AddressIf multiple nodes hav assigned interfaces with the same IP, this returns all known nodes sorted by the interface management priority.
- Specified by:
getNodeId
in interfaceInterfaceToNodeCache
- Parameters:
address
- The IP Address to query.- Returns:
- The node ID of the IP Address if known.
-
setNodeId
@Transactional public boolean setNodeId(String location, InetAddress addr, int nodeid)
Sets the IP Address and Node ID in the Map.- Specified by:
setNodeId
in interfaceInterfaceToNodeCache
- Parameters:
addr
- The IP Address to add.nodeid
- The Node ID to add.- Returns:
- The nodeid if it existed in the map.
-
removeNodeId
public boolean removeNodeId(String location, InetAddress address, int nodeId)
Removes an address from the node ID map.- Specified by:
removeNodeId
in interfaceInterfaceToNodeCache
- Parameters:
address
- The address to remove from the node ID map.- Returns:
- The nodeid that was in the map.
-
size
public int size()
- Specified by:
size
in interfaceInterfaceToNodeCache
-
clear
public void clear()
Description copied from interface:InterfaceToNodeCache
Should only be used for testing.- Specified by:
clear
in interfaceInterfaceToNodeCache
-
removeInterfacesForNode
public void removeInterfacesForNode(int nodeId)
- Specified by:
removeInterfacesForNode
in interfaceInterfaceToNodeCache
-
-