@Override public void processUpdatedChanges( YangInstanceIdentifier identifier, UnderlayItem updatedEntry, String topologyId) { if (updatedEntry != null) { LOGGER.trace("Processing updateChanges"); Map<YangInstanceIdentifier, UnderlayItem> items = topoStoreProvider.getTopologyStore(topologyId).getUnderlayItems(); UnderlayItem oldItem = items.get(identifier); OverlayItem item = oldItem.getOverlayItem(); Queue<UnderlayItem> underlayItems = new ConcurrentLinkedQueue<>(); underlayItems.add(updatedEntry); item.setUnderlayItems(underlayItems); updatedEntry.setOverlayItem(item); items.put(identifier, updatedEntry); manager.updateOverlayItem(item); } }
private void removeUnderlayItemFromOverlayItem(UnderlayItem itemToRemove) { OverlayItem overlayItemIdentifier = itemToRemove.getOverlayItem(); if (null != overlayItemIdentifier) { Queue<UnderlayItem> underlayItems = overlayItemIdentifier.getUnderlayItems(); underlayItems.remove(itemToRemove); itemToRemove.setOverlayItem(null); if (underlayItems.size() < getMinUnderlayItems()) { LOG.debug("Removing overlay item"); for (UnderlayItem remainingNode : underlayItems) { remainingNode.setOverlayItem(null); } topologyManager.removeOverlayItem(overlayItemIdentifier); } else { LOG.debug("Removing underlay item from overlay item"); topologyManager.updateOverlayItem(overlayItemIdentifier); } } }
/** * @param newItem item received from notification * @param topoStoreItem item already stored in topostore */ private void aggregateItems(UnderlayItem newItem, UnderlayItem topoStoreItem) { if (topoStoreItem.getOverlayItem() == null) { LOG.debug("Creating new Logical Node"); // create new logical node List<UnderlayItem> nodesToAggregate = new ArrayList<>(); nodesToAggregate.add(newItem); nodesToAggregate.add(topoStoreItem); OverlayItem overlayItem = new OverlayItem(nodesToAggregate, topoStoreItem.getCorrelationItem()); topoStoreItem.setOverlayItem(overlayItem); newItem.setOverlayItem(overlayItem); topologyManager.addOverlayItem(overlayItem); return; } LOG.debug("Adding physical node to existing Logical Node"); // add new physical node into existing logical node OverlayItem overlayItem = topoStoreItem.getOverlayItem(); newItem.setOverlayItem(overlayItem); overlayItem.addUnderlayItem(newItem); topologyManager.updateOverlayItem(overlayItem); }