org.opennms.web.element
Class NetworkElementFactory

java.lang.Object
  extended by org.opennms.web.element.NetworkElementFactory

public class NetworkElementFactory
extends Object

The source for all network element business objects (nodes, interfaces, services). Encapsulates all lookup functionality for the network element business objects in one place. To use this factory to lookup network elements, you must first initialize the Vault with the database connection manager * and JDBC URL it will use. Call the init method to initialize the factory. After that, you can call any lookup methods.

Author:
Larry Karnowski , OpenNMS

Nested Class Summary
static class NetworkElementFactory.InterfaceComparator
           
 
Field Summary
protected static Map<Integer,String> serviceId2NameMap
          A mapping of service identifiers (integers) to service names (strings).
protected static Map<String,Integer> serviceName2IdMap
          A mapping of service names (strings) to service identifiers (integers).
 
Method Summary
protected static void augmentInterfacesWithSnmpData(Interface[] intfs, Connection conn)
           
static Node[] convertOnmsNodeCollectionToNodeArray(Collection<OnmsNode> ourNodes)
           
protected static void createServiceIdNameMaps()
           
static Interface[] getActiveInterfacesOnNode(int nodeId)
           
static DataLinkInterface[] getAllDataLinks()
           
static Interface[] getAllInterfaces()
           
static Interface[] getAllInterfaces(boolean includeSNMP)
           
static Interface[] getAllInterfacesOnNode(int nodeId)
           
static Node[] getAllNodes()
          Returns all non-deleted nodes.
static Node[] getAllNodes(int serviceId)
           
static Service[] getAllServices()
           
static AtInterface getAtInterface(int nodeID, String ipaddr)
           
static AtInterface[] getAtInterfacesFromPhysaddr(String AtPhysAddr)
           
protected static DataLinkInterface[] getDataLinks(int nodeID)
           
static DataLinkInterface[] getDataLinks(int nodeID, int ifindex)
           
protected static DataLinkInterface[] getDataLinksFromNodeParent(int nodeID)
           
protected static DataLinkInterface[] getDataLinksFromNodeParent(int nodeID, int ifindex)
           
static DataLinkInterface[] getDataLinksOnInterface(int nodeID, int ifindex)
           
static DataLinkInterface[] getDataLinksOnNode(int nodeID)
           
static String getHostname(String ipAddress)
          Resolve an IP address to a DNS hostname via the database.
static Interface getInterface(int ipInterfaceId)
           
static Interface getInterface(int nodeId, String ipAddress)
           
static Interface getInterface(int nodeId, String ipAddress, int ifindex)
           
static Interface[] getInterfacesWithIfAlias(int nodeId, String ifAlias)
          Returns all non-deleted Interfaces on the specified node that contain the given string in an ifAlias
static Interface[] getInterfacesWithIpAddress(String ipAddress)
           
protected static String getIpAddress(int nodeid)
           
protected static String getIpAddress(int nodeid, int ifindex)
           
static IpRouteInterface[] getIpRoute(int nodeID)
           
static IpRouteInterface[] getIpRoute(int nodeID, int ifindex)
           
static Set<Integer> getLinkedNodeIdOnNode(int nodeID)
           
static Set<Integer> getLinkedNodeIdOnNode(int nodeID, Connection conn)
           
static Set<Integer> getLinkedNodeIdOnNodes(Set<Integer> nodeIds, Connection conn)
           
static Node getNode(int nodeId)
           
static List<Integer> getNodeIdsWithIpLike(String iplike)
          Returns all non-deleted nodes with an IP address like the rule given.
static String getNodeLabel(int nodeId)
          Translate a node id into a human-readable node label.
static Node[] getNodesFromPhysaddr(String AtPhysAddr)
           
static Node[] getNodesLike(String nodeLabel)
          Returns all non-deleted nodes that have the given nodeLabel substring somewhere in their nodeLabel.
static Node[] getNodesLike(String nodeLabel, int serviceId)
           
static Node[] getNodesLikeAndIpLike(String nodeLabel, String iplike, int serviceId)
           
static Node[] getNodesWithCategories(NodeDao nodeDao, CategoryDao categoryDao, String[] categories1, boolean onlyNodesWithDownAggregateStatus)
           
static Node[] getNodesWithCategories(NodeDao nodeDao, CategoryDao categoryDao, String[] categories1, String[] categories2, boolean onlyNodesWithDownAggregateStatus)
           
