Search in sources :

Example 1 with NodeIdentifierWithPredicates

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project controller by opendaylight.

the class PrefixedShardConfigWriter method doDelete.

private DOMStoreThreePhaseCommitCohort doDelete(final YangInstanceIdentifier path) {
    final ClientTransaction tx = history.createTransaction();
    final DOMDataTreeWriteCursor cursor = tx.openCursor();
    ClusterUtils.SHARD_LIST_PATH.getPathArguments().forEach(cursor::enter);
    cursor.delete(new NodeIdentifierWithPredicates(ClusterUtils.SHARD_LIST_QNAME, ClusterUtils.SHARD_PREFIX_QNAME, path));
    cursor.close();
    return tx.ready();
}
Also used : DOMDataTreeWriteCursor(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor) ClientTransaction(org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)

Example 2 with NodeIdentifierWithPredicates

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project controller by opendaylight.

the class CandidateListChangeListener method onDataTreeChanged.

@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> newCandidates = addToCurrentCandidates(entityId, candidate);
            shard.tell(new CandidateAdded(entityId, candidate, new ArrayList<>(newCandidates)), shard);
        } else if (type == ModificationType.DELETE || type == ModificationType.DISAPPEARED) {
            LOG.debug("{}: Candidate {} was removed for entity {}", logId, candidate, entityId);
            Collection<String> newCandidates = removeFromCurrentCandidates(entityId, candidate);
            shard.tell(new CandidateRemoved(entityId, candidate, new ArrayList<>(newCandidates)), shard);
        }
    }
}
Also used : DataTreeCandidate(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate) ModificationType(org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType) CandidateAdded(org.opendaylight.controller.cluster.datastore.entityownership.messages.CandidateAdded) DataTreeCandidateNode(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode) ArrayList(java.util.ArrayList) Collection(java.util.Collection) CandidateRemoved(org.opendaylight.controller.cluster.datastore.entityownership.messages.CandidateRemoved) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Example 3 with NodeIdentifierWithPredicates

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project controller by opendaylight.

the class ResolveDataChangeState method getListenerChildrenWildcarded.

private static Collection<RegistrationTreeNode<DataChangeListenerRegistration<?>>> getListenerChildrenWildcarded(final Collection<RegistrationTreeNode<DataChangeListenerRegistration<?>>> parentNodes, final PathArgument child) {
    if (parentNodes.isEmpty()) {
        return Collections.emptyList();
    }
    final List<RegistrationTreeNode<DataChangeListenerRegistration<?>>> result = new ArrayList<>();
    if (child instanceof NodeWithValue || child instanceof NodeIdentifierWithPredicates) {
        NodeIdentifier wildcardedIdentifier = new NodeIdentifier(child.getNodeType());
        addChildNodes(result, parentNodes, wildcardedIdentifier);
    }
    addChildNodes(result, parentNodes, child);
    return result;
}
Also used : RegistrationTreeNode(org.opendaylight.mdsal.dom.spi.RegistrationTreeNode) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ArrayList(java.util.ArrayList) NodeWithValue(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)

Example 4 with NodeIdentifierWithPredicates

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project controller by opendaylight.

the class SimpletxDomRead method executeList.

@Override
public void executeList() {
    final LogicalDatastoreType dsType = getDataStoreType();
    final org.opendaylight.yangtools.yang.common.QName olId = QName.create(OuterList.QNAME, "id");
    final YangInstanceIdentifier pid = YangInstanceIdentifier.builder().node(TestExec.QNAME).node(OuterList.QNAME).build();
    try (DOMDataReadOnlyTransaction tx = domDataBroker.newReadOnlyTransaction()) {
        for (int l = 0; l < outerListElem; l++) {
            YangInstanceIdentifier yid = pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, olId, l));
            CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> submitFuture = tx.read(dsType, yid);
            try {
                Optional<NormalizedNode<?, ?>> optionalDataObject = submitFuture.checkedGet();
                if (optionalDataObject != null && optionalDataObject.isPresent()) {
                    NormalizedNode<?, ?> ret = optionalDataObject.get();
                    LOG.trace("optionalDataObject is {}", ret);
                    txOk++;
                } else {
                    txError++;
                    LOG.warn("optionalDataObject is either null or .isPresent is false");
                }
            } catch (final ReadFailedException e) {
                LOG.warn("failed to ....", e);
                txError++;
            }
        }
    }
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Optional(com.google.common.base.Optional) DOMDataReadOnlyTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) QName(org.opendaylight.yangtools.yang.common.QName) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)

Example 5 with NodeIdentifierWithPredicates

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project controller by opendaylight.

the class TxchainDomRead method executeList.

@Override
public void executeList() {
    final LogicalDatastoreType dsType = getDataStoreType();
    final org.opendaylight.yangtools.yang.common.QName olId = QName.create(OuterList.QNAME, "id");
    final YangInstanceIdentifier pid = YangInstanceIdentifier.builder().node(TestExec.QNAME).node(OuterList.QNAME).build();
    try (DOMDataReadOnlyTransaction tx = domDataBroker.newReadOnlyTransaction()) {
        for (int l = 0; l < outerListElem; l++) {
            YangInstanceIdentifier yid = pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, olId, l));
            Optional<NormalizedNode<?, ?>> optionalDataObject;
            CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> submitFuture = tx.read(dsType, yid);
            try {
                optionalDataObject = submitFuture.checkedGet();
                if (optionalDataObject != null && optionalDataObject.isPresent()) {
                    txOk++;
                }
            } catch (final ReadFailedException e) {
                LOG.warn("failed to ....", e);
                txError++;
            }
        }
    }
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Optional(com.google.common.base.Optional) DOMDataReadOnlyTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) QName(org.opendaylight.yangtools.yang.common.QName) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)

Aggregations

NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)97 Test (org.junit.Test)52 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)49 ArrayList (java.util.ArrayList)37 Flowspec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.Flowspec)34 FlowspecBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.FlowspecBuilder)34 NumericOperand (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.NumericOperand)20 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)20 QName (org.opendaylight.yangtools.yang.common.QName)15 DestinationFlowspecBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.ipv4.DestinationFlowspecBuilder)12 PathArgument (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument)11 AbstractRIBSupportTest (org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest)10 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)10 DOMDataWriteTransaction (org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)9 DataContainerChild (org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild)7 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)6 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)6 BitmaskOperand (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.BitmaskOperand)6 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)5 DestinationFlowspecBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.ipv6.DestinationFlowspecBuilder)5