Search in sources :

Example 1 with MultipartReplyMeterFeatures

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterFeatures in project openflowplugin by opendaylight.

the class MultipartReplyTranslatorUtil method translateMeterFeatures.

private static org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterFeatures translateMeterFeatures(final MultipartReply msg) {
    MultipartReplyMeterFeaturesBuilder message = new MultipartReplyMeterFeaturesBuilder();
    MultipartReplyMeterFeaturesCase caseBody = (MultipartReplyMeterFeaturesCase) msg.getMultipartReplyBody();
    MultipartReplyMeterFeatures replyBody = caseBody.getMultipartReplyMeterFeatures();
    message.setMaxBands(replyBody.getMaxBands());
    message.setMaxColor(replyBody.getMaxColor());
    message.setMaxMeter(new Counter32(replyBody.getMaxMeter()));
    List<Class<? extends MeterCapability>> supportedCapabilities = new ArrayList<>();
    if (replyBody.getCapabilities().isOFPMFBURST()) {
        supportedCapabilities.add(MeterBurst.class);
    }
    if (replyBody.getCapabilities().isOFPMFKBPS()) {
        supportedCapabilities.add(MeterKbps.class);
    }
    if (replyBody.getCapabilities().isOFPMFPKTPS()) {
        supportedCapabilities.add(MeterPktps.class);
    }
    if (replyBody.getCapabilities().isOFPMFSTATS()) {
        supportedCapabilities.add(MeterStats.class);
    }
    message.setMeterCapabilitiesSupported(supportedCapabilities);
    List<Class<? extends MeterBand>> supportedMeterBand = new ArrayList<>();
    if (replyBody.getBandTypes().isOFPMBTDROP()) {
        supportedMeterBand.add(MeterBandDrop.class);
    }
    if (replyBody.getBandTypes().isOFPMBTDSCPREMARK()) {
        supportedMeterBand.add(MeterBandDscpRemark.class);
    }
    message.setMeterBandSupported(supportedMeterBand);
    return message.build();
}
Also used : Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) MeterBand(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBand) MultipartReplyMeterFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesBuilder) MultipartReplyMeterFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures) ArrayList(java.util.ArrayList) MeterCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterCapability) MultipartReplyMeterFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase)

Example 2 with MultipartReplyMeterFeatures

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterFeatures in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactory method serializeMeterFeaturesBody.

private void serializeMeterFeaturesBody(final MultipartReplyBody body, final ByteBuf outBuffer) {
    MultipartReplyMeterFeaturesCase meterFeaturesCase = (MultipartReplyMeterFeaturesCase) body;
    MultipartReplyMeterFeatures meterFeatures = meterFeaturesCase.getMultipartReplyMeterFeatures();
    outBuffer.writeInt(meterFeatures.getMaxMeter().intValue());
    writeBandTypes(meterFeatures.getBandTypes(), outBuffer);
    writeMeterFlags(meterFeatures.getCapabilities(), outBuffer);
    outBuffer.writeByte(meterFeatures.getMaxBands());
    outBuffer.writeByte(meterFeatures.getMaxColor());
    outBuffer.writeZero(METER_FEATURES_PADDING);
}
Also used : MultipartReplyMeterFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures) MultipartReplyMeterFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase)

Example 3 with MultipartReplyMeterFeatures

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterFeatures in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactoryTest method testMeterFeaturesSerialize.