static Node[] getNodesWithCategories(org.springframework.transaction.support.TransactionTemplate transTemplate, NodeDao nodeDao, CategoryDao categoryDao, String[] categories1, boolean onlyNodesWithDownAggregateStatus)
           
static Node[] getNodesWithCategories(org.springframework.transaction.support.TransactionTemplate transTemplate, NodeDao nodeDao, CategoryDao categoryDao, String[] categories1, String[] categories2, boolean onlyNodesWithDownAggregateStatus)
           
static Node[] getNodesWithIfAlias(String ifAlias)
          Returns all non-deleted nodes that contain the given string in an ifAlias
static Node[] getNodesWithIpLike(String iplike)
          Returns all non-deleted nodes with an IP address like the rule given.
static Node[] getNodesWithIpLike(String iplike, int serviceId)
           
static Node[] getNodesWithPhysAddr(String macAddr)
          Returns all non-deleted nodes that have the given mac.
static Node[] getNodesWithPhysAddrAtInterface(String macAddr)
          Returns all non-deleted nodes with a MAC address like the rule given from AtInterface.
static Node[] getNodesWithPhysAddrFromSnmpInterface(String macAddr)
          Returns all non-deleted nodes with a MAC address like the rule given from SnmpInterface.
static Node[] getNodesWithService(int serviceId)
          Returns all non-deleted nodes that have the given service.
static Service getService(int ifServiceId)
          Return the service specified by the node identifier, IP address, and service identifier.
static Service getService(int nodeId, String ipAddress, int serviceId)
          Return the service specified by the node identifier, IP address, and service identifier.
static int getServiceIdFromName(String serviceName)
           
static Map<Integer,String> getServiceIdToNameMap()
           
static String getServiceNameFromId(int serviceId)
           
static Map<String,Integer> getServiceNameToIdMap()
           
static Service[] getServicesOnInterface(int nodeId, String ipAddress)
           
static Service[] getServicesOnInterface(int nodeId, String ipAddress, boolean includeDeletions)
           
static Service[] getServicesOnNode(int nodeId)
          Get the list of all services on a given node.
static Service[] getServicesOnNode(int nodeId, int serviceId)
          Get the list of all instances of a specific service on a given node.
static StpInterface[] getStpInterface(int nodeID)
           
static StpInterface[] getStpInterface(int nodeID, int ifindex)
           
static StpNode[] getStpNode(int nodeID)
           
static Vlan[] getVlansOnNode(int nodeID)
           
protected static DataLinkInterface[] invertDataLinkInterface(DataLinkInterface[] nodes)
           
static boolean isBridgeNode(int nodeID)
           
static boolean isParentNode(int nodeID)
           
static boolean isRouteInfoNode(int nodeID)
           
static boolean nodeHasIfAliases(int nodeId)
          Returns true if node has any snmpIfAliases
protected static AtInterface[] rs2AtInterface(ResultSet rs)
          This method returns the data from the result set as an array of AtInterface objects.
protected static DataLinkInterface[] rs2DataLink(ResultSet rs)
          This method returns the data from the result set as an array of DataLinkInterface objects.
protected static Interface[] rs2Interfaces(ResultSet rs)
          This method returns the data from the result set as an vector of ipinterface objects.
protected static IpRouteInterface[] rs2IpRouteInterface(ResultSet rs)
          This method returns the data from the result set as an array of IpRouteInterface objects.
protected static Node[] rs2Nodes(ResultSet rs)
          This method returns the data from the result set as an array of Node objects.
protected static Service[] rs2Services(ResultSet rs)
           
protected static StpInterface[] rs2StpInterface(ResultSet rs)
          This method returns the data from the result set as an array of StpInterface objects.
protected static StpNode[] rs2StpNode(ResultSet rs)
          This method returns the data from the result set as an array of StpNode objects.
protected static Vlan[] rs2Vlan(ResultSet rs)
          This method returns the data from the result set as an array of StpNode objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serviceName2IdMap

protected static Map<String,Integer> serviceName2IdMap
A mapping of service names (strings) to service identifiers (integers).


serviceId2NameMap

protected static Map<Integer,String> serviceId2NameMap
A mapping of service identifiers (integers) to service names (strings).

Method Detail

getNodeLabel

public static String getNodeLabel(int nodeId)
                           throws SQLException
Translate a node id into a human-readable node label. Note these values are not cached.

Returns:
A human-readable node name or null if the node id given does not specify a real node.
Throws:
SQLException

getNode

public static Node getNode(int nodeId)
                    throws SQLException
Throws:
SQLException

getAllNodes

public static Node[] getAllNodes()
                          throws SQLException
