Tabnine Logo
DataTreeCandidateNode.getModificationType
Code IndexAdd Tabnine to your IDE (free)

How to use
getModificationType
method
in
org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode

Best Java code snippets using org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode.getModificationType (Showing top 20 results out of 315)

origin: io.fd.honeycomb/data-impl

ModificationType getModificationType() {
  return dataCandidate.getModificationType();
}
origin: org.opendaylight.controller/sal-binding-broker-impl

@Override
public DataObjectModification.ModificationType getModificationType() {
  switch(domData.getModificationType()) {
    case WRITE:
      return DataObjectModification.ModificationType.WRITE;
    case APPEARED:
    case SUBTREE_MODIFIED:
      return DataObjectModification.ModificationType.SUBTREE_MODIFIED;
    case DISAPPEARED:
    case DELETE:
      return DataObjectModification.ModificationType.DELETE;
    default:
      // TODO: Should we lie about modification type instead of exception?
      throw new IllegalStateException("Unsupported DOM Modification type " + domData.getModificationType());
  }
}
origin: org.opendaylight.mdsal/mdsal-binding2-dom-codec

@Nonnull
@Override
public TreeNodeModification.ModificationType getModificationType() {
  switch (domData.getModificationType()) {
    case APPEARED:
    case WRITE:
      return TreeNodeModification.ModificationType.WRITE;
    case SUBTREE_MODIFIED:
      return TreeNodeModification.ModificationType.SUBTREE_MODIFIED;
    case DISAPPEARED:
    case DELETE:
      return TreeNodeModification.ModificationType.DELETE;
    default:
      // TODO: Should we lie about modification type instead of exception?
      throw new IllegalStateException("Unsupported DOM Modification type " + domData.getModificationType());
  }
}
origin: opendaylight/yangtools

public static void applyRootToCursor(final DataTreeModificationCursor cursor, final DataTreeCandidateNode node) {
  switch (node.getModificationType()) {
    case DELETE:
      throw new IllegalArgumentException("Can not delete root.");
    case WRITE:
    case SUBTREE_MODIFIED:
      AbstractNodeIterator iterator = new RootNonExitingIterator(node.getChildNodes().iterator());
      do {
        iterator = iterator.next(cursor);
      } while (iterator != null);
      break;
    case UNMODIFIED:
      // No-op
      break;
    default:
      throw new IllegalArgumentException("Unsupported modification " + node.getModificationType());
  }
}
origin: org.opendaylight.yangtools/yang-data-api

public static void applyRootToCursor(final DataTreeModificationCursor cursor, final DataTreeCandidateNode node) {
  switch (node.getModificationType()) {
    case DELETE:
      throw new IllegalArgumentException("Can not delete root.");
    case WRITE:
    case SUBTREE_MODIFIED:
      AbstractNodeIterator iterator = new RootNonExitingIterator(node.getChildNodes().iterator());
      do {
        iterator = iterator.next(cursor);
      } while (iterator != null);
      break;
    case UNMODIFIED:
      // No-op
      break;
    default:
      throw new IllegalArgumentException("Unsupported modification " + node.getModificationType());
  }
}
origin: org.opendaylight.yangtools/yang-data-impl

private void validateNode(final DataTreeCandidateNode node, final LeafRefContext referencedByCtx,
  final LeafRefContext referencingCtx, final YangInstanceIdentifier current) {
  if (node.getModificationType() == ModificationType.WRITE && node.getDataAfter().isPresent()) {
    validateNodeData(node.getDataAfter().get(), referencedByCtx, referencingCtx, node.getModificationType(),
      current);
    return;
  }
  if (node.getModificationType() == ModificationType.DELETE && referencedByCtx != null) {
    validateNodeData(node.getDataBefore().get(), referencedByCtx, null, node.getModificationType(), current);
    return;
  }
  for (final DataTreeCandidateNode childNode : node.getChildNodes()) {
    if (childNode.getModificationType() != ModificationType.UNMODIFIED) {
      final LeafRefContext childReferencedByCtx = getReferencedByCtxChild(referencedByCtx, childNode);
      final LeafRefContext childReferencingCtx = getReferencingCtxChild(referencingCtx, childNode);
      if (childReferencedByCtx != null || childReferencingCtx != null) {
        validateNode(childNode, childReferencedByCtx,childReferencingCtx,
          current.node(childNode.getIdentifier()));
      }
    }
  }
}
origin: opendaylight/yangtools

