use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.load.balancing.object.LoadBalancing in project bgpcep by opendaylight.
the class PCEPLoadBalancingObjectParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
checkArgument(object instanceof LoadBalancing, "Wrong instance of PCEPObject. Passed %s. Needed LoadBalancingObject.", object.getClass());
final LoadBalancing specObj = (LoadBalancing) object;
final ByteBuf body = Unpooled.buffer(SIZE);
body.writeZero(RESERVED + FLAGS_F_LENGTH);
ByteBufUtils.writeOrZero(body, specObj.getMaxLsp());
writeFloat32(specObj.getMinBandwidth(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.getProcessingRule(), object.getIgnore(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.load.balancing.object.LoadBalancing in project bgpcep by opendaylight.
the class PCEPLoadBalancingObjectParser method parseObject.
@Override
public LoadBalancing parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
if (bytes.readableBytes() != SIZE) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.readableBytes() + "; Expected: " + SIZE + ".");
}
bytes.skipBytes(RESERVED + FLAGS_F_LENGTH);
return new LoadBalancingBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setMaxLsp(ByteBufUtils.readUint8(bytes)).setMinBandwidth(new Bandwidth(ByteArray.readAllBytes(bytes))).build();
}
Aggregations