Returns all non-deleted nodes.

Throws:
SQLException

getNodesLike

public static Node[] getNodesLike(String nodeLabel)
                           throws SQLException
Returns all non-deleted nodes that have the given nodeLabel substring somewhere in their nodeLabel.

Throws:
SQLException

getNodesWithIpLike

public static Node[] getNodesWithIpLike(String iplike)
                                 throws SQLException
Returns all non-deleted nodes with an IP address like the rule given.

Throws:
SQLException

getNodesWithService

public static Node[] getNodesWithService(int serviceId)
                                  throws SQLException
Returns all non-deleted nodes that have the given service.

Throws:
SQLException

getNodesWithPhysAddr

public static Node[] getNodesWithPhysAddr(String macAddr)
                                   throws SQLException
Returns all non-deleted nodes that have the given mac.

Throws:
SQLException

getNodesWithPhysAddrAtInterface

public static Node[] getNodesWithPhysAddrAtInterface(String macAddr)
                                              throws SQLException
Returns all non-deleted nodes with a MAC address like the rule given from AtInterface.

Throws:
SQLException

getNodesWithPhysAddrFromSnmpInterface

public static Node[] getNodesWithPhysAddrFromSnmpInterface(String macAddr)
                                                    throws SQLException
Returns all non-deleted nodes with a MAC address like the rule given from SnmpInterface.

Throws:
SQLException

getNodesWithIfAlias

public static Node[] getNodesWithIfAlias(String ifAlias)
                                  throws SQLException
Returns all non-deleted nodes that contain the given string in an ifAlias

Returns:
nodes the nodes with a matching ifAlias on one or more interfaces
Throws:
SQLException

getHostname

public static String getHostname(String ipAddress)
                          throws SQLException
Resolve an IP address to a DNS hostname via the database. If no hostname can be found, the given IP address is returned.

Throws:
SQLException

getInterface

public static Interface getInterface(int ipInterfaceId)
                              throws SQLException
Throws:
SQLException

getInterface

public static Interface getInterface(int nodeId,
                                     String ipAddress)
                              throws SQLException
Throws:
SQLException

getInterface

public static Interface getInterface(int nodeId,
                                     String ipAddress,
                                     int ifindex)
                              throws SQLException
Throws:
SQLException

getInterfacesWithIpAddress

public static Interface[] getInterfacesWithIpAddress(String ipAddress)
                                              throws SQLException
Throws:
SQLException

getInterfacesWithIfAlias

public static Interface[] getInterfacesWithIfAlias(int nodeId,
                                                   String ifAlias)
                                            throws SQLException
Returns all non-deleted Interfaces on the specified node that contain the given string in an ifAlias

Returns:
intfs the Interfaces with a matching ifAlias
Throws:
SQLException

nodeHasIfAliases

public static boolean nodeHasIfAliases(int nodeId)
                                throws SQLException
Returns true if node has any snmpIfAliases

Returns:
boolean true if node has any snmpIfAliases
Throws:
SQLException

getAllInterfacesOnNode

public static Interface[] getAllInterfacesOnNode(int nodeId)
                                          throws SQLException
Throws:
SQLException

getActiveInterfacesOnNode

public static Interface[] getActiveInterfacesOnNode(int nodeId)
                                             throws SQLException
Throws:
SQLException

getAllInterfaces

public static Interface[] getAllInterfaces()
                                    throws SQLException
Throws:
SQLException

getAllInterfaces

public static Interface[] getAllInterfaces(boolean includeSNMP)
                                    throws SQLException
Throws:
SQLException

getService

public static Service getService(int nodeId,
                                 String ipAddress,
                                 int serviceId)
                          throws SQLException
Return the service specified by the node identifier, IP address, and service identifier.

Note that if there are both an active service and historically deleted services with this (nodeid, ipAddress, serviceId) key, then the active service will be returned. If there are only deleted services, then the first deleted service will be returned.

Throws:
SQLException

getService

public static Service getService(int ifServiceId)
                          throws SQLException
Return the service specified by the node identifier, IP address, and service identifier.

Note that if there are both an active service and historically deleted services with this (nodeid, ipAddress, serviceId) key, then the active service will be returned. If there are only deleted services, then the first deleted service will be returned.

Throws:
SQLException

getAllServices

public static Service[] getAllServices()
                                throws SQLException
Throws:
SQLException

getServicesOnInterface

public static Service[] getServicesOnInterface(int nodeId,
                                               String ipAddress)
                                        throws SQLException
Throws:
SQLException