private void validateNode(final DataTreeCandidateNode node, final LeafRefContext referencedByCtx,
  final LeafRefContext referencingCtx, final YangInstanceIdentifier current) {
  if (node.getModificationType() == ModificationType.WRITE && node.getDataAfter().isPresent()) {
    validateNodeData(node.getDataAfter().get(), referencedByCtx, referencingCtx, node.getModificationType(),
      current);
    return;
  }
  if (node.getModificationType() == ModificationType.DELETE && referencedByCtx != null) {
    validateNodeData(node.getDataBefore().get(), referencedByCtx, null, node.getModificationType(), current);
    return;
  }
  for (final DataTreeCandidateNode childNode : node.getChildNodes()) {
    if (childNode.getModificationType() != ModificationType.UNMODIFIED) {
      final LeafRefContext childReferencedByCtx = getReferencedByCtxChild(referencedByCtx, childNode);
      final LeafRefContext childReferencingCtx = getReferencingCtxChild(referencingCtx, childNode);
      if (childReferencedByCtx != null || childReferencingCtx != null) {
        validateNode(childNode, childReferencedByCtx,childReferencingCtx,
          current.node(childNode.getIdentifier()));
      }
    }
  }
}
origin: org.opendaylight.bgpcep/bgp-rib-impl

private void processSupportedSendReceiveTables(final DataTreeCandidateNode sendReceiveModChild, final PeerId peerId) {
  if (sendReceiveModChild != null) {
    if (sendReceiveModChild.getModificationType().equals(ModificationType.DELETE)) {
      final Optional<NormalizedNode<?, ?>> sendReceiveNode = sendReceiveModChild.getDataBefore();
      if (sendReceiveNode.isPresent()) {
        final SendReceive sendReceiveValue = SendReceive.valueOf(BindingMapping.getClassName((String) sendReceiveNode.get().getValue()));
        this.peerAddPathTables.remove(peerId);
        LOG.debug("Supported Add BestPath table {} removed to peer {}", sendReceiveValue, peerId);
      }
    } else {
      final Optional<NormalizedNode<?, ?>> sendReceiveNode = sendReceiveModChild.getDataAfter();
      if (sendReceiveNode.isPresent()) {
        final SendReceive sendReceiveValue = SendReceive.valueOf(BindingMapping.getClassName((String) sendReceiveNode.get().getValue()));
        this.peerAddPathTables.put(peerId, sendReceiveValue);
        LOG.debug("Supported Add BestPath table {} added to peer {}", sendReceiveValue, peerId);
      }
    }
  }
}
origin: org.opendaylight.controller/sal-core-spi

/**
 * Process a candidate tree with respect to registered listeners.
 *
 * @param candidate candidate three which needs to be processed
 */
protected final void processCandidateTree(@Nonnull final DataTreeCandidate candidate) {
  final DataTreeCandidateNode node = candidate.getRootNode();
  if (node.getModificationType() == ModificationType.UNMODIFIED) {
    LOG.debug("Skipping unmodified candidate {}", candidate);
    return;
  }
  try (final RegistrationTreeSnapshot<AbstractDOMDataTreeChangeListenerRegistration<?>> snapshot = takeSnapshot()) {
    final List<PathArgument> toLookup = ImmutableList.copyOf(candidate.getRootPath().getPathArguments());
    lookupAndNotify(toLookup, 0, snapshot.getRootNode(), candidate);
  }
}
origin: org.opendaylight.bgpcep/bgp-rib-impl

@Override
public void onDataTreeChanged(final Collection<DataTreeCandidate> changes) {
  LOG.debug("Data change received for AdjRibOut {}", changes);
  for (final DataTreeCandidate tc : changes) {
    LOG.trace("Change {} type {}", tc.getRootNode(), tc.getRootNode().getModificationType());
    for (final DataTreeCandidateNode child : tc.getRootNode().getChildNodes()) {
      processSupportedFamilyRoutes(child);
    }
  }
  this.session.flush();
}
origin: org.opendaylight.mdsal/mdsal-dom-spi

