Search in sources :

Example 36 with DataTreeCandidate

use of org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate in project controller by opendaylight.

the class AbstractShardTest method mockShardDataTreeCohort.

protected ShardDataTreeCohort mockShardDataTreeCohort() {
    ShardDataTreeCohort cohort = mock(ShardDataTreeCohort.class);
    DataTreeCandidate candidate = mockCandidate("candidate");
    successfulCanCommit(cohort);
    successfulPreCommit(cohort, candidate);
    successfulCommit(cohort);
    doReturn(candidate).when(cohort).getCandidate();
    return cohort;
}
Also used : DataTreeCandidate(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate)

Example 37 with DataTreeCandidate

use of org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate in project controller by opendaylight.

the class AbstractShardTest method commitTransaction.

static DataTreeCandidate commitTransaction(final DataTree store, final DataTreeModification modification) throws DataValidationFailedException {
    modification.ready();
    store.validate(modification);
    final DataTreeCandidate candidate = store.prepare(modification);
    store.commit(candidate);
    return candidate;
}
Also used : DataTreeCandidate(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate)

Example 38 with DataTreeCandidate

use of org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate in project controller by opendaylight.

the class AbstractShardTest method payloadForModification.

static CommitTransactionPayload payloadForModification(final DataTree source, final DataTreeModification mod, final TransactionIdentifier transactionId) throws DataValidationFailedException, IOException {
    source.validate(mod);
    final DataTreeCandidate candidate = source.prepare(mod);
    source.commit(candidate);
    return CommitTransactionPayload.create(transactionId, candidate);
}
Also used : DataTreeCandidate(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate)

Example 39 with DataTreeCandidate

use of org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate in project bgpcep by opendaylight.

the class AbstractRIBTestSetup method ipv4Input.

public Collection<DataTreeCandidate> ipv4Input(final YangInstanceIdentifier target, final ModificationType type, final Ipv4Prefix... prefix) {
    final Collection<DataTreeCandidate> col = new HashSet<>();
    final DataTreeCandidate candidate = mock(DataTreeCandidate.class);
    final DataTreeCandidateNode rootNode = mock(DataTreeCandidateNode.class);
    doReturn(rootNode).when(candidate).getRootNode();
    doReturn(type).when(rootNode).getModificationType();
    doCallRealMethod().when(rootNode).toString();
    doReturn(target).when(candidate).getRootPath();
    doCallRealMethod().when(candidate).toString();
    final Collection<DataTreeCandidateNode> children = new HashSet<>();
    for (final Ipv4Prefix p : prefix) {
        final NodeIdentifierWithPredicates routekey = new NodeIdentifierWithPredicates(Ipv4Route.QNAME, PREFIX_QNAME, p);
        final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> b = ImmutableNodes.mapEntryBuilder();
        b.withNodeIdentifier(routekey);
        b.addChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(PREFIX_QNAME)).withValue(p).build());
        final DataTreeCandidateNode child = mock(DataTreeCandidateNode.class);
        doReturn(createIdentifier(p)).when(child).getIdentifier();
        doReturn(java.util.Optional.of(b.build())).when(child).getDataAfter();
        doReturn(type).when(child).getModificationType();
        children.add(child);
    }
    doReturn(children).when(rootNode).getChildNodes();
    col.add(candidate);
    return col;
}
Also used : DataTreeCandidate(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate) DataTreeCandidateNode(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) HashSet(java.util.HashSet)

Example 40 with DataTreeCandidate

use of org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate in project bgpcep by opendaylight.

the class AdjRibOutListener method onDataTreeChanged.

@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();
}
Also used : DataTreeCandidate(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate) DataTreeCandidateNode(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode)

Aggregations

DataTreeCandidate (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate)41 Test (org.junit.Test)19 DataTreeCandidateNode (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode)13 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)9 DOMDataTreeChangeService (org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService)7 DOMDataWriteTransaction (org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)7 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)7 CountDownLatch (java.util.concurrent.CountDownLatch)6 DataTreeModification (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification)6 ActorRef (akka.actor.ActorRef)5 DataTreeChanged (org.opendaylight.controller.cluster.datastore.messages.DataTreeChanged)5 Props (akka.actor.Props)4 TestKit (akka.testkit.javadsl.TestKit)4 DOMDataTreeChangeListener (org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener)4 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)3 PathArgument (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument)3 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)3 ConflictingModificationAppliedException (org.opendaylight.yangtools.yang.data.api.schema.tree.ConflictingModificationAppliedException)3 DataValidationFailedException (org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException)3 TransactionIdentifier (org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier)2