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);
}
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;
}
Aggregations