コード例 #1
0
 private boolean matchTargetFields(UnderlayItem item1, UnderlayItem item2) {
   boolean targetFieldsMatch = false;
   if (item1.getLeafNodes().size() == item2.getLeafNodes().size()) {
     targetFieldsMatch = true;
     for (Entry<Integer, NormalizedNode<?, ?>> targetFieldEntryOfItem1 :
         item1.getLeafNodes().entrySet()) {
       NormalizedNode<?, ?> targetFieldOfItem2 =
           item2.getLeafNodes().get(targetFieldEntryOfItem1.getKey());
       if (!targetFieldEntryOfItem1.getValue().equals(targetFieldOfItem2)) {
         return false;
       }
     }
   }
   return targetFieldsMatch;
 }
コード例 #2
0
 @Override
 public void processUpdatedChanges(
     YangInstanceIdentifier identifier, UnderlayItem updatedItem, String topologyId) {
   LOG.trace("Processing updatedChanges");
   for (TopologyStore ts : topoStoreProvider.getTopologyStores()) {
     if (ts.getId().equals(topologyId)) {
       LOG.debug("Updating overlay item");
       UnderlayItem underlayItem = ts.getUnderlayItems().get(identifier);
       Preconditions.checkNotNull(
           underlayItem, "Updated underlay item not found in the Topology store");
       underlayItem.setItem(updatedItem.getItem());
       if (underlayItem.getCorrelationItem() == CorrelationItemEnum.Link) {
         if (underlayItem instanceof ComputedLink && updatedItem instanceof ComputedLink) {
           ComputedLink underlayLink = (ComputedLink) underlayItem;
           ComputedLink updatedLink = (ComputedLink) updatedItem;
           if (!matchTargetFields(underlayItem, updatedItem)
               || !underlayLink.getSrcNode().equals(updatedLink.getSrcNode())
               || !underlayLink.getDstNode().equals(updatedLink.getDstNode())) {
             underlayLink.setLeafNodes(updatedLink.getLeafNodes());
             underlayLink.setSrcNode(updatedLink.getSrcNode());
             underlayLink.setDstNode(updatedLink.getDstNode());
             if (underlayItem.getOverlayItem() != null) {
               removeUnderlayItemFromOverlayItem(underlayItem);
             }
             checkForPossibleAggregationOfLinks(updatedLink, underlayLink);
           } else if (underlayItem.getOverlayItem() != null) {
             // in case that only Link value was changed
             topologyManager.updateOverlayItem(underlayItem.getOverlayItem());
           }
           break;
         }
       } else {
         // if Leaf Node was changed
         if (!matchTargetFields(underlayItem, updatedItem)) {
           underlayItem.setLeafNodes(updatedItem.getLeafNodes());
           if (underlayItem.getOverlayItem() != null) {
             removeUnderlayItemFromOverlayItem(underlayItem);
           }
           checkForPossibleAggregation(underlayItem, topologyId);
         } else if (underlayItem.getOverlayItem() != null) {
           // in case that only Node value was changed
           topologyManager.updateOverlayItem(underlayItem.getOverlayItem());
         }
         break;
       }
     }
   }
 }