Search in sources :

Example 1 with MultiExitDisc

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.MultiExitDisc in project bgpcep by opendaylight.

the class MultiExitDiscriminatorAttributeParser method serializeAttribute.

@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
    Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
    final MultiExitDisc multiExitDisc = ((Attributes) attribute).getMultiExitDisc();
    if (multiExitDisc == null) {
        return;
    }
    AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, TYPE, Unpooled.copyInt(multiExitDisc.getMed().intValue()), byteAggregator);
}
Also used : MultiExitDisc(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.MultiExitDisc) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)

Example 2 with MultiExitDisc

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.MultiExitDisc in project bgpcep by opendaylight.

the class BestPathStateImpl method resolveValues.

private void resolveValues() {
    if (resolved) {
        return;
    }
    final NamespaceSpecificIds ids = PATH_CACHE.getUnchecked(attributes.getIdentifier().getNodeType().getModule());
    localPref = (Uint32) NormalizedNodes.findNode(attributes, ids.locPref).map(NormalizedNode::body).orElse(null);
    final Optional<NormalizedNode> maybeMultiExitDisc = NormalizedNodes.findNode(attributes, ids.med);
    if (maybeMultiExitDisc.isPresent()) {
        multiExitDisc = ((Uint32) maybeMultiExitDisc.get().body()).toJava();
    } else {
        multiExitDisc = 0L;
    }
    final Optional<NormalizedNode> maybeOrigin = NormalizedNodes.findNode(attributes, ids.orig);
    if (maybeOrigin.isPresent()) {
        final String originStr = (String) maybeOrigin.get().body();
        origin = BgpOrigin.forName(originStr).orElseThrow(() -> new IllegalArgumentException("Unhandled origin value " + originStr));
    } else {
        origin = null;
    }
    final Optional<NormalizedNode> maybeSegments = NormalizedNodes.findNode(attributes, ids.asPath);
    if (maybeSegments.isPresent()) {
        final UnkeyedListNode segments = (UnkeyedListNode) maybeSegments.get();
        final List<Segments> segs = extractSegments(segments, ids);
        if (!segs.isEmpty()) {
            this.peerAs = BesthPathStateUtil.getPeerAs(segs);
            this.asPathLength = countAsPath(segs);
        }
    }
    final Optional<NormalizedNode> maybeCommunities = NormalizedNodes.findNode(attributes, ids.communities);
    if (maybeCommunities.isPresent()) {
        depreferenced = ((UnkeyedListNode) maybeCommunities.orElseThrow()).body().stream().anyMatch(community -> isStale(ids, community));
    } else {
        depreferenced = false;
    }
    this.resolved = true;
}
Also used : Verify.verifyNotNull(com.google.common.base.Verify.verifyNotNull) SegmentsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.as.path.SegmentsBuilder) BestPathState(org.opendaylight.protocol.bgp.mode.api.BestPathState) LoadingCache(com.google.common.cache.LoadingCache) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) LeafSetEntryNode(org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode) Origin(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.Origin) ArrayList(java.util.ArrayList) ToStringHelper(com.google.common.base.MoreObjects.ToStringHelper) QNameModule(org.opendaylight.yangtools.yang.common.QNameModule) Objects.requireNonNull(java.util.Objects.requireNonNull) MultiExitDisc(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.MultiExitDisc) AsPath(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.AsPath) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) Communities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.Communities) Uint32(org.opendaylight.yangtools.yang.common.Uint32) BgpOrigin(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.BgpOrigin) UnkeyedListNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode) Uint16(org.opendaylight.yangtools.yang.common.Uint16) MoreObjects(com.google.common.base.MoreObjects) LeafSetNode(org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) BesthPathStateUtil(org.opendaylight.protocol.bgp.mode.BesthPathStateUtil) QName(org.opendaylight.yangtools.yang.common.QName) CacheLoader(com.google.common.cache.CacheLoader) Objects(java.util.Objects) List(java.util.List) PathArgument(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument) Segments(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.as.path.Segments) LocalPref(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPref) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) Optional(java.util.Optional) NormalizedNodes(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes) CacheBuilder(com.google.common.cache.CacheBuilder) CommunityUtil(org.opendaylight.protocol.bgp.parser.impl.message.update.CommunityUtil) NonNull(org.eclipse.jdt.annotation.NonNull) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Segments(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.as.path.Segments) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) UnkeyedListNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode)

Aggregations

MoreObjects (com.google.common.base.MoreObjects)1 ToStringHelper (com.google.common.base.MoreObjects.ToStringHelper)1 Verify.verifyNotNull (com.google.common.base.Verify.verifyNotNull)1 CacheBuilder (com.google.common.cache.CacheBuilder)1 CacheLoader (com.google.common.cache.CacheLoader)1 LoadingCache (com.google.common.cache.LoadingCache)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Objects (java.util.Objects)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 Optional (java.util.Optional)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 BesthPathStateUtil (org.opendaylight.protocol.bgp.mode.BesthPathStateUtil)1 BestPathState (org.opendaylight.protocol.bgp.mode.api.BestPathState)1 CommunityUtil (org.opendaylight.protocol.bgp.parser.impl.message.update.CommunityUtil)1 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)1 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)1 MultiExitDisc (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.MultiExitDisc)1 AsPath (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.AsPath)1 Communities (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.Communities)1