/**
 * Process a candidate tree with respect to registered listeners.
 *
 * @param candidate candidate three which needs to be processed
 * @return true if at least one listener was notified or false.
 */
protected final boolean processCandidateTree(final @NonNull DataTreeCandidate candidate) {
  final DataTreeCandidateNode node = candidate.getRootNode();
  if (node.getModificationType() == ModificationType.UNMODIFIED) {
    LOG.debug("Skipping unmodified candidate {}", candidate);
    return false;
  }
  try (RegistrationTreeSnapshot<AbstractDOMDataTreeChangeListenerRegistration<?>> snapshot
      = takeSnapshot()) {
    final List<PathArgument> toLookup = ImmutableList.copyOf(candidate.getRootPath().getPathArguments());
    final Multimap<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate> listenerChanges =
        Multimaps.newListMultimap(new IdentityHashMap<>(), ArrayList::new);
    lookupAndNotify(toLookup, 0, snapshot.getRootNode(), candidate, listenerChanges);
    for (Map.Entry<AbstractDOMDataTreeChangeListenerRegistration<?>, Collection<DataTreeCandidate>> entry:
        listenerChanges.asMap().entrySet()) {
      notifyListener(entry.getKey(), entry.getValue());
    }
    return !listenerChanges.isEmpty();
  }
}
origin: opendaylight/controller

/**
 * Process a candidate tree with respect to registered listeners.
 *
 * @param candidate candidate three which needs to be processed
 */
protected final void processCandidateTree(@Nonnull final DataTreeCandidate candidate) {
  final DataTreeCandidateNode node = candidate.getRootNode();
  if (node.getModificationType() == ModificationType.UNMODIFIED) {
    LOG.debug("Skipping unmodified candidate {}", candidate);
    return;
  }
  try (RegistrationTreeSnapshot<AbstractDOMDataTreeChangeListenerRegistration<?>> snapshot = takeSnapshot()) {
    lookupAndNotify(candidate.getRootPath().getPathArguments(), 0, snapshot.getRootNode(), candidate);
  }
}
origin: org.opendaylight.controller/sal-distributed-datastore

void startCommit(final SimpleShardDataTreeCohort cohort, final DataTreeCandidate candidate) {
  final CommitEntry entry = pendingTransactions.peek();
  Preconditions.checkState(entry != null, "Attempted to start commit of %s when no transactions pending", cohort);
  final SimpleShardDataTreeCohort current = entry.cohort;
  Verify.verify(cohort.equals(current), "Attempted to commit %s while %s is pending", cohort, current);
  if (shard.canSkipPayload() || candidate.getRootNode().getModificationType() == ModificationType.UNMODIFIED) {
    LOG.debug("{}: No replication required, proceeding to finish commit", logContext);
    finishCommit(cohort);
    return;
  }
  final TransactionIdentifier txId = cohort.getIdentifier();
  final Payload payload;
  try {
    payload = CommitTransactionPayload.create(txId, candidate);
  } catch (IOException e) {
    LOG.error("{}: Failed to encode transaction {} candidate {}", logContext, txId, candidate, e);
    pendingTransactions.poll().cohort.failedCommit(e);
    return;
  }
  // Once completed, we will continue via payloadReplicationComplete
  entry.lastAccess = shard.ticker().read();
  shard.persistPayload(txId, payload);
  LOG.debug("{}: Transaction {} submitted to persistence", logContext, txId);
}
origin: opendaylight/yangtools

private void validateChildren(final LeafRefContext rootLeafRefCtx, final Collection<DataTreeCandidateNode> children)
    throws LeafRefDataValidationFailedException {
  for (final DataTreeCandidateNode dataTreeCandidateNode : children) {
    if (dataTreeCandidateNode.getModificationType() != ModificationType.UNMODIFIED) {
      final PathArgument identifier = dataTreeCandidateNode.getIdentifier();
      final QName childQName = identifier.getNodeType();
      final LeafRefContext referencedByCtx = rootLeafRefCtx.getReferencedChildByName(childQName);
      final LeafRefContext referencingCtx = rootLeafRefCtx.getReferencingChildByName(childQName);
      if (referencedByCtx != null || referencingCtx != null) {
        validateNode(dataTreeCandidateNode, referencedByCtx, referencingCtx,
          YangInstanceIdentifier.create(identifier));
      }
    }
  }
  if (!errorsMessages.isEmpty()) {
    final StringBuilder message = new StringBuilder();
    int errCount = 0;
    for (final String errorMessage : errorsMessages) {
      message.append(errorMessage);
      errCount++;
    }
    throw new LeafRefDataValidationFailedException(message.toString(), errCount);
  }
}
origin: org.opendaylight.controller/sal-distributed-datastore

