Search in sources :

Example 51 with InstanceIdentifier

use of org.opendaylight.yangtools.yang.binding.InstanceIdentifier in project bgpcep by opendaylight.

the class BaseAbstractRouteEntry method addPathToDataStore.

@SuppressWarnings("unchecked")
private void addPathToDataStore(final RouteEntryDependenciesContainer entryDep, final Identifier routeKey, final WriteTransaction tx) {
    final RIBSupport ribSup = entryDep.getRibSupport();
    Identifier newRouteKey = ribSup.createNewRouteKey(this.bestPath.getPathId(), routeKey);
    if (newRouteKey == null) {
        newRouteKey = routeKey;
    }
    final Route route = createRoute(ribSup, newRouteKey, this.bestPath.getPathId(), this.bestPath);
    LOG.trace("Selected best route {}", route);
    final KeyedInstanceIdentifier<Tables, TablesKey> locRibTarget = entryDep.getLocRibTableTarget();
    final InstanceIdentifier routeTarget = ribSup.createRouteIdentifier(locRibTarget, newRouteKey);
    LOG.debug("Write route to LocRib {}", route);
    tx.put(LogicalDatastoreType.OPERATIONAL, routeTarget, route);
    fillAdjRibsOut(this.bestPath.getAttributes(), route, newRouteKey, this.bestPath.getPeerId(), entryDep, tx);
}
Also used : InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) Identifier(org.opendaylight.yangtools.yang.binding.Identifier) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) RIBSupport(org.opendaylight.protocol.bgp.rib.spi.RIBSupport) Tables(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) Route(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route)

Example 52 with InstanceIdentifier

use of org.opendaylight.yangtools.yang.binding.InstanceIdentifier in project bgpcep by opendaylight.

the class AddPathAbstractRouteEntry method fillAdjRibsOut.

@SuppressWarnings("unchecked")
private void fillAdjRibsOut(final boolean isFirstBestPath, final Attributes attributes, final Route routeNonAddPath, final Route routeAddPath, final Identifier routeKeyAddNonPath, final Identifier routeKeyAddPath, final PeerId fromPeerId, final TablesKey localTK, final RouteEntryDependenciesContainer routeEntryDep, final WriteTransaction tx) {
    /*
         * We need to keep track of routers and populate adj-ribs-out, too. If we do not, we need to
         * expose from which client a particular route was learned from in the local RIB, and have
         * the listener perform filtering.
         *
         * We walk the policy set in order to minimize the amount of work we do for multiple peers:
         * if we have two eBGP peers, for example, there is no reason why we should perform the translation
         * multiple times.
         */
    final RIBSupport ribSupport = routeEntryDep.getRibSupport();
    for (final Peer toPeer : this.peerTracker.getPeers()) {
        if (!filterRoutes(fromPeerId, toPeer, localTK)) {
            continue;
        }
        final boolean destPeerSupAddPath = toPeer.supportsAddPathSupported(localTK);
        if (toPeer.getPeerId().getValue().equals("bgp://127.0.0.5")) {
            LOG.debug("Write route {} to peer AdjRibsOut {}", toPeer.getPeerId());
        }
        if (peersSupportsAddPathOrIsFirstBestPath(destPeerSupAddPath, isFirstBestPath)) {
            Optional<Attributes> effAttrib = Optional.empty();
            final Peer fromPeer = this.peerTracker.getPeer(fromPeerId);
            if (fromPeer != null && attributes != null) {
                final BGPRouteEntryExportParameters baseExp = new BGPRouteEntryExportParametersImpl(fromPeer, toPeer);
                effAttrib = routeEntryDep.getRoutingPolicies().applyExportPolicies(baseExp, attributes);
            }
            Route newRoute = null;
            InstanceIdentifier ribOutRoute = null;
            if (destPeerSupAddPath) {
                newRoute = routeAddPath;
                ribOutRoute = ribSupport.createRouteIdentifier(toPeer.getRibOutIId(localTK), routeKeyAddPath);
            } else if (!this.oldNonAddPathBestPathTheSame) {
                ribOutRoute = ribSupport.createRouteIdentifier(toPeer.getRibOutIId(localTK), routeKeyAddNonPath);
                newRoute = routeNonAddPath;
            }
            if (effAttrib.isPresent() && newRoute != null) {
                LOG.debug("Write route {} to peer AdjRibsOut {}", newRoute, toPeer.getPeerId());
                tx.put(LogicalDatastoreType.OPERATIONAL, ribOutRoute, newRoute);
                tx.put(LogicalDatastoreType.OPERATIONAL, ribOutRoute.child(Attributes.class), effAttrib.get());
            } else if (ribOutRoute != null) {
                LOG.trace("Removing {} from transaction for peer {}", ribOutRoute, toPeer.getPeerId());
                tx.delete(LogicalDatastoreType.OPERATIONAL, ribOutRoute);
            }
        }
    }
}
Also used : RIBSupport(org.opendaylight.protocol.bgp.rib.spi.RIBSupport) Peer(org.opendaylight.protocol.bgp.rib.spi.Peer) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) BGPRouteEntryExportParametersImpl(org.opendaylight.protocol.bgp.mode.impl.BGPRouteEntryExportParametersImpl) BGPRouteEntryExportParameters(org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters) Route(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route)

