Search in sources :

Example 31 with Route

use of com.google.cloud.compute.v1.Route in project bgpcep by opendaylight.

the class LocRibWriter method updateRoutesEntries.

@SuppressWarnings("unchecked")
private void updateRoutesEntries(final Collection<DataObjectModification<? extends DataObject>> routeChanges, final UnsignedInteger routerId, final Map<RouteUpdateKey, RouteEntry> routes) {
    for (final DataObjectModification<? extends DataObject> route : routeChanges) {
        final Identifier routeKey = ((InstanceIdentifier.IdentifiableItem) route.getIdentifier()).getKey();
        RouteEntry entry = this.routeEntries.get(routeKey);
        final Route newRoute = (Route) route.getDataAfter();
        final Route oldRoute = (Route) route.getDataBefore();
        if (newRoute != null) {
            if (entry == null) {
                entry = createEntry(routeKey);
            }
            final long pathId = this.ribSupport.extractPathId(newRoute);
            entry.addRoute(routerId, pathId, newRoute);
            this.totalPathsCounter.increment();
        } else if (oldRoute != null && entry != null) {
            this.totalPathsCounter.decrement();
            final long pathId = this.ribSupport.extractPathId(oldRoute);
            if (entry.removeRoute(routerId, pathId)) {
                this.routeEntries.remove(routeKey);
                this.totalPrefixesCounter.decrement();
                LOG.trace("Removed route from {}", routerId);
            }
        }
        final RouteUpdateKey routeUpdateKey = new RouteUpdateKey(routerId, routeKey);
        LOG.debug("Updated route {} entry {}", routeKey, entry);
        routes.put(routeUpdateKey, entry);
    }
}
Also used : RouteEntry(org.opendaylight.protocol.bgp.mode.api.RouteEntry) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) Identifier(org.opendaylight.yangtools.yang.binding.Identifier) DataTreeIdentifier(org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier) Route(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route)

Example 32 with Route

use of com.google.cloud.compute.v1.Route in project bgpcep by opendaylight.

the class AddPathAbstractRouteEntry method writeRoutePath.

@SuppressWarnings("unchecked")
private void writeRoutePath(final RouteEntryInfo entryInfo, final boolean destPeerSupAddPath, final AddPathBestPath path, final TablesKey localTK, final RouteEntryDependenciesContainer routeEntryDep, final WriteTransaction tx) {
    final Identifier routeKey = entryInfo.getRouteKey();
    final RIBSupport ribSupport = routeEntryDep.getRibSupport();
    final BGPRouteEntryExportParameters baseExp = new BGPRouteEntryExportParametersImpl(this.peerTracker.getPeer(path.getPeerId()), entryInfo.getToPeer());
    final Optional<Attributes> effAttrib = routeEntryDep.getRoutingPolicies().applyExportPolicies(baseExp, path.getAttributes());
    Identifier newRouteKey = ribSupport.createNewRouteKey(destPeerSupAddPath ? path.getPathId() : NON_PATH_ID_VALUE, routeKey);
    final Peer toPeer = entryInfo.getToPeer();
    final Route route = createRoute(ribSupport, newRouteKey, destPeerSupAddPath ? path.getPathId() : NON_PATH_ID_VALUE, path);
    InstanceIdentifier ribOutIId = ribSupport.createRouteIdentifier(toPeer.getRibOutIId(localTK), newRouteKey);
    if (effAttrib.isPresent() && route != null) {
        LOG.debug("Write route {} to peer AdjRibsOut {}", route, toPeer.getPeerId());
        tx.put(LogicalDatastoreType.OPERATIONAL, ribOutIId, route);
        tx.put(LogicalDatastoreType.OPERATIONAL, ribOutIId.child(Attributes.class), effAttrib.get());
    }
}
Also used : InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) Identifier(org.opendaylight.yangtools.yang.binding.Identifier) 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 33 with Route

use of com.google.cloud.compute.v1.Route in project bgpcep by opendaylight.

the class AddPathAbstractRouteEntry method addPathToDataStore.

private void addPathToDataStore(final RouteEntryDependenciesContainer entryDep, final AddPathBestPath path, final boolean isFirstBestPath, final Identifier routeKey, final WriteTransaction tx) {
    final RIBSupport ribSup = entryDep.getRibSupport();
    final Identifier routeKeyAddPath = ribSup.createNewRouteKey(path.getPathId(), routeKey);
    final Identifier routeKeyAddNonPath = ribSup.createNewRouteKey(NON_PATH_ID_VALUE, routeKey);
    final Route routeAddPath = createRoute(ribSup, routeKeyAddPath, path.getPathId(), path);
    final Route routeNonAddPath = createRoute(ribSup, routeKeyAddNonPath, NON_PATH_ID_VALUE, path);
    final KeyedInstanceIdentifier<Tables, TablesKey> locRibTarget = entryDep.getLocRibTableTarget();
    final InstanceIdentifier routeTarget = ribSup.createRouteIdentifier(locRibTarget, routeKeyAddPath);
    LOG.debug("Write route to LocRib {}", routeAddPath);
    tx.put(LogicalDatastoreType.OPERATIONAL, routeTarget, routeAddPath);
    fillAdjRibsOut(isFirstBestPath, path.getAttributes(), routeNonAddPath, routeAddPath, routeKeyAddNonPath, routeKeyAddPath, path.getPeerId(), entryDep.getLocalTablesKey(), 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 34 with Route

use of com.google.cloud.compute.v1.Route in project bgpcep by opendaylight.

the class ComplexRouteEntry method createRoute.

@Override
public Route createRoute(final RIBSupport ribSup, final Identifier routeKey, final long pathId, final AddPathBestPath path) {
    final OffsetMap map = getOffsets();
    final Route route = map.getValue(this.values, map.offsetOf(path.getRouteKey()));
    return ribSup.createRoute(route, routeKey, pathId, path.getAttributes());
}
Also used : OffsetMap(org.opendaylight.protocol.bgp.mode.impl.add.OffsetMap) Route(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route)

Example 35 with Route

use of com.google.cloud.compute.v1.Route in project bgpcep by opendaylight.

the class ComplexRouteEntry method createRoute.

@Override
public Route createRoute(final RIBSupport ribSup, Identifier routeKey, final long pathId, final BaseBestPath path) {
    final OffsetMap map = getOffsets();
    final Route route = map.getValue(this.values, map.offsetOf(path.getRouterId()));
    return ribSup.createRoute(route, routeKey, pathId, path.getAttributes());
}
Also used : Route(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route)

Aggregations

Route (okhttp3.Route)30 Response (okhttp3.Response)16 Authenticator (okhttp3.Authenticator)14 Request (okhttp3.Request)12 IOException (java.io.IOException)10 OkHttpClient (okhttp3.OkHttpClient)10 InetSocketAddress (java.net.InetSocketAddress)9 Route (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route)9 Proxy (java.net.Proxy)7 Route (io.fabric8.knative.serving.v1.Route)6 RouteBuilder (io.fabric8.knative.serving.v1.RouteBuilder)6 Test (org.junit.Test)6 Test (org.junit.jupiter.api.Test)6 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)6 KeyedInstanceIdentifier (org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier)6 Address (okhttp3.Address)5 Connection (okhttp3.Connection)5 RIBSupport (org.opendaylight.protocol.bgp.rib.spi.RIBSupport)5 Identifier (org.opendaylight.yangtools.yang.binding.Identifier)5 Builder (okhttp3.OkHttpClient.Builder)4