@Override
public void onDataTreeChanged(Collection<DataTreeCandidate> changes) {
  for(DataTreeCandidate change: changes) {
    DataTreeCandidateNode changeRoot = change.getRootNode();
    ModificationType type = changeRoot.getModificationType();
    LOG.debug("{}: Candidate node changed: {}, {}", logId, type, change.getRootPath());
    NodeIdentifierWithPredicates candidateKey =
        (NodeIdentifierWithPredicates) change.getRootPath().getLastPathArgument();
    String candidate = candidateKey.getKeyValues().get(CANDIDATE_NAME_QNAME).toString();
    YangInstanceIdentifier entityId = extractEntityPath(change.getRootPath());
    if(type == ModificationType.WRITE || type == ModificationType.APPEARED) {
      LOG.debug("{}: Candidate {} was added for entity {}", logId, candidate, entityId);
      Collection<String> currentCandidates = addToCurrentCandidates(entityId, candidate);
      shard.tell(new CandidateAdded(entityId, candidate, new ArrayList<>(currentCandidates)), shard);
    } else if(type == ModificationType.DELETE || type == ModificationType.DISAPPEARED) {
      LOG.debug("{}: Candidate {} was removed for entity {}", logId, candidate, entityId);
      Collection<String> currentCandidates = removeFromCurrentCandidates(entityId, candidate);
      shard.tell(new CandidateRemoved(entityId, candidate, new ArrayList<>(currentCandidates)), shard);
    }
  }
}
origin: org.opendaylight.bgpcep/bgp-rib-impl

private void updateNodes(final DataTreeCandidateNode table, final PeerId peerId, final DOMDataWriteTransaction tx,
  final Map<RouteUpdateKey, RouteEntry> routes) {
  for (final DataTreeCandidateNode child : table.getChildNodes()) {
    LOG.debug("Modification type {}", child.getModificationType());
    if ((Attributes.QNAME).equals(child.getIdentifier().getNodeType())) {
      if (child.getDataAfter().isPresent()) {
        // putting uptodate attribute in
        LOG.trace("Uptodate found for {}", child.getDataAfter());
        tx.put(LogicalDatastoreType.OPERATIONAL, this.locRibTarget.node(child.getIdentifier()), child.getDataAfter().get());
      }
      continue;
    }
    updateRoutesEntries(child, peerId, routes);
  }
}
origin: org.opendaylight.controller/sal-core-spi

  private void notifyNode(final YangInstanceIdentifier path, final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> regNode, final DataTreeCandidateNode candNode) {
    if (candNode.getModificationType() == ModificationType.UNMODIFIED) {
      LOG.debug("Skipping unmodified candidate {}", path);
      return;
    }

    final Collection<AbstractDOMDataTreeChangeListenerRegistration<?>> regs = regNode.getRegistrations();
    if (!regs.isEmpty()) {
      notifyListeners(regs, path, candNode);
    }

    for (DataTreeCandidateNode candChild : candNode.getChildNodes()) {
      if (candChild.getModificationType() != ModificationType.UNMODIFIED) {
        final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> regChild = regNode.getExactChild(candChild.getIdentifier());
        if (regChild != null) {
          notifyNode(path.node(candChild.getIdentifier()), regChild, candChild);
        }

        for (RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> rc : regNode.getInexactChildren(candChild.getIdentifier())) {
          notifyNode(path.node(candChild.getIdentifier()), rc, candChild);
        }
      }
    }
  }
}
origin: org.opendaylight.mdsal/mdsal-dom-spi