Example 53 with InstanceIdentifier

use of org.opendaylight.yangtools.yang.binding.InstanceIdentifier in project controller by opendaylight.

the class EventSourceTopicTest method notifyNodeTest.

@Test
public void notifyNodeTest() {
    InstanceIdentifier instanceIdentifierMock = mock(InstanceIdentifier.class);
    eventSourceTopic.notifyNode(instanceIdentifierMock);
    verify(eventSourceServiceMock, times(1)).joinTopic(any(JoinTopicInput.class));
}
Also used : JoinTopicInput(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.JoinTopicInput) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) Test(org.junit.Test)

Example 54 with InstanceIdentifier

use of org.opendaylight.yangtools.yang.binding.InstanceIdentifier in project controller by opendaylight.

the class Bug1418AugmentationTest method complexAugmentationUpdatedTest.

@Test
public void complexAugmentationUpdatedTest() {
    WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
    writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP, top());
    writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
    writeTx.put(LogicalDatastoreType.CONFIGURATION, COMPLEX_AUGMENT, complexUsesAugment(LIST_VIA_USES_KEY));
    assertCommit(writeTx.submit());
    final TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, COMPLEX_AUGMENT, AsyncDataBroker.DataChangeScope.SUBTREE);
    writeTx = getDataBroker().newWriteOnlyTransaction();
    writeTx.put(LogicalDatastoreType.CONFIGURATION, COMPLEX_AUGMENT, complexUsesAugment(LIST_VIA_USES_KEY_MOD));
    assertCommit(writeTx.submit());
    AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
    assertContains(event.getUpdatedData(), COMPLEX_AUGMENT);
    assertContains(event.getCreatedData(), COMPLEX_AUGMENT.child(ListViaUses.class, LIST_VIA_USES_KEY_MOD));
    assertContains(event.getRemovedPaths(), COMPLEX_AUGMENT.child(ListViaUses.class, LIST_VIA_USES_KEY));
    assertContains(event.getOriginalData(), COMPLEX_AUGMENT);
    assertContains(event.getOriginalData(), COMPLEX_AUGMENT.child(ListViaUses.class, LIST_VIA_USES_KEY));
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) ListViaUses(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ListViaUses) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) TopLevelListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey) Test(org.junit.Test) AbstractDataChangeListenerTest(org.opendaylight.controller.md.sal.binding.test.AbstractDataChangeListenerTest)

Example 55 with InstanceIdentifier

use of org.opendaylight.yangtools.yang.binding.InstanceIdentifier in project controller by opendaylight.

the class Bug1418AugmentationTest method leafOnlyAugmentationCreatedTest.

@Test
public void leafOnlyAugmentationCreatedTest() {
    final TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT, AsyncDataBroker.DataChangeScope.SUBTREE, false);
    WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
    writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP, top());
    writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
    writeTx.put(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugment("test leaf"));
    assertCommit(writeTx.submit());
    AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
    assertContains(event.getCreatedData(), SIMPLE_AUGMENT);
    assertEmpty(event.getUpdatedData());
    assertEmpty(event.getOriginalData());
    assertEmpty(event.getRemovedPaths());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) TopLevelListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey) Test(org.junit.Test) AbstractDataChangeListenerTest(org.opendaylight.controller.md.sal.binding.test.AbstractDataChangeListenerTest)

Aggregations

InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)142 Logger (org.slf4j.Logger)57 LoggerFactory (org.slf4j.LoggerFactory)57 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)52 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)52 ArrayList (java.util.ArrayList)47 List (java.util.List)47 Collections (java.util.Collections)40 Optional (com.google.common.base.Optional)39 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)37 BigInteger (java.math.BigInteger)36 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)35 Inject (javax.inject.Inject)34 Singleton (javax.inject.Singleton)34 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)30 ManagedNewTransactionRunnerImpl (org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl)29 JobCoordinator (org.opendaylight.infrautils.jobcoordinator.JobCoordinator)28 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)26 PostConstruct (javax.annotation.PostConstruct)24 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)24