Search in sources :

Example 6 with MultipartReplyMeterFeatures

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures in project openflowplugin by opendaylight.

the class MultipartReplyMeterFeaturesDeserializerTest method deserialize.

@Test
public void deserialize() throws Exception {
    ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    buffer.writeInt(MAX_METER);
    int bitMaskBands = ByteBufUtils.fillBitMask(0, BANDS_SUPPORTED.contains(MeterBandDrop.class), BANDS_SUPPORTED.contains(MeterBandDscpRemark.class));
    buffer.writeInt(bitMaskBands);
    int bitMaskCapabilities = ByteBufUtils.fillBitMask(0, CAPABILITIES_SUPPORTED.contains(MeterKbps.class), CAPABILITIES_SUPPORTED.contains(MeterPktps.class), CAPABILITIES_SUPPORTED.contains(MeterBurst.class), CAPABILITIES_SUPPORTED.contains(MeterStats.class));
    buffer.writeInt(bitMaskCapabilities);
    buffer.writeByte(MAX_BANDS);
    buffer.writeByte(MAX_COLOR);
    final MultipartReplyMeterFeatures reply = (MultipartReplyMeterFeatures) deserializeMultipart(buffer);
    assertEquals(MAX_METER, reply.getMaxMeter().getValue().intValue());
    assertTrue(reply.getMeterBandSupported().containsAll(BANDS_SUPPORTED));
    assertTrue(reply.getMeterCapabilitiesSupported().containsAll(CAPABILITIES_SUPPORTED));
    assertEquals(MAX_BANDS, reply.getMaxBands().byteValue());
    assertEquals(MAX_COLOR, reply.getMaxColor().byteValue());
    assertEquals(0, buffer.readableBytes());
}
Also used : MeterKbps(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterKbps) MeterBurst(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBurst) MeterStats(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterStats) MeterPktps(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterPktps) MultipartReplyMeterFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterFeatures) MeterBandDrop(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandDrop) ByteBuf(io.netty.buffer.ByteBuf) MeterBandDscpRemark(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandDscpRemark) Test(org.junit.Test)

Example 7 with MultipartReplyMeterFeatures

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures in project openflowplugin by opendaylight.

the class MeterFeaturesService method transformToNotification.

@Override
public MeterFeaturesUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
    final int mpSize = result.size();
    Preconditions.checkArgument(mpSize == 1, "unexpected (!=1) mp-reply size received: {}", mpSize);
    MeterFeaturesUpdatedBuilder notification = new MeterFeaturesUpdatedBuilder();
    notification.setId(getDeviceInfo().getNodeId());
    notification.setMoreReplies(Boolean.FALSE);
    notification.setTransactionId(emulatedTxId);
    MultipartReplyMeterFeaturesCase caseBody = (MultipartReplyMeterFeaturesCase) result.get(0).getMultipartReplyBody();
    MultipartReplyMeterFeatures replyBody = caseBody.getMultipartReplyMeterFeatures();
    notification.setMaxBands(replyBody.getMaxBands());
    notification.setMaxColor(replyBody.getMaxColor());
    notification.setMaxMeter(new Counter32(replyBody.getMaxMeter()));
    notification.setMeterCapabilitiesSupported(extractMeterCapabilities(replyBody.getCapabilities()));
    notification.setMeterBandSupported(extractSupportedMeterBand(replyBody, replyBody.getBandTypes()));
    return notification.build();
}
Also used : Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) MultipartReplyMeterFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures) MeterFeaturesUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterFeaturesUpdatedBuilder) MultipartReplyMeterFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase)

Aggregations

MultipartReplyMeterFeaturesCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase)6 MultipartReplyMeterFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures)6 ByteBuf (io.netty.buffer.ByteBuf)4 Test (org.junit.Test)4 MeterBandTypeBitmap (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap)3 MeterFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags)3 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)3 Counter32 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32)2 ArrayList (java.util.ArrayList)1 MeterFeaturesUpdatedBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterFeaturesUpdatedBuilder)1 MultipartReplyMeterFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterFeatures)1 MultipartReplyMeterFeaturesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesBuilder)1 MeterBand (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBand)1 MeterBandDrop (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandDrop)1 MeterBandDscpRemark (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandDscpRemark)1 MeterBurst (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBurst)1 MeterCapability (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterCapability)1 MeterKbps (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterKbps)1 MeterPktps (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterPktps)1 MeterStats (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterStats)1