Search in sources :

Example 6 with Bandwidth

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth in project bgpcep by opendaylight.

the class PCEPBandwidthObjectParser method serializeObject.

@Override
public void serializeObject(final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof Bandwidth, "Wrong instance of PCEPObject. Passed %s. Needed BandwidthObject.", object.getClass());
    final ByteBuf body = Unpooled.buffer();
    writeFloat32(((Bandwidth) object).getBandwidth(), body);
    ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Also used : Bandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.bandwidth.object.Bandwidth) ByteBuf(io.netty.buffer.ByteBuf)

Example 7 with Bandwidth

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth in project bgpcep by opendaylight.

the class PCEPBandwidthObjectParser method parseObject.

@Override
public Bandwidth parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
    Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    if (bytes.readableBytes() != BANDWIDTH_F_LENGTH) {
        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.readableBytes() + "; Expected: " + BANDWIDTH_F_LENGTH + ".");
    }
    final BandwidthBuilder builder = new BandwidthBuilder();
    builder.setIgnore(header.isIgnore());
    builder.setProcessingRule(header.isProcessingRule());
    builder.setBandwidth(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth(ByteArray.getAllBytes(bytes)));
    return builder.build();
}
Also used : Preconditions(com.google.common.base.Preconditions) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException) BandwidthBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.bandwidth.object.BandwidthBuilder)

Example 8 with Bandwidth

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth in project bgpcep by opendaylight.

the class BandwidthUsageObjectCodec method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof BandwidthUsage, "Wrong instance of PCEPObject. Passed %s. Needed BandwidthUsage.", object.getClass());
    final List<Bandwidth> bwSample = ((BandwidthUsage) object).getBwSample();
    final ByteBuf body = Unpooled.buffer(bwSample.size() * BW_LENGTH);
    for (final Bandwidth bw : bwSample) {
        writeFloat32(bw, body);
    }
    ObjectUtil.formatSubobject(getType(), CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Also used : BandwidthUsage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.auto.bandwidth.rev171025.bandwidth.usage.object.BandwidthUsage) Bandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth) ByteBuf(io.netty.buffer.ByteBuf)

Example 9 with Bandwidth

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth in project bgpcep by opendaylight.

the class BandwidthUsageObjectCodec method parseObject.

@Override
public BandwidthUsage parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
    Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    if (bytes.readableBytes() % BW_LENGTH != 0) {
        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.readableBytes() + "; Expected multiple of " + BW_LENGTH + ".");
    }
    final BandwidthUsageBuilder builder = new BandwidthUsageBuilder();
    builder.setIgnore(header.isIgnore());
    builder.setProcessingRule(header.isProcessingRule());
    final List<Bandwidth> bwSamples = new ArrayList<>(bytes.readableBytes() / BW_LENGTH);
    while (bytes.isReadable()) {
        bwSamples.add(new Bandwidth(ByteArray.readBytes(bytes, BW_LENGTH)));
    }
    builder.setBwSample(bwSamples);
    return builder.build();
}
Also used : Bandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth) ArrayList(java.util.ArrayList) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException) BandwidthUsageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.auto.bandwidth.rev171025.bandwidth.usage.object.BandwidthUsageBuilder)

Example 10 with Bandwidth

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth in project bgpcep by opendaylight.

the class BandwidthTest method setUp.

@Before
public void setUp() {
    this.b1 = new Bandwidth(Unpooled.copyInt(1000).array());
    this.b2 = new Bandwidth(Unpooled.copyInt(2000).array());
    this.b3 = new Bandwidth(Unpooled.copyInt(2000).array());
    this.b4 = new Bandwidth(Unpooled.copyInt(100).array());
}
Also used : Bandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth) Before(org.junit.Before)

Aggregations

Bandwidth (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth)24 ByteBuf (io.netty.buffer.ByteBuf)14 ArrayList (java.util.ArrayList)8 Test (org.junit.Test)8 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)5 QosPolicy (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.QosPolicy)5 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)4 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)4 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)4 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)4 Preconditions (com.google.common.base.Preconditions)3 QosNetworkExtension (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.ext.rev160613.QosNetworkExtension)3 TrafficRateExtendedCommunityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.traffic.rate.extended.community.TrafficRateExtendedCommunityBuilder)3 TrafficRateExtendedCommunityCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.update.attributes.extended.communities.extended.community.TrafficRateExtendedCommunityCaseBuilder)3 ExtendedCommunities (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunities)3 ExtendedCommunitiesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunitiesBuilder)3 ShortAsNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ShortAsNumber)3 BandwidthBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.bandwidth.object.BandwidthBuilder)3 Before (org.junit.Before)2 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)2