@Override public void clear() { m_lock.writeLock().lock(); try { m_managedAddresses.clear(); } finally { m_lock.writeLock().unlock(); } } }
private void dataSourceSyncWithinTransaction() { m_lock.writeLock().lock(); try { /* * Make a new list with which we'll replace the existing one, that way * if something goes wrong with the DB we won't lose whatever was already * in there */ final SortedSetMultimap<Key, Value> newAlreadyDiscovered = Multimaps.newSortedSetMultimap(Maps.newHashMap(), TreeSet::new); // Fetch all non-deleted nodes final CriteriaBuilder builder = new CriteriaBuilder(OnmsNode.class); builder.ne("type", String.valueOf(NodeType.DELETED.value())); for (OnmsNode node : m_nodeDao.findMatching(builder.toCriteria())) { for (final OnmsIpInterface iface : node.getIpInterfaces()) { // Skip deleted interfaces // TODO: Refactor the 'D' value with an enumeration if ("D".equals(iface.getIsManaged())) { continue; } LOG.debug("Adding entry: {}:{} -> {}", node.getLocation().getLocationName(), iface.getIpAddress(), node.getId()); newAlreadyDiscovered.put(new Key(node.getLocation().getLocationName(), iface.getIpAddress()), new Value(node.getId(), iface.getIsSnmpPrimary())); } } m_managedAddresses.clear(); m_managedAddresses.putAll(newAlreadyDiscovered); LOG.info("dataSourceSync: initialized list of managed IP addresses with {} members", m_managedAddresses.size()); } finally { m_lock.writeLock().unlock(); } }