Search in sources :

Example 1 with YangInstanceIdentifier

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

the class AdjRibInWriter method transform.

AdjRibInWriter transform(final PeerId newPeerId, final RIBSupportContextRegistry registry, final Set<TablesKey> tableTypes, final Map<TablesKey, SendReceive> addPathTablesType, @Nullable final RegisterAppPeerListener registerAppPeerListener) {
    final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction();
    final YangInstanceIdentifier newPeerPath;
    newPeerPath = createEmptyPeerStructure(newPeerId, tx);
    final ImmutableMap<TablesKey, TableContext> tb = createNewTableInstances(newPeerPath, registry, tableTypes, addPathTablesType, tx);
    Futures.addCallback(tx.submit(), new FutureCallback<Void>() {

        @Override
        public void onSuccess(final Void result) {
            if (registerAppPeerListener != null) {
                LOG.trace("Application Peer Listener registered");
                registerAppPeerListener.register();
            }
        }

        @Override
        public void onFailure(final Throwable throwable) {
            if (registerAppPeerListener != null) {
                LOG.error("Failed to create Empty Structure, Application Peer Listener won't be registered", throwable);
            } else {
                LOG.error("Failed to create Empty Structure", throwable);
            }
        }
    }, MoreExecutors.directExecutor());
    return new AdjRibInWriter(this.ribPath, this.chain, this.role, newPeerPath, tb);
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) DOMDataWriteTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)

Example 2 with YangInstanceIdentifier

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

the class AdjRibInWriter method createEmptyPeerStructure.

private YangInstanceIdentifier createEmptyPeerStructure(final PeerId newPeerId, final DOMDataWriteTransaction tx) {
    final NodeIdentifierWithPredicates peerKey = IdentifierUtils.domPeerId(newPeerId);
    final YangInstanceIdentifier newPeerPath = this.ribPath.node(Peer.QNAME).node(peerKey);
    tx.put(LogicalDatastoreType.OPERATIONAL, newPeerPath, peerSkeleton(peerKey, newPeerId.getValue()));
    LOG.debug("New peer {} structure installed.", newPeerPath);
    return newPeerPath;
}
Also used : NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Example 3 with YangInstanceIdentifier

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

the class ApplicationPeer method processRoutesTable.

private synchronized void processRoutesTable(final DataTreeCandidateNode node, final YangInstanceIdentifier identifier, final DOMDataWriteTransaction tx, final YangInstanceIdentifier routeTableIdentifier) {
    for (final DataTreeCandidateNode child : node.getChildNodes()) {
        final YangInstanceIdentifier childIdentifier = identifier.node(child.getIdentifier());
        switch(child.getModificationType()) {
            case DELETE:
                LOG.trace("App peer -> AdjRibsIn path delete: {}", childIdentifier);
                tx.delete(LogicalDatastoreType.OPERATIONAL, childIdentifier);
                break;
            case UNMODIFIED:
                // No-op
                break;
            case SUBTREE_MODIFIED:
                // we need to go deeper three levels
                if (!routeTableIdentifier.equals(childIdentifier.getParent().getParent().getParent())) {
                    processRoutesTable(child, childIdentifier, tx, routeTableIdentifier);
                    break;
                }
            case WRITE:
                if (child.getDataAfter().isPresent()) {
                    final NormalizedNode<?, ?> dataAfter = child.getDataAfter().get();
                    LOG.trace("App peer -> AdjRibsIn path : {}", childIdentifier);
                    LOG.trace("App peer -> AdjRibsIn data : {}", dataAfter);
                    tx.put(LogicalDatastoreType.OPERATIONAL, childIdentifier, dataAfter);
                }
                break;
            default:
                break;
        }
    }
}
Also used : DataTreeCandidateNode(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Example 4 with YangInstanceIdentifier

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

the class ClientTransactionCursorTest method testWrite.

@Test
public void testWrite() throws Exception {
    final YangInstanceIdentifier.NodeIdentifier path = YangInstanceIdentifier.NodeIdentifier.create(NODE_1);
    final ContainerNode data = createData(path.getNodeType());
    cursor.write(path, data);
    final YangInstanceIdentifier expected = createId(NODE_1);
    verify(transaction).write(expected, data);
}
Also used : ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Test(org.junit.Test)

Example 5 with YangInstanceIdentifier

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

the class ClientTransactionCursorTest method testEnterNodeIterables.

@Test
public void testEnterNodeIterables() throws Exception {
    final Iterable<YangInstanceIdentifier.PathArgument> collect = toPathArg(NODE_1, NODE_2);
    cursor.enter(collect);
    cursor.delete(YangInstanceIdentifier.NodeIdentifier.create(NODE_3));
    final YangInstanceIdentifier expected = createId(NODE_1, NODE_2, NODE_3);
    verify(transaction).delete(expected);
}
Also used : YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Test(org.junit.Test)

Aggregations

YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)187 Test (org.junit.Test)111 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)34 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)21 ActorRef (akka.actor.ActorRef)19 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)19 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)15 TestActorRef (akka.testkit.TestActorRef)14 TestKit (akka.testkit.javadsl.TestKit)13 WriteModification (org.opendaylight.controller.cluster.datastore.modification.WriteModification)12 ArrayList (java.util.ArrayList)11 RegisterDataTreeNotificationListenerReply (org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeNotificationListenerReply)10 DeleteModification (org.opendaylight.controller.cluster.datastore.modification.DeleteModification)10 ActorContext (org.opendaylight.controller.cluster.datastore.utils.ActorContext)10 MapNode (org.opendaylight.yangtools.yang.data.api.schema.MapNode)10 AbstractTest (org.opendaylight.controller.cluster.datastore.AbstractTest)9 RegisterChangeListener (org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListener)9 DOMDataWriteTransaction (org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)9 DOMStoreWriteTransaction (org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction)9 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)9