Search in sources :

Example 16 with Bands

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands in project openflowplugin by opendaylight.

the class MeterModInputMessageFactory method serializeBands.

private void serializeBands(final List<Bands> bands, final ByteBuf outBuffer) {
    if (bands != null) {
        for (Bands currentBand : bands) {
            MeterBand meterBand = currentBand.getMeterBand();
            if (meterBand instanceof MeterBandDropCase) {
                MeterBandDropCase dropBandCase = (MeterBandDropCase) meterBand;
                MeterBandDrop dropBand = dropBandCase.getMeterBandDrop();
                writeBandCommonFields(dropBand, outBuffer);
                outBuffer.writeZero(PADDING_IN_METER_BAND_DROP);
            } else if (meterBand instanceof MeterBandDscpRemarkCase) {
                MeterBandDscpRemarkCase dscpRemarkBandCase = (MeterBandDscpRemarkCase) meterBand;
                MeterBandDscpRemark dscpRemarkBand = dscpRemarkBandCase.getMeterBandDscpRemark();
                writeBandCommonFields(dscpRemarkBand, outBuffer);
                outBuffer.writeByte(dscpRemarkBand.getPrecLevel());
                outBuffer.writeZero(PADDING_IN_METER_BAND_DSCP_REMARK);
            } else if (meterBand instanceof MeterBandExperimenterCase) {
                MeterBandExperimenterCase experimenterBandCase = (MeterBandExperimenterCase) meterBand;
                MeterBandExperimenter experimenterBand = experimenterBandCase.getMeterBandExperimenter();
                ExperimenterIdMeterBand expIdMeterBand = experimenterBand.getAugmentation(ExperimenterIdMeterBand.class);
                if (expIdMeterBand != null) {
                    long expId = expIdMeterBand.getExperimenter().getValue();
                    Class<? extends ExperimenterMeterBandSubType> meterBandSubType = expIdMeterBand.getSubType();
                    try {
                        OFSerializer<MeterBandExperimenterCase> serializer = registry.getSerializer(ExperimenterSerializerKeyFactory.createMeterBandSerializerKey(EncodeConstants.OF13_VERSION_ID, expId, meterBandSubType));
                        serializer.serialize(experimenterBandCase, outBuffer);
                    } catch (final IllegalStateException e) {
                        LOG.warn("Serializer for key: {} wasn't found, exception {}", ExperimenterSerializerKeyFactory.createMeterBandSerializerKey(EncodeConstants.OF13_VERSION_ID, expId, meterBandSubType), e);
                    }
                }
            }
        }
    }
}
Also used : MeterBand(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.MeterBand) ExperimenterIdMeterBand(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMeterBand) MeterBandExperimenter(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenter) MeterBandDscpRemarkCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCase) MeterBandExperimenterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase) MeterBandDropCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCase) Bands(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands) ExperimenterIdMeterBand(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMeterBand) MeterBandDrop(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDrop) MeterBandDscpRemark(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemark)

Example 17 with Bands

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactoryTest method createBandsList.

private static List<Bands> createBandsList() {
    final List<Bands> bandsList = new ArrayList<>();
    final BandsBuilder bandsBuilder = new BandsBuilder();
    final MeterBandDropCaseBuilder dropCaseBuilder = new MeterBandDropCaseBuilder();
    MeterBandDropBuilder dropBand = new MeterBandDropBuilder();
    dropBand.setType(MeterBandType.OFPMBTDROP);
    dropBand.setRate(1L);
    dropBand.setBurstSize(2L);
    dropCaseBuilder.setMeterBandDrop(dropBand.build());
    bandsList.add(bandsBuilder.setMeterBand(dropCaseBuilder.build()).build());
    final MeterBandDscpRemarkCaseBuilder dscpCaseBuilder = new MeterBandDscpRemarkCaseBuilder();
    MeterBandDscpRemarkBuilder dscpRemarkBand = new MeterBandDscpRemarkBuilder();
    dscpRemarkBand.setType(MeterBandType.OFPMBTDSCPREMARK);
    dscpRemarkBand.setRate(1L);
    dscpRemarkBand.setBurstSize(2L);
    dscpRemarkBand.setPrecLevel((short) 3);
    dscpCaseBuilder.setMeterBandDscpRemark(dscpRemarkBand.build());
    bandsList.add(bandsBuilder.setMeterBand(dscpCaseBuilder.build()).build());
    return bandsList;
}
Also used : MeterBandDscpRemarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder) Bands(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands) MeterBandDropCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder) MeterBandDscpRemarkCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder) ArrayList(java.util.ArrayList) MeterBandDropBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder) BandsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.BandsBuilder)

Example 18 with Bands

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands in project openflowplugin by opendaylight.

the class StatisticsGatheringUtilsTest method testGatherStatistics_meterConfig.

