use of org.opendaylight.protocol.bgp.parser.spi.NlriSerializer in project bgpcep by opendaylight.
the class MPReachAttributeParser 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 Attributes pathAttributes = (Attributes) attribute;
final Attributes1 pathAttributes1 = pathAttributes.getAugmentation(Attributes1.class);
if (pathAttributes1 == null) {
return;
}
final MpReachNlri mpReachNlri = pathAttributes1.getMpReachNlri();
final ByteBuf reachBuffer = Unpooled.buffer();
this.reg.serializeMpReach(mpReachNlri, reachBuffer);
for (final NlriSerializer nlriSerializer : this.reg.getSerializers()) {
nlriSerializer.serializeAttribute(attribute, reachBuffer);
}
AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, TYPE, reachBuffer, byteAggregator);
}
use of org.opendaylight.protocol.bgp.parser.spi.NlriSerializer in project bgpcep by opendaylight.
the class SimpleNlriRegistry method registerNlriSerializer.
synchronized AutoCloseable registerNlriSerializer(final Class<? extends DataObject> nlriClass, final NlriSerializer serializer) {
final NlriSerializer prev = this.serializers.get(nlriClass);
Preconditions.checkState(prev == null, "Serializer already bound to class " + prev);
this.serializers.put(nlriClass, serializer);
final Object lock = this;
return new AbstractRegistration() {
@Override
protected void removeRegistration() {
synchronized (lock) {
SimpleNlriRegistry.this.serializers.remove(nlriClass);
}
}
};
}
use of org.opendaylight.protocol.bgp.parser.spi.NlriSerializer in project bgpcep by opendaylight.
the class MPUnreachAttributeParser 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 Attributes pathAttributes = (Attributes) attribute;
final Attributes2 pathAttributes2 = pathAttributes.getAugmentation(Attributes2.class);
if (pathAttributes2 == null) {
return;
}
final MpUnreachNlri mpUnreachNlri = pathAttributes2.getMpUnreachNlri();
final ByteBuf unreachBuffer = Unpooled.buffer();
this.reg.serializeMpUnReach(mpUnreachNlri, unreachBuffer);
for (final NlriSerializer nlriSerializer : this.reg.getSerializers()) {
nlriSerializer.serializeAttribute(attribute, unreachBuffer);
}
AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, TYPE, unreachBuffer, byteAggregator);
}
Aggregations