final class FlowspecRIBSupport extends AbstractRIBSupport {
- private static abstract class ApplyRoute {
+ private abstract static class ApplyRoute {
abstract void apply(DOMDataWriteTransaction tx, YangInstanceIdentifier base, NodeIdentifierWithPredicates routeKey, DataContainerNode<?> route, final ContainerNode attributes);
}
import org.slf4j.LoggerFactory;
final class LinkstateRIBSupport extends AbstractRIBSupport {
- private static abstract class ApplyRoute {
+ private abstract static class ApplyRoute {
abstract void apply(DOMDataWriteTransaction tx, YangInstanceIdentifier base, NodeIdentifierWithPredicates routeKey, DataContainerNode<?> route, final ContainerNode attributes);
}
prefixBytes = Ipv4Util.bytesForPrefixBegin(new Ipv4Prefix(prefix));
prefixType = NlriType.Ipv4Prefix;
} catch(final IllegalArgumentException e) {
+ LOG.debug("Creating Ipv6 prefix because", e);
prefixBytes = Ipv6Util.bytesForPrefixBegin(new Ipv6Prefix(prefix));
prefixType = NlriType.Ipv6Prefix;
}
}
@Override
- public final void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder) {
+ public void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder) {
builder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4CaseBuilder().setDestinationIpv4(
prefixes(nlri)).build()).build());
}
@Override
- public final void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder) throws BGPParsingException {
+ public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder) throws BGPParsingException {
builder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationIpv4CaseBuilder().setDestinationIpv4(prefixes(nlri)).build()).build());
}
}
\ No newline at end of file
}
@Override
- public final void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder) {
+ public void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder) {
builder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6CaseBuilder().setDestinationIpv6(
prefixes(nlri)).build()).build());
}
@Override
- public final void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder) throws BGPParsingException {
+ public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder) throws BGPParsingException {
builder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationIpv6CaseBuilder().setDestinationIpv6(prefixes(nlri)).build()).build());
}
}
\ No newline at end of file
* Common {@link org.opendaylight.protocol.bgp.rib.spi.RIBSupport} class for IPv4 and IPv6 addresses.
*/
abstract class AbstractIPRIBSupport extends AbstractRIBSupport {
- private static abstract class ApplyRoute {
+ private abstract static class ApplyRoute {
abstract void apply(DOMDataWriteTransaction tx, YangInstanceIdentifier base, NodeIdentifierWithPredicates routeKey, DataContainerNode<?> route, final ContainerNode attributes);
}
private static final class DeleteRoute extends ApplyRoute {
@Override
- void apply(final DOMDataWriteTransaction tx, final YangInstanceIdentifier base, NodeIdentifierWithPredicates routeKey, final DataContainerNode<?> route, final ContainerNode attributes) {
+ void apply(final DOMDataWriteTransaction tx, final YangInstanceIdentifier base, final NodeIdentifierWithPredicates routeKey, final DataContainerNode<?> route, final ContainerNode attributes) {
tx.delete(LogicalDatastoreType.OPERATIONAL, base.node(routeKey));
}
}
private final class PutRoute extends ApplyRoute {
@Override
- void apply(final DOMDataWriteTransaction tx, final YangInstanceIdentifier base, NodeIdentifierWithPredicates routeKey, final DataContainerNode<?> route, final ContainerNode attributes) {
+ void apply(final DOMDataWriteTransaction tx, final YangInstanceIdentifier base, final NodeIdentifierWithPredicates routeKey, final DataContainerNode<?> route, final ContainerNode attributes) {
final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> b = ImmutableNodes.mapEntryBuilder();
b.withNodeIdentifier(routeKey);
return false;
}
- private final void processDestination(final DOMDataWriteTransaction tx, final YangInstanceIdentifier tablePath,
+ private void processDestination(final DOMDataWriteTransaction tx, final YangInstanceIdentifier tablePath,
final ContainerNode destination, final ContainerNode attributes, final ApplyRoute function) {
if (destination != null) {
final Optional<DataContainerChild<? extends PathArgument, ?>> maybeRoutes = destination.getChild(nlriRoutesListIdentifier());
// Instance identifier to table/(choice routes)/(map of route)
final YangInstanceIdentifier base = tablePath.node(ROUTES).node(routesContainerIdentifier()).node(routeIdentifier());
for (final UnkeyedListEntryNode e : ((UnkeyedListNode)routes).getValue()) {
- NodeIdentifierWithPredicates routeKey = createRouteKey(e);
+ final NodeIdentifierWithPredicates routeKey = createRouteKey(e);
function.apply(tx, base, routeKey, e, attributes);
}
} else {
}
}
- private NodeIdentifierWithPredicates createRouteKey(UnkeyedListEntryNode e) {
- Optional<DataContainerChild<? extends PathArgument, ?>> maybeKeyLeaf = e.getChild(routeKeyLeafIdentifier());
+ private NodeIdentifierWithPredicates createRouteKey(final UnkeyedListEntryNode e) {
+ final Optional<DataContainerChild<? extends PathArgument, ?>> maybeKeyLeaf = e.getChild(routeKeyLeafIdentifier());
Preconditions.checkState(maybeKeyLeaf.isPresent());
- Object keyValue = ((LeafNode<?>) maybeKeyLeaf.get()).getValue();
+ final Object keyValue = ((LeafNode<?>) maybeKeyLeaf.get()).getValue();
return new NodeIdentifierWithPredicates(routeQName(), keyLeafQName(), keyValue);
}
private static final QName PEER_ROLE = QName.cachedReference(QName.create(Peer.QNAME, "peer-role"));
private final ListenerRegistration<?> registration;
- protected AbstractPeerRoleTracker(final @Nonnull DOMDataTreeChangeService service, @Nonnull final YangInstanceIdentifier ribId) {
+ protected AbstractPeerRoleTracker(@Nonnull final DOMDataTreeChangeService service, @Nonnull final YangInstanceIdentifier ribId) {
// Slightly evil, but our users should be fine with this
final YangInstanceIdentifier roleId = ribId.node(Peer.QNAME).node(Peer.QNAME).node(PEER_ROLE);
this.registration = service.registerDataTreeChangeListener(new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, roleId), new PeerRoleListener());
private static final Logger LOG = LoggerFactory.getLogger(AdjRibOutListener.class);
private final ChannelOutputLimiter session;
- private final RIBSupportContextRegistry registry;
private final RIBSupportContextImpl context;
private final RIBSupport support;
private AdjRibOutListener(final TablesKey tablesKey, final YangInstanceIdentifier ribId, final DOMDataTreeChangeService service, final RIBSupportContextRegistry registry, final ChannelOutputLimiter session) {
- this.registry = Preconditions.checkNotNull(registry);
this.session = Preconditions.checkNotNull(session);
- this.context = (RIBSupportContextImpl) this.registry.getRIBSupportContext(tablesKey);
+ this.context = (RIBSupportContextImpl) registry.getRIBSupportContext(tablesKey);
this.support = this.context.getRibSupport();
final YangInstanceIdentifier adjRibOutId = ribId.node(Peer.QNAME).node(Peer.QNAME).node(AdjRibOut.QNAME).node(Tables.QNAME).node(RibSupportUtils.toYangTablesKey(tablesKey));
service.registerDataTreeChangeListener(new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, adjRibOutId), this);
import com.google.common.collect.ImmutableList;
import java.util.Collection;
import java.util.Iterator;
+import org.opendaylight.protocol.util.Values;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.AsPath;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.ClusterId;
final Optional<NormalizedNode<?, ?>> maybeAsSequence = NormalizedNodes.findNode(segment, this.asPathChoice, this.asPathList, this.asPathSequence);
if (maybeAsSequence.isPresent()) {
final UnkeyedListNode asList = (UnkeyedListNode) maybeAsSequence.get();
- if (asList.getSize() < 255) {
+ if (asList.getSize() < Values.UNSIGNED_BYTE_MAX_VALUE) {
return asList.getValue();
}
}
*/
final class IPv4RIBSupport extends AbstractIPRIBSupport {
@VisibleForTesting
- final static QName PREFIX_QNAME = QName.cachedReference(QName.create(Ipv4Route.QNAME, "prefix"));
+ static final QName PREFIX_QNAME = QName.cachedReference(QName.create(Ipv4Route.QNAME, "prefix"));
private static final IPv4RIBSupport SINGLETON = new IPv4RIBSupport();
private final ChoiceNode emptyRoutes = Builders.choiceBuilder()
.withNodeIdentifier(new NodeIdentifier(Routes.QNAME))
* Class supporting IPv6 unicast RIBs.
*/
final class IPv6RIBSupport extends AbstractIPRIBSupport {
- private final static QName PREFIX_QNAME = QName.cachedReference(QName.create(Ipv6Route.QNAME, "prefix"));
+ private static final QName PREFIX_QNAME = QName.cachedReference(QName.create(Ipv6Route.QNAME, "prefix"));
private static final IPv6RIBSupport SINGLETON = new IPv6RIBSupport();
private final ChoiceNode emptyRoutes = Builders.choiceBuilder()
.withNodeIdentifier(new NodeIdentifier(Routes.QNAME))
private final RIBSupport ribSupport;
private final NodeIdentifierWithPredicates tableKey;
private final RIBSupportContextRegistry registry;
- private final YangInstanceIdentifier adjRibOutTarget;
- private final YangInstanceIdentifier ribId;
LocRibWriter(final RIBSupportContextRegistry registry, final DOMTransactionChain chain, final YangInstanceIdentifier target, final Long ourAs,
final DOMDataTreeChangeService service, final PolicyDatabase pd, final TablesKey tablesKey) {
this.ribSupport = this.registry.getRIBSupportContext(tablesKey).getRibSupport();
this.attributesIdentifier = this.ribSupport.routeAttributesIdentifier();
this.peerPolicyTracker = new ExportPolicyPeerTracker(service, target, pd);
- this.adjRibOutTarget = target.node(Peer.QNAME).node(Peer.QNAME).node(AdjRibOut.QNAME).node(Tables.QNAME).node(this.tableKey);
- this.ribId = target;
final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction();
tx.merge(LogicalDatastoreType.OPERATIONAL, this.locRibTarget, this.ribSupport.emptyRoutes());
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
class RIBSupportContextImpl extends RIBSupportContext {
- private static final Logger LOG = LoggerFactory.getLogger(RIBSupportContextImpl.class);
private static final ContainerNode EMPTY_TABLE_ATTRIBUTES = ImmutableNodes.containerNode(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.tables.Attributes.QNAME);
private static final Set<Class<? extends DataObject>> ATTRIBUTE_CACHEABLES;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-class RIBSupportContextRegistryImpl implements RIBSupportContextRegistry {
+final class RIBSupportContextRegistryImpl implements RIBSupportContextRegistry {
private final LoadingCache<RIBSupport, RIBSupportContextImpl> contexts = CacheBuilder.newBuilder()
.build(new CacheLoader<RIBSupport, RIBSupportContextImpl>(){
@Override
public RIBSupportContextImpl load(final RIBSupport key) {
return createContext(key);
- };
+ }
});
private final RIBExtensionConsumerContext extensionContext;
@Override
public RIBSupportContext getRIBSupportContext(final TablesKey key) {
- final RIBSupport ribSupport = extensionContext.getRIBSupport(key);
+ final RIBSupport ribSupport = this.extensionContext.getRIBSupport(key);
if(ribSupport != null) {
- return contexts.getUnchecked(ribSupport);
+ return this.contexts.getUnchecked(ribSupport);
}
return null;
}
@Override
public RIBSupportContext getRIBSupportContext(final NodeIdentifierWithPredicates key) {
- final RIBSupport ribSupport = extensionContext.getRIBSupport(key);
+ final RIBSupport ribSupport = this.extensionContext.getRIBSupport(key);
if(ribSupport != null) {
- return contexts.getUnchecked(ribSupport);
+ return this.contexts.getUnchecked(ribSupport);
}
return null;
}
private RIBSupportContextImpl createContext(final RIBSupport ribSupport) {
final RIBSupportContextImpl ribContext = new RIBSupportContextImpl(ribSupport);
- if(latestCodecTree != null) {
+ if(this.latestCodecTree != null) {
// FIXME: Do we need to recalculate latestCodecTree? E.g. new rib support was added
// after bgp was started.
- ribContext.onCodecTreeUpdated(latestCodecTree);
+ ribContext.onCodecTreeUpdated(this.latestCodecTree);
}
return ribContext;
}
void onSchemaContextUpdated(final SchemaContext context) {
- final BindingRuntimeContext runtimeContext = BindingRuntimeContext.create(classContext, context);
- latestCodecTree = codecFactory.create(runtimeContext);
- for(final RIBSupportContextImpl rib : contexts.asMap().values()) {
- rib.onCodecTreeUpdated(latestCodecTree);
+ final BindingRuntimeContext runtimeContext = BindingRuntimeContext.create(this.classContext, context);
+ this.latestCodecTree = this.codecFactory.create(runtimeContext);
+ for(final RIBSupportContextImpl rib : this.contexts.asMap().values()) {
+ rib.onCodecTreeUpdated(this.latestCodecTree);
}
}
* @return RIBSupport instance, or null if the AFI/SAFI is
* not implemented.
*/
- public abstract @Nullable RIBSupportContext getRIBSupportContext(TablesKey key);
+ @Nullable abstract RIBSupportContext getRIBSupportContext(TablesKey key);
/**
* Acquire a RIB Support Context for a AFI/SAFI combination.
* @return RIBSupport instance, or null if the AFI/SAFI is
* not implemented.
*/
- public abstract @Nullable RIBSupportContext getRIBSupportContext(NodeIdentifierWithPredicates key);
-
+ @Nullable abstract RIBSupportContext getRIBSupportContext(NodeIdentifierWithPredicates key);
}
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-public class RibSupportUtils {
+public final class RibSupportUtils {
private static final QName AFI_QNAME = QName.cachedReference(QName.create(Tables.QNAME, "afi"));
private static final QName SAFI_QNAME = QName.cachedReference(QName.create(Tables.QNAME, "safi"));
rBuilder.setVendorInformationObject(vendorInfo);
}
// expansion
- if (rpObj.isPathKey()) {
- if (objects.get(0) instanceof PathKey) {
- rBuilder.setPathKeyExpansion(new PathKeyExpansionBuilder().setPathKey((PathKey) objects.get(0)).build());
- }
+ if (rpObj.isPathKey() && objects.get(0) instanceof PathKey) {
+ rBuilder.setPathKeyExpansion(new PathKeyExpansionBuilder().setPathKey((PathKey) objects.get(0)).build());
}
final P2pBuilder p2pBuilder = new P2pBuilder();
private BitArray(final byte[] backingArray, final int size) {
Preconditions.checkNotNull(backingArray, "Byte Array cannot be null");
this.size = size;
- this.backingArray = backingArray;
+ this.backingArray = (backingArray == null) ? null : backingArray.clone();
this.offset = (calculateBytes(this.size) * Byte.SIZE) - this.size;
}