@Test
public void testMeterFeaturesSerialize() throws Exception {
    MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setFlags(new MultipartRequestFlags(true));
    builder.setType(MultipartType.forValue(11));
    final MultipartReplyMeterFeaturesCaseBuilder meterFeaturesCase = new MultipartReplyMeterFeaturesCaseBuilder();
    MultipartReplyMeterFeaturesBuilder meterFeatures = new MultipartReplyMeterFeaturesBuilder();
    meterFeatures.setMaxMeter(1L);
    meterFeatures.setBandTypes(new MeterBandTypeBitmap(true, false));
    meterFeatures.setCapabilities(new MeterFlags(true, false, true, false));
    meterFeatures.setMaxBands((short) 1);
    meterFeatures.setMaxColor((short) 1);
    meterFeaturesCase.setMultipartReplyMeterFeatures(meterFeatures.build());
    builder.setMultipartReplyBody(meterFeaturesCase.build());
    MultipartReplyMessage message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 30);
    Assert.assertEquals("Wrong type", MultipartType.OFPMPMETERFEATURES.getIntValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
    serializedBuffer.skipBytes(PADDING);
    MultipartReplyMeterFeaturesCase body = (MultipartReplyMeterFeaturesCase) message.getMultipartReplyBody();
    MultipartReplyMeterFeatures messageOutput = body.getMultipartReplyMeterFeatures();
    Assert.assertEquals("Wrong max meter", messageOutput.getMaxMeter().intValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong band type", messageOutput.getBandTypes(), createMeterBandTypeBitmap(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong capabilities", messageOutput.getCapabilities(), createMeterFlags(serializedBuffer.readShort()));
    Assert.assertEquals("Wrong max bands", messageOutput.getMaxBands().shortValue(), serializedBuffer.readUnsignedByte());
    Assert.assertEquals("Wrong max color", messageOutput.getMaxColor().shortValue(), serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(2);
}
Also used : MultipartReplyMeterFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCaseBuilder) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) MultipartReplyMeterFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeaturesBuilder) MultipartReplyMeterFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures) MeterFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) MeterBandTypeBitmap(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap) ByteBuf(io.netty.buffer.ByteBuf) MultipartReplyMeterFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase) Test(org.junit.Test)

Example 4 with MultipartReplyMeterFeatures

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterFeatures in project openflowplugin by opendaylight.

the class MultipartReplyMeterFeaturesTest method testMultipartReplyMeterFeatures.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testMultipartReplyMeterFeatures() {
    ByteBuf bb = BufferHelper.buildBuffer(// 
    "00 0B 00 01 00 00 00 00 " + // maxMeter
    "00 00 00 0A " + // bandTypes
    "00 00 00 06 " + // capabilities
    "00 00 00 0F " + // maxBands, maxColor, padding
    "07 08 00 00");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyMeterFeaturesCase messageCase = (MultipartReplyMeterFeaturesCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyMeterFeatures message = messageCase.getMultipartReplyMeterFeatures();
    Assert.assertEquals("Wrong maxMeter", 10, message.getMaxMeter().intValue());
    Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(true, true), message.getBandTypes());
    Assert.assertEquals("Wrong capabilities", new MeterFlags(true, true, true, true), message.getCapabilities());
    Assert.assertEquals("Wrong maxBands", 7, message.getMaxBands().intValue());
    Assert.assertEquals("Wrong maxColor", 8, message.getMaxColor().intValue());
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyMeterFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures) MeterFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags) MeterBandTypeBitmap(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap) ByteBuf(io.netty.buffer.ByteBuf) MultipartReplyMeterFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase) Test(org.junit.Test)

Example 5 with MultipartReplyMeterFeatures

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterFeatures in project openflowplugin by opendaylight.

the class MultipartReplyMeterFeaturesTest method testMultipartReplyMeterFeatures2.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testMultipartReplyMeterFeatures2() {
    ByteBuf bb = BufferHelper.buildBuffer(// 
    "00 0B 00 01 00 00 00 00 " + // maxMeter
    "00 00 00 09 " + // bandTypes
    "00 00 00 00 " + // capabilities
    "00 00 00 00 " + // maxBands, maxColor, padding
    "03 04 00 00");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyMeterFeaturesCase messageCase = (MultipartReplyMeterFeaturesCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyMeterFeatures message = messageCase.getMultipartReplyMeterFeatures();
    Assert.assertEquals("Wrong maxMeter", 9, message.getMaxMeter().intValue());
    Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(false, false), message.getBandTypes());
    Assert.assertEquals("Wrong capabilities", new MeterFlags(false, false, false, false), message.getCapabilities());
    Assert.assertEquals("Wrong maxBands", 3, message.getMaxBands().intValue());
    Assert.assertEquals("Wrong maxColor", 4, message.getMaxColor().intValue());
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyMeterFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures) MeterFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags) MeterBandTypeBitmap(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap) ByteBuf(io.netty.buffer.ByteBuf) MultipartReplyMeterFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase) Test(org.junit.Test)

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