private void notifyNode(final YangInstanceIdentifier path,
    final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> regNode,
    final DataTreeCandidateNode candNode,
    final Multimap<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate> listenerChanges) {
  if (candNode.getModificationType() == ModificationType.UNMODIFIED) {
    LOG.debug("Skipping unmodified candidate {}", path);
    return;
  }
  final Collection<AbstractDOMDataTreeChangeListenerRegistration<?>> regs = regNode.getRegistrations();
  if (!regs.isEmpty()) {
    addToListenerChanges(regs, path, candNode, listenerChanges);
  }
  for (DataTreeCandidateNode candChild : candNode.getChildNodes()) {
    if (candChild.getModificationType() != ModificationType.UNMODIFIED) {
      final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> regChild =
          regNode.getExactChild(candChild.getIdentifier());
      if (regChild != null) {
        notifyNode(path.node(candChild.getIdentifier()), regChild, candChild, listenerChanges);
      }
      for (RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> rc :
        regNode.getInexactChildren(candChild.getIdentifier())) {
        notifyNode(path.node(candChild.getIdentifier()), rc, candChild, listenerChanges);
      }
    }
  }
}
origin: opendaylight/controller

  private void notifyNode(final YangInstanceIdentifier path,
      final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> regNode,
      final DataTreeCandidateNode candNode) {
    if (candNode.getModificationType() == ModificationType.UNMODIFIED) {
      LOG.debug("Skipping unmodified candidate {}", path);
      return;
    }

    final Collection<AbstractDOMDataTreeChangeListenerRegistration<?>> regs = regNode.getRegistrations();
    if (!regs.isEmpty()) {
      notifyListeners(regs, path, candNode);
    }

    for (DataTreeCandidateNode candChild : candNode.getChildNodes()) {
      if (candChild.getModificationType() != ModificationType.UNMODIFIED) {
        final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> regChild =
            regNode.getExactChild(candChild.getIdentifier());
        if (regChild != null) {
          notifyNode(path.node(candChild.getIdentifier()), regChild, candChild);
        }

        for (RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> rc :
            regNode.getInexactChildren(candChild.getIdentifier())) {
          notifyNode(path.node(candChild.getIdentifier()), rc, candChild);
        }
      }
    }
  }
}
origin: org.opendaylight.bgpcep/bgp-rib-impl

private void filterOutPeerRole(final PeerId peerId, final DataTreeCandidateNode rootNode, final YangInstanceIdentifier rootPath) {
  final DataTreeCandidateNode roleChange = rootNode.getModifiedChild(PEER_ROLE_NID);
  if (roleChange != null) {
    if (rootNode.getModificationType() != ModificationType.DELETE) {
      this.cacheDisconnectedPeers.reconnected(peerId);
    }
    // Check for removal
    final Optional<NormalizedNode<?, ?>> maybePeerRole = roleChange.getDataAfter();
    final YangInstanceIdentifier peerPath = IdentifierUtils.peerPath(rootPath);
    LOG.debug("Data Changed for Peer role {} path {}, dataBefore {}, dataAfter {}", roleChange.getIdentifier(),
      peerPath , roleChange.getDataBefore(), maybePeerRole);
    final PeerRole role = PeerRoleUtil.roleForChange(maybePeerRole);
    final SimpleRoutingPolicy srp = getSimpleRoutingPolicy(rootNode);
    if(SimpleRoutingPolicy.AnnounceNone == srp) {
      return;
    }
    this.peerPolicyTracker.peerRoleChanged(peerPath, role);
  }
}
org.opendaylight.yangtools.yang.data.api.schema.treeDataTreeCandidateNodegetModificationType

Javadoc

Return the type of modification this node is undergoing.

Popular methods of DataTreeCandidateNode

  • getChildNodes
    Get an unmodifiable collection of modified child nodes.
  • getIdentifier
    Get the node identifier.
  • getDataAfter
    Return the after-image of data corresponding to the node.
  • getDataBefore
    Return the before-image of data corresponding to the node.
  • getModifiedChild
    Returns modified child or null if child was not modified / does not exists.

Popular in Java

  • Start an intent from android
  • getContentResolver (Context)
  • getResourceAsStream (ClassLoader)
  • requestLocationUpdates (LocationManager)
  • Menu (java.awt)
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Collectors (java.util.stream)
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now