@Test
public void testGatherStatistics_meterConfig() throws Exception {
    final MultipartType type = MultipartType.OFPMPMETERCONFIG;
    final Long meterIdValue = 55L;
    final MeterConfigBuilder meterConfigBld = new MeterConfigBuilder().setMeterId(new MeterId(meterIdValue)).setFlags(new MeterFlags(false, true, false, true)).setBands(Collections.<Bands>emptyList());
    final MultipartReplyMeterConfigBuilder mpReplyMeterConfigBld = new MultipartReplyMeterConfigBuilder();
    mpReplyMeterConfigBld.setMeterConfig(Lists.newArrayList(meterConfigBld.build()));
    final MultipartReplyMeterConfigCaseBuilder mpReplyMeterConfigCaseBld = new MultipartReplyMeterConfigCaseBuilder();
    mpReplyMeterConfigCaseBld.setMultipartReplyMeterConfig(mpReplyMeterConfigBld.build());
    final MultipartReply meterConfigUpdated = assembleMPReplyMessage(type, mpReplyMeterConfigCaseBld.build());
    final List<MultipartReply> statsData = Collections.singletonList(meterConfigUpdated);
    fireAndCheck(type, statsData);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId meterId = new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId(meterIdValue);
    final KeyedInstanceIdentifier<Meter, MeterKey> meterPath = dummyNodePath.augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meterId));
    verify(deviceContext, Mockito.never()).addDeleteToTxChain(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.<InstanceIdentifier<?>>any());
    verify(deviceMeterRegistry).store(meterId);
    verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(meterPath), Matchers.any(Meter.class));
}
Also used : MultipartReplyMeterConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfigBuilder) MeterConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfigBuilder) Meter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter) MultipartType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType) MultipartReplyMeterConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfigBuilder) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId) MeterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey) MultipartReplyMeterConfigCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCaseBuilder) MeterFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags) Test(org.junit.Test)

Example 19 with Bands

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands in project openflowplugin by opendaylight.

the class MeterModInputMessageFactoryTest method decodeBandsList.

private static List<Bands> decodeBandsList(ByteBuf input) {
    final List<Bands> bandsList = new ArrayList<>();
    final BandsBuilder bandsBuilder = new BandsBuilder();
    final MeterBandDropCaseBuilder dropCaseBuilder = new MeterBandDropCaseBuilder();
    MeterBandDropBuilder dropBand = new MeterBandDropBuilder();
    dropBand.setType(MeterBandType.forValue(input.readUnsignedShort()));
    input.skipBytes(Short.SIZE / Byte.SIZE);
    dropBand.setRate(input.readUnsignedInt());
    dropBand.setBurstSize(input.readUnsignedInt());
    input.skipBytes(4);
    dropCaseBuilder.setMeterBandDrop(dropBand.build());
    bandsList.add(bandsBuilder.setMeterBand(dropCaseBuilder.build()).build());
    final MeterBandDscpRemarkCaseBuilder dscpCaseBuilder = new MeterBandDscpRemarkCaseBuilder();
    MeterBandDscpRemarkBuilder dscpRemarkBand = new MeterBandDscpRemarkBuilder();
    dscpRemarkBand.setType(MeterBandType.forValue(input.readUnsignedShort()));
    input.skipBytes(Short.SIZE / Byte.SIZE);
    dscpRemarkBand.setRate(input.readUnsignedInt());
    dscpRemarkBand.setBurstSize(input.readUnsignedInt());
    dscpRemarkBand.setPrecLevel(input.readUnsignedByte());
    input.skipBytes(3);
    dscpCaseBuilder.setMeterBandDscpRemark(dscpRemarkBand.build());
    bandsList.add(bandsBuilder.setMeterBand(dscpCaseBuilder.build()).build());
    return bandsList;
}
Also used : MeterBandDscpRemarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder) Bands(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands) MeterBandDropCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder) MeterBandDscpRemarkCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder) ArrayList(java.util.ArrayList) MeterBandDropBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder) BandsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.BandsBuilder)

Example 20 with Bands

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands in project openflowplugin by opendaylight.

the class MeterModInputMessageFactoryTest method testMeterModInputMessage.

/**
 * Testing of {@link MeterModInputMessageFactory} for correct translation from POJO.
 */
@Test
public void testMeterModInputMessage() throws Exception {
    MeterModInputBuilder builder = new MeterModInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setCommand(MeterModCommand.forValue(1));
    builder.setFlags(new MeterFlags(false, true, true, false));
    builder.setMeterId(new MeterId(2248L));
    builder.setBands(createBandsList());
    MeterModInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    meterModFactory.serialize(message, out);
    BufferHelper.checkHeaderV13(out, (byte) 29, 48);
    Assert.assertEquals("Wrong meterModCommand", message.getCommand().getIntValue(), out.readUnsignedShort());
    Assert.assertEquals("Wrong meterFlags", message.getFlags(), decodeMeterModFlags(out.readShort()));
    Assert.assertEquals("Wrong meterId", message.getMeterId().getValue().intValue(), out.readUnsignedInt());
    Assert.assertEquals("Wrong bands", message.getBands(), decodeBandsList(out));
}
Also used : MeterModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder) MeterFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags) ByteBuf(io.netty.buffer.ByteBuf) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId) MeterModInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)14 MeterBandDropCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder)9 MeterBandDscpRemarkCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder)9 MeterBandDropBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder)9 MeterBandDscpRemarkBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder)9 Bands (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands)9 MeterBandExperimenterCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase)8 Test (org.junit.Test)7 MeterBandHeader (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader)6 MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId)6 MeterModInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder)6 MeterBand (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.MeterBand)6 MeterBandDropCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCase)6 MeterBandDscpRemarkCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCase)6 Bands (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands)6 MeterBandType (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandType)5 DscpRemarkBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemarkBuilder)5 MeterBandHeadersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder)5 MeterBandHeaderBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder)5 MeterBandTypesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder)5