private Optional<Integer> resolveNodeId(String location, InetAddress trapAddress) { // If there was no location in the trap message, assume that // it was generated in the default location if (location == null) { return cache.getFirstNodeId(MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID, trapAddress); } return cache.getFirstNodeId(location, trapAddress); } }
@Override public Object execute() throws Exception { interfaceToNodeCache.dataSourceSync(); return null; } }
@Override public boolean matches(String location, InetAddress address) { return Iterables.isEmpty(interfaceToNodeCache.getNodeId(location, address)); }
m_cache.removeNodeId(oldNode.getLocation().getLocationName(), event.getInterfaceAddress(), oldNode.getId()); m_cache.setNodeId(newNode.getLocation().getLocationName(), event.getInterfaceAddress(), newNode.getId());
@EventHandler(uei=EventConstants.NODE_GAINED_INTERFACE_EVENT_UEI) @Transactional public void handleNodeGainedInterface(Event event) { LOG.debug("Received event: {}", event.getUei()); Long nodeId = event.getNodeid(); if (nodeId == null) { LOG.error(EventConstants.NODE_GAINED_INTERFACE_EVENT_UEI + ": Event with no node ID: " + event.toString()); return; } OnmsNode node = m_nodeDao.get(nodeId.intValue()); if (node == null) { LOG.warn(EventConstants.NODE_GAINED_INTERFACE_EVENT_UEI + ": Cannot find node in DB: " + nodeId); return; } // add to known nodes m_cache.setNodeId(node.getLocation().getLocationName(), event.getInterfaceAddress(), nodeId.intValue()); }
@EventHandler(uei=EventConstants.INTERFACE_DELETED_EVENT_UEI) @Transactional public void handleInterfaceDeleted(Event event) { LOG.debug("Received event: {}", event.getUei()); Long nodeId = event.getNodeid(); if (nodeId == null) { LOG.error(EventConstants.INTERFACE_DELETED_EVENT_UEI + ": Event with no node ID: " + event.toString()); return; } OnmsNode node = m_nodeDao.get(nodeId.intValue()); if (node == null) { LOG.warn(EventConstants.INTERFACE_DELETED_EVENT_UEI + ": Cannot find node in DB: " + nodeId); return; } // remove from known nodes m_cache.removeNodeId(node.getLocation().getLocationName(), event.getInterfaceAddress(), nodeId.intValue()); }
private Optional<Integer> resolveNodeId(String location, InetAddress trapAddress) { // If there was no location in the trap message, assume that // it was generated in the default location if (location == null) { return cache.getFirstNodeId(MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID, trapAddress); } return cache.getFirstNodeId(location, trapAddress); } }
@Override public boolean matches(String location, InetAddress address) { return Iterables.isEmpty(interfaceToNodeCache.getNodeId(location, address)); }
private Optional<NodeDocument> getNodeInfo(String location, InetAddress ipAddress) { final Optional<Integer> nodeId = interfaceToNodeCache.getFirstNodeId(location, ipAddress); if (nodeId.isPresent()) { try (Timer.Context ctx = nodeLoadTimer.time()) { final OnmsNode onmsNode = nodeDao.get(nodeId.get()); if (onmsNode != null) { final NodeDocument nodeInfo = new NodeDocument(); nodeInfo.setForeignSource(onmsNode.getForeignSource()); nodeInfo.setForeignId(onmsNode.getForeignId()); nodeInfo.setNodeId(nodeId.get()); nodeInfo.setCategories(onmsNode.getCategories().stream().map(OnmsCategory::getName).collect(Collectors.toList())); return Optional.of(nodeInfo); } else { LOG.warn("Node with id: {} at location: {} with IP address: {} is in the interface to node cache, but wasn't found in the database."); } } } return Optional.empty(); }
private Optional<NodeDocument> getNodeInfo(String location, InetAddress ipAddress) { final Optional<Integer> nodeId = interfaceToNodeCache.getFirstNodeId(location, ipAddress); if (nodeId.isPresent()) { try (Timer.Context ctx = nodeLoadTimer.time()) { final OnmsNode onmsNode = nodeDao.get(nodeId.get()); if (onmsNode != null) { final NodeDocument nodeInfo = new NodeDocument(); nodeInfo.setForeignSource(onmsNode.getForeignSource()); nodeInfo.setForeignId(onmsNode.getForeignId()); nodeInfo.setNodeId(nodeId.get()); nodeInfo.setCategories(onmsNode.getCategories().stream().map(OnmsCategory::getName).collect(Collectors.toList())); return Optional.of(nodeInfo); } else { LOG.warn("Node with id: {} at location: {} with IP address: {} is in the interface to node cache, but wasn't found in the database."); } } } return Optional.empty(); }
final Optional<Integer> nodeId = interfaceToNodeCache.getFirstNodeId(messageLog.getLocation(), inetAddress); if (nodeId.isPresent()) {
LOG.debug(" Telemetry message content : {} ", msg); final InetAddress inetAddress = InetAddress.getByName(msg.getNodeIdStr()); final Optional<Integer> nodeId = interfaceToNodeCache.getFirstNodeId(messageLog.getLocation(), inetAddress); if (nodeId.isPresent()) {
final Optional<Integer> nodeId = interfaceToNodeCache.getFirstNodeId(messageLog.getLocation(), inetAddress);
cache.getFirstNodeId(location, hostAddress) .ifPresent(bldr::setNodeid);