getServicesOnInterface

public static Service[] getServicesOnInterface(int nodeId,
                                               String ipAddress,
                                               boolean includeDeletions)
                                        throws SQLException
Throws:
SQLException

getServicesOnNode

public static Service[] getServicesOnNode(int nodeId)
                                   throws SQLException
Get the list of all services on a given node.

Throws:
SQLException

getServicesOnNode

public static Service[] getServicesOnNode(int nodeId,
                                          int serviceId)
                                   throws SQLException
Get the list of all instances of a specific service on a given node.

Throws:
SQLException

rs2Nodes

protected static Node[] rs2Nodes(ResultSet rs)
                          throws SQLException
This method returns the data from the result set as an array of Node objects.

Throws:
SQLException

rs2Interfaces

protected static Interface[] rs2Interfaces(ResultSet rs)
                                    throws SQLException
This method returns the data from the result set as an vector of ipinterface objects.

Throws:
SQLException

augmentInterfacesWithSnmpData

protected static void augmentInterfacesWithSnmpData(Interface[] intfs,
                                                    Connection conn)
                                             throws SQLException
Throws:
SQLException

rs2Services

protected static Service[] rs2Services(ResultSet rs)
                                throws SQLException
Throws:
SQLException

getServiceNameFromId

public static String getServiceNameFromId(int serviceId)
                                   throws SQLException
Throws:
SQLException

getServiceIdFromName

public static int getServiceIdFromName(String serviceName)
                                throws SQLException
Throws:
SQLException

getServiceIdToNameMap

public static Map<Integer,String> getServiceIdToNameMap()
                                                 throws SQLException
Throws:
SQLException

getServiceNameToIdMap

public static Map<String,Integer> getServiceNameToIdMap()
                                                 throws SQLException
Throws:
SQLException

createServiceIdNameMaps

protected static void createServiceIdNameMaps()
                                       throws SQLException
Throws:
SQLException

getNodesLikeAndIpLike

public static Node[] getNodesLikeAndIpLike(String nodeLabel,
                                           String iplike,
                                           int serviceId)
                                    throws SQLException
Throws:
SQLException

getNodesLike

public static Node[] getNodesLike(String nodeLabel,
                                  int serviceId)
                           throws SQLException
Throws:
SQLException

getNodesWithIpLike

public static Node[] getNodesWithIpLike(String iplike,
                                        int serviceId)
                                 throws SQLException
Throws:
SQLException

getAllNodes

public static Node[] getAllNodes(int serviceId)
                          throws SQLException
Throws:
SQLException

getAtInterfacesFromPhysaddr

public static AtInterface[] getAtInterfacesFromPhysaddr(String AtPhysAddr)
                                                 throws SQLException
Throws:
SQLException

getNodesFromPhysaddr

public static Node[] getNodesFromPhysaddr(String AtPhysAddr)
                                   throws SQLException
Throws:
SQLException

getAtInterface

public static AtInterface getAtInterface(int nodeID,
                                         String ipaddr)
                                  throws SQLException
Throws:
SQLException

getIpRoute

public static IpRouteInterface[] getIpRoute(int nodeID)
                                     throws SQLException
Throws:
SQLException

getIpRoute

public static IpRouteInterface[] getIpRoute(int nodeID,
                                            int ifindex)
                                     throws SQLException
Throws:
SQLException

isParentNode

public static boolean isParentNode(int nodeID)
                            throws SQLException
Throws:
SQLException

isBridgeNode

public static boolean isBridgeNode(int nodeID)
                            throws SQLException
Throws:
SQLException

isRouteInfoNode

public static boolean isRouteInfoNode(int nodeID)
                               throws SQLException
Throws:
SQLException

getDataLinksOnNode

public static DataLinkInterface[] getDataLinksOnNode(int nodeID)
                                              throws SQLException
Throws:
SQLException

getLinkedNodeIdOnNode

public static Set<Integer> getLinkedNodeIdOnNode(int nodeID)
                                          throws SQLException
Throws:
SQLException

getLinkedNodeIdOnNode

public static Set<Integer> getLinkedNodeIdOnNode(int nodeID,
                                                 Connection conn)
                                          throws SQLException
Throws:
SQLException

getLinkedNodeIdOnNodes

public static Set<Integer> getLinkedNodeIdOnNodes(Set<Integer> nodeIds,
                                                  Connection conn)
                                           throws SQLException
Throws:
SQLException

getDataLinks

protected static DataLinkInterface[] getDataLinks(int nodeID)
                                           throws SQLException
Throws:
SQLException

getDataLinksFromNodeParent

protected static DataLinkInterface[] getDataLinksFromNodeParent(int nodeID)
                                                         throws SQLException
Throws:
SQLException

getDataLinksOnInterface

public static DataLinkInterface[] getDataLinksOnInterface(int nodeID,
                                                          int ifindex)
                                                   throws SQLException
Throws:
SQLException

getDataLinks

public static DataLinkInterface[] getDataLinks(int nodeID,
                                               int ifindex)
                                        throws SQLException
Throws:
SQLException

getDataLinksFromNodeParent

protected static DataLinkInterface[] getDataLinksFromNodeParent(int nodeID,
                                                                int ifindex)
                                                         throws SQLException
Throws:
SQLException

getAllDataLinks

public static DataLinkInterface[] getAllDataLinks()
                                           throws SQLException
Throws:
SQLException

getVlansOnNode

public static Vlan[] getVlansOnNode(int nodeID)
                             throws SQLException
Throws:
SQLException

getStpInterface

public static StpInterface[] getStpInterface(int nodeID)
                                      throws SQLException
Throws:
SQLException

getStpInterface

public static StpInterface[] getStpInterface(int nodeID,
                                             int ifindex)
                                      throws SQLException
Throws:
SQLException

getStpNode

public static StpNode[] getStpNode(int nodeID)
                            throws SQLException
Throws:
SQLException

rs2AtInterface

protected static AtInterface[] rs2AtInterface(ResultSet rs)
                                       throws SQLException
This method returns the data from the result set as an array of AtInterface objects.

Throws:
SQLException

rs2IpRouteInterface

protected static IpRouteInterface[] rs2IpRouteInterface(ResultSet rs)
                                                 throws SQLException
This method returns the data from the result set as an array of IpRouteInterface objects.

Throws:
SQLException

rs2StpInterface

protected static StpInterface[] rs2StpInterface(ResultSet rs)
                                         throws SQLException
This method returns the data from the result set as an array of StpInterface objects.

Throws:
SQLException

rs2StpNode

protected static StpNode[] rs2StpNode(ResultSet rs)
                               throws SQLException
This method returns the data from the result set as an array of StpNode objects.

Throws:
SQLException

rs2Vlan

protected static Vlan[] rs2Vlan(ResultSet rs)
                         throws SQLException
This method returns the data from the result set as an array of StpNode objects.

Throws:
SQLException

rs2DataLink

protected static DataLinkInterface[] rs2DataLink(ResultSet rs)
                                          throws SQLException
This method returns the data from the result set as an array of DataLinkInterface objects.

Throws:
SQLException

invertDataLinkInterface

protected static DataLinkInterface[] invertDataLinkInterface(DataLinkInterface[] nodes)

getIpAddress

protected static String getIpAddress(int nodeid)
                              throws SQLException
Throws:
SQLException

getIpAddress

protected static String getIpAddress(int nodeid,
                                     int ifindex)
                              throws SQLException
Throws:
SQLException

getNodeIdsWithIpLike

public static List<Integer> getNodeIdsWithIpLike(String iplike)
                                          throws SQLException
Returns all non-deleted nodes with an IP address like the rule given.

Throws:
SQLException

getNodesWithCategories

public static Node[] getNodesWithCategories(org.springframework.transaction.support.TransactionTemplate transTemplate,
                                            NodeDao nodeDao,
                                            CategoryDao categoryDao,
                                            String[] categories1,
                                            boolean onlyNodesWithDownAggregateStatus)

getNodesWithCategories

public static Node[] getNodesWithCategories(NodeDao nodeDao,
                                            CategoryDao categoryDao,
                                            String[] categories1,
                                            boolean onlyNodesWithDownAggregateStatus)

getNodesWithCategories

public static Node[] getNodesWithCategories(org.springframework.transaction.support.TransactionTemplate transTemplate,
                                            NodeDao nodeDao,
                                            CategoryDao categoryDao,
                                            String[] categories1,
                                            String[] categories2,
                                            boolean onlyNodesWithDownAggregateStatus)

getNodesWithCategories

public static Node[] getNodesWithCategories(NodeDao nodeDao,
                                            CategoryDao categoryDao,
                                            String[] categories1,
                                            String[] categories2,
                                            boolean onlyNodesWithDownAggregateStatus)

convertOnmsNodeCollectionToNodeArray

public static Node[] convertOnmsNodeCollectionToNodeArray(Collection<OnmsNode> ourNodes)


Copyright © 2009. All Rights Reserved.